Skip to content
This repository has been archived by the owner on May 2, 2021. It is now read-only.

Fix: potential fix for HaylLtd/cordova-background-geolocation-plugin#19 #1

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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 @@ -57,6 +57,13 @@ public class BackgroundGeolocationFacade {
Manifest.permission.ACCESS_FINE_LOCATION
};

public static final String[] PERMISSIONS10 = {
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_BACKGROUND_LOCATION
};
private String[] PERMISSIONSNEW = PERMISSIONS;

private boolean mServiceBroadcastReceiverRegistered = false;
private boolean mLocationModeChangeReceiverRegistered = false;
private boolean mIsPaused = false;
Expand Down Expand Up @@ -212,10 +219,14 @@ private synchronized void unregisterServiceBroadcast() {
}

public void start() {
logger.debug("Starting service");

if(android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
PERMISSIONSNEW = PERMISSIONS;
}else {
PERMISSIONSNEW = PERMISSIONS10;
}
logger.debug("Starting service");
PermissionManager permissionManager = PermissionManager.getInstance(getContext());
permissionManager.checkPermissions(Arrays.asList(PERMISSIONS), new PermissionManager.PermissionRequestListener() {
permissionManager.checkPermissions(Arrays.asList(PERMISSIONSNEW), new PermissionManager.PermissionRequestListener() {
@Override
public void onPermissionGranted() {
logger.info("User granted requested permissions");
Expand Down