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

Commit 3bf0f6d6 authored by Gopi Sakshihally Bhuthaiah's avatar Gopi Sakshihally Bhuthaiah
Browse files

fix for BT crash caused by factoryReset pandora API.

clearBluetooth() was called when HFP is in `CONNECTING` state
leads to BT Crash.

Bug: 366643930
Test: atest avatar
Flag: TEST_ONLY
Change-Id: Ia71f922bc6020e6aa176fba97b09d002bba0149c
parent 62b8eede
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.bluetooth.BluetoothAssignedNumbers
import android.bluetooth.BluetoothDevice
import android.bluetooth.BluetoothDevice.ADDRESS_TYPE_PUBLIC
import android.bluetooth.BluetoothDevice.BOND_BONDED
import android.bluetooth.BluetoothDevice.BOND_NONE
import android.bluetooth.BluetoothDevice.TRANSPORT_BREDR
import android.bluetooth.BluetoothDevice.TRANSPORT_LE
import android.bluetooth.BluetoothManager
@@ -166,6 +167,15 @@ class Host(
            // remove bond for each device to avoid auto connection if remote resets faster
            for (device in bluetoothAdapter.bondedDevices) {
                device.removeBond()
                Log.i(TAG, "wait for remove bond to complete : device=$device")
                flow
                    .filter { it.action == BluetoothDevice.ACTION_BOND_STATE_CHANGED }
                    .filter { it.getBluetoothDeviceExtra() == device }
                    .map {
                        it.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothAdapter.ERROR)
                    }
                    .filter { it == BOND_NONE }
                    .first()
            }

            val stateFlow =