Status Update
Comments
ra...@google.com <ra...@google.com>
ra...@google.com <ra...@google.com> #2
Please provide sample project or apk to reproduce the issue. Also mention the steps to be followed for reproducing the issue with the given sample project or apk.
Android bug report (to be captured after reproducing the issue on latest public build)
For steps to capture a bug report, please refer:
Alternate method
Navigate to “Developer options”, ensure “USB debugging” is enabled, then enable “Bug report shortcut”. Capture bug report by holding the power button and selecting the “Take bug report” option.
Note: Please upload the bug report to google drive and share the folder to android-bugreport@google.com, then share the link here.
lk...@gmail.com <lk...@gmail.com> #3
The easiest way to reproduce the issue is by using an app like Nordic's
Prerequisites:
Any BLE device you can create a GATT connection to
Steps to reproduce:
- Open nRF Connect for Mobile
- Discover the BLE device
- Create a connection to the BLE device
- Pull from the left side of the screen in nRF to reveal the log window (or look at logcat on a connected computer)
- Terminate the BLE connection by powering off or taking the BLE device out of range
Expected result:
If the BLE device is taken out of range, the GATT status value in
If the BLE device terminates the connection, the GATT status value in
The GATT status should only be '0' when the app closes the connection via a call to
Actual result:
In Android 12, regardless how the BLE connection is terminated the GATT status is always '0'.
See attached screen shot ('Comparison.png') for a comparison between an older Android version and Android 12.
Pixel 12:
GATT_CONN_TIMEOUT, disconnect reason 8:
2021-11-29 11:48:13.635 13689-13722/? D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=9 device=xx:xx:xx:xx:xx:xx
GATT_CONN_TERMINATE_PEER_USER, disconnect reason 19:
2021-11-29 11:53:02.644 13689-21741/? D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=9 device=xx:xx:xx:xx:xx:xx
Bugreport
lk...@gmail.com <lk...@gmail.com> #4
The headline 'Pixel 12' should have been: 'Pixel 4, Android 12'. 😀
ra...@google.com <ra...@google.com> #5
We have shared this with our product and engineering team and will update this issue with more information as it becomes available.
lk...@gmail.com <lk...@gmail.com> #6
If you look into the HCI snoop log, you can see that the disconnect reasons (0x08 and 0x13), are correctly shown there.
Though I noticed that in the HCI log, there is a 'Status: Success (0x00)' field. Is this the one which is now passed on to the onClientConnectionState() / onConnectionStateChanged() methods?
If that is the case, then how do we get the 'disconnect reason' through the API in Android 12?
Android 12:
GATT_CONN_TIMEOUT, disconnect reason 8 ((0x08):
HCI log:
44563 10:48:13.617287 0.000839 controller host HCI_EVT 7 Rcvd Disconnect Complete
Frame 44563: 7 bytes on wire (56 bits), 7 bytes captured (56 bits)
Bluetooth
Bluetooth HCI H4
Bluetooth HCI Event - Disconnect Complete
Event Code: Disconnect Complete (0x05)
Parameter Total Length: 4
Status: Success (0x00)
Connection Handle: 0x0002
Reason: Connection Timeout (0x08)
Log cat:
2021-11-29 11:48:13.635 13689-13722/? D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=9 device=xx:xx:xx:xx:xx:xx
GATT_CONN_TERMINATE_PEER_USER, disconnect reason 19 (0x13):
HCI log:
45054 10:53:02.634023 16.743903 controller host HCI_EVT 7 Rcvd Disconnect Complete
Frame 45054: 7 bytes on wire (56 bits), 7 bytes captured (56 bits)
Bluetooth
Bluetooth HCI H4
Bluetooth HCI Event - Disconnect Complete
Event Code: Disconnect Complete (0x05)
Parameter Total Length: 4
Status: Success (0x00)
Connection Handle: 0x0003
Reason: Remote User Terminated Connection (0x13)
Log cat:
2021-11-29 11:53:02.644 13689-21741/? D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=9 device=xx:xx:xx:xx:xx:xx
Android 11:
GATT_CONN_TIMEOUT, disconnect reason 8 ((0x08):
HCI log:
19997 11:20:16.335340 0.001857 controller host HCI_EVT 7 Rcvd Disconnect Complete
Frame 19997: 7 bytes on wire (56 bits), 7 bytes captured (56 bits)
Bluetooth
Bluetooth HCI H4
Bluetooth HCI Event - Disconnect Complete
Event Code: Disconnect Complete (0x05)
Parameter Total Length: 4
Status: Success (0x00)
Connection Handle: 0x0040
Reason: Connection Timeout (0x08)
Log cat:
12-02 11:20:16.348 10268 25440 26308 D BluetoothGatt: onClientConnectionState() - status=8 clientIf=11 device=52:31:2C:E1:EF:82
12-02 11:20:16.349--BluetoothRemoteDevices -- ACTION_ACL_DISCONNECTED, device is 52312C, reason is 8, linktype is 2
GATT_CONN_TERMINATE_PEER_USER, disconnect reason 19 (0x13):
HCI log:
20386 11:21:13.816370 3.541896 controller host HCI_EVT 7 Rcvd Disconnect Complete
Frame 20386: 7 bytes on wire (56 bits), 7 bytes captured (56 bits)
Bluetooth
Bluetooth HCI H4
Bluetooth HCI Event - Disconnect Complete
Event Code: Disconnect Complete (0x05)
Parameter Total Length: 4
Status: Success (0x00)
Connection Handle: 0x0040
Reason: Remote User Terminated Connection (0x13)
Log cat:
12-02 11:21:13.826 10268 25440 26126 D BluetoothGatt: onClientConnectionState() - status=19 clientIf=11 device=52:31:2C:E1:EF:82
12-02 11:21:13.828--BluetoothRemoteDevices -- ACTION_ACL_DISCONNECTED, device is 52312C, reason is 19, linktype is 2
lk...@gmail.com <lk...@gmail.com> #7
Same situation with Android 12L Beta on Pixel 4 :( - still always returns 'status = 0'.
Pixel 4, SB1.211112.006
lk...@gmail.com <lk...@gmail.com> #8
...and also still a problem on Pixel 6 with the January patch: SQ1D.220105.007
lk...@gmail.com <lk...@gmail.com> #9
...and on Pixel 4 with Android 13 developer preview: TPP1.220114.016
da...@gmail.com <da...@gmail.com> #10
al...@gmail.com <al...@gmail.com> #11
da...@gmail.com <da...@gmail.com> #12
sh...@striiv.com <sh...@striiv.com> #13
Is there any update on this? When this issue is going to be fixed?
lk...@gmail.com <lk...@gmail.com> #14
The situation is unchanged for 12.1.0 (SP2A.220305.012, Mar 2022) :(
ma...@sensoriainc.com <ma...@sensoriainc.com> #15
ju...@gmail.com <ju...@gmail.com> #16
lk...@gmail.com <lk...@gmail.com> #17
Nope. Same problem in Android 12.1 May and Android 13 beta 2 😣
al...@gmail.com <al...@gmail.com> #18
[Deleted User] <[Deleted User]> #19
lk...@gmail.com <lk...@gmail.com> #20
In
We still need these disconnect reasons in order help our customers when something goes wrong. As it is now, we have no way of knowing if a disconnect was caused by the the user walking out of range, a phone error, a device error etc, so we cannot guide the user on how to recover, when the connection breaks.
/**
* Converts HCI disconnect reasons to Android disconnect reasons.
* <p>
* The HCI Error Codes used for ACL disconnect reasons propagated up from native code were
* copied from: packages/modules/Bluetooth/system/stack/include/hci_error_code.h
* <p>
* These error codes are specified and described in Bluetooth Core Spec v5.1, Vol 2, Part D.
*
* @param hciReason is the raw HCI disconnect reason from native.
* @return the Android disconnect reason for apps.
*/
static @BluetoothAdapter.BluetoothConnectionCallback.DisconnectReason int
hciToAndroidDisconnectReason(int hciReason) {
switch(hciReason) {
case /*HCI_SUCCESS*/ 0x00:
case /*HCI_ERR_UNSPECIFIED*/ 0x1F:
case /*HCI_ERR_UNDEFINED*/ 0xff:
return BluetoothStatusCodes.ERROR_UNKNOWN;
case /*HCI_ERR_ILLEGAL_COMMAND*/ 0x01:
case /*HCI_ERR_NO_CONNECTION*/ 0x02:
case /*HCI_ERR_HW_FAILURE*/ 0x03:
case /*HCI_ERR_DIFF_TRANSACTION_COLLISION*/ 0x2A:
case /*HCI_ERR_ROLE_SWITCH_PENDING*/ 0x32:
case /*HCI_ERR_ROLE_SWITCH_FAILED*/ 0x35:
return BluetoothStatusCodes.ERROR_DISCONNECT_REASON_LOCAL;
case /*HCI_ERR_PAGE_TIMEOUT*/ 0x04:
case /*HCI_ERR_CONNECTION_TOUT*/ 0x08:
case /*HCI_ERR_HOST_TIMEOUT*/ 0x10:
case /*HCI_ERR_LMP_RESPONSE_TIMEOUT*/ 0x22:
case /*HCI_ERR_ADVERTISING_TIMEOUT*/ 0x3C:
case /*HCI_ERR_CONN_FAILED_ESTABLISHMENT*/ 0x3E:
return BluetoothStatusCodes.ERROR_DISCONNECT_REASON_TIMEOUT;
case /*HCI_ERR_AUTH_FAILURE*/ 0x05:
case /*HCI_ERR_KEY_MISSING*/ 0x06:
case /*HCI_ERR_HOST_REJECT_SECURITY*/ 0x0E:
case /*HCI_ERR_REPEATED_ATTEMPTS*/ 0x17:
case /*HCI_ERR_PAIRING_NOT_ALLOWED*/ 0x18:
case /*HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE*/ 0x25:
case /*HCI_ERR_UNIT_KEY_USED*/ 0x26:
case /*HCI_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED*/ 0x29:
case /*HCI_ERR_INSUFFCIENT_SECURITY*/ 0x2F:
case /*HCI_ERR_HOST_BUSY_PAIRING*/ 0x38:
return BluetoothStatusCodes.ERROR_DISCONNECT_REASON_SECURITY;
case /*HCI_ERR_MEMORY_FULL*/ 0x07:
case /*HCI_ERR_MAX_NUM_OF_CONNECTIONS*/ 0x09:
case /*HCI_ERR_MAX_NUM_OF_SCOS*/ 0x0A:
case /*HCI_ERR_COMMAND_DISALLOWED*/ 0x0C:
case /*HCI_ERR_HOST_REJECT_RESOURCES*/ 0x0D:
case /*HCI_ERR_LIMIT_REACHED*/ 0x43:
return BluetoothStatusCodes.ERROR_DISCONNECT_REASON_RESOURCE_LIMIT_REACHED;
case /*HCI_ERR_CONNECTION_EXISTS*/ 0x0B:
return BluetoothStatusCodes.ERROR_DISCONNECT_REASON_CONNECTION_ALREADY_EXISTS;
case /*HCI_ERR_HOST_REJECT_DEVICE*/ 0x0F:
return BluetoothStatusCodes.ERROR_DISCONNECT_REASON_SYSTEM_POLICY;
case /*HCI_ERR_ILLEGAL_PARAMETER_FMT*/ 0x12:
return BluetoothStatusCodes.ERROR_DISCONNECT_REASON_BAD_PARAMETERS;
case /*HCI_ERR_PEER_USER*/ 0x13:
return BluetoothStatusCodes.ERROR_DISCONNECT_REASON_REMOTE_REQUEST;
case /*HCI_ERR_CONN_CAUSE_LOCAL_HOST*/ 0x16:
return BluetoothStatusCodes.ERROR_DISCONNECT_REASON_LOCAL_REQUEST;
case /*HCI_ERR_UNSUPPORTED_REM_FEATURE*/ 0x1A:
return BluetoothStatusCodes.ERROR_DISCONNECT_REASON_REMOTE;
case /*HCI_ERR_UNACCEPT_CONN_INTERVAL*/ 0x3B:
return BluetoothStatusCodes.ERROR_DISCONNECT_REASON_BAD_PARAMETERS;
default:
Log.e(TAG, "Invalid HCI disconnect reason: " + hciReason);
return BluetoothStatusCodes.ERROR_UNKNOWN;
}
}
ri...@gmail.com <ri...@gmail.com> #21
Anyone from the Google Team, cxan we get some help on this.
Thanks
Rishabh
lk...@gmail.com <lk...@gmail.com> #22
I just noticed that OnePlus has solved this in their latest Android 13 release - but it is still not working on Pixel phones.
Working, i.e. disconnect reasons are provided:
OnePlus 8T, Android 13, KB2003_11_F.15 (December 5, 2022, security patch)
Still not working:
Pixel 6, Android 13, T2B2.221216.008
ra...@google.com <ra...@google.com> #23
lk...@gmail.com <lk...@gmail.com> #24
Sounds great. Can you provide a change ID? Any news about ud this will go into Android 13, or if we will have to wait for Android 14?
lk...@gmail.com <lk...@gmail.com> #25
lk...@gmail.com <lk...@gmail.com> #26
I just checked QPR3 beta2, and the fix is in!
We are now finally again getting GATT disconnect reasons:
11:48:05.801 [Callback] Connection state changed with status: 8 and new state: DISCONNECTED(0)
11:48:05.802 Error 8 (0x8): GATT CONN TIMEOUT
11:48:05.802 Disconnected
11:48:06.001 [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
Description
I originally filed an issue report for this on 2021-09-02 during the Android 12 beta testing. That report is not publicly accessible, so I am not filing this report, so everyone can see it.
What type of Android issue is this?
Bluetooth Low Energy
What steps would let us observe this issue?
What did you expect to happen?
GATT status = 8
What actually happened?
GATT status = 0
How often has this happened?
Every time
What was the effect of this issue on your device usage, such as lost time or work?
Moderate
Additional comments
Now that Android 12 has been officially released, we have tested this on more phones and SW builds. All Android 12 builds we have tested so far exclusively return BLE GATT status '0' on disconnects - Regardless of why the connection was terminated.
On previous versions of Android, the GATT status describes the disconnection reason as detailed in tGATT_DISCONN_REASON in packages/modules/Bluetooth/system/stack/include/gatt_api.h
With Android 12 all disconnects now result in the GATT status being '0'.
Tested phones:
Google Pixel 4, SP1A.210812.015
Google Pixel 6, SD1A.210817.037
Samsung Galaxy S21, SP1A.210812.016.G991BXXU3BUK8
Bugreport https://issuetracker.google.com/issues/198596180
See