Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1cfce4f5 authored by Pranav Madapurmath's avatar Pranav Madapurmath Committed by Bharath
Browse files

Prevent infinite SPEAKER_OFF looping

Originating from an external request to turn speaker off, if the routing
ends up being the same in the case of a video call, then prevent the
additional SPEAKER_OFF msg from being sent. This normally ends up being
needed for the pending code path to turn off the notification for
instance but if the routing doesn't change, then we should not send this
extra message.

Bug: 425988954
Flag: EXEMPT bug fix
Test: atest CallAudioRouteControllerTest
Change-Id: I3ded7bf357ff2b8362e9ce4997cadcb6261b5073
parent b756170a
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -1151,10 +1151,13 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
            // Update status bar notification
            mStatusBarNotifier.notifySpeakerphone(false);
        } else if (mCurrentRoute.getType() == AudioRoute.TYPE_SPEAKER) {
            routeTo(mIsActive, getBaseRoute(true, null));
            AudioRoute newRoute = getBaseRoute(true, null);
            routeTo(mIsActive, newRoute);
            // Since the route switching triggered by this message, we need to manually send it
            // again so that we won't stuck in the pending route
            if (mIsActive) {
            // again so that we won't stuck in the pending route. Do not send the additional
            // SPEAKER_OFF msg if we find that audio wasn't routed out of speaker. This would have
            // the potential to cause an infinite loop if routing doesn't change.
            if (mIsActive && newRoute.getType() != TYPE_SPEAKER) {
                sendMessageWithSessionInfo(SPEAKER_OFF);
            }
            onAvailableRoutesChanged();
+1 −0
Original line number Diff line number Diff line
@@ -499,6 +499,7 @@ public class CallAudioRouteControllerTest extends TelecomTestCase {
        assertTrue(mController.isActive());

        mController.sendMessageWithSessionInfo(SWITCH_FOCUS, NO_FOCUS, 0);
        mController.sendMessageWithSessionInfo(BT_AUDIO_DISCONNECTED, 0, BLUETOOTH_DEVICE_1);
        // 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();