Skip to content

Commit

Permalink
Merge branch 'master' into android-neverforlocation-opt-out
Browse files Browse the repository at this point in the history
  • Loading branch information
boskokg authored Oct 14, 2022
2 parents fe3760e + 9a6808a commit 61306b6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
## 1.4.0
**Breaking Change**
* Android: Opt-out of the `neverForLocation` permission flag for the `BLUETOOTH_SCAN` permission.

If `neverForLocation` is desired,
Expand All @@ -8,6 +7,9 @@
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation" />
```
* Android: Scan BLE long range -devices #139 (thanks to jonik-dev)
* Android: Prevent deprecation warnings #107 (thanks to sqcsabbey)
* Allow native implementation to handle pairing request #109 (thanks to JRazek)

## 1.3.1
* Reverted: Ios: fixed manufacturer data parsing #104 (thanks to sqcsabbey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,16 @@ private void startScan21(Protos.ScanSettings proto) throws IllegalStateException
if(scanner == null) throw new IllegalStateException("getBluetoothLeScanner() is null. Is the Adapter on?");
int scanMode = proto.getAndroidScanMode();
List<ScanFilter> filters = fetchFilters(proto);
ScanSettings settings = new ScanSettings.Builder().setScanMode(scanMode).build();
ScanSettings settings;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
settings = new ScanSettings.Builder()
.setPhy(ScanSettings.PHY_LE_ALL_SUPPORTED)
.setLegacy(false)
.setScanMode(scanMode)
.build();
} else {
settings = new ScanSettings.Builder().setScanMode(scanMode).build();
}
scanner.startScan(filters, settings, getScanCallback21());
}

Expand Down Expand Up @@ -932,6 +941,7 @@ private BluetoothAdapter.LeScanCallback getScanCallback18() {
return scanCallback18;
}

@SuppressWarnings("deprecation")
private void startScan18(Protos.ScanSettings proto) throws IllegalStateException {
List<String> serviceUuids = proto.getServiceUuidsList();
UUID[] uuids = new UUID[serviceUuids.size()];
Expand All @@ -942,6 +952,7 @@ private void startScan18(Protos.ScanSettings proto) throws IllegalStateException
if(!success) throw new IllegalStateException("getBluetoothLeScanner() is null. Is the Adapter on?");
}

@SuppressWarnings("deprecation")
private void stopScan18() {
mBluetoothAdapter.stopLeScan(getScanCallback18());
}
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.3.1"
version: "1.4.0"
flutter_lints:
dependency: "direct dev"
description:
Expand Down
6 changes: 2 additions & 4 deletions lib/src/bluetooth_device.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ class BluetoothDevice {
/// Send a pairing request to the device.
/// Currently only implemented on Android.
Future<void> pair() async {
if (Platform.isAndroid) {
return FlutterBluePlus.instance._channel
.invokeMethod('pair', id.toString());
}
return FlutterBluePlus.instance._channel
.invokeMethod('pair', id.toString());
}

/// Cancels connection to the Bluetooth Device
Expand Down

0 comments on commit 61306b6

Please sign in to comment.