Loading src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java +3 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ public class AvailableMediaBluetoothDeviceUpdater extends BluetoothDeviceUpdater } boolean isFilterMatched = false; if (isDeviceConnected(cachedDevice)) { if (isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)) { if (DBG) { Log.d(TAG, "isFilterMatched() current audio profile : " + currentAudioProfile); } Loading @@ -74,6 +74,8 @@ public class AvailableMediaBluetoothDeviceUpdater extends BluetoothDeviceUpdater // It would show in Available Devices group. if (cachedDevice.isConnectedHearingAidDevice() || cachedDevice.isConnectedLeAudioDevice()) { Log.d(TAG, "isFilterMatched() device : " + cachedDevice.getName() + ", the profile is connected."); return true; } // According to the current audio profile type, Loading src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java +4 −0 Original line number Diff line number Diff line Loading @@ -326,4 +326,8 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback, ((BluetoothDevicePreference) preference).onPreferenceAttributesChanged(); } } protected boolean isDeviceInCachedDevicesList(CachedBluetoothDevice cachedDevice){ return mLocalManager.getCachedDeviceManager().getCachedDevicesCopy().contains(cachedDevice); } } src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java +1 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater { } boolean isFilterMatched = false; if (isDeviceConnected(cachedDevice)) { if (isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)) { if (DBG) { Log.d(TAG, "isFilterMatched() current audio profile : " + currentAudioProfile); } Loading src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java +2 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,8 @@ public class SavedBluetoothDeviceUpdater extends BluetoothDeviceUpdater + cachedDevice.isConnected()); } return device.getBondState() == BluetoothDevice.BOND_BONDED && (mDisplayConnected || !device.isConnected()); && (mDisplayConnected || (!device.isConnected() && isDeviceInCachedDevicesList( cachedDevice))); } @Override Loading tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java +30 −4 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest { mShadowCachedBluetoothDeviceManager = Shadow.extract( Utils.getLocalBtManager(mContext).getCachedDeviceManager()); mCachedDevices = new ArrayList<>(); mCachedDevices.add(mCachedBluetoothDevice); mShadowCachedBluetoothDeviceManager.setCachedDevicesCopy(mCachedDevices); Pair<Drawable, String> pairs = new Pair<>(mDrawable, "fake_device"); Loading @@ -109,7 +110,6 @@ public class AvailableMediaBluetoothDeviceUpdaterTest { when(mBluetoothDeviceUpdater. isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true); when(mCachedBluetoothDevice.isConnectedHfpDevice()).thenReturn(true); mCachedDevices.add(mCachedBluetoothDevice); mBluetoothDeviceUpdater.onAudioModeChanged(); Loading @@ -122,7 +122,6 @@ public class AvailableMediaBluetoothDeviceUpdaterTest { when(mBluetoothDeviceUpdater. isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true); when(mCachedBluetoothDevice.isConnectedHfpDevice()).thenReturn(true); mCachedDevices.add(mCachedBluetoothDevice); mBluetoothDeviceUpdater.onAudioModeChanged(); Loading @@ -135,7 +134,6 @@ public class AvailableMediaBluetoothDeviceUpdaterTest { when(mBluetoothDeviceUpdater. isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true); when(mCachedBluetoothDevice.isConnectedA2dpDevice()).thenReturn(true); mCachedDevices.add(mCachedBluetoothDevice); mBluetoothDeviceUpdater.onAudioModeChanged(); Loading @@ -148,7 +146,6 @@ public class AvailableMediaBluetoothDeviceUpdaterTest { when(mBluetoothDeviceUpdater. isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true); when(mCachedBluetoothDevice.isConnectedA2dpDevice()).thenReturn(true); mCachedDevices.add(mCachedBluetoothDevice); mBluetoothDeviceUpdater.onAudioModeChanged(); Loading Loading @@ -260,6 +257,35 @@ public class AvailableMediaBluetoothDeviceUpdaterTest { verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice); } @Test public void onProfileConnectionStateChanged_deviceIsNotInList_notInCall_invokesRemovePreference() { mAudioManager.setMode(AudioManager.MODE_NORMAL); when(mBluetoothDeviceUpdater .isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true); when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true); mCachedDevices.clear(); mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice, BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO); verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice); } @Test public void onProfileConnectionStateChanged_deviceIsNotInList_inCall_invokesRemovePreference() { mAudioManager.setMode(AudioManager.MODE_IN_CALL); when(mBluetoothDeviceUpdater .isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true); when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true); mCachedDevices.clear(); mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice, BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO); verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice); } @Test public void onProfileConnectionStateChanged_deviceDisconnected_removePreference() { mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice, Loading Loading
src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java +3 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ public class AvailableMediaBluetoothDeviceUpdater extends BluetoothDeviceUpdater } boolean isFilterMatched = false; if (isDeviceConnected(cachedDevice)) { if (isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)) { if (DBG) { Log.d(TAG, "isFilterMatched() current audio profile : " + currentAudioProfile); } Loading @@ -74,6 +74,8 @@ public class AvailableMediaBluetoothDeviceUpdater extends BluetoothDeviceUpdater // It would show in Available Devices group. if (cachedDevice.isConnectedHearingAidDevice() || cachedDevice.isConnectedLeAudioDevice()) { Log.d(TAG, "isFilterMatched() device : " + cachedDevice.getName() + ", the profile is connected."); return true; } // According to the current audio profile type, Loading
src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java +4 −0 Original line number Diff line number Diff line Loading @@ -326,4 +326,8 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback, ((BluetoothDevicePreference) preference).onPreferenceAttributesChanged(); } } protected boolean isDeviceInCachedDevicesList(CachedBluetoothDevice cachedDevice){ return mLocalManager.getCachedDeviceManager().getCachedDevicesCopy().contains(cachedDevice); } }
src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java +1 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater { } boolean isFilterMatched = false; if (isDeviceConnected(cachedDevice)) { if (isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)) { if (DBG) { Log.d(TAG, "isFilterMatched() current audio profile : " + currentAudioProfile); } Loading
src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java +2 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,8 @@ public class SavedBluetoothDeviceUpdater extends BluetoothDeviceUpdater + cachedDevice.isConnected()); } return device.getBondState() == BluetoothDevice.BOND_BONDED && (mDisplayConnected || !device.isConnected()); && (mDisplayConnected || (!device.isConnected() && isDeviceInCachedDevicesList( cachedDevice))); } @Override Loading
tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java +30 −4 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest { mShadowCachedBluetoothDeviceManager = Shadow.extract( Utils.getLocalBtManager(mContext).getCachedDeviceManager()); mCachedDevices = new ArrayList<>(); mCachedDevices.add(mCachedBluetoothDevice); mShadowCachedBluetoothDeviceManager.setCachedDevicesCopy(mCachedDevices); Pair<Drawable, String> pairs = new Pair<>(mDrawable, "fake_device"); Loading @@ -109,7 +110,6 @@ public class AvailableMediaBluetoothDeviceUpdaterTest { when(mBluetoothDeviceUpdater. isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true); when(mCachedBluetoothDevice.isConnectedHfpDevice()).thenReturn(true); mCachedDevices.add(mCachedBluetoothDevice); mBluetoothDeviceUpdater.onAudioModeChanged(); Loading @@ -122,7 +122,6 @@ public class AvailableMediaBluetoothDeviceUpdaterTest { when(mBluetoothDeviceUpdater. isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true); when(mCachedBluetoothDevice.isConnectedHfpDevice()).thenReturn(true); mCachedDevices.add(mCachedBluetoothDevice); mBluetoothDeviceUpdater.onAudioModeChanged(); Loading @@ -135,7 +134,6 @@ public class AvailableMediaBluetoothDeviceUpdaterTest { when(mBluetoothDeviceUpdater. isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true); when(mCachedBluetoothDevice.isConnectedA2dpDevice()).thenReturn(true); mCachedDevices.add(mCachedBluetoothDevice); mBluetoothDeviceUpdater.onAudioModeChanged(); Loading @@ -148,7 +146,6 @@ public class AvailableMediaBluetoothDeviceUpdaterTest { when(mBluetoothDeviceUpdater. isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true); when(mCachedBluetoothDevice.isConnectedA2dpDevice()).thenReturn(true); mCachedDevices.add(mCachedBluetoothDevice); mBluetoothDeviceUpdater.onAudioModeChanged(); Loading Loading @@ -260,6 +257,35 @@ public class AvailableMediaBluetoothDeviceUpdaterTest { verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice); } @Test public void onProfileConnectionStateChanged_deviceIsNotInList_notInCall_invokesRemovePreference() { mAudioManager.setMode(AudioManager.MODE_NORMAL); when(mBluetoothDeviceUpdater .isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true); when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true); mCachedDevices.clear(); mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice, BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO); verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice); } @Test public void onProfileConnectionStateChanged_deviceIsNotInList_inCall_invokesRemovePreference() { mAudioManager.setMode(AudioManager.MODE_IN_CALL); when(mBluetoothDeviceUpdater .isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true); when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true); mCachedDevices.clear(); mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice, BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO); verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice); } @Test public void onProfileConnectionStateChanged_deviceDisconnected_removePreference() { mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice, Loading