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

Commit 89ddc2bd authored by Hall Liu's avatar Hall Liu
Browse files

Force mute off and speaker on during emergency RTT

In an emergency RTT call, force the speakerphone on at all times. Do not
allow the user to change the audio route to anything other than speaker.

In addition, when any emergency call is in progress, do not allow the
microphone to be muted. If another app attempts to mute the microphone,
immediately unmute it.

Change-Id: I4c6bb7196ddf75161975fb173f8a486dab3f4e6b
Merged-In: I4c6bb7196ddf75161975fb173f8a486dab3f4e6b
Fixes: 74436944
Test: manual
parent 78aa4843
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1440,6 +1440,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
            if ((mConnectionProperties & Connection.PROPERTY_IS_RTT) ==
                    Connection.PROPERTY_IS_RTT) {
                createRttStreams();
                if (isEmergencyCall()) {
                    mCallsManager.setAudioRoute(CallAudioState.ROUTE_SPEAKER, null);
                    mCallsManager.mute(false);
                }
            }
            mWasHighDefAudio = (connectionProperties & Connection.PROPERTY_HIGH_DEF_AUDIO) ==
                    Connection.PROPERTY_HIGH_DEF_AUDIO;
+8 −1
Original line number Diff line number Diff line
@@ -179,6 +179,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
        put(MUTE_ON, "MUTE_ON");
        put(MUTE_OFF, "MUTE_OFF");
        put(TOGGLE_MUTE, "TOGGLE_MUTE");
        put(MUTE_EXTERNALLY_CHANGED, "MUTE_EXTERNALLY_CHANGED");

        put(SWITCH_FOCUS, "SWITCH_FOCUS");

@@ -1230,7 +1231,13 @@ public class CallAudioRouteStateMachine extends StateMachine {
        public void onReceive(Context context, Intent intent) {
            Log.startSession("CARSM.mCR");
            if (AudioManager.ACTION_MICROPHONE_MUTE_CHANGED.equals(intent.getAction())) {
                if (mCallsManager.hasEmergencyCall()) {
                    Log.i(this, "Mute was externally changed when there's an emergency call. " +
                            "Forcing mute back off.");
                    sendInternalMessage(MUTE_OFF);
                } else {
                    sendInternalMessage(MUTE_EXTERNALLY_CHANGED);
                }
            } else {
                Log.w(this, "Received non-mute-change intent");
            }
+18 −0
Original line number Diff line number Diff line
@@ -836,6 +836,15 @@ public class CallsManager extends Call.ListenerBase
        return false;
    }

    public boolean hasEmergencyRttCall() {
        for (Call call : mCalls) {
            if (call.isEmergencyCall() && call.isRttCall()) {
                return true;
            }
        }
        return false;
    }

    @VisibleForTesting
    public boolean hasOnlyDisconnectedCalls() {
        if (mCalls.size() == 0) {
@@ -1786,6 +1795,10 @@ public class CallsManager extends Call.ListenerBase

    /** Called by the in-call UI to change the mute state. */
    void mute(boolean shouldMute) {
        if (hasEmergencyCall() && shouldMute) {
            Log.i(this, "Refusing to turn on mute because we're in an emergency call");
            shouldMute = false;
        }
        mCallAudioManager.mute(shouldMute);
    }

@@ -1794,6 +1807,11 @@ public class CallsManager extends Call.ListenerBase
      * speaker phone.
      */
    void setAudioRoute(int route, String bluetoothAddress) {
        if (hasEmergencyRttCall() && route != CallAudioState.ROUTE_SPEAKER) {
            Log.i(this, "In an emergency RTT call. Forcing route to speaker.");
            route = CallAudioState.ROUTE_SPEAKER;
            bluetoothAddress = null;
        }
        mCallAudioManager.setAudioRoute(route, bluetoothAddress);
    }