Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on flutter channel 'beta' Android requires permission BLUETOOTH_PRIVILEGED ? #36

Closed
jdar opened this issue Dec 22, 2020 · 3 comments
Closed

Comments

@jdar
Copy link

jdar commented Dec 22, 2020

Context: trying to run the example folder, on android 11.

Works fine on flutter chanel 'stable' (2.10.4). Symptoms below appear on channel 'beta'

When I build and run the app, and click "startScan"
OR
When I add bluetooth permissions to AndroidManifest, build and run the app, and click "startScan"

Then the debug log shows a permission error (below). There are some very old comments that the BLUETOOTH_PRIVILEDGED permission is not available for third-party apps. Perhaps there is a workaround for using some of these functions?

D/BluetoothAdapter(13764): isLeEnabled(): BLE_ON
D/BluetoothLeScanner(13764): onScannerRegistered() - status=0 scannerId=10 mScannerId=0
W/Binder (13764): Caught a RuntimeException from the binder stub implementation.
W/Binder (13764): java.lang.SecurityException: Need BLUETOOTH_PRIVILEGED permission: Neither user 10452 nor current process has android.permission.BLUETOOTH_PRIVILEGED.
W/Binder (13764): at android.os.Parcel.createExceptionOrNull(Parcel.java:2373)
W/Binder (13764): at android.os.Parcel.createException(Parcel.java:2357)
W/Binder (13764): at android.os.Parcel.readException(Parcel.java:2340)
W/Binder (13764): at android.os.Parcel.readException(Parcel.java:2282)
W/Binder (13764): at android.bluetooth.IBluetoothGatt$Stub$Proxy.startScan(IBluetoothGatt.java:1377)
W/Binder (13764): at android.bluetooth.le.BluetoothLeScanner$BleScanCallbackWrapper.onScannerRegistered(BluetoothLeScanner.java:457)
W/Binder (13764): at android.bluetooth.le.IScannerCallback$Stub.onTransact(IScannerCallback.java:115)
W/Binder (13764): at android.os.Binder.execTransactInternal(Binder.java:1159)
W/Binder (13764): at android.os.Binder.execTransact(Binder.java:1123)

I have tried with and without AndroidManifest permissions:

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
<uses-feature android:name="android.hardware.bluetooth_le"
        android:required="false" />
@jdar jdar changed the title on Android, permission BLUETOOTH_PRIVILEGED ? on flutter channel 'beta' Android requires permission BLUETOOTH_PRIVILEGED ? Dec 22, 2020
@Sunbreak
Copy link
Collaborator

You should turn on the bluetoot first. Or you'll get the java.lang.SecurityException: Need BLUETOOTH_PRIVILEGED permission

https://stackoverflow.com/a/49502483/8017194

@Sunbreak
Copy link
Collaborator

Add isBluetoothAvailable to QuickBlue #37

@jdar
Copy link
Author

jdar commented Dec 23, 2020

this works. Thanks!

@jdar jdar closed this as completed Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants