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

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

Merge "DSDA: Handle call resume failure" into main

parents c59df810 2262ddee
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -77,3 +77,11 @@ flag {
      purpose: PURPOSE_BUGFIX
    }
}

# OWNER=pmadapurmath TARGET=25Q4
flag {
  name: "call_sequencing_call_resume_failed"
  namespace: "telecom"
  description: "Connection event received when a call resume fails"
  bug: "390116261"
}
+7 −0
Original line number Diff line number Diff line
@@ -205,6 +205,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        default void onHoldToneRequested(Call call) {};
        default void onCallHoldFailed(Call call) {};
        default void onCallSwitchFailed(Call call) {};
        default void onCallResumeFailed(Call call) {};
        default void onConnectionEvent(Call call, String event, Bundle extras) {};
        default void onCallStreamingStateChanged(Call call, boolean isStreaming) {}
        default void onExternalCallChanged(Call call, boolean isExternalCall) {};
@@ -295,6 +296,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        @Override
        public void onCallSwitchFailed(Call call) {}
        @Override
        public void onCallResumeFailed(Call call) {}
        @Override
        public void onConnectionEvent(Call call, String event, Bundle extras) {}
        @Override
        public void onCallStreamingStateChanged(Call call, boolean isStreaming) {}
@@ -4545,6 +4548,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
            for (Listener l : mListeners) {
                l.onCallSwitchFailed(this);
            }
        } else if (Connection.EVENT_CALL_RESUME_FAILED.equals(event)) {
            for (Listener l : mListeners) {
                l.onCallResumeFailed(this);
            }
        } else if (Connection.EVENT_DEVICE_TO_DEVICE_MESSAGE.equals(event)
                && extras != null && extras.containsKey(
                Connection.EXTRA_DEVICE_TO_DEVICE_MESSAGE_TYPE)
+8 −0
Original line number Diff line number Diff line
@@ -1477,6 +1477,14 @@ public class CallsManager extends Call.ListenerBase
        markAllAnsweredCallAsRinging(call, "switch");
    }

    @Override
    public void onCallResumeFailed(Call call) {
        Call heldCall = getFirstCallWithState(call, true /* skipSelfManaged */, CallState.ON_HOLD);
        if (heldCall != null) {
            mCallSequencingAdapter.handleCallResumeFailed(call, heldCall);
        }
    }

    private void markAllAnsweredCallAsRinging(Call call, String actionName) {
        // Normally, we don't care whether a call hold or switch has failed.
        // However, if a call was held or switched in order to answer an incoming call, that
+14 −0
Original line number Diff line number Diff line
@@ -364,6 +364,20 @@ public class CallsManagerCallSequencingAdapter {
        });
    }

    /**
     * Upon a call resume failure, we will auto-unhold the foreground call that was held. Note that
     * this should only apply for calls across phone accounts as the ImsPhoneCallTracker handles
     * this for a single phone.
     * @param callResumeFailed The call that failed to resume.
     * @param callToUnhold The fg call that was held.
     */
    public void handleCallResumeFailed(Call callResumeFailed, Call callToUnhold) {
        if (mIsCallSequencingEnabled && !mSequencingController.arePhoneAccountsSame(
                callResumeFailed, callToUnhold)) {
            unholdCall(callToUnhold);
        }
    }

    public Handler getHandler() {
        return mHandler;
    }
+24 −0
Original line number Diff line number Diff line
@@ -18,8 +18,10 @@ package com.android.server.telecom.callsequencing;

import com.android.internal.annotations.VisibleForTesting;
import com.android.server.telecom.Call;
import com.android.server.telecom.CallState;
import com.android.server.telecom.TelecomSystem;

import android.telecom.CallException;
import android.telecom.Log;

import java.util.Set;
@@ -56,6 +58,26 @@ public class VerifyCallStateChangeTransaction extends CallTransaction {
        }
    };

    private final Call.ListenerBase mCallListenerImpl = new Call.ListenerBase() {
        @Override
        public void onCallHoldFailed(Call call) {
            if (call.equals(mCall) && mTargetCallStates.contains(CallState.ON_HOLD)) {
                // Fail the transaction if a call hold failure is received.
                mTransactionResult.complete(new CallTransactionResult(
                        CallException.CODE_CANNOT_HOLD_CURRENT_ACTIVE_CALL, "error holding call"));
            }
        }
        @Override
        public void onCallResumeFailed(Call call) {
            if (call.equals(mCall) && mTargetCallStates.contains(CallState.ACTIVE)) {
                // Fail the transaction if a call resume failure is received (this means that the
                // current call could not be unheld).
                mTransactionResult.complete(new CallTransactionResult(
                        CallException.CODE_CALL_CANNOT_BE_SET_TO_ACTIVE, "error unholding call"));
            }
        }
    };

    public VerifyCallStateChangeTransaction(TelecomSystem.SyncRoot lock,  Call call,
            int... targetCallStates) {
        super(lock, CALL_STATE_TIMEOUT_MILLISECONDS);
@@ -73,12 +95,14 @@ public class VerifyCallStateChangeTransaction extends CallTransaction {
            return mTransactionResult;
        }
        mCall.addCallStateListener(mCallStateListenerImpl);
        mCall.addListener(mCallListenerImpl);
        return mTransactionResult;
    }

    @Override
    public void finishTransaction() {
        mCall.removeCallStateListener(mCallStateListenerImpl);
        mCall.removeListener(mCallListenerImpl);
    }

    private boolean isNewCallStateTargetCallState() {
Loading