Loading android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -287,7 +287,7 @@ class ActiveDeviceManager { setA2dpActiveDevice(null); } } else { setA2dpActiveDevice(null); mA2dpActiveDevice = null; } } } Loading Loading @@ -366,7 +366,7 @@ class ActiveDeviceManager { setHfpActiveDevice(null); } } else { setHfpActiveDevice(null); mHfpActiveDevice = null; } } } Loading android/app/tests/unit/src/com/android/bluetooth/btservice/ActiveDeviceManagerTest.java +8 −33 Original line number Diff line number Diff line Loading @@ -133,14 +133,16 @@ public class ActiveDeviceManagerTest { when(mLeAudioService.setActiveDevice(any(), anyBoolean())).thenReturn(true); when(mA2dpService.getFallbackDevice()).thenAnswer(invocation -> { int index = Math.max(mDeviceConnectionStack.indexOf(mA2dpDevice), mDeviceConnectionStack.indexOf(mA2dpHeadsetDevice)); return (index == -1) ? null : mDeviceConnectionStack.get(index); if (mDeviceConnectionStack.contains(mA2dpDevice)) { return mA2dpDevice; } return null; }); when(mHeadsetService.getFallbackDevice()).thenAnswer(invocation -> { int index = Math.max(mDeviceConnectionStack.indexOf(mHeadsetDevice), mDeviceConnectionStack.indexOf(mA2dpHeadsetDevice)); return (index == -1) ? null : mDeviceConnectionStack.get(index); if (mDeviceConnectionStack.contains(mHeadsetDevice)) { return mHeadsetDevice; } return null; }); when(mDatabaseManager.getMostRecentlyConnectedDevicesInList(any())).thenAnswer( invocation -> { Loading Loading @@ -318,33 +320,6 @@ public class ActiveDeviceManagerTest { verify(mHeadsetService, timeout(TIMEOUT_MS)).setActiveDevice(mHeadsetDevice); } /** * Test setActiveDevice(null) for both A2dpService and HeadsetService are called when an * activated combo (A2DP + Headset) device is disconnected while in call. */ @Test public void a2dpHeadsetDisconnected_callsSetActiveDeviceNull() { when(mAudioManager.getMode()).thenReturn(AudioManager.MODE_NORMAL); // A2dpHeadset connected headsetConnected(mA2dpHeadsetDevice); a2dpConnected(mA2dpHeadsetDevice); // Verify activation of A2DP in media mode verify(mA2dpService, timeout(TIMEOUT_MS)).setActiveDevice(mA2dpHeadsetDevice, false); // Mode changed to call mode when(mAudioManager.getMode()).thenReturn(AudioManager.MODE_IN_CALL); mAudioModeChangedListener.onModeChanged(AudioManager.MODE_IN_CALL); // Verify activation of HFP in call mode verify(mHeadsetService, timeout(TIMEOUT_MS)).setActiveDevice(mA2dpHeadsetDevice); // A2dpHeadset disconnected headsetDisconnected(mA2dpHeadsetDevice); a2dpDisconnected(mA2dpHeadsetDevice); // Verify setActiveDevice(null) called verify(mHeadsetService, timeout(TIMEOUT_MS)).setActiveDevice(null); verify(mA2dpService, timeout(TIMEOUT_MS)).setActiveDevice(null, false); } /** * A combo (A2DP + Headset) device is connected. Then a Hearing Aid is connected. */ Loading Loading
android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -287,7 +287,7 @@ class ActiveDeviceManager { setA2dpActiveDevice(null); } } else { setA2dpActiveDevice(null); mA2dpActiveDevice = null; } } } Loading Loading @@ -366,7 +366,7 @@ class ActiveDeviceManager { setHfpActiveDevice(null); } } else { setHfpActiveDevice(null); mHfpActiveDevice = null; } } } Loading
android/app/tests/unit/src/com/android/bluetooth/btservice/ActiveDeviceManagerTest.java +8 −33 Original line number Diff line number Diff line Loading @@ -133,14 +133,16 @@ public class ActiveDeviceManagerTest { when(mLeAudioService.setActiveDevice(any(), anyBoolean())).thenReturn(true); when(mA2dpService.getFallbackDevice()).thenAnswer(invocation -> { int index = Math.max(mDeviceConnectionStack.indexOf(mA2dpDevice), mDeviceConnectionStack.indexOf(mA2dpHeadsetDevice)); return (index == -1) ? null : mDeviceConnectionStack.get(index); if (mDeviceConnectionStack.contains(mA2dpDevice)) { return mA2dpDevice; } return null; }); when(mHeadsetService.getFallbackDevice()).thenAnswer(invocation -> { int index = Math.max(mDeviceConnectionStack.indexOf(mHeadsetDevice), mDeviceConnectionStack.indexOf(mA2dpHeadsetDevice)); return (index == -1) ? null : mDeviceConnectionStack.get(index); if (mDeviceConnectionStack.contains(mHeadsetDevice)) { return mHeadsetDevice; } return null; }); when(mDatabaseManager.getMostRecentlyConnectedDevicesInList(any())).thenAnswer( invocation -> { Loading Loading @@ -318,33 +320,6 @@ public class ActiveDeviceManagerTest { verify(mHeadsetService, timeout(TIMEOUT_MS)).setActiveDevice(mHeadsetDevice); } /** * Test setActiveDevice(null) for both A2dpService and HeadsetService are called when an * activated combo (A2DP + Headset) device is disconnected while in call. */ @Test public void a2dpHeadsetDisconnected_callsSetActiveDeviceNull() { when(mAudioManager.getMode()).thenReturn(AudioManager.MODE_NORMAL); // A2dpHeadset connected headsetConnected(mA2dpHeadsetDevice); a2dpConnected(mA2dpHeadsetDevice); // Verify activation of A2DP in media mode verify(mA2dpService, timeout(TIMEOUT_MS)).setActiveDevice(mA2dpHeadsetDevice, false); // Mode changed to call mode when(mAudioManager.getMode()).thenReturn(AudioManager.MODE_IN_CALL); mAudioModeChangedListener.onModeChanged(AudioManager.MODE_IN_CALL); // Verify activation of HFP in call mode verify(mHeadsetService, timeout(TIMEOUT_MS)).setActiveDevice(mA2dpHeadsetDevice); // A2dpHeadset disconnected headsetDisconnected(mA2dpHeadsetDevice); a2dpDisconnected(mA2dpHeadsetDevice); // Verify setActiveDevice(null) called verify(mHeadsetService, timeout(TIMEOUT_MS)).setActiveDevice(null); verify(mA2dpService, timeout(TIMEOUT_MS)).setActiveDevice(null, false); } /** * A combo (A2DP + Headset) device is connected. Then a Hearing Aid is connected. */ Loading