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

Commit 386b3349 authored by Dong Zhou's avatar Dong Zhou Committed by Android Git Automerger
Browse files

am 3871849d: Speed up audio setup for IMS MT call

* commit '3871849d':
  Speed up audio setup for IMS MT call
parents e70f32b1 3871849d
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;
        }
    }