Skip to content

Commit

Permalink
Merge pull request #742 from wzijden/master
Browse files Browse the repository at this point in the history
Assume hasPermission for BTScan/Connect always true on AndroidSDK < 31
  • Loading branch information
randdusing authored Nov 26, 2022
2 parents 568c07d + 7797e1b commit 83220ae
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/android/BluetoothLePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ private void stopAdvertisingAction(JSONArray args, CallbackContext callbackConte
}

advertiser.stopAdvertising(advertiseCallback);

if (isAdvertising) isAdvertising = false;

JSONObject returnObj = new JSONObject();
Expand Down Expand Up @@ -926,7 +926,7 @@ public void requestPermissionAction(CallbackContext callbackContext) {
public void hasPermissionBtScanAction(CallbackContext callbackContext) {
JSONObject returnObj = new JSONObject();

addProperty(returnObj, "hasPermission", cordova.hasPermission(Manifest.permission.BLUETOOTH_SCAN));
addProperty(returnObj, "hasPermission", Build.VERSION.SDK_INT < Build.VERSION_CODES.S || cordova.hasPermission(Manifest.permission.BLUETOOTH_SCAN));

callbackContext.success(returnObj);
}
Expand All @@ -951,7 +951,7 @@ public void requestPermissionBtScanAction(CallbackContext callbackContext) {
public void hasPermissionBtConnectAction(CallbackContext callbackContext) {
JSONObject returnObj = new JSONObject();

addProperty(returnObj, "hasPermission", cordova.hasPermission(Manifest.permission.BLUETOOTH_CONNECT));
addProperty(returnObj, "hasPermission", Build.VERSION.SDK_INT < Build.VERSION_CODES.S || cordova.hasPermission(Manifest.permission.BLUETOOTH_CONNECT));

callbackContext.success(returnObj);
}
Expand Down Expand Up @@ -2866,7 +2866,7 @@ private void setPinAction(JSONArray args, CallbackContext callbackContext) {
if (isNotArgsObject(obj, callbackContext)) {
return;
}

String address = getAddress(obj);
if (isNotAddress(address, callbackContext)) {
return;
Expand All @@ -2876,7 +2876,7 @@ private void setPinAction(JSONArray args, CallbackContext callbackContext) {
if (pin==null) {
return;
}

Log.d("BLE","set pin " + address + " " + pin);
JSONObject returnObj = new JSONObject();
try {
Expand Down Expand Up @@ -2957,7 +2957,7 @@ public void onReceive(Context context, Intent intent) {

// Reset isAdvertising when adapter is off (if STATE_TURNING_OFF doesn't trigger)
if (isAdvertising) isAdvertising = false;

gattServer = null;

pluginResult = new PluginResult(PluginResult.Status.OK, returnObj);
Expand Down Expand Up @@ -3036,7 +3036,7 @@ public void onReceive(Context context, Intent intent) {
}
}
};

private BroadcastReceiver mPairingRequestReceiver;

@Override
Expand Down

0 comments on commit 83220ae

Please sign in to comment.