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

Commit fc86020f authored by Pranav Madapurmath's avatar Pranav Madapurmath
Browse files

Update internal audio state before updating ICS.

In the case that an ICS is bound during a system audio update (for
instance, when entering a new audio route), it's possible for that ICS
to receive an incorrect audio state because the internal call audio
state hasn't been updated yet. InCallController#onConnected will
retrieve the current call audio state from CallAudioRouteStateMachine to
send an audio update to the ICS.

By updating the internal call audio state beforehand, we will ensure
that the ICS receives the updated call state. This handles 3 different
scenarios depending on when the ICS is bound:

(1) ICS bound before internal audio update.
(2) ICS bound after internal audio update and before system audio update
(which sends audio update to ICS and CS).
(3) ICS bound after system audio update.

Bug: 335538831
Test: atest CallAudioRouteControllerTest (with flag enabled locally in
setUp)
Test: atest CallAudioRouteTransitionTests (with flag enabled locally in
setUp)

Change-Id: I610106f96a3d4283979fe8e682513e69dfb84fac
parent 12419774
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -88,3 +88,14 @@ flag {
  description: "Update switching bt devices based on arbitrary device chosen if no device is specified."
  bug: "333751408"
}

# OWNER=pmadapurmath TARGET=24Q3
flag {
  name: "early_update_internal_call_audio_state"
  namespace: "telecom"
  description: "Update internal call audio state before sending updated state to ICS"
  bug: "335538831"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}
+35 −10
Original line number Diff line number Diff line
@@ -288,9 +288,14 @@ public class CallAudioRouteStateMachine extends StateMachine implements CallAudi
            CallAudioState newState = new CallAudioState(mIsMuted, ROUTE_EARPIECE,
                    mAvailableRoutes, null,
                    mBluetoothRouteManager.getConnectedDevices());
            if (mFeatureFlags.earlyUpdateInternalCallAudioState()) {
                updateInternalCallAudioState();
                setSystemAudioState(newState, true);
            } else {
                setSystemAudioState(newState, true);
                updateInternalCallAudioState();
            }
        }

        @Override
        public void updateSystemAudioState() {
@@ -511,9 +516,14 @@ public class CallAudioRouteStateMachine extends StateMachine implements CallAudi
            }
            CallAudioState newState = new CallAudioState(mIsMuted, ROUTE_WIRED_HEADSET,
                    mAvailableRoutes, null, mBluetoothRouteManager.getConnectedDevices());
            if (mFeatureFlags.earlyUpdateInternalCallAudioState()) {
                updateInternalCallAudioState();
                setSystemAudioState(newState, true);
            } else {
                setSystemAudioState(newState, true);
                updateInternalCallAudioState();
            }
        }

        @Override
        public void updateSystemAudioState() {
@@ -749,8 +759,13 @@ public class CallAudioRouteStateMachine extends StateMachine implements CallAudi
            CallAudioState newState = new CallAudioState(mIsMuted, ROUTE_BLUETOOTH,
                    mAvailableRoutes, mBluetoothRouteManager.getBluetoothAudioConnectedDevice(),
                    mBluetoothRouteManager.getConnectedDevices());
            if (mFeatureFlags.earlyUpdateInternalCallAudioState()) {
                updateInternalCallAudioState();
                setSystemAudioState(newState, true);
            } else {
                setSystemAudioState(newState, true);
                updateInternalCallAudioState();
            }
            // Do not send RINGER_MODE_CHANGE if no Bluetooth SCO audio device is available
            if (mBluetoothRouteManager.getBluetoothAudioConnectedDevice() != null) {
                mCallAudioManager.onRingerModeChange();
@@ -898,9 +913,14 @@ public class CallAudioRouteStateMachine extends StateMachine implements CallAudi
            CallAudioState newState = new CallAudioState(mIsMuted, ROUTE_BLUETOOTH,
                    mAvailableRoutes, mBluetoothRouteManager.getBluetoothAudioConnectedDevice(),
                    mBluetoothRouteManager.getConnectedDevices());
            setSystemAudioState(newState);
            if (mFeatureFlags.earlyUpdateInternalCallAudioState()) {
                updateInternalCallAudioState();
                setSystemAudioState(newState, true);
            } else {
                setSystemAudioState(newState, true);
                updateInternalCallAudioState();
            }
        }

        @Override
        public void updateSystemAudioState() {
@@ -1122,9 +1142,14 @@ public class CallAudioRouteStateMachine extends StateMachine implements CallAudi
            mWasOnSpeaker = true;
            CallAudioState newState = new CallAudioState(mIsMuted, ROUTE_SPEAKER,
                    mAvailableRoutes, null, mBluetoothRouteManager.getConnectedDevices());
            if (mFeatureFlags.earlyUpdateInternalCallAudioState()) {
                updateInternalCallAudioState();
                setSystemAudioState(newState, true);
            } else {
                setSystemAudioState(newState, true);
                updateInternalCallAudioState();
            }
        }

        @Override
        public void updateSystemAudioState() {