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

Commit e8809de0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Force mute off and speaker on during emergency RTT" into pi-dev

parents d0c6caba ccd793f2
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1433,6 +1433,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");

@@ -1236,7 +1237,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
@@ -835,6 +835,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) {
@@ -1796,6 +1805,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);
    }

@@ -1804,6 +1817,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);
    }