react-native-ble-manager 11.5.2 → 11.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,8 +2,6 @@ package it.innove;
2
2
 
3
3
  import static android.app.Activity.RESULT_OK;
4
4
  import static android.bluetooth.BluetoothProfile.GATT;
5
- import static android.os.Build.VERSION_CODES.LOLLIPOP;
6
- import static android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE;
7
5
  import android.annotation.SuppressLint;
8
6
  import android.app.Activity;
9
7
  import android.bluetooth.BluetoothAdapter;
@@ -167,7 +165,7 @@ class BleManager extends ReactContextBaseJavaModule {
167
165
  filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
168
166
  IntentFilter intentFilter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST);
169
167
  intentFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
170
- if (Build.VERSION.SDK_INT >= UPSIDE_DOWN_CAKE){
168
+ if (Build.VERSION.SDK_INT >= 34){
171
169
  // Google in 2023 decides that flag RECEIVER_NOT_EXPORTED or RECEIVER_EXPORTED should be explicit set SDK 34(UPSIDE_DOWN_CAKE) on registering receivers.
172
170
  // Also the export flags are available on Android 8 and higher, should be used with caution so that don't break compability with that devices.
173
171
  context.registerReceiver(mReceiver, filter, Context.RECEIVER_EXPORTED);
@@ -565,11 +563,17 @@ class BleManager extends ReactContextBaseJavaModule {
565
563
  break;
566
564
  case BluetoothAdapter.STATE_TURNING_OFF:
567
565
  state = "turning_off";
566
+ if (scanManager != null) {
567
+ scanManager.setScanning(false);
568
+ }
568
569
  break;
569
570
  case BluetoothAdapter.STATE_OFF:
570
571
  default:
571
572
  // should not happen as per https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getState()
572
573
  state = "off";
574
+ if (scanManager != null) {
575
+ scanManager.setScanning(false);
576
+ }
573
577
  break;
574
578
  }
575
579
  }
@@ -64,10 +64,12 @@ public class CompanionScanner {
64
64
  if (peripheral != null && scanCallback != null) {
65
65
  scanCallback.invoke(null, peripheral.asWritableMap());
66
66
  scanCallback = null;
67
+ bleManager.sendEvent("BleManagerCompanionPeripheral", peripheral.asWritableMap());
67
68
  }
68
69
  } else {
69
70
  scanCallback.invoke(null, null);
70
71
  scanCallback = null;
72
+ bleManager.sendEvent("BleManagerCompanionPeripheral", null);
71
73
  }
72
74
 
73
75
  } else {
@@ -122,6 +124,9 @@ public class CompanionScanner {
122
124
  Log.d(LOG_TAG, "companion failure: " + charSequence);
123
125
  scanCallback.invoke("Companion association failed: " + charSequence.toString());
124
126
  scanCallback = null;
127
+ WritableMap map = Arguments.createMap();
128
+ map.putString("error", charSequence.toString());
129
+ bleManager.sendEvent("BleManagerCompanionFailure", map);
125
130
  }
126
131
 
127
132
  @Override
@@ -255,7 +255,13 @@ public class DefaultScanManager extends ScanManager {
255
255
  }
256
256
  };
257
257
 
258
+ @Override
258
259
  public boolean isScanning() {
259
260
  return isScanning;
260
261
  }
262
+
263
+ @Override
264
+ public void setScanning(boolean scanning) {
265
+ isScanning = scanning;
266
+ }
261
267
  }
@@ -104,4 +104,9 @@ public class LegacyScanManager extends ScanManager {
104
104
  public boolean isScanning() {
105
105
  return false;
106
106
  }
107
+
108
+ @Override
109
+ public void setScanning(boolean value) {
110
+
111
+ }
107
112
  }
@@ -39,4 +39,6 @@ public abstract class ScanManager {
39
39
  public abstract void scan(ReadableArray serviceUUIDs, final int scanSeconds, ReadableMap options, Callback callback);
40
40
 
41
41
  public abstract boolean isScanning();
42
+
43
+ public abstract void setScanning(boolean value);
42
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ble-manager",
3
- "version": "11.5.2",
3
+ "version": "11.5.3",
4
4
  "description": "A BLE module for react native.",
5
5
  "repository": {
6
6
  "type": "git",