Loading src/com/android/server/telecom/CallAudioRouteController.java +16 −18 Original line number Diff line number Diff line Loading @@ -879,12 +879,11 @@ public class CallAudioRouteController implements CallAudioRouteAdapter { mFocusType = focus; switch (focus) { case NO_FOCUS -> { if (mIsActive) { // Notify the CallAudioModeStateMachine that audio operations are complete so // that we can relinquish audio focus. mCallAudioManager.notifyAudioOperationsComplete(); // Reset mute state after call ends. // Reset mute state after call ends. This should remain unaffected if audio routing // never went active. handleMuteChanged(false); // Ensure we reset call audio state at the end of the call (i.e. if we're on // speaker, route back to earpiece). If we're on BT, remain on BT if it's still Loading @@ -897,7 +896,6 @@ public class CallAudioRouteController implements CallAudioRouteAdapter { mPendingAudioRoute.clearPendingMessages(); clearRingingBluetoothAddress(); } } case ACTIVE_FOCUS -> { // Route to active baseline route (we may need to change audio route in the case // when a video call is put on hold). Ignore route changes if we're handling playing Loading tests/src/com/android/server/telecom/tests/CallAudioRouteControllerTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -1099,6 +1099,38 @@ public class CallAudioRouteControllerTest extends TelecomTestCase { any(CallAudioState.class), eq(expectedState)); } @Test @SmallTest public void testAbandonCallAudioFocusAfterCallEnd() { // Make sure in-band ringing is disabled so that route never becomes active when(mBluetoothRouteManager.isInbandRingEnabled(eq(BLUETOOTH_DEVICE_1))).thenReturn(false); mController.initialize(); mController.sendMessageWithSessionInfo(BT_DEVICE_ADDED, AudioRoute.TYPE_BLUETOOTH_SCO, BLUETOOTH_DEVICE_1); CallAudioState expectedState = new CallAudioState(false, CallAudioState.ROUTE_BLUETOOTH, CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_BLUETOOTH | CallAudioState.ROUTE_SPEAKER, BLUETOOTH_DEVICE_1, BLUETOOTH_DEVICES); mController.sendMessageWithSessionInfo(BT_ACTIVE_DEVICE_PRESENT, AudioRoute.TYPE_BLUETOOTH_SCO, BT_ADDRESS_1); verify(mCallsManager, timeout(TEST_TIMEOUT)).onCallAudioStateChanged( any(CallAudioState.class), eq(expectedState)); assertFalse(mController.isActive()); // Verify route never went active due to in-band ringing being disabled. mController.sendMessageWithSessionInfo(SWITCH_FOCUS, RINGING_FOCUS, 0); assertFalse(mController.isActive()); // Emulate scenario of rejecting an incoming call so that call focus is lost and verify // that we abandon the call audio focus that was gained from when the call went to // ringing state. mController.sendMessageWithSessionInfo(SWITCH_FOCUS, NO_FOCUS, 0); // Ensure we tell the CallAudioManager that audio operations are done so that we can ensure // audio focus is relinquished. verify(mCallAudioManager, timeout(TEST_TIMEOUT)).notifyAudioOperationsComplete(); } private void verifyConnectBluetoothDevice(int audioType) { mController.initialize(); mController.setActive(true); Loading Loading
src/com/android/server/telecom/CallAudioRouteController.java +16 −18 Original line number Diff line number Diff line Loading @@ -879,12 +879,11 @@ public class CallAudioRouteController implements CallAudioRouteAdapter { mFocusType = focus; switch (focus) { case NO_FOCUS -> { if (mIsActive) { // Notify the CallAudioModeStateMachine that audio operations are complete so // that we can relinquish audio focus. mCallAudioManager.notifyAudioOperationsComplete(); // Reset mute state after call ends. // Reset mute state after call ends. This should remain unaffected if audio routing // never went active. handleMuteChanged(false); // Ensure we reset call audio state at the end of the call (i.e. if we're on // speaker, route back to earpiece). If we're on BT, remain on BT if it's still Loading @@ -897,7 +896,6 @@ public class CallAudioRouteController implements CallAudioRouteAdapter { mPendingAudioRoute.clearPendingMessages(); clearRingingBluetoothAddress(); } } case ACTIVE_FOCUS -> { // Route to active baseline route (we may need to change audio route in the case // when a video call is put on hold). Ignore route changes if we're handling playing Loading
tests/src/com/android/server/telecom/tests/CallAudioRouteControllerTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -1099,6 +1099,38 @@ public class CallAudioRouteControllerTest extends TelecomTestCase { any(CallAudioState.class), eq(expectedState)); } @Test @SmallTest public void testAbandonCallAudioFocusAfterCallEnd() { // Make sure in-band ringing is disabled so that route never becomes active when(mBluetoothRouteManager.isInbandRingEnabled(eq(BLUETOOTH_DEVICE_1))).thenReturn(false); mController.initialize(); mController.sendMessageWithSessionInfo(BT_DEVICE_ADDED, AudioRoute.TYPE_BLUETOOTH_SCO, BLUETOOTH_DEVICE_1); CallAudioState expectedState = new CallAudioState(false, CallAudioState.ROUTE_BLUETOOTH, CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_BLUETOOTH | CallAudioState.ROUTE_SPEAKER, BLUETOOTH_DEVICE_1, BLUETOOTH_DEVICES); mController.sendMessageWithSessionInfo(BT_ACTIVE_DEVICE_PRESENT, AudioRoute.TYPE_BLUETOOTH_SCO, BT_ADDRESS_1); verify(mCallsManager, timeout(TEST_TIMEOUT)).onCallAudioStateChanged( any(CallAudioState.class), eq(expectedState)); assertFalse(mController.isActive()); // Verify route never went active due to in-band ringing being disabled. mController.sendMessageWithSessionInfo(SWITCH_FOCUS, RINGING_FOCUS, 0); assertFalse(mController.isActive()); // Emulate scenario of rejecting an incoming call so that call focus is lost and verify // that we abandon the call audio focus that was gained from when the call went to // ringing state. mController.sendMessageWithSessionInfo(SWITCH_FOCUS, NO_FOCUS, 0); // Ensure we tell the CallAudioManager that audio operations are done so that we can ensure // audio focus is relinquished. verify(mCallAudioManager, timeout(TEST_TIMEOUT)).notifyAudioOperationsComplete(); } private void verifyConnectBluetoothDevice(int audioType) { mController.initialize(); mController.setActive(true); Loading