Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 0b463845 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Jakub Pawłowski
Browse files

TbsGatt and MCS: unregister adapter state listener to prevent crash

Here is current flow of events when BT is disabled, while we have background scanning eneabled:
MESSAGE_BLUETOOTH_STATE_CHANGE: ON > TURNING_OFF
TbsService: cleanup()
MESSAGE_BLUETOOTH_STATE_CHANGE: TURNING_OFF > BLE_ON


And this happens when we try to enable it afterwards:
MESSAGE_BLUETOOTH_STATE_CHANGE: BLE_ON > TURNING_ON
MESSAGE_BLUETOOTH_STATE_CHANGE: TURNING_ON > ON
TbsService: start()
MESSAGE_BLUETOOTH_STATE_CHANGE: TURNING_ON > ON
TbsGatt : onBluetoothStateChange: state=ON
!Crash!


Crash happens, because in cleanup() we don't unregister Adapter State listener, and it would be executed on old service instance.

After this patch, callback is being unregistered in TbsGatt.cleanup(), and re-registered in TbsGatt.start(), with fresh instance that wouldn't cause crashes.


Test: restart bluetooth while location and background scanning is on
Bug: 304549080
Change-Id: Ibb08948b39f8ff1657a414234f67653b3dc12b25
parent e90b0121
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment