I have been testing Android 14 with bidirectionnal client and server connection, using BleManager.connect with autoConnect = true to connect to a Ble device, it works great with all versions below, but seems to be broken on Android 14. I can connect with it, the first disconnection and reconnection works, but after the second disconnection, the device never reconnects.
The cause :
From what I understand, if autoconnect is used with true, the library first connects with autoConnect false. Then the library uses gatt.connect() on the first disconnection to trigger the autoconnect to true. The problem seems that the gatt.connect() on Android 14 does not do the same as before, it doesn't set autoConnect to true and works only for the next connection. So after the second disconnection, the device does not reconnect anymore.
Diagnosis :
I first noticed that on the first disconnection on Android 14, we have a log not present on previous Android versions :
Connecting...
10:36:10.030 D gatt.connect()
10:36:10.031 D connect(void) - device: XX:XX:XX:XX:6D:DE, auto=false // HERE
It seems like its autoconnecting with false here. It can only reconnect once after this.
So I have been playing with autoconnect without the library and Android 14 :
If I connect with first autoconnect false, then gatt.connect after the first disconnection, it behave like I mentioned before and doesn't reconnect after the second disconnection
If I connect with first autoconnect false, then autoconnect = true after the first disconnection it works
Fix :
To fix it, use a connectGatt with autoConnect = true if we detect Android 14 on the phone.
Hi,
The issue :
I have been testing Android 14 with bidirectionnal client and server connection, using BleManager.connect with
autoConnect = true
to connect to a Ble device, it works great with all versions below, but seems to be broken on Android 14. I can connect with it, the first disconnection and reconnection works, but after the second disconnection, the device never reconnects.The cause :
From what I understand, if autoconnect is used with true, the library first connects with autoConnect false. Then the library uses
gatt.connect()
on the first disconnection to trigger the autoconnect to true. The problem seems that thegatt.connect()
on Android 14 does not do the same as before, it doesn't set autoConnect to true and works only for the next connection. So after the second disconnection, the device does not reconnect anymore.Diagnosis :
I first noticed that on the first disconnection on Android 14, we have a log not present on previous Android versions :
It seems like its autoconnecting with false here. It can only reconnect once after this.
So I have been playing with autoconnect without the library and Android 14 :
gatt.connect
after the first disconnection, it behave like I mentioned before and doesn't reconnect after the second disconnectionautoconnect = true
after the first disconnection it worksFix :
To fix it, use a connectGatt with autoConnect = true if we detect Android 14 on the phone.