Closed akimakitalo closed 4 years ago
Looks like there's not an easy fix here.
According to this SO post, modifying Bluetooth state programmatically (without prompting user permission) on Android 9+ requires WRITE_SETTINGS
permission which itself requires a special permission request process (see here).
So the best course of action (as you've suggested) would be to try to hook in to the outcome of the permission request dialog. However so far I've not found any example of how the plugin can get async notification of the user decision in that dialog on Android 9.
I've tested this on a Pixel 2 running Android 9.0 and I'm not seeing the permissions dialog appear: setBluetoothState()
works as expected.
So I wonder if this is specific to the Huawei Honor 9 variant of Android 9?
Also tested on Android 10/Q Beta 4 running on Pixel 2 and also no permissions dialog when using setBluetoothState()
to enable/disable the Bluetooth device setting
Closed as unable to repro
I know this is closed, but in order to reproduce, you need a Huawei phone with Android 9+.
I'm submitting a ... (check one with "x"):
Bug report
Current behavior: On android version 9 (Honor 9), setBluetoothState() does not work correctly anymore, and successCallback returns an incorrect value. I cannot confirm if this is a general change on android 9.0, or if this is a Huawei change that applies to Honor phones.
Prior to update to android 9, setBluetoothState correctly turned bluetooth on, while success callback was called properly.
After updating to android 9, setBluetoothState now causes a popup from OS asking the user to allow/deny change to bluetooth state. Presumably this is a security update intended to limit the ability of apps to change bluetooth state without user permission.
However the success callback is still called immediately and always returns OK, even if user has not yet granted permission to let the application change the bluetooth state or even if user ultimately denies permission.
Example of how it works right now on android 9:
Expected behavior: setBluetoothState() should probably wait for user confirmation before calling the success callback, and call errorCallback if user denies permission to change bluetooth state.
Example on how it should work:
Steps to reproduce:
On android 9, simply do the following:
Environment information
8.0.0
android 7.1.4
cordova.plugins.diagnostic 4.0.12 "Diagnostic"
Win 7 professional
Runtime issue
Huawei Honor 9 (STF-L09)
Android version 9, EMUI: 9.0.1.162 (C432E2R1P5)