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

Commit a31be432 authored by Dong Zhou's avatar Dong Zhou Committed by The Android Automerger
Browse files

Speed up audio setup for IMS MT call

Set audio mode into in_call mode right after accepting the call
without waiting for the call be ACTIVE from RIL.

Bug: 19656525
Change-Id: I83ec03f14ba859680ab5a42e945d940d698e6915
parent f7a075b2
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ final class CallAudioManager extends CallsManagerListenerBase
    private boolean mIsTonePlaying;
    private boolean mWasSpeakerOn;
    private int mMostRecentlyUsedMode = AudioManager.MODE_IN_CALL;
    private Call mCallToSpeedUpMTAudio = null;

    CallAudioManager(Context context, StatusBarNotifier statusBarNotifier,
            WiredHeadsetManager wiredHeadsetManager) {
@@ -106,6 +107,12 @@ final class CallAudioManager extends CallsManagerListenerBase
        }

        setSystemAudioState(false /* isMute */, route, mAudioState.getSupportedRouteMask());

        if (call.can(android.telecom.Call.Details.CAPABILITY_SPEED_UP_MT_AUDIO)) {
            Log.v(this, "Speed up audio setup for IMS MT call.");
            mCallToSpeedUpMTAudio = call;
            updateAudioStreamAndMode();
        }
    }

    @Override
@@ -282,6 +289,10 @@ final class CallAudioManager extends CallsManagerListenerBase
        boolean wasNotVoiceCall = mAudioFocusStreamType != AudioManager.STREAM_VOICE_CALL;
        updateAudioStreamAndMode();

        if (call != null && call.getState() == CallState.ACTIVE &&
                            call == mCallToSpeedUpMTAudio) {
            mCallToSpeedUpMTAudio = null;
        }
        // If we transition from not voice call to voice call, we need to set an initial state.
        if (wasNotVoiceCall && mAudioFocusStreamType == AudioManager.STREAM_VOICE_CALL) {
            setInitialAudioState(call, true /* force */);
@@ -361,7 +372,11 @@ final class CallAudioManager extends CallsManagerListenerBase
            Call foregroundCall = getForegroundCall();
            Call waitingForAccountSelectionCall =
                    CallsManager.getInstance().getFirstCallWithState(CallState.PRE_DIAL_WAIT);
            if (foregroundCall != null && waitingForAccountSelectionCall == null) {
            Call call = CallsManager.getInstance().getForegroundCall();
            if (foregroundCall == null && call != null && call == mCallToSpeedUpMTAudio) {
                requestAudioFocusAndSetMode(AudioManager.STREAM_VOICE_CALL,
                                                         AudioManager.MODE_IN_CALL);
            } else if (foregroundCall != null && waitingForAccountSelectionCall == null) {
                // In the case where there is a call that is waiting for account selection,
                // this will fall back to abandonAudioFocus() below, which temporarily exits
                // the in-call audio mode. This is to allow TalkBack to speak the "Call with"
@@ -412,6 +427,7 @@ final class CallAudioManager extends CallsManagerListenerBase
            Log.v(this, "abandoning audio focus");
            mAudioManager.abandonAudioFocusForCall();
            mAudioFocusStreamType = STREAM_NONE;
            mCallToSpeedUpMTAudio = null;
        }
    }