Skip to content

Commit 7287aab

Browse files
authored
Removed unsafe manifest permissions and updated readme
1 parent d167a70 commit 7287aab

File tree

7 files changed

+138
-135
lines changed

7 files changed

+138
-135
lines changed

README.md

Lines changed: 55 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,25 @@
44

55
Flutter library that handles BLE operations for multiple devices.
66

7-
## Usage
7+
## Contributing
8+
Feel free to open an new issue or a pull request to make this project better
9+
10+
## Setup
11+
12+
This project uses melos to manage all the packages inside this repo.
13+
14+
Install melos: `dart pub global activate melos`
15+
Setup melos to point to the dependencies in your local folder: `melos bootstrap`
16+
17+
### Android
18+
19+
Library requires kotlin version `1.5.31`.
20+
21+
### Update kotlin version
22+
23+
To update the kotlin version open Android studio and go to `Tools > Kotlin > Configure Kotlin plugin updates` and update `Update channel` to `1.5.x`.
24+
25+
## Features
826

927
The reactive BLE lib supports the following:
1028

@@ -18,6 +36,41 @@ The reactive BLE lib supports the following:
1836
- Clear GATT cache
1937
- Negotiate MTU size
2038

39+
## Getting Started
40+
### Android
41+
42+
You need to add the following permissions to your AndroidManifest.xml file:
43+
```xml
44+
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
45+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
46+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" />
47+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="30" />
48+
```
49+
50+
If you use `BLUETOOTH_SCAN` to determine location, remove `android:usesPermissionFlags="neverForLocation"`
51+
52+
If you use location services in your app, remove `android:maxSdkVersion="30"` from the location permission tags
53+
54+
### Android ProGuard rules
55+
In case you are using ProGuard add the following snippet to your `proguard-rules.pro` file:
56+
57+
```
58+
-keep class com.signify.hue.** { *; }
59+
```
60+
61+
This will prevent issues like [#131](https://github.com/PhilipsHue/flutter_reactive_ble/issues/131).
62+
63+
### iOS
64+
65+
For iOS it is required you add the following entries to the `Info.plist` file of your app. It is not allowed to access Core BLuetooth without this. See [our example app](https://github.com/PhilipsHue/flutter_reactive_ble/blob/master/example/ios/Runner/Info.plist) on how to implement this. For more indepth details: [Blog post on iOS bluetooth permissions](https://medium.com/flawless-app-stories/handling-ios-13-bluetooth-permissions-26c6a8cbb816)
66+
67+
iOS13 and higher
68+
* NSBluetoothAlwaysUsageDescription
69+
70+
iOS12 and lower
71+
* NSBluetoothPeripheralUsageDescription
72+
73+
## Usage
2174
### Initialization
2275

2376
Initializing the library should be done the following:
@@ -168,24 +221,6 @@ The Android OS maintains a table per device of the discovered service in cache.
168221
await flutterReactiveBle.clearGattCache(foundDeviceId);
169222
```
170223

171-
### Contributing
172-
Feel free to open an new issue or a pull request to make this project better
173-
174-
#### Setup
175-
176-
This project uses melos to manage all the packages inside this repo.
177-
178-
Install melos: `dart pub global activate melos`
179-
Setup melos to point to the dependencies in your local folder: `melos bootstrap`
180-
181-
### Android
182-
183-
Library requires kotlin version `1.5.31`.
184-
185-
#### Update kotlin version
186-
187-
To update the kotlin version open Android studio and go to `Tools > Kotlin > Configure Kotlin plugin updates` and update `Update channel` to `1.5.x`.
188-
189224
### FAQ
190225

191226
#### How to handle the BLE undeliverable exception
@@ -208,56 +243,6 @@ RxJavaPlugins.setErrorHandler { throwable ->
208243
}
209244
```
210245

211-
#### Which permissions are needed?
212-
**Android**
213-
214-
For android the library uses the following permissions, depending on the SDK level:
215-
216-
Up to SDK 30 (Android 11):
217-
* ACCESS_FINE_LOCATION : this permission is needed because old Nexus devices need location services in order to provide reliable scan results
218-
* BLUETOOTH : allows apps to connect to a paired Bluetooth device
219-
* BLUETOOTH_ADMIN: allows apps to discover and pair Bluetooth devices
220-
* BLUETOOTH_SCAN: add this permission with `tools:node="remove"` to remove it from the merged manifest.
221-
```
222-
<uses-permission
223-
android:name="android.permission.BLUETOOTH_SCAN"
224-
android:usesPermissionFlags="neverForLocation" tools:node="remove" />
225-
```
226-
This will prevent issues like [#410](https://github.com/PhilipsHue/flutter_reactive_ble/issues/410).
227-
228-
229-
SDK 31 and up (Android 12+):
230-
* BLUETOOTH_CONNECT: allows apps to connect to a Bluetooth device
231-
* BLUETOOTH_SCAN: allows apps to scan for Bluetooth devices
232-
233-
These permissions are already added in the manifest of this library and thus should automatically merge
234-
into the manifest of your app. It is not needed to add the permissions in your manifest.
235-
236-
Only when using Android SDK 31 (Android 12) and higher please make sure you manifest is correctly setup
237-
regarding `android:usesPermissionFlags="neverForLocation"` for the `android:name="android.permission.BLUETOOTH_SCAN"` permission,
238-
depending on the use cases of your app. See [This link](https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#declare-android12-or-higher)
239-
for more information and [the manifest of the example app](https://github.com/PhilipsHue/flutter_reactive_ble/blob/master/example/android/app/src/main/AndroidManifest.xml) for an example usage.
240-
241-
**iOS**
242-
243-
For iOS it is required you add the following entries to the `Info.plist` file of your app. It is not allowed to access Core BLuetooth without this. See [our example app](https://github.com/PhilipsHue/flutter_reactive_ble/blob/master/example/ios/Runner/Info.plist) on how to implement this. For more indepth details: [Blog post on iOS bluetooth permissions](https://medium.com/flawless-app-stories/handling-ios-13-bluetooth-permissions-26c6a8cbb816)
244-
245-
iOS13 and higher
246-
* NSBluetoothAlwaysUsageDescription
247-
248-
iOS12 and lower
249-
* NSBluetoothPeripheralUsageDescription
250-
251-
#### How to adjust ProGuard (Android)
252-
253-
In case you are using ProGuard add the following snippet to your `proguard-rules.pro` file:
254-
255-
```
256-
-keep class com.signify.hue.** { *; }
257-
```
258-
259-
This will prevent issues like [#131](https://github.com/PhilipsHue/flutter_reactive_ble/issues/131).
260-
261246
#### Why doesn't the BLE stack directly connect to my peripheral
262247

263248
Before you are able to execute BLE operations the BLE-stack of the device makes sure everything is setup correctly and then reports ready for operation. For some devices this takes a bit longer than for others. When starting the app make sure that the BLE-stack is properly initialized before you execute BLE operations. The safest way to do this is by listening to the `statusStream` and wait for `BleStatus.ready`.
@@ -266,4 +251,4 @@ This will prevent issues like [#147](https://github.com/PhilipsHue/flutter_react
266251

267252
#### Unofficial example apps
268253

269-
Example implementation UART over BLE:[link](https://github.com/wolfc01/flutter_reactive_ble_uart_example)
254+
Example implementation UART over BLE:[link](https://github.com/wolfc01/flutter_reactive_ble_uart_example)

example/pubspec.lock

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,13 @@ packages:
312312
url: "https://pub.dartlang.org"
313313
source: hosted
314314
version: "0.12.11"
315+
material_color_utilities:
316+
dependency: transitive
317+
description:
318+
name: material_color_utilities
319+
url: "https://pub.dartlang.org"
320+
source: hosted
321+
version: "0.1.3"
315322
meta:
316323
dependency: transitive
317324
description:
@@ -404,11 +411,11 @@ packages:
404411
source: path
405412
version: "5.0.2"
406413
reactive_ble_platform_interface:
407-
dependency: "direct overridden"
414+
dependency: transitive
408415
description:
409-
path: "../packages/reactive_ble_platform_interface"
410-
relative: true
411-
source: path
416+
name: reactive_ble_platform_interface
417+
url: "https://pub.dartlang.org"
418+
source: hosted
412419
version: "5.0.2"
413420
shelf:
414421
dependency: transitive
@@ -484,7 +491,7 @@ packages:
484491
name: test_api
485492
url: "https://pub.dartlang.org"
486493
source: hosted
487-
version: "0.4.3"
494+
version: "0.4.8"
488495
timing:
489496
dependency: transitive
490497
description:
@@ -529,4 +536,4 @@ packages:
529536
version: "3.1.0"
530537
sdks:
531538
dart: ">=2.14.0 <3.0.0"
532-
flutter: ">=1.16.0"
539+
flutter: ">=2.0.0"

packages/flutter_reactive_ble/README.md

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Flutter library that handles BLE operations for multiple devices.
66

7-
## Usage
7+
## Features
88

99
The reactive BLE lib supports the following:
1010

@@ -18,6 +18,41 @@ The reactive BLE lib supports the following:
1818
- Clear GATT cache
1919
- Negotiate MTU size
2020

21+
## Getting Started
22+
### Android
23+
24+
You need to add the following permissions to your AndroidManifest.xml file:
25+
```xml
26+
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
27+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
28+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" />
29+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="30" />
30+
```
31+
32+
If you use `BLUETOOTH_SCAN` to determine location, remove `android:usesPermissionFlags="neverForLocation"`
33+
34+
If you use location services in your app, remove `android:maxSdkVersion="30"` from the location permission tags
35+
36+
### Android ProGuard rules
37+
In case you are using ProGuard add the following snippet to your `proguard-rules.pro` file:
38+
39+
```
40+
-keep class com.signify.hue.** { *; }
41+
```
42+
43+
This will prevent issues like [#131](https://github.com/PhilipsHue/flutter_reactive_ble/issues/131).
44+
45+
### iOS
46+
47+
For iOS it is required you add the following entries to the `Info.plist` file of your app. It is not allowed to access Core BLuetooth without this. See [our example app](https://github.com/PhilipsHue/flutter_reactive_ble/blob/master/example/ios/Runner/Info.plist) on how to implement this. For more indepth details: [Blog post on iOS bluetooth permissions](https://medium.com/flawless-app-stories/handling-ios-13-bluetooth-permissions-26c6a8cbb816)
48+
49+
iOS13 and higher
50+
* NSBluetoothAlwaysUsageDescription
51+
52+
iOS12 and lower
53+
* NSBluetoothPeripheralUsageDescription
54+
55+
## Usage
2156
### Initialization
2257

2358
Initializing the library should be done the following:
@@ -54,7 +89,7 @@ _ble.statusStream.listen((status) {
5489

5590
Use ` _ble.status` to get the current status of the host device.
5691

57-
See [BleStatus](https://github.com/PhilipsHue/flutter_reactive_ble/blob/master/lib/src/model/ble_status.dart) for
92+
See [BleStatus](https://github.com/PhilipsHue/flutter_reactive_ble/blob/master/packages/reactive_ble_platform_interface/lib/src/model/ble_status.dart) for
5893
more info about the meaning of the different statuses.
5994

6095
### Establishing connection
@@ -190,37 +225,6 @@ RxJavaPlugins.setErrorHandler { throwable ->
190225
}
191226
```
192227

193-
#### Which permissions are needed?
194-
**Android**
195-
196-
For android the library uses the following permissions:
197-
* ACCESS_FINE_LOCATION : this permission is needed because old Nexus devices need location services in order to provide reliable scan results
198-
* BLUETOOTH : allows apps to connect to a paired bluetooth device
199-
* BLUETOOTH_ADMIN: allows apps to discover and pair bluetooth devices
200-
201-
These permissions are already added in the manifest of the this library and thus should automatically merge
202-
into the manifest of your app. It is not needed to add the permissions in your manifest.
203-
204-
**iOS**
205-
206-
For iOS it is required you add the following entries to the `Info.plist` file of your app. It is not allowed to access Core BLuetooth without this. See [our example app](https://github.com/PhilipsHue/flutter_reactive_ble/blob/master/example/ios/Runner/Info.plist) on how to implement this. For more indepth details: [Blog post on iOS bluetooth permissions](https://medium.com/flawless-app-stories/handling-ios-13-bluetooth-permissions-26c6a8cbb816)
207-
208-
iOS13 and higher
209-
* NSBluetoothAlwaysUsageDescription
210-
211-
iOS12 and lower
212-
* NSBluetoothPeripheralUsageDescription
213-
214-
#### How to adjust ProGuard (Android)
215-
216-
In case you are using ProGuard add the following snippet to your `proguard-rules.pro` file:
217-
218-
```
219-
-keep class com.signify.hue.** { *; }
220-
```
221-
222-
This will prevent issues like [#131](https://github.com/PhilipsHue/flutter_reactive_ble/issues/131).
223-
224228
#### Why doesn't the BLE stack directly connect to my peripheral
225229

226230
Before you are able to execute BLE operations the BLE-stack of the device makes sure everything is setup correctly and then reports ready for operation. For some devices this takes a bit longer than for others. When starting the app make sure that the BLE-stack is properly initialized before you execute BLE operations. The safest way to do this is by listening to the `statusStream` and wait for `BleStatus.ready`.

packages/flutter_reactive_ble/pubspec.lock

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,13 @@ packages:
291291
url: "https://pub.dartlang.org"
292292
source: hosted
293293
version: "0.12.11"
294+
material_color_utilities:
295+
dependency: transitive
296+
description:
297+
name: material_color_utilities
298+
url: "https://pub.dartlang.org"
299+
source: hosted
300+
version: "0.1.3"
294301
meta:
295302
dependency: "direct main"
296303
description:
@@ -371,16 +378,16 @@ packages:
371378
reactive_ble_mobile:
372379
dependency: "direct main"
373380
description:
374-
path: "../reactive_ble_mobile"
375-
relative: true
376-
source: path
381+
name: reactive_ble_mobile
382+
url: "https://pub.dartlang.org"
383+
source: hosted
377384
version: "5.0.2"
378385
reactive_ble_platform_interface:
379386
dependency: "direct main"
380387
description:
381-
path: "../reactive_ble_platform_interface"
382-
relative: true
383-
source: path
388+
name: reactive_ble_platform_interface
389+
url: "https://pub.dartlang.org"
390+
source: hosted
384391
version: "5.0.2"
385392
shelf:
386393
dependency: transitive
@@ -456,7 +463,7 @@ packages:
456463
name: test_api
457464
url: "https://pub.dartlang.org"
458465
source: hosted
459-
version: "0.4.3"
466+
version: "0.4.8"
460467
timing:
461468
dependency: transitive
462469
description:

packages/reactive_ble_mobile/android/src/main/AndroidManifest.xml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,4 @@
88
<uses-permission
99
android:name="android.permission.BLUETOOTH_ADMIN"
1010
android:maxSdkVersion="30" />
11-
12-
<!-- required for API 23 - 30 -->
13-
<uses-permission-sdk-23
14-
android:name="android.permission.ACCESS_COARSE_LOCATION"
15-
android:maxSdkVersion="30" />
16-
<uses-permission-sdk-23
17-
android:name="android.permission.ACCESS_FINE_LOCATION"
18-
android:maxSdkVersion="30" />
19-
20-
<!-- API 31+ -->
21-
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
22-
<!-- add android:usesPermissionFlags="neverForLocation" when you can strongly assert that
23-
your app never derives physical location from Bluetooth scan results. -->
24-
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
2511
</manifest>

0 commit comments

Comments
 (0)