Loading src/java/com/android/internal/telephony/NetworkTypeController.java +48 −30 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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; Loading @@ -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(); Loading @@ -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() { Loading @@ -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(); Loading @@ -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(); } } Loading @@ -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(); } Loading Loading @@ -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) { Loading @@ -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) { Loading Loading @@ -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(); Loading @@ -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(); } } Loading @@ -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); } Loading @@ -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()); Loading Loading @@ -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; } Loading Loading @@ -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; Loading @@ -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; Loading Loading @@ -1320,7 +1338,7 @@ public class NetworkTypeController extends StateMachine { + ", mPrimaryTimerState=" + mPrimaryTimerState + ", mSecondaryTimerState=" + mSecondaryTimerState + ", mPreviousState=" + mPreviousState + ", misNrAdvanced=" + isNrAdvanced(); + ", mIsNrAdvanced=" + isNrAdvanced(); } @Override Loading src/java/com/android/internal/telephony/data/PhoneSwitcher.java +68 −6 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()); } } } Loading @@ -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()); } } } Loading Loading @@ -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; } Loading Loading @@ -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; Loading Loading @@ -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]; Loading @@ -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; } Loading src/java/com/android/internal/telephony/data/TelephonyNetworkFactory.java +9 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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)); } Loading Loading @@ -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()) { Loading @@ -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(); } } Loading
src/java/com/android/internal/telephony/NetworkTypeController.java +48 −30 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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; Loading @@ -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(); Loading @@ -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() { Loading @@ -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(); Loading @@ -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(); } } Loading @@ -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(); } Loading Loading @@ -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) { Loading @@ -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) { Loading Loading @@ -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(); Loading @@ -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(); } } Loading @@ -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); } Loading @@ -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()); Loading Loading @@ -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; } Loading Loading @@ -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; Loading @@ -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; Loading Loading @@ -1320,7 +1338,7 @@ public class NetworkTypeController extends StateMachine { + ", mPrimaryTimerState=" + mPrimaryTimerState + ", mSecondaryTimerState=" + mSecondaryTimerState + ", mPreviousState=" + mPreviousState + ", misNrAdvanced=" + isNrAdvanced(); + ", mIsNrAdvanced=" + isNrAdvanced(); } @Override Loading
src/java/com/android/internal/telephony/data/PhoneSwitcher.java +68 −6 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()); } } } Loading @@ -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()); } } } Loading Loading @@ -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; } Loading Loading @@ -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; Loading Loading @@ -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]; Loading @@ -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; } Loading
src/java/com/android/internal/telephony/data/TelephonyNetworkFactory.java +9 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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)); } Loading Loading @@ -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()) { Loading @@ -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(); } }