Status Update
Comments
za...@gmail.com <za...@gmail.com> #2
Could you please provide a sample project that reproduces your issue?
You are right about restoring the request codes, but under normal usage of the API, that should not cause this failure.
vi...@google.com <vi...@google.com> #3
Unfortunately I'm unable to reproduce the issue neither in a sample nor in the real project.
These crashes are received from the users of production app. I'll try to add more logs for better understanding what users do before the crash.
za...@gmail.com <za...@gmail.com> #4
Branch: androidx-master-dev
commit b2a3eca325760e3686411e619048e2bc52befda8
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Sep 16 16:55:46 2020
Ensure request code start is consistent after restore
When the ActivityResultRegistry is recreated due to either config change
or process death, the next request code is started at the number of
current request codes without including the initial offset.
We should make sure to include the initial offset on restore to remain
consistent.
Relnote: "When restoring the ActivityResultRegistry, the request codes
are now properly started from their previous value instead of the value
of the number of existing request codes."
Test: all ActivityResultRegistryTest pass
Bug: 168374000
Change-Id: I463711fe19233877f1b534e4a7a3325fcfd8f983
M activity/activity/src/main/java/androidx/activity/result/ActivityResultRegistry.java
vi...@google.com <vi...@google.com> #5
This change ensures the request code matches, if your issue is not solved and you find a way to reproduce it, please file another bug.
ha...@google.com <ha...@google.com> #7
Could you upload the bugreport here for us to look into? Thank you!
it...@gmail.com <it...@gmail.com> #8
Hi, the same crash is occurring in my app as well. It only happens on Android 13 and Android 14, and it has not occurred even once on Android 12 or below. 95% of the devices experiencing this crash are Google Pixel devices. The crash log is exactly the same.
java.lang.SecurityException: Need BLUETOOTH PRIVILEGED permission: Neither user 10296 nor current process has android.permission.BLUETOOTH_PRIVILEGED.
at android.app.ContextImpl.enforce(ContextImpl.java:2332)
at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:2360)
at android.content.ContextWrapper.enforceCallingOrSelfPermission(ContextWrapper.java:982)
at android.content.ContextWrapper.enforceCallingOrSelfPermission(ContextWrapper.java:982)
at com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission(Utils.java:477)
at com.android.bluetooth.gatt.GattService.permissionCheck(GattService.java:473)
at com.android.bluetooth.gatt.GattService.registerForNotification(GattService.java:4042)
at com.android.bluetooth.gatt.GattService$BluetoothGattBinder.registerForNotification(GattService.java:1118)
at com.android.bluetooth.gatt.GattService$BluetoothGattBinder.registerForNotification(GattService.java:1106)
at android.bluetooth.IBluetoothGatt$Stub.onTransact(IBluetoothGatt.java:1088)
at android.os.Binder.execTransactInternal(Binder.java:1337)
at android.os.Binder.execTransact(Binder.java:1278)
ma...@djoglobal.com <ma...@djoglobal.com> #9
Hi,
I can reproduce this crash by doing the following steps on a Pixel 6 with Android 14:
- Connect a BLE HID Keyboard
- Disconnect the BLE HID Keyboard
- Connect my BLE Earbuds
- Open the application of the earbuds
- Wait for the app to crash
- Turn off and on the Bluetooth
- Open the application of the earbuds
- Everything works fine
The crash log:
java.lang.SecurityException: Need BLUETOOTH PRIVILEGED permission: Neither user 10358 nor current process has android.permission.BLUETOOTH_PRIVILEGED.
at android.app.ContextImpl.enforce(ContextImpl.java:2332)
at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:2360)
at android.content.ContextWrapper.enforceCallingOrSelfPermission(ContextWrapper.java:982)
at android.content.ContextWrapper.enforceCallingOrSelfPermission(ContextWrapper.java:982)
at com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission(Utils.java:477)
at com.android.bluetooth.gatt.GattService.permissionCheck(GattService.java:474)
at com.android.bluetooth.gatt.GattService.registerForNotification(GattService.java:4050)
at com.android.bluetooth.gatt.GattService$BluetoothGattBinder.registerForNotification(GattService.java:1119)
at com.android.bluetooth.gatt.GattService$BluetoothGattBinder.registerForNotification(GattService.java:1107)
at android.bluetooth.IBluetoothGatt$Stub.onTransact(IBluetoothGatt.java:1088)
at android.os.Binder.execTransactInternal(Binder.java:1363)
at android.os.Binder.execTransact(Binder.java:1304)
Connecting the BLE HID Keyboard is the key to reproducing the crash. I'm having crashes on one of our products in production with the same stack trace reported by Crashlytics.
ha...@google.com <ha...@google.com> #10
If you could upload the bugreport here, that would be very helpful!
ma...@djoglobal.com <ma...@djoglobal.com> #11
ha...@google.com <ha...@google.com>
za...@gmail.com <za...@gmail.com> #14
That's exciting news. Will it be updated to Android 14 and earlier versions?
ha...@google.com <ha...@google.com> #15
Hi Zacharyli, it seems that this fix won't be included in the last QPR (i.e. QPR 3) of Android 14, so I think it won't be available in Android 14 or below. Thank you!
Description
I would like to report a potential system bug in Android BLE to the Google team. During the debugging of a BLE application, I encountered the following issue with its stack trace as below:
This issue appears to have a low occurrence rate. After this problem occurs, other Bluetooth applications (like nRF Connect) also fail to work properly. However, turning Bluetooth off and then on again seems to restore normal functionality.
Through logcat, I noticed that after enabling notifications for a specific UUID, the notification gets directly shut down by the system and this exception is received (I regret not taking a screenshot of this).