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

Commit 2182ed7e authored by Hall Liu's avatar Hall Liu Committed by android-build-merger
Browse files

Add ANSWERED state to call states am: 9eec68de

am: cac015dc

Change-Id: I75a6b92dc369f9c8d86686070b4543a1862e85d8
parents e1213e3c cac015dc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -875,6 +875,7 @@ public class BluetoothPhoneServiceImpl {
                return CALL_STATE_HELD;

            case CallState.RINGING:
            case CallState.ANSWERED:
                if (isForegroundCall) {
                    return CALL_STATE_INCOMING;
                } else {
+7 −3
Original line number Diff line number Diff line
@@ -944,6 +944,9 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
                case CallState.RINGING:
                    event = LogUtils.Events.SET_RINGING;
                    break;
                case CallState.ANSWERED:
                    event = LogUtils.Events.SET_ANSWERED;
                    break;
            }
            if (event != null) {
                // The string data should be just the tag.
@@ -1985,6 +1988,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        switch (mState) {
            case CallState.NEW:
            case CallState.RINGING:
            case CallState.ANSWERED:
            case CallState.DISCONNECTED:
            case CallState.ABORTED:
                return false;
@@ -3054,13 +3058,13 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
    /**
     * Sets the video history based on the state and state transitions of the call. Always add the
     * current video state to the video state history during a call transition except for the
     * transitions DIALING->ACTIVE and RINGING->ACTIVE. In these cases, clear the history. If a
     * transitions DIALING->ACTIVE and RINGING->ANSWERED. In these cases, clear the history. If a
     * call starts dialing/ringing as a VT call and gets downgraded to audio, we need to record
     * the history as an audio call.
     */
    private void updateVideoHistoryViaState(int oldState, int newState) {
        if ((oldState == CallState.DIALING || oldState == CallState.RINGING)
                && newState == CallState.ACTIVE) {
        if ((oldState == CallState.DIALING && newState == CallState.ACTIVE)
                || (oldState == CallState.RINGING && newState == CallState.ANSWERED)) {
            mVideoStateHistory = mVideoState;
        }

+32 −32
Original line number Diff line number Diff line
@@ -105,11 +105,10 @@ public class CallAudioManager extends CallsManagerListenerBase {
        Log.d(LOG_TAG, "Call state changed for TC@%s: %s -> %s", call.getId(),
                CallState.toString(oldState), CallState.toString(newState));

        for (int i = 0; i < mCallStateToCalls.size(); i++) {
            mCallStateToCalls.valueAt(i).remove(call);
        }
        if (mCallStateToCalls.get(newState) != null) {
            mCallStateToCalls.get(newState).add(call);
        removeCallFromAllBins(call);
        HashSet<Call> newBinForCall = getBinForCall(call);
        if (newBinForCall != null) {
            newBinForCall.add(call);
        }

        updateForegroundCall();
@@ -148,8 +147,9 @@ public class CallAudioManager extends CallsManagerListenerBase {
        Log.d(LOG_TAG, "Call added with id TC@%s in state %s", call.getId(),
                CallState.toString(call.getState()));

        if (mCallStateToCalls.get(call.getState()) != null) {
            mCallStateToCalls.get(call.getState()).add(call);
        HashSet<Call> newBinForCall = getBinForCall(call);
        if (newBinForCall != null) {
            newBinForCall.add(call);
        }
        updateForegroundCall();
        mCalls.add(call);
@@ -168,9 +168,7 @@ public class CallAudioManager extends CallsManagerListenerBase {
        Log.d(LOG_TAG, "Call removed with id TC@%s in state %s", call.getId(),
                CallState.toString(call.getState()));

        for (int i = 0; i < mCallStateToCalls.size(); i++) {
            mCallStateToCalls.valueAt(i).remove(call);
        }
        removeCallFromAllBins(call);

        updateForegroundCall();
        mCalls.remove(call);
@@ -226,24 +224,6 @@ public class CallAudioManager extends CallsManagerListenerBase {
            return;
        }

        // This is called after the UI answers the call, but before the connection service
        // sets the call to active. Only thing to handle for mode here is the audio speedup thing.

        if (call.can(android.telecom.Call.Details.CAPABILITY_SPEED_UP_MT_AUDIO)) {
            if (mForegroundCall == call) {
                Log.i(LOG_TAG, "Invoking the MT_AUDIO_SPEEDUP mechanism. Transitioning into " +
                        "an active in-call audio state before connection service has " +
                        "connected the call.");
                if (mCallStateToCalls.get(call.getState()) != null) {
                    mCallStateToCalls.get(call.getState()).remove(call);
                }
                mActiveDialingOrConnectingCalls.add(call);
                mCallAudioModeStateMachine.sendMessageWithArgs(
                        CallAudioModeStateMachine.MT_AUDIO_SPEEDUP_FOR_RINGING_CALL,
                        makeArgsForModeStateMachine());
            }
        }

        // Turn off mute when a new incoming call is answered iff it's not a handover.
        if (!call.isHandoverInProgress()) {
            mute(false /* shouldMute */);
@@ -325,10 +305,7 @@ public class CallAudioManager extends CallsManagerListenerBase {
            onCallAdded(call);
        } else {
            // The call joined a conference, so stop tracking it.
            if (mCallStateToCalls.get(call.getState()) != null) {
                mCallStateToCalls.get(call.getState()).remove(call);
            }

            removeCallFromAllBins(call);
            updateForegroundCall();
            mCalls.remove(call);
        }
@@ -591,6 +568,11 @@ public class CallAudioManager extends CallsManagerListenerBase {
                onCallEnteringActiveDialingOrConnecting();
                playRingbackForCall(call);
                break;
            case CallState.ANSWERED:
                if (call.can(android.telecom.Call.Details.CAPABILITY_SPEED_UP_MT_AUDIO)) {
                    onCallEnteringActiveDialingOrConnecting();
                }
                break;
        }
    }

@@ -681,6 +663,24 @@ public class CallAudioManager extends CallsManagerListenerBase {
                Log.createSubsession());
    }

    private HashSet<Call> getBinForCall(Call call) {
        if (call.getState() == CallState.ANSWERED) {
            // If the call has the speed-up-mt-audio capability, treat answered state as active
            // for audio purposes.
            if (call.can(android.telecom.Call.Details.CAPABILITY_SPEED_UP_MT_AUDIO)) {
                return mActiveDialingOrConnectingCalls;
            }
            return mRingingCalls;
        }
        return mCallStateToCalls.get(call.getState());
    }

    private void removeCallFromAllBins(Call call) {
        for (int i = 0; i < mCallStateToCalls.size(); i++) {
            mCallStateToCalls.valueAt(i).remove(call);
        }
    }

    private void playToneForDisconnectedCall(Call call) {
        // If this call is being disconnected as a result of being handed over to another call,
        // we will not play a disconnect tone.
+0 −11
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@ public class CallAudioModeStateMachine extends StateMachine {
    public static final int NEW_ACTIVE_OR_DIALING_CALL = 2001;
    public static final int NEW_RINGING_CALL = 2002;
    public static final int NEW_HOLDING_CALL = 2003;
    public static final int MT_AUDIO_SPEEDUP_FOR_RINGING_CALL = 2004;

    public static final int TONE_STARTED_PLAYING = 3001;
    public static final int TONE_STOPPED_PLAYING = 3002;
@@ -109,7 +108,6 @@ public class CallAudioModeStateMachine extends StateMachine {
        put(NEW_ACTIVE_OR_DIALING_CALL, "NEW_ACTIVE_OR_DIALING_CALL");
        put(NEW_RINGING_CALL, "NEW_RINGING_CALL");
        put(NEW_HOLDING_CALL, "NEW_HOLDING_CALL");
        put(MT_AUDIO_SPEEDUP_FOR_RINGING_CALL, "MT_AUDIO_SPEEDUP_FOR_RINGING_CALL");
        put(TONE_STARTED_PLAYING, "TONE_STARTED_PLAYING");
        put(TONE_STOPPED_PLAYING, "TONE_STOPPED_PLAYING");
        put(FOREGROUND_VOIP_MODE_CHANGE, "FOREGROUND_VOIP_MODE_CHANGE");
@@ -279,15 +277,6 @@ public class CallAudioModeStateMachine extends StateMachine {
                            " Args are: " + args.toString());
                    transitionTo(mOtherFocusState);
                    return HANDLED;
                case MT_AUDIO_SPEEDUP_FOR_RINGING_CALL:
                    // This happens when an IMS call is answered by the in-call UI. Special case
                    // that we have to deal with for some reason.

                    // The IMS audio routing may be via modem or via RTP stream. In case via RTP
                    // stream, the state machine should transit to mVoipCallFocusState.
                    transitionTo(args.foregroundCallIsVoip
                            ? mVoipCallFocusState : mSimCallFocusState);
                    return HANDLED;
                case RINGER_MODE_CHANGE: {
                    Log.i(LOG_TAG, "RINGING state, received RINGER_MODE_CHANGE");
                    tryStartRinging();
+8 −0
Original line number Diff line number Diff line
@@ -114,6 +114,12 @@ public final class CallState {
     */
    public static final int PULLING = TelecomProtoEnums.PULLING; // = 10

    /**
     * Indicates that an incoming call has been answered by the in-call UI, but Telephony hasn't yet
     * set the call to active.
     */
    public static final int ANSWERED = 11;

    public static String toString(int callState) {
        switch (callState) {
            case NEW:
@@ -138,6 +144,8 @@ public final class CallState {
                return "DISCONNECTING";
            case PULLING:
                return "PULLING";
            case ANSWERED:
                return "ANSWERED";
            default:
                return "UNKNOWN";
        }
Loading