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

Commit ec107cb8 authored by Wink Saville's avatar Wink Saville
Browse files

Add CMD_SET_ENABLE_FAIL_FAST_MOBILE_DATA to DcTracker.

To fail fast we turn off data stall detection and do no retires.

Bug: 9279964
Change-Id: I42c326a21e05aa301e9d974ed9ac1d59472780ec
parent 4a65a2c9
Loading
Loading
Loading
Loading
+18 −4
Original line number Original line Diff line number Diff line
@@ -1594,11 +1594,23 @@ public final class DcTracker extends DcTrackerBase {
        }
        }
    }
    }


    /**
     * @return number of milli-seconds to delay between trying apns'
     */
    private int getApnDelay() {
        if (mFailFast) {
            return SystemProperties.getInt("persist.radio.apn_ff_delay",
                    APN_FAIL_FAST_DELAY_DEFAULT_MILLIS);
        } else {
            return SystemProperties.getInt("persist.radio.apn_delay", APN_DELAY_DEFAULT_MILLIS);
        }
    }

    /**
    /**
     * Error has occurred during the SETUP {aka bringUP} request and the DCT
     * Error has occurred during the SETUP {aka bringUP} request and the DCT
     * should either try the next waiting APN or start over from the
     * should either try the next waiting APN or start over from the
     * beginning if the list is empty. Between each SETUP request there will
     * beginning if the list is empty. Between each SETUP request there will
     * be a delay defined by {@link #APN_DELAY_MILLIS}.
     * be a delay defined by {@link #getApnDelay()}.
     */
     */
    @Override
    @Override
    protected void onDataSetupCompleteError(AsyncResult ar) {
    protected void onDataSetupCompleteError(AsyncResult ar) {
@@ -1626,14 +1638,14 @@ public final class DcTracker extends DcTrackerBase {
                if (DBG) {
                if (DBG) {
                    log("onDataSetupComplete: Not all APN's had permanent failures, short delay");
                    log("onDataSetupComplete: Not all APN's had permanent failures, short delay");
                }
                }
                startAlarmForRestartTrySetup(APN_DELAY_MILLIS, apnContext);
                startAlarmForRestartTrySetup(getApnDelay(), apnContext);
            }
            }
        } else {
        } else {
            if (DBG) log("onDataSetupComplete: Try next APN");
            if (DBG) log("onDataSetupComplete: Try next APN");
            apnContext.setState(DctConstants.State.SCANNING);
            apnContext.setState(DctConstants.State.SCANNING);
            // Wait a bit before trying the next APN, so that
            // Wait a bit before trying the next APN, so that
            // we're not tying up the RIL command channel
            // we're not tying up the RIL command channel
            startAlarmForReconnect(APN_DELAY_MILLIS, apnContext);
            startAlarmForReconnect(getApnDelay(), apnContext);
        }
        }
    }
    }


