Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -424,7 +424,9 @@ public class BluetoothEventManager { for (BluetoothCallback callback : mCallbacks) { callback.onDeviceBondStateChanged(cachedDevice, bondState); } cachedDevice.onBondingStateChanged(bondState); int prevBondState = intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, BluetoothDevice.ERROR); cachedDevice.onBondingStateChanged(bondState, prevBondState); if (bondState == BluetoothDevice.BOND_NONE) { // Check if we need to remove other Coordinated set member devices / Hearing Aid Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +23 −2 Original line number Diff line number Diff line Loading @@ -145,6 +145,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> * The value is reset if a disconnection happens. */ private long mConnectAttempted = -1; private long mBondFailureTimeMillis = -1; private boolean mIsAclConnectedBrEdr = false; private boolean mIsAclConnectedLe = false; Loading Loading @@ -1105,7 +1106,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> dispatchAttributesChanged(); } void onBondingStateChanged(int bondState) { void onBondingStateChanged(int bondState, int prevBondState) { if (bondState == BluetoothDevice.BOND_NONE) { synchronized (mProfileLock) { mProfiles.clear(); Loading @@ -1115,9 +1116,17 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> mDevice.setSimAccessPermission(BluetoothDevice.ACCESS_UNKNOWN); mBondTimestamp = null; if (Flags.enableBluetoothDiagnosis()) { if (prevBondState == BluetoothDevice.BOND_BONDING) { mBondFailureTimeMillis = SystemClock.elapsedRealtime(); } } } if (!Flags.enableBluetoothDiagnosis()) { refresh(); } if (bondState == BluetoothDevice.BOND_BONDED) { mBondTimestamp = new Timestamp(System.currentTimeMillis()); Loading @@ -1129,6 +1138,14 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> // Saves this device as just bonded and checks if it's an hearing device after // profiles are connected. This is for judging whether to display the survey. HearingAidStatsLogUtils.addToJustBonded(getAddress()); if (Flags.enableBluetoothDiagnosis()) { mBondFailureTimeMillis = -1; } } if (Flags.enableBluetoothDiagnosis()) { refresh(); } } Loading Loading @@ -1188,6 +1205,10 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> return mBondTimestamp; } public long getBondFailureTimeMillis() { return mBondFailureTimeMillis; } public BluetoothClass getBtClass() { return mDevice.getBluetoothClass(); } Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java +26 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ package com.android.settingslib.bluetooth; import static com.android.settingslib.flags.Flags.FLAG_ENABLE_BLUETOOTH_DIAGNOSIS; import static com.android.settingslib.flags.Flags.FLAG_ENABLE_LE_AUDIO_SHARING; import static com.android.settingslib.flags.Flags.FLAG_REFACTOR_BATTERY_LEVEL_DISPLAY; Loading Loading @@ -2942,6 +2943,31 @@ public class CachedBluetoothDeviceTest { assertThat(summary).isNull(); } @Test @EnableFlags(FLAG_ENABLE_BLUETOOTH_DIAGNOSIS) public void onBondingStateChanged_bondFailure_setFailureTime() { mCachedDevice.onBondingStateChanged( BluetoothDevice.BOND_NONE, BluetoothDevice.BOND_BONDING); assertThat(mCachedDevice.getBondFailureTimeMillis()).isNotEqualTo(-1); } @Test @EnableFlags(FLAG_ENABLE_BLUETOOTH_DIAGNOSIS) public void onBondingStateChanged_bondSuccess_resetFailureTime() { mCachedDevice.onBondingStateChanged( BluetoothDevice.BOND_NONE, BluetoothDevice.BOND_BONDING); assertThat(mCachedDevice.getBondFailureTimeMillis()).isNotEqualTo(-1); mCachedDevice.onBondingStateChanged( BluetoothDevice.BOND_BONDING, BluetoothDevice.BOND_NONE); mCachedDevice.onBondingStateChanged( BluetoothDevice.BOND_BONDED, BluetoothDevice.BOND_BONDING); assertThat(mCachedDevice.getBondFailureTimeMillis()).isEqualTo(-1); } private void updateProfileStatus(LocalBluetoothProfile profile, int status) { doReturn(status).when(profile).getConnectionStatus(mDevice); mCachedDevice.onProfileStateChanged(profile, status); Loading Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -424,7 +424,9 @@ public class BluetoothEventManager { for (BluetoothCallback callback : mCallbacks) { callback.onDeviceBondStateChanged(cachedDevice, bondState); } cachedDevice.onBondingStateChanged(bondState); int prevBondState = intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, BluetoothDevice.ERROR); cachedDevice.onBondingStateChanged(bondState, prevBondState); if (bondState == BluetoothDevice.BOND_NONE) { // Check if we need to remove other Coordinated set member devices / Hearing Aid Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +23 −2 Original line number Diff line number Diff line Loading @@ -145,6 +145,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> * The value is reset if a disconnection happens. */ private long mConnectAttempted = -1; private long mBondFailureTimeMillis = -1; private boolean mIsAclConnectedBrEdr = false; private boolean mIsAclConnectedLe = false; Loading Loading @@ -1105,7 +1106,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> dispatchAttributesChanged(); } void onBondingStateChanged(int bondState) { void onBondingStateChanged(int bondState, int prevBondState) { if (bondState == BluetoothDevice.BOND_NONE) { synchronized (mProfileLock) { mProfiles.clear(); Loading @@ -1115,9 +1116,17 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> mDevice.setSimAccessPermission(BluetoothDevice.ACCESS_UNKNOWN); mBondTimestamp = null; if (Flags.enableBluetoothDiagnosis()) { if (prevBondState == BluetoothDevice.BOND_BONDING) { mBondFailureTimeMillis = SystemClock.elapsedRealtime(); } } } if (!Flags.enableBluetoothDiagnosis()) { refresh(); } if (bondState == BluetoothDevice.BOND_BONDED) { mBondTimestamp = new Timestamp(System.currentTimeMillis()); Loading @@ -1129,6 +1138,14 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> // Saves this device as just bonded and checks if it's an hearing device after // profiles are connected. This is for judging whether to display the survey. HearingAidStatsLogUtils.addToJustBonded(getAddress()); if (Flags.enableBluetoothDiagnosis()) { mBondFailureTimeMillis = -1; } } if (Flags.enableBluetoothDiagnosis()) { refresh(); } } Loading Loading @@ -1188,6 +1205,10 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> return mBondTimestamp; } public long getBondFailureTimeMillis() { return mBondFailureTimeMillis; } public BluetoothClass getBtClass() { return mDevice.getBluetoothClass(); } Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java +26 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ package com.android.settingslib.bluetooth; import static com.android.settingslib.flags.Flags.FLAG_ENABLE_BLUETOOTH_DIAGNOSIS; import static com.android.settingslib.flags.Flags.FLAG_ENABLE_LE_AUDIO_SHARING; import static com.android.settingslib.flags.Flags.FLAG_REFACTOR_BATTERY_LEVEL_DISPLAY; Loading Loading @@ -2942,6 +2943,31 @@ public class CachedBluetoothDeviceTest { assertThat(summary).isNull(); } @Test @EnableFlags(FLAG_ENABLE_BLUETOOTH_DIAGNOSIS) public void onBondingStateChanged_bondFailure_setFailureTime() { mCachedDevice.onBondingStateChanged( BluetoothDevice.BOND_NONE, BluetoothDevice.BOND_BONDING); assertThat(mCachedDevice.getBondFailureTimeMillis()).isNotEqualTo(-1); } @Test @EnableFlags(FLAG_ENABLE_BLUETOOTH_DIAGNOSIS) public void onBondingStateChanged_bondSuccess_resetFailureTime() { mCachedDevice.onBondingStateChanged( BluetoothDevice.BOND_NONE, BluetoothDevice.BOND_BONDING); assertThat(mCachedDevice.getBondFailureTimeMillis()).isNotEqualTo(-1); mCachedDevice.onBondingStateChanged( BluetoothDevice.BOND_BONDING, BluetoothDevice.BOND_NONE); mCachedDevice.onBondingStateChanged( BluetoothDevice.BOND_BONDED, BluetoothDevice.BOND_BONDING); assertThat(mCachedDevice.getBondFailureTimeMillis()).isEqualTo(-1); } private void updateProfileStatus(LocalBluetoothProfile profile, int status) { doReturn(status).when(profile).getConnectionStatus(mDevice); mCachedDevice.onProfileStateChanged(profile, status); Loading