Skip to content

Commit

Permalink
fix(Android 10): Use ACCESS_FINE_LOCATION instead of COARSE
Browse files Browse the repository at this point in the history
  • Loading branch information
NunoSav committed Jun 16, 2020
1 parent b5a1c56 commit 27bf1a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</config-file>
</platform>
Expand Down
8 changes: 4 additions & 4 deletions src/android/BluetoothLePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
public class BluetoothLePlugin extends CordovaPlugin {
//Initialization related variables
private final int REQUEST_BT_ENABLE = 59627; /*Random integer*/
private final int REQUEST_ACCESS_COARSE_LOCATION = 59628;
private final int REQUEST_ACCESS_FINE_LOCATION = 59628;
private final int REQUEST_LOCATION_SOURCE_SETTINGS = 59629;
private BluetoothAdapter bluetoothAdapter;
private boolean isReceiverRegistered = false;
Expand Down Expand Up @@ -872,7 +872,7 @@ private void notifyAction(JSONArray args, CallbackContext callbackContext) {
public void hasPermissionAction(CallbackContext callbackContext) {
JSONObject returnObj = new JSONObject();

addProperty(returnObj, "hasPermission", cordova.hasPermission(Manifest.permission.ACCESS_COARSE_LOCATION));
addProperty(returnObj, "hasPermission", cordova.hasPermission(Manifest.permission.ACCESS_FINE_LOCATION));

callbackContext.success(returnObj);
}
Expand All @@ -887,7 +887,7 @@ public void requestPermissionAction(CallbackContext callbackContext) {
}

permissionsCallback = callbackContext;
cordova.requestPermission(this, REQUEST_ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION);
cordova.requestPermission(this, REQUEST_ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION);
}

public void onRequestPermissionResult(int requestCode, String[] permissions, int[] grantResults) throws JSONException {
Expand All @@ -898,7 +898,7 @@ public void onRequestPermissionResult(int requestCode, String[] permissions, int
//Just call hasPermission again to verify
JSONObject returnObj = new JSONObject();

addProperty(returnObj, "requestPermission", cordova.hasPermission(Manifest.permission.ACCESS_COARSE_LOCATION));
addProperty(returnObj, "requestPermission", cordova.hasPermission(Manifest.permission.ACCESS_FINE_LOCATION));

permissionsCallback.success(returnObj);
}
Expand Down

0 comments on commit 27bf1a5

Please sign in to comment.