@@ -1673,7 +1685,7 @@ public final class DcTracker extends DcTrackerBase {
            // Wait a bit before trying the next APN, so that
            // Wait a bit before trying the next APN, so that
            // we're not tying up the RIL command channel.
            // we're not tying up the RIL command channel.
            // This also helps in any external dependency to turn off the context.
            // This also helps in any external dependency to turn off the context.
            startAlarmForReconnect(APN_DELAY_MILLIS, apnContext);
            startAlarmForReconnect(getApnDelay(), apnContext);
        } else {
        } else {
            apnContext.setApnSetting(null);
            apnContext.setApnSetting(null);
            apnContext.setDataConnectionAc(null);
            apnContext.setDataConnectionAc(null);
@@ -1712,6 +1724,7 @@ public final class DcTracker extends DcTrackerBase {
    @Override
    @Override
    protected void onVoiceCallStarted() {
    protected void onVoiceCallStarted() {
        if (DBG) log("onVoiceCallStarted");
        if (DBG) log("onVoiceCallStarted");
        mInVoiceCall = true;
        if (isConnected() && ! mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed()) {
        if (isConnected() && ! mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed()) {
            if (DBG) log("onVoiceCallStarted stop polling");
            if (DBG) log("onVoiceCallStarted stop polling");
            stopNetStatPoll();
            stopNetStatPoll();
@@ -1723,6 +1736,7 @@ public final class DcTracker extends DcTrackerBase {
    @Override
    @Override
    protected void onVoiceCallEnded() {
    protected void onVoiceCallEnded() {
        if (DBG) log("onVoiceCallEnded");
        if (DBG) log("onVoiceCallEnded");
        mInVoiceCall = false;
        if (isConnected()) {
        if (isConnected()) {
            if (!mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed()) {
            if (!mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed()) {
                startNetStatPoll();
                startNetStatPoll();
+40 −4
Original line number Original line Diff line number Diff line
@@ -85,8 +85,10 @@ public abstract class DcTrackerBase extends Handler {


    /** Delay between APN attempts.
    /** Delay between APN attempts.
        Note the property override mechanism is there just for testing purpose only. */
        Note the property override mechanism is there just for testing purpose only. */
    protected static final int APN_DELAY_MILLIS =
    protected static final int APN_DELAY_DEFAULT_MILLIS = 20000;
                                SystemProperties.getInt("persist.radio.apn_delay", 20000);

    /** Delay between APN attempts when in fail fast mode */
    protected static final int APN_FAIL_FAST_DELAY_DEFAULT_MILLIS = 3000;


    AlarmManager mAlarmManager;
    AlarmManager mAlarmManager;


@@ -202,6 +204,13 @@ public abstract class DcTrackerBase extends Handler {
    protected long mSentSinceLastRecv;
    protected long mSentSinceLastRecv;
    // Controls when a simple recovery attempt it to be tried
    // Controls when a simple recovery attempt it to be tried
    protected int mNoRecvPollCount = 0;
    protected int mNoRecvPollCount = 0;
    // True if data stall detection is enabled
    protected volatile boolean mDataStallDetectionEnabled = true;

    protected volatile boolean mFailFast = false;

    // True when in voice call
    protected boolean mInVoiceCall = false;


    // wifi connection status will be updated by sticky intent
    // wifi connection status will be updated by sticky intent
    protected boolean mIsWifiConnected = false;
    protected boolean mIsWifiConnected = false;
@@ -356,6 +365,9 @@ public abstract class DcTrackerBase extends Handler {
     */
     */
    private static final int DEFAULT_MDC_INITIAL_RETRY = 1;
    private static final int DEFAULT_MDC_INITIAL_RETRY = 1;
    protected int getInitialMaxRetry() {
    protected int getInitialMaxRetry() {
        if (mFailFast) {
            return 0;
        }
        // Get default value from system property or use DEFAULT_MDC_INITIAL_RETRY
        // Get default value from system property or use DEFAULT_MDC_INITIAL_RETRY
        int value = SystemProperties.getInt(
        int value = SystemProperties.getInt(
                Settings.Global.MDC_INITIAL_MAX_RETRY, DEFAULT_MDC_INITIAL_RETRY);
                Settings.Global.MDC_INITIAL_MAX_RETRY, DEFAULT_MDC_INITIAL_RETRY);
@@ -741,6 +753,28 @@ public abstract class DcTrackerBase extends Handler {
                onSetPolicyDataEnabled(enabled);
                onSetPolicyDataEnabled(enabled);
                break;
                break;
            }
            }
            case DctConstants.CMD_SET_ENABLE_FAIL_FAST_MOBILE_DATA: {
                final boolean enabled = (msg.arg1 == DctConstants.ENABLED) ? true : false;
                if (DBG) log("CMD_SET_ENABLE_FAIL_FAST_MOBILE_DATA: enabled=" + enabled);
                if (mFailFast != enabled) {
                    mFailFast = enabled;
                    mDataStallDetectionEnabled = !enabled;
                    if (mDataStallDetectionEnabled
                            && (getOverallState() == DctConstants.State.CONNECTED)
                            && (!mInVoiceCall ||
                                    mPhone.getServiceStateTracker()
                                        .isConcurrentVoiceAndDataAllowed())) {
                        if (DBG) log("CMD_SET_ENABLE_FAIL_FAST_MOBILE_DATA: start data stall");
                        stopDataStallAlarm();
                        startDataStallAlarm(DATA_STALL_NOT_SUSPECTED);
                    } else {
                        if (DBG) log("CMD_SET_ENABLE_FAIL_FAST_MOBILE_DATA: stop data stall");
                        stopDataStallAlarm();
                    }
                }

                break;
            }
            case DctConstants.EVENT_ICC_CHANGED: {
            case DctConstants.EVENT_ICC_CHANGED: {
                onUpdateIcc();
                onUpdateIcc();
                break;
                break;
@@ -1183,7 +1217,8 @@ public abstract class DcTrackerBase extends Handler {
    protected abstract DctConstants.State getOverallState();
    protected abstract DctConstants.State getOverallState();


    protected void startNetStatPoll() {
    protected void startNetStatPoll() {
        if (getOverallState() == DctConstants.State.CONNECTED && mNetStatPollEnabled == false) {
        if (getOverallState() == DctConstants.State.CONNECTED
                && mNetStatPollEnabled == false) {
            if (DBG) log("startNetStatPoll");
            if (DBG) log("startNetStatPoll");
            resetPollStats();
            resetPollStats();
            mNetStatPollEnabled = true;
            mNetStatPollEnabled = true;
@@ -1403,7 +1438,7 @@ public abstract class DcTrackerBase extends Handler {
        int nextAction = getRecoveryAction();
        int nextAction = getRecoveryAction();
        int delayInMs;
        int delayInMs;


        if (getOverallState() == DctConstants.State.CONNECTED) {
        if (mDataStallDetectionEnabled && getOverallState() == DctConstants.State.CONNECTED) {
            // If screen is on or data stall is currently suspected, set the alarm
            // If screen is on or data stall is currently suspected, set the alarm
            // with an aggresive timeout.
            // with an aggresive timeout.
            if (mIsScreenOn || suspectedStall || RecoveryAction.isAggressiveRecovery(nextAction)) {
            if (mIsScreenOn || suspectedStall || RecoveryAction.isAggressiveRecovery(nextAction)) {
@@ -1492,6 +1527,7 @@ public abstract class DcTrackerBase extends Handler {
        pw.println(" mNetStatPollEnabled=" + mNetStatPollEnabled);
        pw.println(" mNetStatPollEnabled=" + mNetStatPollEnabled);
        pw.println(" mDataStallTxRxSum=" + mDataStallTxRxSum);
        pw.println(" mDataStallTxRxSum=" + mDataStallTxRxSum);
        pw.println(" mDataStallAlarmTag=" + mDataStallAlarmTag);
        pw.println(" mDataStallAlarmTag=" + mDataStallAlarmTag);
        pw.println(" mDataStallDetectionEanbled=" + mDataStallDetectionEnabled);
        pw.println(" mSentSinceLastRecv=" + mSentSinceLastRecv);
        pw.println(" mSentSinceLastRecv=" + mSentSinceLastRecv);
        pw.println(" mNoRecvPollCount=" + mNoRecvPollCount);
        pw.println(" mNoRecvPollCount=" + mNoRecvPollCount);
        pw.println(" mResolver=" + mResolver);
        pw.println(" mResolver=" + mResolver);