Loading src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java +9 −4 Original line number Diff line number Diff line Loading @@ -694,7 +694,7 @@ public class BluetoothRouteManager extends StateMachine { BluetoothHeadsetProxy bluetoothHeadset = mDeviceManager.getHeadsetService(); BluetoothHearingAid bluetoothHearingAid = mDeviceManager.getHearingAidService(); BluetoothDevice hfpActiveDevice = null; BluetoothDevice hfpAudioOnDevice = null; BluetoothDevice hearingAidActiveDevice = null; if (bluetoothHeadset == null && bluetoothHearingAid == null) { Loading @@ -703,7 +703,12 @@ public class BluetoothRouteManager extends StateMachine { } if (bluetoothHeadset != null) { hfpActiveDevice = bluetoothHeadset.getActiveDevice(); hfpAudioOnDevice = bluetoothHeadset.getActiveDevice(); if (bluetoothHeadset.getAudioState(hfpAudioOnDevice) == BluetoothHeadset.STATE_AUDIO_DISCONNECTED) { hfpAudioOnDevice = null; } } if (bluetoothHearingAid != null) { Loading @@ -717,13 +722,13 @@ public class BluetoothRouteManager extends StateMachine { // Return the active device reported by either HFP or hearing aid. If both are reporting // active devices, go with the most recent one as reported by the receiver. if (hfpActiveDevice != null) { if (hfpAudioOnDevice != null) { if (hearingAidActiveDevice != null) { Log.i(this, "Both HFP and hearing aid are reporting active devices. Going with" + " the most recently reported active device: %s"); return mMostRecentlyReportedActiveDevice; } return hfpActiveDevice; return hfpAudioOnDevice; } return hearingAidActiveDevice; } Loading tests/src/com/android/server/telecom/tests/BluetoothRouteManagerTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,22 @@ public class BluetoothRouteManagerTest extends TelecomTestCase { sm.quitNow(); } @SmallTest @Test public void testAudioOnDeviceWithScoOffActiveDevice() { BluetoothRouteManager sm = setupStateMachine( BluetoothRouteManager.AUDIO_CONNECTED_STATE_NAME_PREFIX, DEVICE1); setupConnectedDevices(new BluetoothDevice[]{DEVICE1}, null, DEVICE1, null); when(mHeadsetProxy.getAudioState(DEVICE1)) .thenReturn(BluetoothHeadset.STATE_AUDIO_DISCONNECTED); executeRoutingAction(sm, BluetoothRouteManager.BT_AUDIO_LOST, DEVICE1.getAddress()); verifyConnectionAttempt(DEVICE1, 0); assertEquals(BluetoothRouteManager.AUDIO_OFF_STATE_NAME, sm.getCurrentState().getName()); sm.quitNow(); } @SmallTest @Test public void testConnectHfpRetryWhileConnectedToAnotherDevice() { Loading Loading @@ -164,6 +180,8 @@ public class BluetoothRouteManagerTest extends TelecomTestCase { when(mDeviceManager.getConnectedDevices()).thenReturn(allDevices); when(mHeadsetProxy.getConnectedDevices()).thenReturn(Arrays.asList(hfpDevices)); when(mHeadsetProxy.getActiveDevice()).thenReturn(hfpActiveDevice); when(mHeadsetProxy.getAudioState(hfpActiveDevice)) .thenReturn(BluetoothHeadset.STATE_AUDIO_CONNECTED); when(mBluetoothHearingAid.getConnectedDevices()) .thenReturn(Arrays.asList(hearingAidDevices)); Loading tests/src/com/android/server/telecom/tests/BluetoothRouteTransitionTests.java +2 −0 Original line number Diff line number Diff line Loading @@ -341,6 +341,8 @@ public class BluetoothRouteTransitionTests extends TelecomTestCase { when(mHeadsetProxy.getActiveDevice()).thenReturn(activeDevice); if (audioOnDevice != null) { when(mHeadsetProxy.getActiveDevice()).thenReturn(audioOnDevice); when(mHeadsetProxy.getAudioState(audioOnDevice)) .thenReturn(BluetoothHeadset.STATE_AUDIO_CONNECTED); } } Loading Loading
src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java +9 −4 Original line number Diff line number Diff line Loading @@ -694,7 +694,7 @@ public class BluetoothRouteManager extends StateMachine { BluetoothHeadsetProxy bluetoothHeadset = mDeviceManager.getHeadsetService(); BluetoothHearingAid bluetoothHearingAid = mDeviceManager.getHearingAidService(); BluetoothDevice hfpActiveDevice = null; BluetoothDevice hfpAudioOnDevice = null; BluetoothDevice hearingAidActiveDevice = null; if (bluetoothHeadset == null && bluetoothHearingAid == null) { Loading @@ -703,7 +703,12 @@ public class BluetoothRouteManager extends StateMachine { } if (bluetoothHeadset != null) { hfpActiveDevice = bluetoothHeadset.getActiveDevice(); hfpAudioOnDevice = bluetoothHeadset.getActiveDevice(); if (bluetoothHeadset.getAudioState(hfpAudioOnDevice) == BluetoothHeadset.STATE_AUDIO_DISCONNECTED) { hfpAudioOnDevice = null; } } if (bluetoothHearingAid != null) { Loading @@ -717,13 +722,13 @@ public class BluetoothRouteManager extends StateMachine { // Return the active device reported by either HFP or hearing aid. If both are reporting // active devices, go with the most recent one as reported by the receiver. if (hfpActiveDevice != null) { if (hfpAudioOnDevice != null) { if (hearingAidActiveDevice != null) { Log.i(this, "Both HFP and hearing aid are reporting active devices. Going with" + " the most recently reported active device: %s"); return mMostRecentlyReportedActiveDevice; } return hfpActiveDevice; return hfpAudioOnDevice; } return hearingAidActiveDevice; } Loading
tests/src/com/android/server/telecom/tests/BluetoothRouteManagerTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,22 @@ public class BluetoothRouteManagerTest extends TelecomTestCase { sm.quitNow(); } @SmallTest @Test public void testAudioOnDeviceWithScoOffActiveDevice() { BluetoothRouteManager sm = setupStateMachine( BluetoothRouteManager.AUDIO_CONNECTED_STATE_NAME_PREFIX, DEVICE1); setupConnectedDevices(new BluetoothDevice[]{DEVICE1}, null, DEVICE1, null); when(mHeadsetProxy.getAudioState(DEVICE1)) .thenReturn(BluetoothHeadset.STATE_AUDIO_DISCONNECTED); executeRoutingAction(sm, BluetoothRouteManager.BT_AUDIO_LOST, DEVICE1.getAddress()); verifyConnectionAttempt(DEVICE1, 0); assertEquals(BluetoothRouteManager.AUDIO_OFF_STATE_NAME, sm.getCurrentState().getName()); sm.quitNow(); } @SmallTest @Test public void testConnectHfpRetryWhileConnectedToAnotherDevice() { Loading Loading @@ -164,6 +180,8 @@ public class BluetoothRouteManagerTest extends TelecomTestCase { when(mDeviceManager.getConnectedDevices()).thenReturn(allDevices); when(mHeadsetProxy.getConnectedDevices()).thenReturn(Arrays.asList(hfpDevices)); when(mHeadsetProxy.getActiveDevice()).thenReturn(hfpActiveDevice); when(mHeadsetProxy.getAudioState(hfpActiveDevice)) .thenReturn(BluetoothHeadset.STATE_AUDIO_CONNECTED); when(mBluetoothHearingAid.getConnectedDevices()) .thenReturn(Arrays.asList(hearingAidDevices)); Loading
tests/src/com/android/server/telecom/tests/BluetoothRouteTransitionTests.java +2 −0 Original line number Diff line number Diff line Loading @@ -341,6 +341,8 @@ public class BluetoothRouteTransitionTests extends TelecomTestCase { when(mHeadsetProxy.getActiveDevice()).thenReturn(activeDevice); if (audioOnDevice != null) { when(mHeadsetProxy.getActiveDevice()).thenReturn(audioOnDevice); when(mHeadsetProxy.getAudioState(audioOnDevice)) .thenReturn(BluetoothHeadset.STATE_AUDIO_CONNECTED); } } Loading