DO NOT MERGE: HA still appears in Media device list even though it has been unpaired.

-Add mUnpairing to mark the device triggers removeBond()
-For HA, once it calls removeBond(), two HA would be unpaired. It causes the incorrect state if we do main/sub devices switching.

Bug: 198124571
Test: manual test

Merged-In: I4ed5db2bd01f4b4e8f246ed3e8f74e24149571f9
Change-Id: I4ed5db2bd01f4b4e8f246ed3e8f74e24149571f9
(cherry picked from commit 5597cbd76b)
This commit is contained in:
Tim Peng
2021-09-11 05:56:08 +00:00
parent ce87ba4e87
commit 68dac6c41e
2 changed files with 9 additions and 0 deletions

View File

@@ -106,6 +106,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
private boolean mIsA2dpProfileConnectedFail = false;
private boolean mIsHeadsetProfileConnectedFail = false;
private boolean mIsHearingAidProfileConnectedFail = false;
private boolean mUnpairing = false;
// Group second device for Hearing Aid
private CachedBluetoothDevice mSubDevice;
@VisibleForTesting
@@ -402,6 +403,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
if (state != BluetoothDevice.BOND_NONE) {
final BluetoothDevice dev = mDevice;
if (dev != null) {
mUnpairing = true;
final boolean successful = dev.removeBond();
if (successful) {
releaseLruCache();
@@ -1243,4 +1245,8 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
void releaseLruCache() {
mDrawableCache.evictAll();
}
boolean getUnpairing() {
return mUnpairing;
}
}

View File

@@ -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