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

Commit ec2d6354 authored by Ling Ma's avatar Ling Ma Committed by Android (Google) Code Review
Browse files

Merge "Improve auto data switch related log"

parents 9313efc0 f84f5895
Loading
Loading
Loading
Loading
+25 −12
Original line number Diff line number Diff line
@@ -212,8 +212,8 @@ public class PhoneSwitcher extends Handler {
    @VisibleForTesting
    protected final CellularNetworkValidator mValidator;
    private int mPendingSwitchSubId = INVALID_SUBSCRIPTION_ID;
    /** The last reason for auto switch (e.g. CBRS) **/
    private int mLastAutoSelectedSwitchReason = -1;
    /** The reason for the last time changing preferred data sub **/
    private int mLastSwitchPreferredDataReason = -1;
    /** {@code true} if we've displayed the notification the first time auto switch occurs **/
    private boolean mDisplayedAutoSwitchNotification = false;
    private boolean mPendingSwitchNeedValidation;
@@ -579,8 +579,6 @@ public class PhoneSwitcher extends Handler {
                                    @TelephonyManager.DataEnabledChangedReason int reason,
                                    @NonNull String callingPackage) {
                                logl("user changed data settings");
                                evaluateIfImmediateDataSwitchIsNeeded("user changed data settings",
                                        DataSwitch.Reason.DATA_SWITCH_REASON_IN_CALL);
                                evaluateIfAutoSwitchIsNeeded();
                            }});
                phone.getDataSettingsManager().registerCallback(
@@ -1130,6 +1128,15 @@ public class PhoneSwitcher extends Handler {

            if (mPreferredDataPhoneId == primaryPhoneId) {
                // on primary data sub

                if (isAnyVoiceCallActiveOnDevice()) {
                    // if on voice call, switch immediately
                    evaluateIfImmediateDataSwitchIsNeeded(
                            "user updates data settings during voice call",
                            DataSwitch.Reason.DATA_SWITCH_REASON_IN_CALL);
                    return;
                }

                int candidateSubId = getAutoSwitchTargetSubIdIfExists();
                if (candidateSubId != INVALID_SUBSCRIPTION_ID) {
                    startAutoDataSwitchStabilityCheck(candidateSubId, true);
@@ -1144,7 +1151,7 @@ public class PhoneSwitcher extends Handler {
                    // immediately switch back if user setting changes
                    mAutoSelectedDataSubId = DEFAULT_SUBSCRIPTION_ID;
                    evaluateIfImmediateDataSwitchIsNeeded("User disabled data settings",
                            DataSwitch.Reason.DATA_SWITCH_REASON_AUTO);
                            DataSwitch.Reason.DATA_SWITCH_REASON_MANUAL);
                    return;
                }

@@ -1298,6 +1305,7 @@ public class PhoneSwitcher extends Handler {
            sb.append(" mPrimaryDataSubId ").append(mPrimaryDataSubId).append("->")
                .append(primaryDataSubId);
            mPrimaryDataSubId = primaryDataSubId;
            mLastSwitchPreferredDataReason = DataSwitch.Reason.DATA_SWITCH_REASON_MANUAL;
        }

        // Check to see if there is any active subscription on any phone
@@ -1592,11 +1600,13 @@ public class PhoneSwitcher extends Handler {
            logl("updatePreferredDataPhoneId: preferred data overridden for emergency."
                    + " phoneId = " + mEmergencyOverride.mPhoneId);
            mPreferredDataPhoneId = mEmergencyOverride.mPhoneId;
            mLastSwitchPreferredDataReason = DataSwitch.Reason.DATA_SWITCH_REASON_UNKNOWN;
        } else if (isDataEnabled) {
            // If a phone is in call and user enabled its mobile data, we
            // should switch internet connection to it. Because the other modem
            // will lose data connection anyway.
            mPreferredDataPhoneId = mPhoneIdInVoiceCall;
            mLastSwitchPreferredDataReason = DataSwitch.Reason.DATA_SWITCH_REASON_IN_CALL;
        } else {
            int subId = getSubIdForDefaultNetworkRequests();
            int phoneId = SubscriptionManager.INVALID_PHONE_INDEX;
@@ -1757,7 +1767,7 @@ public class PhoneSwitcher extends Handler {
            return;
        }

        mLastAutoSelectedSwitchReason = switchReason;
        mLastSwitchPreferredDataReason = switchReason;
        logDataSwitchEvent(subIdToValidate,
                TelephonyEvent.EventState.EVENT_STATE_START,
                switchReason);
@@ -1817,7 +1827,7 @@ public class PhoneSwitcher extends Handler {
    private void setAutoSelectedDataSubIdInternal(int subId) {
        if (mAutoSelectedDataSubId != subId) {
            mAutoSelectedDataSubId = subId;
            onEvaluate(REQUESTS_UNCHANGED, switchReasonToString(mLastAutoSelectedSwitchReason));
            onEvaluate(REQUESTS_UNCHANGED, switchReasonToString(mLastSwitchPreferredDataReason));
        }
    }

@@ -1832,7 +1842,7 @@ public class PhoneSwitcher extends Handler {
            resultForCallBack = SET_OPPORTUNISTIC_SUB_VALIDATION_FAILED;

            // retry for auto data switch validation failure
            if (mLastAutoSelectedSwitchReason == DataSwitch.Reason.DATA_SWITCH_REASON_AUTO) {
            if (mLastSwitchPreferredDataReason == DataSwitch.Reason.DATA_SWITCH_REASON_AUTO) {
                scheduleAutoSwitchRetryEvaluation();
                mAutoSwitchRetryFailedCount++;
            }
@@ -2075,6 +2085,8 @@ public class PhoneSwitcher extends Handler {
        pw.println("mAutoDataSwitchAvailabilityStabilityTimeThreshold="
                + mAutoDataSwitchAvailabilityStabilityTimeThreshold);
        pw.println("mAutoDataSwitchValidationMaxRetry=" + mAutoDataSwitchValidationMaxRetry);
        pw.println("mLastSwitchPreferredDataReason="
                + switchReasonToString(mLastSwitchPreferredDataReason));
        pw.println("mDisplayedAutoSwitchNotification=" + mDisplayedAutoSwitchNotification);
        pw.println("Local logs:");
        pw.increaseIndent();
@@ -2141,16 +2153,17 @@ public class PhoneSwitcher extends Handler {
                    AUTO_DATA_SWITCH_NOTIFICATION_ID);
            return;
        }
        // proceed only the first time auto data switch occurs
        if (mLastAutoSelectedSwitchReason != DataSwitch.Reason.DATA_SWITCH_REASON_AUTO) {
        // proceed only the first time auto data switch occurs, which includes data during call
        if (mLastSwitchPreferredDataReason != DataSwitch.Reason.DATA_SWITCH_REASON_AUTO) {
            log("displayAutoDataSwitchNotification: Ignore DDS switch due to "
                    + switchReasonToString(mLastAutoSelectedSwitchReason));
                    + switchReasonToString(mLastSwitchPreferredDataReason));
            return;
        }
        SubscriptionInfo subInfo = mSubscriptionController.getSubscriptionInfo(
                mAutoSelectedDataSubId);
        if (subInfo == null || subInfo.isOpportunistic()) {
            loge("displayAutoDataSwitchNotification: unexpected " + subInfo);
            loge("displayAutoDataSwitchNotification:mAutoSelectedDataSubId="
                    + mAutoSelectedDataSubId + " unexpected subInfo " + subInfo);
            return;
        }
        logl("displayAutoDataSwitchNotification: display for subId=" + mAutoSelectedDataSubId);