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

Commit da21f0de authored by Jack Yu's avatar Jack Yu
Browse files

Reduced the retry after disconnect delay

Reduced the delay from 20 seconds to 10 seconds. And created
a separate delay configuration for it.

Test: Manual
bug: 63633916
Change-Id: I793e2172657e27fb2153d456e846a0c9c5e451af
parent 72fb3ffc
Loading
Loading
Loading
Loading
+24 −35
Original line number Diff line number Diff line
@@ -27,8 +27,6 @@ import android.util.Pair;

import com.android.internal.telephony.dataconnection.ApnSetting;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Random;

@@ -111,6 +109,11 @@ public class RetryManager {
     */
    private static final long DEFAULT_INTER_APN_DELAY_FOR_PROVISIONING = 3000;

    /**
     * The default value (in milliseconds) for retrying APN after disconnect
     */
    private static final long DEFAULT_APN_RETRY_AFTER_DISCONNECT_DELAY = 10000;

    /**
     * The value indicating no retry is needed
     */
@@ -140,6 +143,12 @@ public class RetryManager {
     */
    private long mFailFastInterApnDelay;

    /**
     * The delay (in milliseconds) for APN retrying after disconnect (e.g. Modem suddenly reports
     * data call lost)
     */
    private long mApnRetryAfterDisconnectDelay;

    /**
     * Modem suggested delay for retrying the current APN
     */
@@ -337,6 +346,9 @@ public class RetryManager {
            mFailFastInterApnDelay = b.getLong(
                    CarrierConfigManager.KEY_CARRIER_DATA_CALL_APN_DELAY_FASTER_LONG,
                    DEFAULT_INTER_APN_DELAY_FOR_PROVISIONING);
            mApnRetryAfterDisconnectDelay = b.getLong(
                    CarrierConfigManager.KEY_CARRIER_DATA_CALL_APN_RETRY_AFTER_DISCONNECT_LONG,
                    DEFAULT_APN_RETRY_AFTER_DISCONNECT_DELAY);

            // Load all retry patterns for all different APNs.
            String[] allConfigStrings = b.getStringArray(
@@ -645,44 +657,21 @@ public class RetryManager {
    }

    /**
     * Get the delay between APN setting trying. This is the fixed delay used for APN setting trying
     * within the same round, comparing to the exponential delay used for different rounds.
     * @param failFastEnabled True if fail fast mode enabled, which a shorter delay will be used
     * Get the delay in milliseconds for APN retry after disconnect
     * @return The delay in milliseconds
     */
    public long getInterApnDelay(boolean failFastEnabled) {
        return (failFastEnabled) ? mFailFastInterApnDelay : mInterApnDelay;
    public long getRetryAfterDisconnectDelay() {
        return mApnRetryAfterDisconnectDelay;
    }

    public String toString() {
        return "mApnType=" + mApnType + " mRetryCount=" + mRetryCount +
                " mMaxRetryCount=" + mMaxRetryCount + " mCurrentApnIndex=" + mCurrentApnIndex +
                " mSameApnRtryCount=" + mSameApnRetryCount + " mModemSuggestedDelay=" +
                mModemSuggestedDelay + " mRetryForever=" + mRetryForever +
                " mConfig={" + mConfig + "}";
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("  RetryManager");
        pw.println("***************************************");

        pw.println("    config = " + mConfig);
        pw.println("    mApnType = " + mApnType);
        pw.println("    mCurrentApnIndex = " + mCurrentApnIndex);
        pw.println("    mRetryCount = " + mRetryCount);
        pw.println("    mMaxRetryCount = " + mMaxRetryCount);
        pw.println("    mSameApnRetryCount = " + mSameApnRetryCount);
        pw.println("    mModemSuggestedDelay = " + mModemSuggestedDelay);

        if (mWaitingApns != null) {
            pw.println("    APN list: ");
            for (int i = 0; i < mWaitingApns.size(); i++) {
                pw.println("      [" + i + "]=" + mWaitingApns.get(i));
            }
        }

        pw.println("***************************************");
        pw.flush();
        if (mConfig == null) return "";
        return "RetryManager: mApnType=" + mApnType + " mRetryCount=" + mRetryCount
                + " mMaxRetryCount=" + mMaxRetryCount + " mCurrentApnIndex=" + mCurrentApnIndex
                + " mSameApnRtryCount=" + mSameApnRetryCount + " mModemSuggestedDelay="
                + mModemSuggestedDelay + " mRetryForever=" + mRetryForever + " mInterApnDelay="
                + mInterApnDelay + " mApnRetryAfterDisconnectDelay=" + mApnRetryAfterDisconnectDelay
                + " mConfig={" + mConfig + "}";
    }

    private void log(String s) {
+3 −4
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.internal.telephony.dataconnection;

import android.app.PendingIntent;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
import android.net.NetworkConfig;
@@ -536,8 +535,8 @@ public class ApnContext {
        return mConnectionGeneration.get();
    }

    public long getInterApnDelay(boolean failFastEnabled) {
        return mRetryManager.getInterApnDelay(failFastEnabled || isFastRetryReason());
    long getRetryAfterDisconnectDelay() {
        return mRetryManager.getRetryAfterDisconnectDelay();
    }

    public static int apnIdForType(int networkType) {
@@ -726,7 +725,7 @@ public class ApnContext {
                l.dump(fd, pw, args);
            }
            pw.decreaseIndent();
            pw.println("mRetryManager={" + mRetryManager.toString() + "}");
            pw.println(mRetryManager);
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -3178,7 +3178,7 @@ public class DcTracker extends Handler {
            // we're not tying up the RIL command channel.
            // This also helps in any external dependency to turn off the context.
            if (DBG) log("onDisconnectDone: attached, ready and retry after disconnect");
            long delay = apnContext.getInterApnDelay(mFailFast);
            long delay = apnContext.getRetryAfterDisconnectDelay();
            if (delay > 0) {
                // Data connection is in IDLE state, so when we reconnect later, we'll rebuild
                // the waiting APN list, which will also reset/reconfigure the retry manager.