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

Commit 93d36437 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8656240 from c32eabef to tm-release

Change-Id: Iffb8b7dfda0f635314426336fcc3352c96655f2a
parents aad296d4 c32eabef
Loading
Loading
Loading
Loading
+48 −30
Original line number Diff line number Diff line
@@ -543,10 +543,12 @@ public class NetworkTypeController extends StateMachine {
            switch (msg.what) {
                case EVENT_UPDATE:
                case EVENT_PREFERRED_NETWORK_MODE_CHANGED:
                    if (DBG) log("Reset timers since preferred network mode changed.");
                    resetAllTimers();
                    transitionToCurrentState();
                    break;
                case EVENT_QUIT:
                    if (DBG) log("Reset timers on state machine quitting.");
                    resetAllTimers();
                    unRegisterForAllEvents();
                    quit();
@@ -585,25 +587,32 @@ public class NetworkTypeController extends StateMachine {
                        log("mIsPhysicalChannelConfigOn changed to: " + mIsPhysicalChannelConfigOn);
                    }
                    if (!mIsPhysicalChannelConfigOn) {
                        if (DBG) {
                            log("Reset timers since physical channel config indications are off.");
                        }
                        resetAllTimers();
                    }
                    transitionToCurrentState();
                    break;
                case EVENT_CARRIER_CONFIG_CHANGED:
                    parseCarrierConfigs();
                    if (DBG) log("Reset timers since carrier configurations changed.");
                    resetAllTimers();
                    transitionToCurrentState();
                    break;
                case EVENT_PRIMARY_TIMER_EXPIRED:
                    if (DBG) log("Primary timer expired for state: " + mPrimaryTimerState);
                    transitionWithSecondaryTimerTo((IState) msg.obj);
                    break;
                case EVENT_SECONDARY_TIMER_EXPIRED:
                    if (DBG) log("Secondary timer expired for state: " + mSecondaryTimerState);
                    mIsSecondaryTimerActive = false;
                    mSecondaryTimerState = "";
                    updateTimers();
                    updateOverrideNetworkType();
                    break;
                case EVENT_RADIO_OFF_OR_UNAVAILABLE:
                    if (DBG) log("Reset timers since radio is off or unavailable.");
                    resetAllTimers();
                    transitionTo(mLegacyState);
                    break;
@@ -614,6 +623,7 @@ public class NetworkTypeController extends StateMachine {
                        log("mIsDeviceIdleMode changed to: " + mIsDeviceIdleMode);
                    }
                    if (mIsDeviceIdleMode) {
                        if (DBG) log("Reset timers since device is in idle mode.");
                        resetAllTimers();
                    }
                    transitionToCurrentState();
@@ -637,7 +647,7 @@ public class NetworkTypeController extends StateMachine {
     * This is the initial state.
     */
    private final class LegacyState extends State {
        private Boolean mIsNrRestricted = false;
        private boolean mIsNrRestricted = false;

        @Override
        public void enter() {
@@ -664,7 +674,7 @@ public class NetworkTypeController extends StateMachine {
                                ? mLteConnectedState : mIdleState);
                    } else {
                        if (!isLte(rat)) {
                            // Rat is 3G or 2G, and it doesn't need NR timer.
                            if (DBG) log("Reset timers since 2G and 3G don't need NR timers.");
                            resetAllTimers();
                        }
                        updateOverrideNetworkType();
@@ -689,6 +699,7 @@ public class NetworkTypeController extends StateMachine {
                    if (isUsingPhysicalChannelConfigForRrcDetection()) {
                        mPhysicalLinkStatus = getPhysicalLinkStatusFromPhysicalChannelConfig();
                        if (mIsTimerResetEnabledForLegacyStateRRCIdle && !isPhysicalLinkActive()) {
                            if (DBG) log("Reset timers since timer reset is enabled for RRC idle.");
                            resetAllTimers();
                        }
                    }
@@ -699,6 +710,7 @@ public class NetworkTypeController extends StateMachine {
                    AsyncResult ar = (AsyncResult) msg.obj;
                    mPhysicalLinkStatus = (int) ar.result;
                    if (mIsTimerResetEnabledForLegacyStateRRCIdle && !isPhysicalLinkActive()) {
                        if (DBG) log("Reset timers since timer reset is enabled for RRC idle.");
                        resetAllTimers();
                        updateOverrideNetworkType();
                    }
@@ -889,14 +901,14 @@ public class NetworkTypeController extends StateMachine {
    private final LteConnectedState mLteConnectedState = new LteConnectedState();

    /**
     * Device is connected to 5G NR as the secondary cell.
     * Device is connected to 5G NR as the primary or secondary cell.
     */
    private final class NrConnectedState extends State {
        private Boolean mIsNrAdvanced = false;
        private boolean mIsNrAdvanced = false;

        @Override
        public void enter() {
            if (DBG) log("Entering NrConnectedState");
            if (DBG) log("Entering NrConnectedState(" + getName() + ")");
            updateTimers();
            updateOverrideNetworkType();
            if (!mIsPrimaryTimerActive && !mIsSecondaryTimerActive) {
@@ -907,7 +919,7 @@ public class NetworkTypeController extends StateMachine {

        @Override
        public boolean processMessage(Message msg) {
            if (DBG) log("NrConnectedState: process " + getEventName(msg.what));
            if (DBG) log("NrConnectedState(" + getName() + "): process " + getEventName(msg.what));
            updateTimers();
            int rat = getDataNetworkType();
            switch (msg.what) {
@@ -974,10 +986,10 @@ public class NetworkTypeController extends StateMachine {
                return;
            }
            if (!isNrAdvanced()) {
                // STATE_CONNECTED_NR_ADVANCED -> STATE_CONNECTED
                if (DBG) log("updateNrAdvancedState: CONNECTED_NR_ADVANCED -> CONNECTED");
                transitionWithTimerTo(mNrConnectedState);
            } else {
                // STATE_CONNECTED -> STATE_CONNECTED_NR_ADVANCED
                if (DBG) log("updateNrAdvancedState: CONNECTED -> CONNECTED_NR_ADVANCED");
                transitionTo(mNrConnectedState);
            }
            mIsNrAdvanced = isNrAdvanced();
@@ -1002,10 +1014,10 @@ public class NetworkTypeController extends StateMachine {
                    && mNrAdvancedCapablePcoId > 0
                    && pcodata.pcoId == mNrAdvancedCapablePcoId
            ) {
                log("EVENT_PCO_DATA_CHANGED: Nr Advanced is allowed by PCO. length:"
                log("EVENT_PCO_DATA_CHANGED: NR_ADVANCED is allowed by PCO. length:"
                        + pcodata.contents.length + ",value: " + Arrays.toString(pcodata.contents));
                mIsNrAdvancedAllowedByPco = (pcodata.contents.length > 0)
                        ? pcodata.contents[pcodata.contents.length - 1] == 1 : false;
                mIsNrAdvancedAllowedByPco = pcodata.contents.length > 0
                        && pcodata.contents[pcodata.contents.length - 1] == 1;
                updateNrAdvancedState();
            }
        }
@@ -1015,14 +1027,15 @@ public class NetworkTypeController extends StateMachine {

    private void transitionWithTimerTo(IState destState) {
        String destName = destState.getName();
        if (DBG) log("Transition with primary timer from " + mPreviousState + " to " + destName);
        OverrideTimerRule rule = mOverrideTimerRules.get(mPreviousState);
        if (!mIsDeviceIdleMode && rule != null && rule.getTimer(destName) > 0) {
            if (DBG) log("Primary timer started for state: " + mPreviousState);
            int duration = rule.getTimer(destName);
            if (DBG) log(duration + "s primary timer started for state: " + mPreviousState);
            mPrimaryTimerState = mPreviousState;
            mPreviousState = getCurrentState().getName();
            mIsPrimaryTimerActive = true;
            sendMessageDelayed(EVENT_PRIMARY_TIMER_EXPIRED, destState,
                    rule.getTimer(destName) * 1000L);
            sendMessageDelayed(EVENT_PRIMARY_TIMER_EXPIRED, destState, duration * 1000L);
        }
        transitionTo(destState);
    }
@@ -1030,13 +1043,17 @@ public class NetworkTypeController extends StateMachine {
    private void transitionWithSecondaryTimerTo(IState destState) {
        String currentName = getCurrentState().getName();
        OverrideTimerRule rule = mOverrideTimerRules.get(mPrimaryTimerState);
        if (DBG) {
            log("Transition with secondary timer from " + currentName + " to "
                    + destState.getName());
        }
        if (!mIsDeviceIdleMode && rule != null && rule.getSecondaryTimer(currentName) > 0) {
            if (DBG) log("Secondary timer started for state: " + currentName);
            int duration = rule.getSecondaryTimer(currentName);
            if (DBG) log(duration + "s secondary timer started for state: " + currentName);
            mSecondaryTimerState = currentName;
            mPreviousState = currentName;
            mIsSecondaryTimerActive = true;
            sendMessageDelayed(EVENT_SECONDARY_TIMER_EXPIRED, destState,
                    rule.getSecondaryTimer(currentName) * 1000L);
            sendMessageDelayed(EVENT_SECONDARY_TIMER_EXPIRED, destState, duration * 1000L);
        }
        mIsPrimaryTimerActive = false;
        transitionTo(getCurrentState());
@@ -1070,6 +1087,7 @@ public class NetworkTypeController extends StateMachine {
    private void updateTimers() {
        if ((mPhone.getCachedAllowedNetworkTypesBitmask()
                & TelephonyManager.NETWORK_TYPE_BITMASK_NR) == 0) {
            if (DBG) log("Reset timers since NR is not allowed.");
            resetAllTimers();
            return;
        }
@@ -1098,21 +1116,21 @@ public class NetworkTypeController extends StateMachine {
            mSecondaryTimerState = "";
        }

        if (mIsPrimaryTimerActive || mIsSecondaryTimerActive) {
            if (currentState.equals(STATE_CONNECTED_NR_ADVANCED)) {
                if (DBG) log("Reset timers since state is NR_ADVANCED.");
                resetAllTimers();
            }

            int rat = getDataNetworkType();
            if (!isLte(rat) && rat != TelephonyManager.NETWORK_TYPE_NR) {
            // Rat is 3G or 2G, and it doesn't need NR timer.
                if (DBG) log("Reset timers since 2G and 3G don't need NR timers.");
                resetAllTimers();
            }
        }
    }

    private void resetAllTimers() {
        if (DBG) {
            log("Remove all timers");
        }
        removeMessages(EVENT_PRIMARY_TIMER_EXPIRED);
        removeMessages(EVENT_SECONDARY_TIMER_EXPIRED);
        mIsPrimaryTimerActive = false;
@@ -1125,7 +1143,7 @@ public class NetworkTypeController extends StateMachine {
     * Private class defining timer rules between states to prevent flickering. These rules are
     * created in {@link #parseCarrierConfigs()} based on various carrier configs.
     */
    private class OverrideTimerRule {
    private static class OverrideTimerRule {
        /** The 5G state this timer rule applies for. See {@link #ALL_STATES}. */
        final String mState;

@@ -1320,7 +1338,7 @@ public class NetworkTypeController extends StateMachine {
                + ", mPrimaryTimerState=" + mPrimaryTimerState
                + ", mSecondaryTimerState=" + mSecondaryTimerState
                + ", mPreviousState=" + mPreviousState
                + ", misNrAdvanced=" + isNrAdvanced();
                + ", mIsNrAdvanced=" + isNrAdvanced();
    }

    @Override
+68 −6
Original line number Diff line number Diff line
@@ -312,7 +312,7 @@ public class PhoneSwitcher extends Handler {

    protected RadioConfig mRadioConfig;

    private static final int MAX_LOCAL_LOG_LINES = 32;
    private static final int MAX_LOCAL_LOG_LINES = 256;

    // Default timeout value of network validation in millisecond.
    private final static int DEFAULT_VALIDATION_EXPIRATION_TIME = 2000;
@@ -958,7 +958,7 @@ public class PhoneSwitcher extends Handler {
                mPrioritizedDcRequests.add(dcRequest);
                Collections.sort(mPrioritizedDcRequests);
                onEvaluate(REQUESTS_CHANGED, "netRequest");
                log("Added DcRequest, size: " + mPrioritizedDcRequests.size());
                if (VDBG) log("Added DcRequest, size: " + mPrioritizedDcRequests.size());
            }
        }
    }
@@ -979,7 +979,7 @@ public class PhoneSwitcher extends Handler {
            if (mPrioritizedDcRequests.remove(dcRequest)) {
                onEvaluate(REQUESTS_CHANGED, "netReleased");
                collectReleaseNetworkMetrics(networkRequest);
                log("Removed DcRequest, size: " + mPrioritizedDcRequests.size());
                if (VDBG) log("Removed DcRequest, size: " + mPrioritizedDcRequests.size());
            }
        }
    }
@@ -1264,7 +1264,7 @@ public class PhoneSwitcher extends Handler {

    protected void sendRilCommands(int phoneId) {
        if (!SubscriptionManager.isValidPhoneId(phoneId)) {
            log("sendRilCommands: skip dds switch due to invalid phoneid=" + phoneId);
            log("sendRilCommands: skip dds switch due to invalid phoneId=" + phoneId);
            return;
        }

@@ -1674,8 +1674,54 @@ public class PhoneSwitcher extends Handler {
        mLocalLog.log(l);
    }

    /**
     * Convert data switch reason into string.
     *
     * @param reason The switch reason.
     * @return The switch reason in string format.
     */
    private static @NonNull String switchReasonToString(int reason) {
        switch(reason) {
            case TelephonyEvent.DataSwitch.Reason.DATA_SWITCH_REASON_UNKNOWN:
                return "UNKNOWN";
            case TelephonyEvent.DataSwitch.Reason.DATA_SWITCH_REASON_MANUAL:
                return "MANUAL";
            case TelephonyEvent.DataSwitch.Reason.DATA_SWITCH_REASON_IN_CALL:
                return "IN_CALL";
            case TelephonyEvent.DataSwitch.Reason.DATA_SWITCH_REASON_CBRS:
                return "CBRS";
            default: return "UNKNOWN(" + reason + ")";
        }
    }

    /**
     * Concert switching state to string
     *
     * @param state The switching state.
     * @return The switching state in string format.
     */
    private static @NonNull String switchStateToString(int state) {
        switch(state) {
            case TelephonyEvent.EventState.EVENT_STATE_UNKNOWN:
                return "UNKNOWN";
            case TelephonyEvent.EventState.EVENT_STATE_START:
                return "START";
            case TelephonyEvent.EventState.EVENT_STATE_END:
                return "END";
            default: return "UNKNOWN(" + state + ")";
        }
    }

    /**
     * Log data switch event
     *
     * @param subId Subscription index.
     * @param state The switching state.
     * @param reason The switching reason.
     */
    private void logDataSwitchEvent(int subId, int state, int reason) {
        log("logDataSwitchEvent subId " + subId + " state " + state + " reason " + reason);
        log("Data switch event. subId=" + subId + ", state=" + switchStateToString(state)
                + ", reason=" + switchReasonToString(reason));
        DataSwitch dataSwitch = new DataSwitch();
        dataSwitch.state = state;
        dataSwitch.reason = reason;
@@ -1708,6 +1754,7 @@ public class PhoneSwitcher extends Handler {
    public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
        final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");
        pw.println("PhoneSwitcher:");
        pw.increaseIndent();
        Calendar c = Calendar.getInstance();
        for (int i = 0; i < mActiveModemCount; i++) {
            PhoneState ps = mPhoneStates[i];
@@ -1716,14 +1763,29 @@ public class PhoneSwitcher extends Handler {
                    (ps.lastRequested == 0 ? "never" :
                     String.format("%tm-%td %tH:%tM:%tS.%tL", c, c, c, c, c, c)));
        }
        pw.println("mPreferredDataPhoneId=" + mPreferredDataPhoneId);
        pw.println("mPreferredDataSubId=" + mPreferredDataSubId.get());
        pw.println("DefaultDataSubId=" + mSubscriptionController.getDefaultDataSubId());
        pw.println("DefaultDataPhoneId=" + mSubscriptionController.getPhoneId(
                mSubscriptionController.getDefaultDataSubId()));
        pw.println("mPrimaryDataSubId=" + mPrimaryDataSubId);
        pw.println("mOpptDataSubId=" + mOpptDataSubId);
        pw.println("mIsRegisteredForImsRadioTechChange=" + mIsRegisteredForImsRadioTechChange);
        pw.println("mPendingSwitchNeedValidation=" + mPendingSwitchNeedValidation);
        pw.println("mMaxDataAttachModemCount=" + mMaxDataAttachModemCount);
        pw.println("mActiveModemCount=" + mActiveModemCount);
        pw.println("mPhoneIdInVoiceCall=" + mPhoneIdInVoiceCall);
        pw.println("mCurrentDdsSwitchFailure=" + mCurrentDdsSwitchFailure);
        pw.println("Local logs:");
        pw.increaseIndent();
        mLocalLog.dump(fd, pw, args);
        pw.decreaseIndent();
        pw.decreaseIndent();
    }

    private boolean isAnyVoiceCallActiveOnDevice() {
        boolean ret = mPhoneIdInVoiceCall != SubscriptionManager.INVALID_PHONE_INDEX;
        log("isAnyVoiceCallActiveOnDevice: " + ret);
        if (VDBG) log("isAnyVoiceCallActiveOnDevice: " + ret);
        return ret;
    }

+9 −2
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ public class TelephonyNetworkFactory extends NetworkFactory {
    public final String LOG_TAG;
    protected static final boolean DBG = true;

    private static final int REQUEST_LOG_SIZE = 32;
    private static final int REQUEST_LOG_SIZE = 256;

    private static final int ACTION_NO_OP   = 0;
    private static final int ACTION_REQUEST = 1;
@@ -302,6 +302,7 @@ public class TelephonyNetworkFactory extends NetworkFactory {

    // apply or revoke requests if our active-ness changes
    private void onActivePhoneSwitch() {
        logl("onActivePhoneSwitch");
        for (Map.Entry<TelephonyNetworkRequest, Integer> entry : mNetworkRequests.entrySet()) {
            TelephonyNetworkRequest networkRequest = entry.getKey();
            boolean applied = entry.getValue() != AccessNetworkConstants.TRANSPORT_TYPE_INVALID;
@@ -338,7 +339,7 @@ public class TelephonyNetworkFactory extends NetworkFactory {
        final int newSubscriptionId = mSubscriptionController.getSubIdUsingPhoneId(
                mPhone.getPhoneId());
        if (mSubscriptionId != newSubscriptionId) {
            if (DBG) log("onSubIdChange " + mSubscriptionId + "->" + newSubscriptionId);
            if (DBG) logl("onSubIdChange " + mSubscriptionId + "->" + newSubscriptionId);
            mSubscriptionId = newSubscriptionId;
            setCapabilityFilter(makeNetworkFilter(mSubscriptionId));
        }
@@ -535,6 +536,8 @@ public class TelephonyNetworkFactory extends NetworkFactory {
     */
    public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
        final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");
        pw.println("TelephonyNetworkFactory-" + mPhone.getPhoneId());
        pw.increaseIndent();
        pw.println("Network Requests:");
        pw.increaseIndent();
        for (Map.Entry<TelephonyNetworkRequest, Integer> entry : mNetworkRequests.entrySet()) {
@@ -543,7 +546,11 @@ public class TelephonyNetworkFactory extends NetworkFactory {
            pw.println(nr + (transport != AccessNetworkConstants.TRANSPORT_TYPE_INVALID
                    ? (" applied on " + transport) : " not applied"));
        }
        pw.decreaseIndent();
        pw.print("Local logs:");
        pw.increaseIndent();
        mLocalLog.dump(fd, pw, args);
        pw.decreaseIndent();
        pw.decreaseIndent();
    }
}