Polar SDK searchForDevice() doesn't work on phones running Android 10/EMUI (Huawei, Xiaomi)
orestesgaolin opened this issue · 1 comments
Platform on which you observed the bug:
- Android
- iOS
- Other
- Platform is not relevant for this bug
Device on which you observed the bug:
- Polar OH1
- Polar Verity Sense
- Polar H10
- Polar H9
- Other
- Device is not relevant for this bug
Describe the bug
Polar bands cannot be discovered when using searchForDevice()
on Huawei/Xiaomi phones (EMUI 12, Android 10).This seems to be similar to #330.
We have the same issue running Huawei P30 Lite and Android 10 (EMUI 12). Interestingly this issue has been introduced in one of the OEM software updates. I don't have the exact build number of the previously working EMUI version, but after updating overnight to 12.0.0.262
the Polar SDK stopped reporting devices.
We are using ACCESS_BACKGROUND_LOCATION
permission, but it doesn't help.
How to Reproduce
Polar SDK com.github.polarofficial:polar-ble-sdk:5.5.0
searchDisposable = PolarBleApiDefaultImpl.defaultImplementation(
applicationContext,
PolarBleApi.PolarBleSdkFeature.values().toSet()
)
.searchForDevice()
.subscribe(
{ data ->
Logger.info(TAG, "Received ${data.deviceId} ${data.isConnectable} ${data.rssi} ${data.name}")
set.add(DeviceConnection(
BtConnectionStatus.Unknown,
data.deviceId,
data.name,
data.address,
data.isConnectable,
))
Handler(Looper.getMainLooper()).post {
eventSink.success(
"[${set.joinToString(",")}]"
)
}
},
{
error ->
Logger.error(TAG, "Error occurred when searching for Polar devices", error)
}
)
Expected behavior
Scan should return Polar devices or throw error if there's something missing e.g. in terms of permissions.
Screenshots and logs
Permissions:
Some logcat entries filtered by "bluetooth":
2024-03-06 09:52:03.663 3526-4923 BluetoothLeScanner com.huawei.nearby D onScannerRegistered() - status=0 scannerId=8 mScannerId=0
2024-03-06 09:52:03.665 3042-3211 BluetoothState com.huawei.iaware I new active bluetooth uid: 1000, pid:3526, reason:BLE_SCAN
2024-03-06 09:52:04.762 3526-10207 iconnect:BluetoothApi com.huawei.nearby I adapter status 12
2024-03-06 09:52:04.763 3526-10207 iconnect:N...viceDetect com.huawei.nearby I isPropEnable=true, isBluetoothEnabled=true, isScreenOn=true, isNotSpecialAppOnTop=false, scanCondition=2
2024-03-06 09:52:04.763 3526-10207 iconnect:BluetoothApi com.huawei.nearby I adapter status 12
2024-03-06 09:52:04.769 3526-4113 BluetoothAdapter com.huawei.nearby I isLeEnabled(): ON
2024-03-06 09:52:04.779 3183-4173 bt_stack com.android.bluetooth I [INFO:bta_gattc_api.cc(101)] BTA_GATTC_AppDeregister client_if = 8
2024-03-06 09:52:04.779 3183-4173 bt_stack com.android.bluetooth I [INFO:bta_gattc_api.cc(85)] app_deregister_impl client_if = 8
2024-03-06 09:52:04.779 3183-4173 bt_stack com.android.bluetooth E [ERROR:bta_gattc_act.cc(238)] bta_gattc_deregister p_clreg->num_clcb is 0
2024-03-06 09:52:04.779 3183-4173 bt_stack com.android.bluetooth I [INFO:bta_gattc_act.cc(1028)] bta_gattc_deregister_cmpl client_if is 8
2024-03-06 09:52:04.779 3183-4173 bt_stack com.android.bluetooth I [INFO:gatt_api.cc(1016)] GATT_Deregister gatt_if=8
2024-03-06 09:52:04.794 3042-3211 BluetoothState com.huawei.iaware I inactive bluetooth uid: 1000, pid:3526, reason:BLE_SCAN
2024-03-06 09:52:04.794 3042-3211 BluetoothState com.huawei.iaware D stop bt uid:1000 state:BLE_SCAN total(ms):122426
2024-03-06 09:53:47.886 14453-14453 BFSSHI com.REDACTED.tst V bluetooth_foreground_service/connection. onListen called.
2024-03-06 09:53:47.894 14453-14453 BFSSHI com.REDACTED.tst V bluetooth_foreground_service/battery. onListen called.
2024-03-06 09:53:47.895 14453-14453 BFSSHI com.REDACTED.tst V bluetooth_foreground_service/version. onListen called.
2024-03-06 09:53:47.896 14453-14453 BFSSHI com.REDACTED.tst V bluetooth_foreground_service/contact. onListen called.
2024-03-06 09:53:47.919 14453-14453 BFSSHI com.REDACTED.tst V bluetooth_foreground_service/synchronization. onListen called.
2024-03-06 09:53:48.570 14453-14453 BluetoothAdapter com.REDACTED.tst I isLeEnabled(): ON
2024-03-06 09:55:20.073 14453-14453 BluetoothAdapter com.REDACTED.tst I isLeEnabled(): ON
2024-03-06 09:55:20.080 3183-4173 bt_stack com.android.bluetooth I [INFO:bta_gattc_act.cc(175)] bta_gattc_register: state:2
2024-03-06 09:55:20.081 3183-4173 bt_stack com.android.bluetooth I [INFO:gatt_api.cc(974)] GATT_Register 3735e93b-6751-072d-8325-bd58ea536996
2024-03-06 09:55:20.081 3183-4173 bt_stack com.android.bluetooth I [INFO:gatt_api.cc(994)] allocated gatt_if=8
2024-03-06 09:55:20.081 3183-4173 bt_stack com.android.bluetooth I [INFO:gatt_api.cc(1090)] GATT_StartIf gatt_if=8
2024-03-06 09:55:20.081 3183-4173 bt_stack com.android.bluetooth I [INFO:gatt_utils.cc(260)] gatt_find_the_connected_bda start_idx=0
2024-03-06 09:55:20.081 3183-4173 bt_stack com.android.bluetooth I [INFO:gatt_utils.cc(272)] found=0 found_idx=7
2024-03-06 09:55:20.082 14453-17390 BluetoothLeScanner com.REDACTED.tst D onScannerRegistered() - status=0 scannerId=8 mScannerId=0
2024-03-06 09:55:20.087 3042-3211 BluetoothState com.huawei.iaware I new active bluetooth uid: 10198, pid:14453, reason:BLE_SCAN
2024-03-06 09:55:20.236 3183-3195 droid.bluetoot com.android.bluetooth W Reducing the number of considered missed Gc histogram windows from 183 to 100
2024-03-06 09:55:20.274 3183-3220 bt_btif com.android.bluetooth W Remote device:a0:9e:**:**:**:eb, no link key or ble key found
2024-03-06 09:55:20.275 3183-3220 chatty com.android.bluetooth I uid=1002(bluetooth) BT Service Call identical 2 lines
2024-03-06 09:55:20.289 3183-3220 bt_btif com.android.bluetooth W Remote device:a0:9e:**:**:**:eb, no link key or ble key found
2024-03-06 09:55:20.453 3183-3220 bt_btif com.android.bluetooth W Remote device:a0:9e:**:**:**:02, no link key or ble key found
2024-03-06 09:55:20.453 3183-3220 chatty com.android.bluetooth I uid=1002(bluetooth) BT Service Call identical 2 lines
2024-03-06 09:55:20.455 3183-3220 bt_btif com.android.bluetooth W Remote device:a0:9e:**:**:**:02, no link key or ble key found
And entire logcat from just before the scan started: