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

Commit e0592ed3 authored by Robert Greenwalt's avatar Robert Greenwalt Committed by Android (Google) Code Review
Browse files

Merge "Don't rety permanent failures on every RAT change" into lmp-mr1-dev

parents 12d0c974 c2d1d6b2
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -48,6 +48,12 @@ public class ApnContext {

    private ArrayList<ApnSetting> mWaitingApns = null;

    /**
     * Used to check if conditions (new RAT) are resulting in a new list which warrants a retry.
     * Set in the last trySetupData call.
     */
    private ArrayList<ApnSetting> mOriginalWaitingApns = null;

    public final int priority;

    /** A zero indicates that all waiting APNs had a permanent error */
@@ -76,6 +82,12 @@ public class ApnContext {

    private final DcTrackerBase mDcTracker;

    /**
     * Remember this as a change in this value to a more permissive state
     * should cause us to retry even permanent failures
     */
    private boolean mConcurrentVoiceAndDataAllowed;

    public ApnContext(Context context, String apnType, String logTag, NetworkConfig config,
            DcTrackerBase tracker) {
        mContext = context;
@@ -126,6 +138,7 @@ public class ApnContext {

    public synchronized void setWaitingApns(ArrayList<ApnSetting> waitingApns) {
        mWaitingApns = waitingApns;
        mOriginalWaitingApns = new ArrayList<ApnSetting>(waitingApns);
        mWaitingApnsPermanentFailureCountDown.set(mWaitingApns.size());
    }

@@ -155,10 +168,22 @@ public class ApnContext {
        }
    }

    public synchronized ArrayList<ApnSetting> getOriginalWaitingApns() {
        return mOriginalWaitingApns;
    }

    public synchronized ArrayList<ApnSetting> getWaitingApns() {
        return mWaitingApns;
    }

    public synchronized void setConcurrentVoiceAndDataAllowed(boolean allowed) {
        mConcurrentVoiceAndDataAllowed = allowed;
    }

    public synchronized boolean isConcurrentVoiceAndDataAllowed() {
        return mConcurrentVoiceAndDataAllowed;
    }

    public synchronized void setState(DctConstants.State s) {
        if (DBG) {
            log("setState: " + s + ", previous state:" + mState);
+48 −7
Original line number Diff line number Diff line
@@ -753,23 +753,59 @@ public final class DcTracker extends DcTrackerBase {
        return allowed;
    }

    // arg for setupDataOnConnectableApns
    private enum RetryFailures {
        // retry failed networks always (the old default)
        ALWAYS,
        // retry only when a substantial change has occured.  Either:
        // 1) we were restricted by voice/data concurrency and aren't anymore
        // 2) our apn list has change
        ONLY_ON_CHANGE
    };

    private void setupDataOnConnectableApns(String reason) {
        setupDataOnConnectableApns(reason, RetryFailures.ALWAYS);
    }

    private void setupDataOnConnectableApns(String reason, RetryFailures retryFailures) {
        if (DBG) log("setupDataOnConnectableApns: " + reason);
        ArrayList<ApnSetting> waitingApns = null;

        for (ApnContext apnContext : mPrioritySortedApnContexts) {
            if (DBG) log("setupDataOnConnectableApns: apnContext " + apnContext);
            if (apnContext.getState() == DctConstants.State.FAILED) {
                if (retryFailures == RetryFailures.ALWAYS) {
                    apnContext.setState(DctConstants.State.IDLE);
                } else if (apnContext.isConcurrentVoiceAndDataAllowed() == false &&
                         mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed()) {
                    // RetryFailures.ONLY_ON_CHANGE - check if voice concurrency has changed
                    apnContext.setState(DctConstants.State.IDLE);
                } else {
                    // RetryFailures.ONLY_ON_CHANGE - check if the apns have changed
                    int radioTech = mPhone.getServiceState().getRilDataRadioTechnology();
                    ArrayList<ApnSetting> originalApns = apnContext.getOriginalWaitingApns();
                    if (originalApns != null && originalApns.isEmpty() == false) {
                        waitingApns = buildWaitingApns(apnContext.getApnType(), radioTech);
                        if (originalApns.size() != waitingApns.size() ||
                                originalApns.containsAll(waitingApns) == false) {
                            apnContext.setState(DctConstants.State.IDLE);
                        }
                    }
                }
            }
            if (apnContext.isConnectable()) {
                log("setupDataOnConnectableApns: isConnectable() call trySetupData");
                apnContext.setReason(reason);
                trySetupData(apnContext);
                trySetupData(apnContext, waitingApns);
            }
        }
    }

    private boolean trySetupData(ApnContext apnContext) {
        return trySetupData(apnContext, null);
    }

    private boolean trySetupData(ApnContext apnContext, ArrayList<ApnSetting> waitingApns) {
        if (DBG) {
            log("trySetupData for type:" + apnContext.getApnType() +
                    " due to " + apnContext.getReason() + " apnContext=" + apnContext);
@@ -789,7 +825,8 @@ public final class DcTracker extends DcTrackerBase {
        // Allow SETUP_DATA request for E-APN to be completed during emergency call
        // and MOBILE DATA On/Off cases as well.
        boolean isEmergencyApn = apnContext.getApnType().equals(PhoneConstants.APN_TYPE_EMERGENCY);
        boolean desiredPowerState = mPhone.getServiceStateTracker().getDesiredPowerState();
        final ServiceStateTracker sst = mPhone.getServiceStateTracker();
        boolean desiredPowerState = sst.getDesiredPowerState();
        boolean checkUserDataEnabled =
                    !(apnContext.getApnType().equals(PhoneConstants.APN_TYPE_IMS));

@@ -801,10 +838,11 @@ public final class DcTracker extends DcTrackerBase {
                apnContext.setState(DctConstants.State.IDLE);
            }
            int radioTech = mPhone.getServiceState().getRilDataRadioTechnology();
            apnContext.setConcurrentVoiceAndDataAllowed(sst.isConcurrentVoiceAndDataAllowed());
            if (apnContext.getState() == DctConstants.State.IDLE) {

                ArrayList<ApnSetting> waitingApns = buildWaitingApns(apnContext.getApnType(),
                        radioTech);
                if (waitingApns == null) {
                    waitingApns = buildWaitingApns(apnContext.getApnType(), radioTech);
                }
                if (waitingApns.isEmpty()) {
                    notifyNoData(DcFailCause.MISSING_UNKNOWN_APN, apnContext);
                    notifyOffApnsOfAvailability(apnContext.getReason());
@@ -2074,6 +2112,8 @@ public final class DcTracker extends DcTrackerBase {
            mDisconnectPendingCount--;

        if (mDisconnectPendingCount == 0) {
            apnContext.setConcurrentVoiceAndDataAllowed(
                    mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed());
            notifyDataDisconnectComplete();
            notifyAllDataDisconnected();
        }
@@ -2635,7 +2675,8 @@ public final class DcTracker extends DcTrackerBase {

            case DctConstants.EVENT_DATA_RAT_CHANGED:
                //May new Network allow setupData, so try it here
                setupDataOnConnectableApns(Phone.REASON_NW_TYPE_CHANGED);
                setupDataOnConnectableApns(Phone.REASON_NW_TYPE_CHANGED,
                        RetryFailures.ONLY_ON_CHANGE);
                break;

            case DctConstants.CMD_CLEAR_PROVISIONING_SPINNER: