We seem to be having an issue on several Android devices, where reconnecting sometimes triggers an erroneous GATT_INSUF_AUTHORIZATION. This then causes Android to automatically delete the bond information on the phone, meaning our device needs repairing.
Our application uses the same pairing strategy as the ANCS examples found in SDKs 14 and 15. This is easily reproducible using Android nRF connect along with ble_app_ancs_c_pca10040_s132.hex.
The phones that we can reproduce this on so far:
Huawei P10 Lite (Android 7.0)
Pixel (Android 8.0)
Nexus X5, Nokia 6.1 and Pixel (Android 8.1)
So what's going on here that causes this issue? Is there a potential solution?
Android Log:
nRF Connect, 2018-09-06 ANCS (C2:C9:8C:56:D1:0D) V 10:33:12.318 Connecting to C2:C9:8C:56:D1:0D... D 10:33:12.318 gatt = device.connectGatt(autoConnect = true, TRANSPORT_LE, preferred PHY = LE 1M) D 10:33:12.332 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2) I 10:33:12.332 Connected to C2:C9:8C:56:D1:0D D 10:33:12.333 wait(1600ms) V 10:33:13.935 Discovering services... D 10:33:13.935 gatt.discoverServices() D 10:33:13.969 [Callback] Services discovered with status: 0 I 10:33:13.969 Services discovered V 10:33:13.983 Generic Access (0x1800) - Device Name [R W] (0x2A00) - Appearance [R] (0x2A01) - Peripheral Preferred Connection Parameters [R] (0x2A04) - Central Address Resolution [R] (0x2AA6) Generic Attribute (0x1801) D 10:36:03.929 [Callback] Connection state changed with status: 8 and new state: DISCONNECTED (0) E 10:36:03.929 Error 8 (0x8): GATT CONN TIMEOUT I 10:36:03.929 Disconnected D 10:36:03.985 [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED D 10:36:18.163 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED D 10:36:18.163 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2) I 10:36:18.163 Connected to C2:C9:8C:56:D1:0D D 10:36:18.253 wait(1600ms) I 10:36:19.584 Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms) V 10:36:19.854 Discovering services... D 10:36:19.854 gatt.discoverServices() D 10:36:24.555 [Callback] Connection state changed with status: 8 and new state: DISCONNECTED (0) E 10:36:24.555 Error 8 (0x8): GATT CONN TIMEOUT I 10:36:24.555 Disconnected D 10:36:24.600 [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED D 10:36:30.930 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2) D 10:36:30.930 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED D 10:36:30.930 gatt.close() I 10:36:30.966 Connected to C2:C9:8C:56:D1:0D D 10:36:30.966 wait(200) D 10:36:30.980 wait(1600ms) V 10:36:31.168 Connecting to C2:C9:8C:56:D1:0D... D 10:36:31.169 gatt = device.connectGatt(autoConnect = true, TRANSPORT_LE, preferred PHY = LE 1M) D 10:36:31.193 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2) I 10:36:31.193 Connected to C2:C9:8C:56:D1:0D D 10:36:31.195 wait(1600ms) I 10:36:31.368 Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms) I 10:36:31.638 Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 5000ms) V 10:36:32.582 Discovering services... D 10:36:32.582 gatt.discoverServices() D 10:36:32.610 [Callback] Services discovered with status: 0 I 10:36:32.610 Services discovered V 10:36:32.625 Generic Access (0x1800) - Device Name [R W] (0x2A00) - Appearance [R] (0x2A01) - Peripheral Preferred Connection Parameters [R] (0x2A04) - Central Address Resolution [R] (0x2AA6) Generic Attribute (0x1801) V 10:36:32.795 Discovering services... D 10:36:32.795 gatt.discoverServices() D 10:36:32.816 [Callback] Services discovered with status: 0 I 10:36:32.816 Services discovered V 10:36:32.836 Generic Access (0x1800) - Device Name [R W] (0x2A00) - Appearance [R] (0x2A01) - Peripheral Preferred Connection Parameters [R] (0x2A04) - Central Address Resolution [R] (0x2AA6) Generic Attribute (0x1801) I 10:36:37.846 Connection parameters updated (interval: 997.5ms, latency: 0, timeout: 4000ms) D 10:36:49.032 [Callback] Connection state changed with status: 8 and new state: DISCONNECTED (0) E 10:36:49.032 Error 8 (0x8): GATT CONN TIMEOUT I 10:36:49.032 Disconnected D 10:36:49.091 [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED D 10:36:53.291 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED D 10:36:53.291 gatt.close() D 10:36:53.309 wait(200) V 10:36:53.511 Connecting to C2:C9:8C:56:D1:0D... D 10:36:53.512 gatt = device.connectGatt(autoConnect = true, TRANSPORT_LE, preferred PHY = LE 1M) D 10:36:53.541 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2) I 10:36:53.541 Connected to C2:C9:8C:56:D1:0D D 10:36:53.544 wait(1600ms) I 10:36:54.273 Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms) I 10:36:54.452 Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 5000ms) V 10:36:55.144 Discovering services... D 10:36:55.144 gatt.discoverServices() D 10:36:55.167 [Callback] Services discovered with status: 0 I 10:36:55.167 Services discovered V 10:36:55.173 Generic Access (0x1800) - Device Name [R W] (0x2A00) - Appearance [R] (0x2A01) - Peripheral Preferred Connection Parameters [R] (0x2A04) - Central Address Resolution [R] (0x2AA6) Generic Attribute (0x1801) I 10:36:58.780 Connection parameters updated (interval: 997.5ms, latency: 0, timeout: 4000ms) D 10:37:10.723 [Callback] Connection state changed with status: 8 and new state: DISCONNECTED (0) D 10:37:10.723 [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED E 10:37:10.724 Error 8 (0x8): GATT CONN TIMEOUT I 10:37:10.724 Disconnected D 10:37:14.623 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED D 10:37:14.623 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2) I 10:37:14.623 Connected to C2:C9:8C:56:D1:0D D 10:37:14.653 wait(1600ms) V 10:37:16.255 Discovering services... D 10:37:16.255 gatt.discoverServices() D 10:37:16.290 [Callback] Services discovered with status: 0 I 10:37:16.290 Services discovered V 10:37:16.325 Generic Access (0x1800) - Device Name [R W] (0x2A00) - Appearance [R] (0x2A01) - Peripheral Preferred Connection Parameters [R] (0x2A04) - Central Address Resolution [R] (0x2AA6) Generic Attribute (0x1801) W 10:37:23.811 Connection parameters update failed with status 8 (interval: 45.0ms, latency: 0, timeout: 5000ms) E 10:37:23.811 Error 8 (0x8): GATT INSUF AUTHORIZATION D 10:37:23.911 [Callback] Connection state changed with status: 8 and new state: DISCONNECTED (0) D 10:37:23.911 [Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_NONE (10) E 10:37:23.911 Error 8 (0x8): GATT CONN TIMEOUT I 10:37:23.911 Disconnected I 10:37:23.911 Bond information deleted D 10:37:23.911 [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED