Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ public class BackgroundGeolocationFacade {
public static final int AUTHORIZATION_AUTHORIZED = 1;
public static final int AUTHORIZATION_DENIED = 0;

public static final String[] PERMISSIONS = {
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION
};
public static final String[] PERMISSIONS = getRequiredPermissions();

private boolean mServiceBroadcastReceiverRegistered = false;
private boolean mLocationModeChangeReceiverRegistered = false;
Expand All @@ -70,6 +67,22 @@ public class BackgroundGeolocationFacade {

private org.slf4j.Logger logger;

private static String[] getRequiredPermissions() {
if(android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
return new String[]{
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION
};
}
else {
return new String[]{
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_BACKGROUND_LOCATION
};
}
}

public BackgroundGeolocationFacade(Context context, PluginDelegate delegate) {
mContext = context;
mDelegate = delegate;
Expand Down