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

Commit bf1cdce9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes If05dd110,Iab541d69,I816a1b6e,I9bec0e35

* changes:
  Improve auto data switch related log
  Relax anomaly report for duplicate interface
  Unregister after replacement for network agent to avoid onLost
  Update auto switch notification intent
parents 5a14644d ef96d6cd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2380,7 +2380,7 @@ public class DataNetwork extends StateMachine {
                        + dataNetwork + ". Silently tear down now.");
                // If this is a pre-5G data setup, that means APN database has some problems. For
                // example, different APN settings have the same APN name.
                if (response.getTrafficDescriptors().isEmpty()) {
                if (response.getTrafficDescriptors().isEmpty() && dataNetwork.isConnected()) {
                    reportAnomaly("Duplicate network interface " + response.getInterfaceName()
                            + " detected.", "62f66e7e-8d71-45de-a57b-dc5c78223fd5");
                }
+32 −21
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;
                }

@@ -1259,6 +1266,7 @@ public class PhoneSwitcher extends Handler {
                // the alternative phone must have HOME availability
                if (mPhoneStates[phoneId].dataRegState
                        == NetworkRegistrationInfo.REGISTRATION_STATE_HOME) {
                    log("getAutoSwitchTargetSubId: found phone " + phoneId + " in HOME service");
                    Phone secondaryDataPhone = findPhoneById(phoneId);
                    if (secondaryDataPhone != null && // check auto switch feature enabled
                            secondaryDataPhone.isDataAllowed()) {
@@ -1297,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
@@ -1595,11 +1604,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;
@@ -1760,7 +1771,7 @@ public class PhoneSwitcher extends Handler {
            return;
        }

        mLastAutoSelectedSwitchReason = switchReason;
        mLastSwitchPreferredDataReason = switchReason;
        logDataSwitchEvent(subIdToValidate,
                TelephonyEvent.EventState.EVENT_STATE_START,
                switchReason);
@@ -1820,7 +1831,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));
        }
    }

@@ -1835,7 +1846,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++;
            }
@@ -2078,6 +2089,9 @@ 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();
        mLocalLog.dump(fd, pw, args);
@@ -2137,35 +2151,32 @@ public class PhoneSwitcher extends Handler {

        if (mDisplayedAutoSwitchNotification) {
            // cancel posted notification if any exist
            if (VDBG) {
            log("displayAutoDataSwitchNotification: canceling any notifications for subId "
                    + mAutoSelectedDataSubId);
            }
            notificationManager.cancel(AUTO_DATA_SWITCH_NOTIFICATION_TAG,
                    AUTO_DATA_SWITCH_NOTIFICATION_ID);
            return;
        }
        // proceed only the first time auto data switch occurs
        if (mLastAutoSelectedSwitchReason != DataSwitch.Reason.DATA_SWITCH_REASON_AUTO) {
            if (VDBG) {
        // 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;
        }
        log("displayAutoDataSwitchNotification: displaying for subId=" + mAutoSelectedDataSubId);
        logl("displayAutoDataSwitchNotification: display for subId=" + mAutoSelectedDataSubId);
        // "Mobile network settings" screen / dialog
        Intent intent = new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS);
        final Bundle fragmentArgs = new Bundle();
        // Special contract for Settings to highlight permission row
        fragmentArgs.putString(SETTINGS_EXTRA_FRAGMENT_ARG_KEY, AUTO_DATA_SWITCH_SETTING_R_ID);
        fragmentArgs.putInt(Settings.EXTRA_SUB_ID, mAutoSelectedDataSubId);
        intent.putExtra(Settings.EXTRA_SUB_ID, mAutoSelectedDataSubId);
        intent.putExtra(SETTINGS_EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArgs);
        PendingIntent contentIntent = PendingIntent.getActivity(
                mContext, mAutoSelectedDataSubId, intent, PendingIntent.FLAG_IMMUTABLE);
+9 −5
Original line number Diff line number Diff line
@@ -50,6 +50,9 @@ public class TelephonyNetworkAgent extends NetworkAgent {
    private final String mLogTag;
    private final LocalLog mLocalLog = new LocalLog(128);

    /** Max unregister network agent delay. */
    private static final int NETWORK_AGENT_TEARDOWN_DELAY_MS = 5_000;

    /** The parent data network. */
    private final @NonNull DataNetwork mDataNetwork;

@@ -296,14 +299,15 @@ public class TelephonyNetworkAgent extends NetworkAgent {

    /**
     * Abandon the network agent. This is used for telephony to re-create the network agent when
     * immutable capabilities got changed, where telephony calls {@link NetworkAgent#unregister()}
     * and then create another network agent with new capabilities. Abandon this network agent
     * allowing it ignore the subsequent {@link #onNetworkUnwanted()} invocation caused by
     * {@link NetworkAgent#unregister()}.
     * immutable capabilities got changed, where telephony calls
     * {@link NetworkAgent#unregisterAfterReplacement} and then create another network agent with
     * new capabilities. Abandon this network agent allowing it ignore the subsequent
     * {@link #onNetworkUnwanted()} invocation caused by
     * {@link NetworkAgent#unregisterAfterReplacement}.
     */
    public void abandon() {
        mAbandoned = true;
        unregister();
        unregisterAfterReplacement(NETWORK_AGENT_TEARDOWN_DELAY_MS);
    }

    /**