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

Commit 3048f13e authored by Ravindra's avatar Ravindra Committed by Gerrit - the friendly Code Review server
Browse files

Set audio mode after accepting the call

Set the audio mode to incall immediately after accepting the call and not wait
till call is reported as ACTIVE by RIL. This is done to speed up time taken for audio
to set up the voice path

Change-Id: Id78c467869693087c49b743e67b7a77aff841ae3
CRs-Fixed: 726708
parent 91d85e78
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -46,4 +46,8 @@

    <!-- DTMF key to be used for LCH hold tone -->
    <string name="Lch_dtmf_key" translatable="false">D</string>

    <!-- Flag indicating if the speed up audio on mt call code should be executed -->
    <bool name="config_speed_up_audio_on_mt_calls">false</bool>

</resources>
+28 −4
Original line number Diff line number Diff line
@@ -43,6 +43,9 @@ final class CallAudioManager extends CallsManagerListenerBase
    private boolean mIsTonePlaying;
    private boolean mWasSpeakerOn;
    private int mMostRecentlyUsedMode = AudioManager.MODE_IN_CALL;
    private boolean mSpeedUpAudioForMtCall = false;
    private Context mContext;
    private String mSubId;

    CallAudioManager(Context context, StatusBarNotifier statusBarNotifier,
            WiredHeadsetManager wiredHeadsetManager) {
@@ -54,6 +57,7 @@ final class CallAudioManager extends CallsManagerListenerBase

        saveAudioState(getInitialAudioState(null));
        mAudioFocusStreamType = STREAM_NONE;
        mContext = context;
    }

    AudioState getAudioState() {
@@ -102,8 +106,21 @@ final class CallAudioManager extends CallsManagerListenerBase
            mBluetoothManager.connectBluetoothAudio();
            route = AudioState.ROUTE_BLUETOOTH;
        }

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

        if (mContext == null) {
            Log.d(this, "Speedup Audio Path enhancement: Context is null");
        } else if (mContext.getResources().getBoolean(
                com.android.server.telecom.R.bool.config_speed_up_audio_on_mt_calls)) {
            Log.d(this, "Speedup Audio Path enhancement");
            mSpeedUpAudioForMtCall = true;
            mSubId = call.getTargetPhoneAccount().getId();
            if (mIsRinging) {
                setIsRinging(false);
            } else {
                updateAudioStreamAndMode();
            }
        }
    }

    @Override
@@ -262,7 +279,11 @@ final class CallAudioManager extends CallsManagerListenerBase
    private void onCallUpdated(Call call) {
        boolean wasNotVoiceCall = mAudioFocusStreamType != AudioManager.STREAM_VOICE_CALL;
        updateAudioStreamAndMode();

        if ((call != null) && (call.getState() == CallState.ACTIVE) &&
                call.getTargetPhoneAccount().getId().equals(mSubId) && mSpeedUpAudioForMtCall) {
            Log.d(this,"Reset mSpeedUpAudioForMtCall");
            mSpeedUpAudioForMtCall = false;
        }
        // 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 */);
@@ -336,7 +357,8 @@ final class CallAudioManager extends CallsManagerListenerBase
    private void updateAudioStreamAndMode() {
        Log.i(this, "updateAudioStreamAndMode, mIsRinging: %b, mIsTonePlaying: %b", mIsRinging,
                mIsTonePlaying);
        if (mIsRinging) {
        Log.v(this, "updateAudioStreamAndMode, mSpeedUpAudioForMtCall: %b", mSpeedUpAudioForMtCall);
        if (mIsRinging && !mSpeedUpAudioForMtCall) {
            requestAudioFocusAndSetMode(AudioManager.STREAM_RING, AudioManager.MODE_RINGTONE);
        } else {
            Call call = getForegroundCall();
@@ -384,6 +406,7 @@ final class CallAudioManager extends CallsManagerListenerBase
            Log.v(this, "abandoning audio focus");
            mAudioManager.abandonAudioFocusForCall();
            mAudioFocusStreamType = STREAM_NONE;
            mSpeedUpAudioForMtCall = false;
        }
    }

@@ -403,6 +426,7 @@ final class CallAudioManager extends CallsManagerListenerBase
                mAudioManager.setMode(AudioManager.MODE_NORMAL);
            }
            mAudioManager.setMode(newMode);
            Log.d(this, "SetMode Done");
            mMostRecentlyUsedMode = newMode;
        }
    }
@@ -488,7 +512,7 @@ final class CallAudioManager extends CallsManagerListenerBase

        // We ignore any foreground call that is in the ringing state because we deal with ringing
        // calls exclusively through the mIsRinging variable set by {@link Ringer}.
        if (call != null && call.getState() == CallState.RINGING) {
        if (call != null && call.getState() == CallState.RINGING && !mSpeedUpAudioForMtCall ) {
            call = null;
        }
        return call;