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

Commit 62cc9aa3 authored by Jack Yu's avatar Jack Yu Committed by Daniel Bright
Browse files

Properly support handover retry

1. If retrying handover, do not tear down the
   data connection on the source transport.
2. For handover fallback, fail fast the retry instead
   of letting it retry and fail with ON_OTHER_TRANSPORT
   error. This is no behavioral change but optimization
   only.

(clean cherry-pick)

Fix: 170796126
Test: Manual
Merged-In: I8e3cb41f15366477d686adf42851b6208a545c43
Change-Id: I8e3cb41f15366477d686adf42851b6208a545c43
parent e6a695e7
Loading
Loading
Loading
Loading
+33 −16
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ import android.telephony.gsm.GsmCellLocation;
import android.text.TextUtils;
import android.util.EventLog;
import android.util.LocalLog;
import android.util.Log;
import android.util.Pair;
import android.util.SparseArray;
import android.view.WindowManager;
@@ -2844,8 +2845,15 @@ public class DcTracker extends Handler {
     * A SETUP (aka bringUp) has completed, possibly with an error. If
     * there is an error this method will call {@link #onDataSetupCompleteError}.
     */
    protected void onDataSetupComplete(ApnContext apnContext, boolean success, int cause,
            @RequestNetworkType int requestType, @HandoverFailureMode int handoverFailureMode) {
    protected void onDataSetupComplete(ApnContext apnContext, boolean success,
            @DataFailureCause int cause, @RequestNetworkType int requestType,
            @HandoverFailureMode int handoverFailureMode) {
        if (success && (handoverFailureMode != DataCallResponse.HANDOVER_FAILURE_MODE_UNKNOWN
                && handoverFailureMode != DataCallResponse.HANDOVER_FAILURE_MODE_LEGACY)) {
            Log.wtf(mLogTag, "bad failure mode: "
                    + DataCallResponse.failureModeToString(handoverFailureMode));
        } else if (handoverFailureMode
                != DataCallResponse.HANDOVER_FAILURE_MODE_NO_FALLBACK_RETRY_HANDOVER) {
            int apnType = ApnSetting.getApnTypesBitmaskFromString(apnContext.getApnType());
            List<Message> messageList = mRequestNetworkCompletionMsgs.get(apnType);
            if (messageList != null) {
@@ -2855,6 +2863,7 @@ public class DcTracker extends Handler {
                }
                messageList.clear();
            }
        }

        if (success) {
            DataConnection dataConnection = apnContext.getDataConnection();
@@ -2879,7 +2888,7 @@ public class DcTracker extends Handler {
            }
            if (dataConnection == null) {
                log("onDataSetupComplete: no connection to DC, handle as error");
                onDataSetupCompleteError(apnContext, requestType);
                onDataSetupCompleteError(apnContext, requestType, false);
            } else {
                ApnSetting apn = apnContext.getApnSetting();
                if (DBG) {
@@ -3001,7 +3010,12 @@ public class DcTracker extends Handler {
                log("cause = " + cause + ", mark apn as permanent failed. apn = " + apn);
                apnContext.markApnPermanentFailed(apn);
            }
            onDataSetupCompleteError(apnContext, requestType);

            requestType = (handoverFailureMode
                    == DataCallResponse.HANDOVER_FAILURE_MODE_NO_FALLBACK_RETRY_HANDOVER)
                    ? REQUEST_TYPE_HANDOVER : REQUEST_TYPE_NORMAL;
            onDataSetupCompleteError(apnContext, requestType,
                    shouldFallbackOnFailedHandover(handoverFailureMode, requestType, cause));
        }
    }

@@ -3012,13 +3026,16 @@ public class DcTracker extends Handler {
     * be a delay defined by {@link ApnContext#getDelayForNextApn(boolean)}.
     */
    protected void onDataSetupCompleteError(ApnContext apnContext,
                                          @RequestNetworkType int requestType) {
            @RequestNetworkType int requestType, boolean fallback) {
        long delay = apnContext.getDelayForNextApn(mFailFast);

        // Check if we need to retry or not.
        // TODO: We should support handover retry in the future.
        if (delay >= 0) {
            if (DBG) log("onDataSetupCompleteError: Try next APN. delay = " + delay);
        if (delay >= 0 && !fallback) {
            if (DBG) {
                log("onDataSetupCompleteError: APN type=" + apnContext.getApnType()
                        + ". Request type=" + requestTypeToString(requestType) + ", Retry in "
                        + delay + "ms.");
            }
            apnContext.setState(DctConstants.State.RETRYING);
            // Wait a bit before trying the next APN, so that
            // we're not tying up the RIL command channel
@@ -3705,7 +3722,7 @@ public class DcTracker extends Handler {
                generation = pair.second;
                handoverFailureMode = msg.arg2;
                if (apnContext.getConnectionGeneration() == generation) {
                    onDataSetupCompleteError(apnContext, handoverFailureMode);
                    onDataSetupCompleteError(apnContext, handoverFailureMode, false);
                } else {
                    loge("EVENT_DATA_SETUP_COMPLETE_ERROR: Dropped the event because generation "
                            + "did not match.");
+1 −1
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ public class VendorDcTracker extends DcTracker {

    @Override
    protected void onDataSetupCompleteError(ApnContext apnContext,
            @RequestNetworkType int requestType) {
            @RequestNetworkType int requestType, boolean fallback) {
        long delay = apnContext.getDelayForNextApn(mFailFast);
        if (mPhone.getContext().getResources().getBoolean(
                com.android.internal.R.bool.config_pdp_reject_enable_retry)) {