diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java index 021ba2247e67f..cac34aebc073c 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java @@ -21,7 +21,6 @@ import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothCsipSetCoordinator; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHearingAid; -import android.bluetooth.BluetoothLeAudio; import android.bluetooth.BluetoothProfile; import android.bluetooth.BluetoothUuid; import android.content.Context; @@ -116,6 +115,7 @@ public class CachedBluetoothDevice implements Comparable private boolean mIsHeadsetProfileConnectedFail = false; private boolean mIsHearingAidProfileConnectedFail = false; private boolean mIsLeAudioProfileConnectedFail = false; + private boolean mUnpairing = false; // Group second device for Hearing Aid private CachedBluetoothDevice mSubDevice; // Group member devices for the coordinated set @@ -457,6 +457,7 @@ public class CachedBluetoothDevice implements Comparable if (state != BluetoothDevice.BOND_NONE) { final BluetoothDevice dev = mDevice; if (dev != null) { + mUnpairing = true; final boolean successful = dev.removeBond(); if (successful) { releaseLruCache(); @@ -1387,4 +1388,8 @@ public class CachedBluetoothDevice implements Comparable void releaseLruCache() { mDrawableCache.evictAll(); } + + boolean getUnpairing() { + return mUnpairing; + } } diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidDeviceManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidDeviceManager.java index 20ece69d7281b..818f5ca33ebf6 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidDeviceManager.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidDeviceManager.java @@ -180,6 +180,9 @@ public class HearingAidDeviceManager { break; case BluetoothProfile.STATE_DISCONNECTED: mainDevice = findMainDevice(cachedDevice); + if (cachedDevice.getUnpairing()) { + return true; + } if (mainDevice != null) { // When main device exists, receiving sub device disconnection // To update main device UI