Loading src/java/com/android/internal/telephony/NetworkTypeController.java +47 −54 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import android.telephony.AccessNetworkConstants; import android.telephony.Annotation; import android.telephony.CarrierConfigManager; import android.telephony.NetworkRegistrationInfo; import android.telephony.PhoneStateListener; import android.telephony.RadioAccessFamily; import android.telephony.ServiceState; import android.telephony.SubscriptionManager; Loading @@ -36,6 +35,8 @@ import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.text.TextUtils; import com.android.internal.telephony.dataconnection.DcController; import com.android.internal.telephony.dataconnection.DcController.PhysicalLinkState; import com.android.internal.util.IState; import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.State; Loading Loading @@ -81,19 +82,19 @@ public class NetworkTypeController extends StateMachine { private static final int EVENT_DATA_RAT_CHANGED = 2; private static final int EVENT_NR_STATE_CHANGED = 3; private static final int EVENT_NR_FREQUENCY_CHANGED = 4; private static final int EVENT_DATA_ACTIVITY_CHANGED = 5; private static final int EVENT_PHYSICAL_LINK_STATE_CHANGED = 5; private static final int EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED = 6; private static final int EVENT_CARRIER_CONFIG_CHANGED = 7; private static final int EVENT_PRIMARY_TIMER_EXPIRED = 8; private static final int EVENT_SECONDARY_TIMER_EXPIRED = 9; private static final int EVENT_RADIO_OFF_OR_UNAVAILABLE = 10; private static final int EVENT_DATA_CONNECTION_STATE_CHANGED = 11; private static final int EVENT_PREFERRED_NETWORK_MODE_CHANGED = 12; private static final int EVENT_PREFERRED_NETWORK_MODE_CHANGED = 11; private static final int EVENT_INIITIALIZE = 12; // events that don't reset the timer private static final int[] ALL_EVENTS = { EVENT_DATA_RAT_CHANGED, EVENT_NR_STATE_CHANGED, EVENT_NR_FREQUENCY_CHANGED, EVENT_DATA_ACTIVITY_CHANGED, EVENT_NR_FREQUENCY_CHANGED, EVENT_PHYSICAL_LINK_STATE_CHANGED, EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED, EVENT_PRIMARY_TIMER_EXPIRED, EVENT_SECONDARY_TIMER_EXPIRED, EVENT_DATA_CONNECTION_STATE_CHANGED }; EVENT_SECONDARY_TIMER_EXPIRED}; private static final String[] sEvents = new String[EVENT_PREFERRED_NETWORK_MODE_CHANGED + 1]; static { Loading @@ -102,20 +103,18 @@ public class NetworkTypeController extends StateMachine { sEvents[EVENT_DATA_RAT_CHANGED] = "EVENT_DATA_RAT_CHANGED"; sEvents[EVENT_NR_STATE_CHANGED] = "EVENT_NR_STATE_CHANGED"; sEvents[EVENT_NR_FREQUENCY_CHANGED] = "EVENT_NR_FREQUENCY_CHANGED"; sEvents[EVENT_DATA_ACTIVITY_CHANGED] = "EVENT_DATA_ACTIVITY_CHANGED"; sEvents[EVENT_PHYSICAL_LINK_STATE_CHANGED] = "EVENT_PHYSICAL_LINK_STATE_CHANGED"; sEvents[EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED] = "EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED"; sEvents[EVENT_CARRIER_CONFIG_CHANGED] = "EVENT_CARRIER_CONFIG_CHANGED"; sEvents[EVENT_PRIMARY_TIMER_EXPIRED] = "EVENT_PRIMARY_TIMER_EXPIRED"; sEvents[EVENT_SECONDARY_TIMER_EXPIRED] = "EVENT_SECONDARY_TIMER_EXPIRED"; sEvents[EVENT_RADIO_OFF_OR_UNAVAILABLE] = "EVENT_RADIO_OFF_OR_UNAVAILABLE"; sEvents[EVENT_DATA_CONNECTION_STATE_CHANGED] = "EVENT_DATA_CONNECTION_STATE_CHANGED"; sEvents[EVENT_PREFERRED_NETWORK_MODE_CHANGED] = "EVENT_PREFERRED_NETWORK_MODE_CHANGED"; } private final Phone mPhone; private final DisplayInfoController mDisplayInfoController; private final TelephonyManager mTelephonyManager; private final SettingsObserver mSettingsObserver; private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { @Override Loading @@ -129,16 +128,6 @@ public class NetworkTypeController extends StateMachine { } } }; private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() { @Override public void onDataActivity(int direction) { sendMessage(EVENT_DATA_ACTIVITY_CHANGED); } @Override public void onDataConnectionStateChanged(int state, int networkType) { sendMessage(EVENT_DATA_CONNECTION_STATE_CHANGED); } }; private Map<String, OverrideTimerRule> mOverrideTimerRules = new HashMap<>(); private String mLteEnhancedPattern = ""; Loading @@ -149,6 +138,7 @@ public class NetworkTypeController extends StateMachine { private String mPrimaryTimerState; private String mSecondaryTimerState; private String mPreviousState; private @PhysicalLinkState int mPhysicalLinkState; /** * NetworkTypeController constructor. Loading @@ -160,8 +150,6 @@ public class NetworkTypeController extends StateMachine { super(TAG, displayInfoController); mPhone = phone; mDisplayInfoController = displayInfoController; mTelephonyManager = TelephonyManager.from(phone.getContext()) .createForSubscriptionId(phone.getSubId()); mSettingsObserver = new SettingsObserver(mPhone.getContext(), getHandler()); mOverrideNetworkType = TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE; mIsPhysicalChannelConfigOn = true; Loading @@ -171,9 +159,8 @@ public class NetworkTypeController extends StateMachine { addState(mLteConnectedState, mDefaultState); addState(mNrConnectedState, mDefaultState); setInitialState(mDefaultState); registerForAllEvents(); parseCarrierConfigs(); start(); sendMessage(EVENT_INIITIALIZE); } /** Loading @@ -190,6 +177,9 @@ public class NetworkTypeController extends StateMachine { mPhone.getServiceStateTracker().registerForDataRegStateOrRatChanged( AccessNetworkConstants.TRANSPORT_TYPE_WWAN, getHandler(), EVENT_DATA_RAT_CHANGED, null); mPhone.getDcTracker(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .registerForPhysicalLinkStateChanged(getHandler(), EVENT_PHYSICAL_LINK_STATE_CHANGED); mPhone.getServiceStateTracker().registerForNrStateChanged(getHandler(), EVENT_NR_STATE_CHANGED, null); mPhone.getServiceStateTracker().registerForNrFrequencyChanged(getHandler(), Loading @@ -199,10 +189,6 @@ public class NetworkTypeController extends StateMachine { IntentFilter filter = new IntentFilter(); filter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED); mPhone.getContext().registerReceiver(mIntentReceiver, filter, null, mPhone); if (mTelephonyManager != null) { mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_DATA_ACTIVITY | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); } mSettingsObserver.observe(Settings.Global.getUriFor(Settings.Global.PREFERRED_NETWORK_MODE), EVENT_PREFERRED_NETWORK_MODE_CHANGED); } Loading @@ -215,9 +201,6 @@ public class NetworkTypeController extends StateMachine { mPhone.getServiceStateTracker().unregisterForNrFrequencyChanged(getHandler()); mPhone.getDeviceStateMonitor().unregisterForPhysicalChannelConfigNotifChanged(getHandler()); mPhone.getContext().unregisterReceiver(mIntentReceiver); if (mTelephonyManager != null) { mTelephonyManager.listen(mPhoneStateListener, 0); } mSettingsObserver.unobserve(); } Loading Loading @@ -393,7 +376,7 @@ public class NetworkTypeController extends StateMachine { keys.add(STATE_CONNECTED); break; case NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED: keys.add(isDataActive() ? STATE_NOT_RESTRICTED_RRC_CON keys.add(isPhysicalLinkActive() ? STATE_NOT_RESTRICTED_RRC_CON : STATE_NOT_RESTRICTED_RRC_IDLE); break; case NetworkRegistrationInfo.NR_STATE_RESTRICTED: Loading Loading @@ -457,12 +440,22 @@ public class NetworkTypeController extends StateMachine { unRegisterForAllEvents(); quit(); break; case EVENT_INIITIALIZE: // The reason that we do it here is because some of the works below requires // other modules (e.g. DcTracker, ServiceStateTracker), which is not created // yet when NetworkTypeController is created. registerForAllEvents(); parseCarrierConfigs(); break; case EVENT_DATA_RAT_CHANGED: case EVENT_NR_STATE_CHANGED: case EVENT_NR_FREQUENCY_CHANGED: case EVENT_DATA_ACTIVITY_CHANGED: // ignored break; case EVENT_PHYSICAL_LINK_STATE_CHANGED: AsyncResult ar = (AsyncResult) msg.obj; mPhysicalLinkState = (int) ar.result; break; case EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED: AsyncResult result = (AsyncResult) msg.obj; mIsPhysicalChannelConfigOn = (boolean) result.result; Loading Loading @@ -498,13 +491,6 @@ public class NetworkTypeController extends StateMachine { resetAllTimers(); transitionTo(mLegacyState); break; case EVENT_DATA_CONNECTION_STATE_CHANGED: if (mPhone.getServiceState().getDataNetworkType() != mDisplayInfoController.getTelephonyDisplayInfo().getNetworkType()) { resetAllTimers(); transitionToCurrentState(); } break; case EVENT_PREFERRED_NETWORK_MODE_CHANGED: resetAllTimers(); transitionToCurrentState(); Loading Loading @@ -551,7 +537,8 @@ public class NetworkTypeController extends StateMachine { if (rat == TelephonyManager.NETWORK_TYPE_NR || isLte(rat) && isNrConnected()) { transitionTo(mNrConnectedState); } else if (isLte(rat) && isNrNotRestricted()) { transitionWithTimerTo(isDataActive() ? mLteConnectedState : mIdleState); transitionWithTimerTo(isPhysicalLinkActive() ? mLteConnectedState : mIdleState); } else { updateOverrideNetworkType(); } Loading @@ -561,14 +548,14 @@ public class NetworkTypeController extends StateMachine { if (isNrConnected()) { transitionTo(mNrConnectedState); } else if (isLte(rat) && isNrNotRestricted()) { transitionWithTimerTo(isDataActive() ? mLteConnectedState : mIdleState); transitionWithTimerTo(isPhysicalLinkActive() ? mLteConnectedState : mIdleState); } else if (isLte(rat) && isNrRestricted()) { updateOverrideNetworkType(); } mIsNrRestricted = isNrRestricted(); break; case EVENT_NR_FREQUENCY_CHANGED: case EVENT_DATA_ACTIVITY_CHANGED: // ignored break; default: Loading Loading @@ -625,10 +612,12 @@ public class NetworkTypeController extends StateMachine { case EVENT_NR_FREQUENCY_CHANGED: // ignore break; case EVENT_DATA_ACTIVITY_CHANGED: case EVENT_PHYSICAL_LINK_STATE_CHANGED: AsyncResult ar = (AsyncResult) msg.obj; mPhysicalLinkState = (int) ar.result; if (isNrNotRestricted()) { // NOT_RESTRICTED_RRC_IDLE -> NOT_RESTRICTED_RRC_CON if (isDataActive()) { if (isPhysicalLinkActive()) { transitionWithTimerTo(mLteConnectedState); } } else { Loading Loading @@ -690,10 +679,12 @@ public class NetworkTypeController extends StateMachine { case EVENT_NR_FREQUENCY_CHANGED: // ignore break; case EVENT_DATA_ACTIVITY_CHANGED: case EVENT_PHYSICAL_LINK_STATE_CHANGED: AsyncResult ar = (AsyncResult) msg.obj; mPhysicalLinkState = (int) ar.result; if (isNrNotRestricted()) { // NOT_RESTRICTED_RRC_CON -> NOT_RESTRICTED_RRC_IDLE if (!isDataActive()) { if (!isPhysicalLinkActive()) { transitionWithTimerTo(mIdleState); } } else { Loading Loading @@ -745,14 +736,16 @@ public class NetworkTypeController extends StateMachine { if (rat == TelephonyManager.NETWORK_TYPE_NR || isLte(rat) && isNrConnected()) { updateOverrideNetworkType(); } else if (isLte(rat) && isNrNotRestricted()) { transitionWithTimerTo(isDataActive() ? mLteConnectedState : mIdleState); transitionWithTimerTo(isPhysicalLinkActive() ? mLteConnectedState : mIdleState); } else { transitionWithTimerTo(mLegacyState); } break; case EVENT_NR_STATE_CHANGED: if (isLte(rat) && isNrNotRestricted()) { transitionWithTimerTo(isDataActive() ? mLteConnectedState : mIdleState); transitionWithTimerTo(isPhysicalLinkActive() ? mLteConnectedState : mIdleState); } else if (rat != TelephonyManager.NETWORK_TYPE_NR && !isNrConnected()) { transitionWithTimerTo(mLegacyState); } Loading @@ -772,7 +765,9 @@ public class NetworkTypeController extends StateMachine { } mIsNrMmwave = isNrMmwave(); break; case EVENT_DATA_ACTIVITY_CHANGED: case EVENT_PHYSICAL_LINK_STATE_CHANGED: AsyncResult ar = (AsyncResult) msg.obj; mPhysicalLinkState = (int) ar.result; if (!isNrConnected()) { log("NR state changed. Sending EVENT_NR_STATE_CHANGED"); sendMessage(EVENT_NR_STATE_CHANGED); Loading Loading @@ -831,7 +826,7 @@ public class NetworkTypeController extends StateMachine { transitionState = mNrConnectedState; mPreviousState = isNrMmwave() ? STATE_CONNECTED_MMWAVE : STATE_CONNECTED; } else if (isLte(dataRat) && isNrNotRestricted()) { if (isDataActive()) { if (isPhysicalLinkActive()) { transitionState = mLteConnectedState; mPreviousState = STATE_NOT_RESTRICTED_RRC_CON; } else { Loading Loading @@ -994,10 +989,8 @@ public class NetworkTypeController extends StateMachine { || rat == TelephonyManager.NETWORK_TYPE_LTE_CA; } private boolean isDataActive() { PhoneInternalInterface.DataActivityState activity = mPhone.getDataActivityState(); return activity != PhoneInternalInterface.DataActivityState.DORMANT && activity != PhoneInternalInterface.DataActivityState.NONE; private boolean isPhysicalLinkActive() { return mPhysicalLinkState == DcController.PHYSICAL_LINK_ACTIVE; } private String getEventName(int event) { Loading src/java/com/android/internal/telephony/dataconnection/DcController.java +57 −0 Original line number Diff line number Diff line Loading @@ -16,12 +16,14 @@ package com.android.internal.telephony.dataconnection; import android.annotation.IntDef; import android.content.Context; import android.hardware.radio.V1_4.DataConnActiveStatus; import android.net.LinkAddress; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; import android.os.RegistrantList; import android.telephony.AccessNetworkConstants; import android.telephony.DataFailCause; import android.telephony.PhoneStateListener; Loading @@ -42,6 +44,8 @@ import com.android.telephony.Rlog; import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.HashMap; import java.util.List; Loading @@ -55,6 +59,24 @@ public class DcController extends StateMachine { private static final boolean DBG = true; private static final boolean VDBG = false; /** Physical link state unknown */ public static final int PHYSICAL_LINK_UNKNOWN = 0; /** Physical link state inactive (i.e. RRC idle) */ public static final int PHYSICAL_LINK_NOT_ACTIVE = 1; /** Physical link state active (i.e. RRC connected) */ public static final int PHYSICAL_LINK_ACTIVE = 2; /** @hide */ @IntDef(prefix = { "PHYSICAL_LINK_" }, value = { PHYSICAL_LINK_UNKNOWN, PHYSICAL_LINK_NOT_ACTIVE, PHYSICAL_LINK_ACTIVE }) @Retention(RetentionPolicy.SOURCE) public @interface PhysicalLinkState{} private final Phone mPhone; private final DcTracker mDct; private final DataServiceManager mDataServiceManager; Loading @@ -76,6 +98,16 @@ public class DcController extends StateMachine { //carrier network change private volatile boolean mExecutingCarrierChange; /** * Aggregated physical link state from all data connections. This reflects the device's RRC * connection state. * // TODO: Instead of tracking the RRC state here, we should make PhysicalChannelConfig work in * S. */ private @PhysicalLinkState int mPhysicalLinkState = PHYSICAL_LINK_UNKNOWN; private RegistrantList mPhysicalLinkStateChangedRegistrants = new RegistrantList(); /** * Constructor. * Loading Loading @@ -394,6 +426,12 @@ public class DcController extends StateMachine { if (mDataServiceManager.getTransportType() == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) { int physicalLinkState = isAnyDataCallActive ? PHYSICAL_LINK_ACTIVE : PHYSICAL_LINK_NOT_ACTIVE; if (mPhysicalLinkState != physicalLinkState) { mPhysicalLinkState = physicalLinkState; mPhysicalLinkStateChangedRegistrants.notifyResult(mPhysicalLinkState); } if (isAnyDataCallDormant && !isAnyDataCallActive) { // There is no way to indicate link activity per APN right now. So // Link Activity will be considered dormant only when all data calls Loading Loading @@ -436,6 +474,25 @@ public class DcController extends StateMachine { } } /** * Register for physical link state (i.e. RRC state) changed event. * * @param h The handler * @param what The event */ public void registerForPhysicalLinkStateChanged(Handler h, int what) { mPhysicalLinkStateChangedRegistrants.addUnique(h, what, null); } /** * Unregister from physical link state (i.e. RRC state) changed event. * * @param h The previously registered handler */ public void unregisterForPhysicalLinkStateChanged(Handler h) { mPhysicalLinkStateChangedRegistrants.remove(h); } /** * lr is short name for logAndAddLogRec * @param s Loading src/java/com/android/internal/telephony/dataconnection/DcTracker.java +19 −0 Original line number Diff line number Diff line Loading @@ -5142,4 +5142,23 @@ public class DcTracker extends Handler { } updateLinkBandwidths(bandwidths, useLte); } /** * Register for physical link state (i.e. RRC state) changed event. * * @param h The handler * @param what The event */ public void registerForPhysicalLinkStateChanged(Handler h, int what) { mDcc.registerForPhysicalLinkStateChanged(h, what); } /** * Unregister from physical link state (i.e. RRC state) changed event. * * @param h The previously registered handler */ public void unregisterForPhysicalLinkStateChanged(Handler h) { mDcc.unregisterForPhysicalLinkStateChanged(h); } } tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java +13 −38 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.telephony.TelephonyManager; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import com.android.internal.telephony.dataconnection.DcController; import com.android.internal.util.IState; import com.android.internal.util.StateMachine; Loading @@ -49,14 +50,13 @@ public class NetworkTypeControllerTest extends TelephonyTest { private static final int EVENT_DATA_RAT_CHANGED = 2; private static final int EVENT_NR_STATE_CHANGED = 3; private static final int EVENT_NR_FREQUENCY_CHANGED = 4; private static final int EVENT_DATA_ACTIVITY_CHANGED = 5; private static final int EVENT_PHYSICAL_LINK_STATE_CHANGED = 5; private static final int EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED = 6; private static final int EVENT_CARRIER_CONFIG_CHANGED = 7; private static final int EVENT_PRIMARY_TIMER_EXPIRED = 8; private static final int EVENT_SECONDARY_TIMER_EXPIRED = 9; private static final int EVENT_RADIO_OFF_OR_UNAVAILABLE = 10; private static final int EVENT_DATA_CONNECTION_STATE_CHANGED = 11; private static final int EVENT_PREFERRED_NETWORK_MODE_CHANGED = 12; private static final int EVENT_PREFERRED_NETWORK_MODE_CHANGED = 11; private NetworkTypeController mNetworkTypeController; private PersistableBundle mBundle; Loading Loading @@ -94,6 +94,7 @@ public class NetworkTypeControllerTest extends TelephonyTest { doReturn(TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA).when(mPhone) .getCachedPreferredNetworkType(); mNetworkTypeController = new NetworkTypeController(mPhone, mDisplayInfoController); processAllMessages(); } @After Loading Loading @@ -190,9 +191,8 @@ public class NetworkTypeControllerTest extends TelephonyTest { assertEquals("DefaultState", getCurrentState().getName()); doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType(); doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(mServiceState).getNrState(); doReturn(PhoneInternalInterface.DataActivityState.DORMANT) .when(mPhone).getDataActivityState(); mNetworkTypeController.sendMessage(EVENT_PHYSICAL_LINK_STATE_CHANGED, new AsyncResult(null, DcController.PHYSICAL_LINK_NOT_ACTIVE, null)); mNetworkTypeController.sendMessage(NetworkTypeController.EVENT_UPDATE); processAllMessages(); assertEquals("not_restricted_rrc_idle", getCurrentState().getName()); Loading @@ -203,9 +203,8 @@ public class NetworkTypeControllerTest extends TelephonyTest { assertEquals("DefaultState", getCurrentState().getName()); doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType(); doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(mServiceState).getNrState(); doReturn(PhoneInternalInterface.DataActivityState.DATAINANDOUT) .when(mPhone).getDataActivityState(); mNetworkTypeController.sendMessage(EVENT_PHYSICAL_LINK_STATE_CHANGED, new AsyncResult(null, DcController.PHYSICAL_LINK_ACTIVE, null)); mNetworkTypeController.sendMessage(NetworkTypeController.EVENT_UPDATE); processAllMessages(); assertEquals("not_restricted_rrc_con", getCurrentState().getName()); Loading Loading @@ -284,9 +283,8 @@ public class NetworkTypeControllerTest extends TelephonyTest { testTransitionToCurrentStateNrConnectedMmwave(); doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType(); doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(mServiceState).getNrState(); doReturn(PhoneInternalInterface.DataActivityState.DATAINANDOUT) .when(mPhone).getDataActivityState(); mNetworkTypeController.sendMessage(EVENT_PHYSICAL_LINK_STATE_CHANGED, new AsyncResult(null, DcController.PHYSICAL_LINK_ACTIVE, null)); mNetworkTypeController.sendMessage(EVENT_NR_FREQUENCY_CHANGED); mNetworkTypeController.sendMessage(EVENT_NR_STATE_CHANGED); processAllMessages(); Loading @@ -295,13 +293,11 @@ public class NetworkTypeControllerTest extends TelephonyTest { } @Test public void testEventDataActivityChanged() throws Exception { public void testEventPhysicalLinkStateChanged() throws Exception { testTransitionToCurrentStateLteConnected(); doReturn(ServiceState.FREQUENCY_RANGE_MMWAVE).when(mServiceState).getNrFrequencyRange(); doReturn(PhoneInternalInterface.DataActivityState.DORMANT) .when(mPhone).getDataActivityState(); mNetworkTypeController.sendMessage(EVENT_DATA_ACTIVITY_CHANGED); mNetworkTypeController.sendMessage(EVENT_PHYSICAL_LINK_STATE_CHANGED, new AsyncResult(null, DcController.PHYSICAL_LINK_NOT_ACTIVE, null)); processAllMessages(); assertEquals("not_restricted_rrc_idle", getCurrentState().getName()); } Loading Loading @@ -334,27 +330,6 @@ public class NetworkTypeControllerTest extends TelephonyTest { mNetworkTypeController.getOverrideNetworkType()); } @Test public void testEventDataConnectionStateChanged() throws Exception { testTransitionToCurrentStateNrConnected(); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA, mNetworkTypeController.getOverrideNetworkType()); // TelephonyDisplayInfo can't be mocked since it's final, so create a new one for testing TelephonyDisplayInfo telephonyDisplayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_UNKNOWN, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE); doReturn(NetworkRegistrationInfo.NR_STATE_NONE).when(mServiceState).getNrState(); doReturn(telephonyDisplayInfo).when(mDisplayInfoController).getTelephonyDisplayInfo(); doReturn(TelephonyManager.NETWORK_TYPE_HSPAP).when(mServiceState).getDataNetworkType(); mNetworkTypeController.sendMessage(EVENT_DATA_CONNECTION_STATE_CHANGED); processAllMessages(); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, mNetworkTypeController.getOverrideNetworkType()); } @Test public void testEventPreferredNetworkModeChanged() throws Exception { testTransitionToCurrentStateNrConnected(); Loading Loading
src/java/com/android/internal/telephony/NetworkTypeController.java +47 −54 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import android.telephony.AccessNetworkConstants; import android.telephony.Annotation; import android.telephony.CarrierConfigManager; import android.telephony.NetworkRegistrationInfo; import android.telephony.PhoneStateListener; import android.telephony.RadioAccessFamily; import android.telephony.ServiceState; import android.telephony.SubscriptionManager; Loading @@ -36,6 +35,8 @@ import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.text.TextUtils; import com.android.internal.telephony.dataconnection.DcController; import com.android.internal.telephony.dataconnection.DcController.PhysicalLinkState; import com.android.internal.util.IState; import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.State; Loading Loading @@ -81,19 +82,19 @@ public class NetworkTypeController extends StateMachine { private static final int EVENT_DATA_RAT_CHANGED = 2; private static final int EVENT_NR_STATE_CHANGED = 3; private static final int EVENT_NR_FREQUENCY_CHANGED = 4; private static final int EVENT_DATA_ACTIVITY_CHANGED = 5; private static final int EVENT_PHYSICAL_LINK_STATE_CHANGED = 5; private static final int EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED = 6; private static final int EVENT_CARRIER_CONFIG_CHANGED = 7; private static final int EVENT_PRIMARY_TIMER_EXPIRED = 8; private static final int EVENT_SECONDARY_TIMER_EXPIRED = 9; private static final int EVENT_RADIO_OFF_OR_UNAVAILABLE = 10; private static final int EVENT_DATA_CONNECTION_STATE_CHANGED = 11; private static final int EVENT_PREFERRED_NETWORK_MODE_CHANGED = 12; private static final int EVENT_PREFERRED_NETWORK_MODE_CHANGED = 11; private static final int EVENT_INIITIALIZE = 12; // events that don't reset the timer private static final int[] ALL_EVENTS = { EVENT_DATA_RAT_CHANGED, EVENT_NR_STATE_CHANGED, EVENT_NR_FREQUENCY_CHANGED, EVENT_DATA_ACTIVITY_CHANGED, EVENT_NR_FREQUENCY_CHANGED, EVENT_PHYSICAL_LINK_STATE_CHANGED, EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED, EVENT_PRIMARY_TIMER_EXPIRED, EVENT_SECONDARY_TIMER_EXPIRED, EVENT_DATA_CONNECTION_STATE_CHANGED }; EVENT_SECONDARY_TIMER_EXPIRED}; private static final String[] sEvents = new String[EVENT_PREFERRED_NETWORK_MODE_CHANGED + 1]; static { Loading @@ -102,20 +103,18 @@ public class NetworkTypeController extends StateMachine { sEvents[EVENT_DATA_RAT_CHANGED] = "EVENT_DATA_RAT_CHANGED"; sEvents[EVENT_NR_STATE_CHANGED] = "EVENT_NR_STATE_CHANGED"; sEvents[EVENT_NR_FREQUENCY_CHANGED] = "EVENT_NR_FREQUENCY_CHANGED"; sEvents[EVENT_DATA_ACTIVITY_CHANGED] = "EVENT_DATA_ACTIVITY_CHANGED"; sEvents[EVENT_PHYSICAL_LINK_STATE_CHANGED] = "EVENT_PHYSICAL_LINK_STATE_CHANGED"; sEvents[EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED] = "EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED"; sEvents[EVENT_CARRIER_CONFIG_CHANGED] = "EVENT_CARRIER_CONFIG_CHANGED"; sEvents[EVENT_PRIMARY_TIMER_EXPIRED] = "EVENT_PRIMARY_TIMER_EXPIRED"; sEvents[EVENT_SECONDARY_TIMER_EXPIRED] = "EVENT_SECONDARY_TIMER_EXPIRED"; sEvents[EVENT_RADIO_OFF_OR_UNAVAILABLE] = "EVENT_RADIO_OFF_OR_UNAVAILABLE"; sEvents[EVENT_DATA_CONNECTION_STATE_CHANGED] = "EVENT_DATA_CONNECTION_STATE_CHANGED"; sEvents[EVENT_PREFERRED_NETWORK_MODE_CHANGED] = "EVENT_PREFERRED_NETWORK_MODE_CHANGED"; } private final Phone mPhone; private final DisplayInfoController mDisplayInfoController; private final TelephonyManager mTelephonyManager; private final SettingsObserver mSettingsObserver; private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { @Override Loading @@ -129,16 +128,6 @@ public class NetworkTypeController extends StateMachine { } } }; private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() { @Override public void onDataActivity(int direction) { sendMessage(EVENT_DATA_ACTIVITY_CHANGED); } @Override public void onDataConnectionStateChanged(int state, int networkType) { sendMessage(EVENT_DATA_CONNECTION_STATE_CHANGED); } }; private Map<String, OverrideTimerRule> mOverrideTimerRules = new HashMap<>(); private String mLteEnhancedPattern = ""; Loading @@ -149,6 +138,7 @@ public class NetworkTypeController extends StateMachine { private String mPrimaryTimerState; private String mSecondaryTimerState; private String mPreviousState; private @PhysicalLinkState int mPhysicalLinkState; /** * NetworkTypeController constructor. Loading @@ -160,8 +150,6 @@ public class NetworkTypeController extends StateMachine { super(TAG, displayInfoController); mPhone = phone; mDisplayInfoController = displayInfoController; mTelephonyManager = TelephonyManager.from(phone.getContext()) .createForSubscriptionId(phone.getSubId()); mSettingsObserver = new SettingsObserver(mPhone.getContext(), getHandler()); mOverrideNetworkType = TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE; mIsPhysicalChannelConfigOn = true; Loading @@ -171,9 +159,8 @@ public class NetworkTypeController extends StateMachine { addState(mLteConnectedState, mDefaultState); addState(mNrConnectedState, mDefaultState); setInitialState(mDefaultState); registerForAllEvents(); parseCarrierConfigs(); start(); sendMessage(EVENT_INIITIALIZE); } /** Loading @@ -190,6 +177,9 @@ public class NetworkTypeController extends StateMachine { mPhone.getServiceStateTracker().registerForDataRegStateOrRatChanged( AccessNetworkConstants.TRANSPORT_TYPE_WWAN, getHandler(), EVENT_DATA_RAT_CHANGED, null); mPhone.getDcTracker(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .registerForPhysicalLinkStateChanged(getHandler(), EVENT_PHYSICAL_LINK_STATE_CHANGED); mPhone.getServiceStateTracker().registerForNrStateChanged(getHandler(), EVENT_NR_STATE_CHANGED, null); mPhone.getServiceStateTracker().registerForNrFrequencyChanged(getHandler(), Loading @@ -199,10 +189,6 @@ public class NetworkTypeController extends StateMachine { IntentFilter filter = new IntentFilter(); filter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED); mPhone.getContext().registerReceiver(mIntentReceiver, filter, null, mPhone); if (mTelephonyManager != null) { mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_DATA_ACTIVITY | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); } mSettingsObserver.observe(Settings.Global.getUriFor(Settings.Global.PREFERRED_NETWORK_MODE), EVENT_PREFERRED_NETWORK_MODE_CHANGED); } Loading @@ -215,9 +201,6 @@ public class NetworkTypeController extends StateMachine { mPhone.getServiceStateTracker().unregisterForNrFrequencyChanged(getHandler()); mPhone.getDeviceStateMonitor().unregisterForPhysicalChannelConfigNotifChanged(getHandler()); mPhone.getContext().unregisterReceiver(mIntentReceiver); if (mTelephonyManager != null) { mTelephonyManager.listen(mPhoneStateListener, 0); } mSettingsObserver.unobserve(); } Loading Loading @@ -393,7 +376,7 @@ public class NetworkTypeController extends StateMachine { keys.add(STATE_CONNECTED); break; case NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED: keys.add(isDataActive() ? STATE_NOT_RESTRICTED_RRC_CON keys.add(isPhysicalLinkActive() ? STATE_NOT_RESTRICTED_RRC_CON : STATE_NOT_RESTRICTED_RRC_IDLE); break; case NetworkRegistrationInfo.NR_STATE_RESTRICTED: Loading Loading @@ -457,12 +440,22 @@ public class NetworkTypeController extends StateMachine { unRegisterForAllEvents(); quit(); break; case EVENT_INIITIALIZE: // The reason that we do it here is because some of the works below requires // other modules (e.g. DcTracker, ServiceStateTracker), which is not created // yet when NetworkTypeController is created. registerForAllEvents(); parseCarrierConfigs(); break; case EVENT_DATA_RAT_CHANGED: case EVENT_NR_STATE_CHANGED: case EVENT_NR_FREQUENCY_CHANGED: case EVENT_DATA_ACTIVITY_CHANGED: // ignored break; case EVENT_PHYSICAL_LINK_STATE_CHANGED: AsyncResult ar = (AsyncResult) msg.obj; mPhysicalLinkState = (int) ar.result; break; case EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED: AsyncResult result = (AsyncResult) msg.obj; mIsPhysicalChannelConfigOn = (boolean) result.result; Loading Loading @@ -498,13 +491,6 @@ public class NetworkTypeController extends StateMachine { resetAllTimers(); transitionTo(mLegacyState); break; case EVENT_DATA_CONNECTION_STATE_CHANGED: if (mPhone.getServiceState().getDataNetworkType() != mDisplayInfoController.getTelephonyDisplayInfo().getNetworkType()) { resetAllTimers(); transitionToCurrentState(); } break; case EVENT_PREFERRED_NETWORK_MODE_CHANGED: resetAllTimers(); transitionToCurrentState(); Loading Loading @@ -551,7 +537,8 @@ public class NetworkTypeController extends StateMachine { if (rat == TelephonyManager.NETWORK_TYPE_NR || isLte(rat) && isNrConnected()) { transitionTo(mNrConnectedState); } else if (isLte(rat) && isNrNotRestricted()) { transitionWithTimerTo(isDataActive() ? mLteConnectedState : mIdleState); transitionWithTimerTo(isPhysicalLinkActive() ? mLteConnectedState : mIdleState); } else { updateOverrideNetworkType(); } Loading @@ -561,14 +548,14 @@ public class NetworkTypeController extends StateMachine { if (isNrConnected()) { transitionTo(mNrConnectedState); } else if (isLte(rat) && isNrNotRestricted()) { transitionWithTimerTo(isDataActive() ? mLteConnectedState : mIdleState); transitionWithTimerTo(isPhysicalLinkActive() ? mLteConnectedState : mIdleState); } else if (isLte(rat) && isNrRestricted()) { updateOverrideNetworkType(); } mIsNrRestricted = isNrRestricted(); break; case EVENT_NR_FREQUENCY_CHANGED: case EVENT_DATA_ACTIVITY_CHANGED: // ignored break; default: Loading Loading @@ -625,10 +612,12 @@ public class NetworkTypeController extends StateMachine { case EVENT_NR_FREQUENCY_CHANGED: // ignore break; case EVENT_DATA_ACTIVITY_CHANGED: case EVENT_PHYSICAL_LINK_STATE_CHANGED: AsyncResult ar = (AsyncResult) msg.obj; mPhysicalLinkState = (int) ar.result; if (isNrNotRestricted()) { // NOT_RESTRICTED_RRC_IDLE -> NOT_RESTRICTED_RRC_CON if (isDataActive()) { if (isPhysicalLinkActive()) { transitionWithTimerTo(mLteConnectedState); } } else { Loading Loading @@ -690,10 +679,12 @@ public class NetworkTypeController extends StateMachine { case EVENT_NR_FREQUENCY_CHANGED: // ignore break; case EVENT_DATA_ACTIVITY_CHANGED: case EVENT_PHYSICAL_LINK_STATE_CHANGED: AsyncResult ar = (AsyncResult) msg.obj; mPhysicalLinkState = (int) ar.result; if (isNrNotRestricted()) { // NOT_RESTRICTED_RRC_CON -> NOT_RESTRICTED_RRC_IDLE if (!isDataActive()) { if (!isPhysicalLinkActive()) { transitionWithTimerTo(mIdleState); } } else { Loading Loading @@ -745,14 +736,16 @@ public class NetworkTypeController extends StateMachine { if (rat == TelephonyManager.NETWORK_TYPE_NR || isLte(rat) && isNrConnected()) { updateOverrideNetworkType(); } else if (isLte(rat) && isNrNotRestricted()) { transitionWithTimerTo(isDataActive() ? mLteConnectedState : mIdleState); transitionWithTimerTo(isPhysicalLinkActive() ? mLteConnectedState : mIdleState); } else { transitionWithTimerTo(mLegacyState); } break; case EVENT_NR_STATE_CHANGED: if (isLte(rat) && isNrNotRestricted()) { transitionWithTimerTo(isDataActive() ? mLteConnectedState : mIdleState); transitionWithTimerTo(isPhysicalLinkActive() ? mLteConnectedState : mIdleState); } else if (rat != TelephonyManager.NETWORK_TYPE_NR && !isNrConnected()) { transitionWithTimerTo(mLegacyState); } Loading @@ -772,7 +765,9 @@ public class NetworkTypeController extends StateMachine { } mIsNrMmwave = isNrMmwave(); break; case EVENT_DATA_ACTIVITY_CHANGED: case EVENT_PHYSICAL_LINK_STATE_CHANGED: AsyncResult ar = (AsyncResult) msg.obj; mPhysicalLinkState = (int) ar.result; if (!isNrConnected()) { log("NR state changed. Sending EVENT_NR_STATE_CHANGED"); sendMessage(EVENT_NR_STATE_CHANGED); Loading Loading @@ -831,7 +826,7 @@ public class NetworkTypeController extends StateMachine { transitionState = mNrConnectedState; mPreviousState = isNrMmwave() ? STATE_CONNECTED_MMWAVE : STATE_CONNECTED; } else if (isLte(dataRat) && isNrNotRestricted()) { if (isDataActive()) { if (isPhysicalLinkActive()) { transitionState = mLteConnectedState; mPreviousState = STATE_NOT_RESTRICTED_RRC_CON; } else { Loading Loading @@ -994,10 +989,8 @@ public class NetworkTypeController extends StateMachine { || rat == TelephonyManager.NETWORK_TYPE_LTE_CA; } private boolean isDataActive() { PhoneInternalInterface.DataActivityState activity = mPhone.getDataActivityState(); return activity != PhoneInternalInterface.DataActivityState.DORMANT && activity != PhoneInternalInterface.DataActivityState.NONE; private boolean isPhysicalLinkActive() { return mPhysicalLinkState == DcController.PHYSICAL_LINK_ACTIVE; } private String getEventName(int event) { Loading
src/java/com/android/internal/telephony/dataconnection/DcController.java +57 −0 Original line number Diff line number Diff line Loading @@ -16,12 +16,14 @@ package com.android.internal.telephony.dataconnection; import android.annotation.IntDef; import android.content.Context; import android.hardware.radio.V1_4.DataConnActiveStatus; import android.net.LinkAddress; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; import android.os.RegistrantList; import android.telephony.AccessNetworkConstants; import android.telephony.DataFailCause; import android.telephony.PhoneStateListener; Loading @@ -42,6 +44,8 @@ import com.android.telephony.Rlog; import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.HashMap; import java.util.List; Loading @@ -55,6 +59,24 @@ public class DcController extends StateMachine { private static final boolean DBG = true; private static final boolean VDBG = false; /** Physical link state unknown */ public static final int PHYSICAL_LINK_UNKNOWN = 0; /** Physical link state inactive (i.e. RRC idle) */ public static final int PHYSICAL_LINK_NOT_ACTIVE = 1; /** Physical link state active (i.e. RRC connected) */ public static final int PHYSICAL_LINK_ACTIVE = 2; /** @hide */ @IntDef(prefix = { "PHYSICAL_LINK_" }, value = { PHYSICAL_LINK_UNKNOWN, PHYSICAL_LINK_NOT_ACTIVE, PHYSICAL_LINK_ACTIVE }) @Retention(RetentionPolicy.SOURCE) public @interface PhysicalLinkState{} private final Phone mPhone; private final DcTracker mDct; private final DataServiceManager mDataServiceManager; Loading @@ -76,6 +98,16 @@ public class DcController extends StateMachine { //carrier network change private volatile boolean mExecutingCarrierChange; /** * Aggregated physical link state from all data connections. This reflects the device's RRC * connection state. * // TODO: Instead of tracking the RRC state here, we should make PhysicalChannelConfig work in * S. */ private @PhysicalLinkState int mPhysicalLinkState = PHYSICAL_LINK_UNKNOWN; private RegistrantList mPhysicalLinkStateChangedRegistrants = new RegistrantList(); /** * Constructor. * Loading Loading @@ -394,6 +426,12 @@ public class DcController extends StateMachine { if (mDataServiceManager.getTransportType() == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) { int physicalLinkState = isAnyDataCallActive ? PHYSICAL_LINK_ACTIVE : PHYSICAL_LINK_NOT_ACTIVE; if (mPhysicalLinkState != physicalLinkState) { mPhysicalLinkState = physicalLinkState; mPhysicalLinkStateChangedRegistrants.notifyResult(mPhysicalLinkState); } if (isAnyDataCallDormant && !isAnyDataCallActive) { // There is no way to indicate link activity per APN right now. So // Link Activity will be considered dormant only when all data calls Loading Loading @@ -436,6 +474,25 @@ public class DcController extends StateMachine { } } /** * Register for physical link state (i.e. RRC state) changed event. * * @param h The handler * @param what The event */ public void registerForPhysicalLinkStateChanged(Handler h, int what) { mPhysicalLinkStateChangedRegistrants.addUnique(h, what, null); } /** * Unregister from physical link state (i.e. RRC state) changed event. * * @param h The previously registered handler */ public void unregisterForPhysicalLinkStateChanged(Handler h) { mPhysicalLinkStateChangedRegistrants.remove(h); } /** * lr is short name for logAndAddLogRec * @param s Loading
src/java/com/android/internal/telephony/dataconnection/DcTracker.java +19 −0 Original line number Diff line number Diff line Loading @@ -5142,4 +5142,23 @@ public class DcTracker extends Handler { } updateLinkBandwidths(bandwidths, useLte); } /** * Register for physical link state (i.e. RRC state) changed event. * * @param h The handler * @param what The event */ public void registerForPhysicalLinkStateChanged(Handler h, int what) { mDcc.registerForPhysicalLinkStateChanged(h, what); } /** * Unregister from physical link state (i.e. RRC state) changed event. * * @param h The previously registered handler */ public void unregisterForPhysicalLinkStateChanged(Handler h) { mDcc.unregisterForPhysicalLinkStateChanged(h); } }
tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java +13 −38 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.telephony.TelephonyManager; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import com.android.internal.telephony.dataconnection.DcController; import com.android.internal.util.IState; import com.android.internal.util.StateMachine; Loading @@ -49,14 +50,13 @@ public class NetworkTypeControllerTest extends TelephonyTest { private static final int EVENT_DATA_RAT_CHANGED = 2; private static final int EVENT_NR_STATE_CHANGED = 3; private static final int EVENT_NR_FREQUENCY_CHANGED = 4; private static final int EVENT_DATA_ACTIVITY_CHANGED = 5; private static final int EVENT_PHYSICAL_LINK_STATE_CHANGED = 5; private static final int EVENT_PHYSICAL_CHANNEL_CONFIG_NOTIF_CHANGED = 6; private static final int EVENT_CARRIER_CONFIG_CHANGED = 7; private static final int EVENT_PRIMARY_TIMER_EXPIRED = 8; private static final int EVENT_SECONDARY_TIMER_EXPIRED = 9; private static final int EVENT_RADIO_OFF_OR_UNAVAILABLE = 10; private static final int EVENT_DATA_CONNECTION_STATE_CHANGED = 11; private static final int EVENT_PREFERRED_NETWORK_MODE_CHANGED = 12; private static final int EVENT_PREFERRED_NETWORK_MODE_CHANGED = 11; private NetworkTypeController mNetworkTypeController; private PersistableBundle mBundle; Loading Loading @@ -94,6 +94,7 @@ public class NetworkTypeControllerTest extends TelephonyTest { doReturn(TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA).when(mPhone) .getCachedPreferredNetworkType(); mNetworkTypeController = new NetworkTypeController(mPhone, mDisplayInfoController); processAllMessages(); } @After Loading Loading @@ -190,9 +191,8 @@ public class NetworkTypeControllerTest extends TelephonyTest { assertEquals("DefaultState", getCurrentState().getName()); doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType(); doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(mServiceState).getNrState(); doReturn(PhoneInternalInterface.DataActivityState.DORMANT) .when(mPhone).getDataActivityState(); mNetworkTypeController.sendMessage(EVENT_PHYSICAL_LINK_STATE_CHANGED, new AsyncResult(null, DcController.PHYSICAL_LINK_NOT_ACTIVE, null)); mNetworkTypeController.sendMessage(NetworkTypeController.EVENT_UPDATE); processAllMessages(); assertEquals("not_restricted_rrc_idle", getCurrentState().getName()); Loading @@ -203,9 +203,8 @@ public class NetworkTypeControllerTest extends TelephonyTest { assertEquals("DefaultState", getCurrentState().getName()); doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType(); doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(mServiceState).getNrState(); doReturn(PhoneInternalInterface.DataActivityState.DATAINANDOUT) .when(mPhone).getDataActivityState(); mNetworkTypeController.sendMessage(EVENT_PHYSICAL_LINK_STATE_CHANGED, new AsyncResult(null, DcController.PHYSICAL_LINK_ACTIVE, null)); mNetworkTypeController.sendMessage(NetworkTypeController.EVENT_UPDATE); processAllMessages(); assertEquals("not_restricted_rrc_con", getCurrentState().getName()); Loading Loading @@ -284,9 +283,8 @@ public class NetworkTypeControllerTest extends TelephonyTest { testTransitionToCurrentStateNrConnectedMmwave(); doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType(); doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(mServiceState).getNrState(); doReturn(PhoneInternalInterface.DataActivityState.DATAINANDOUT) .when(mPhone).getDataActivityState(); mNetworkTypeController.sendMessage(EVENT_PHYSICAL_LINK_STATE_CHANGED, new AsyncResult(null, DcController.PHYSICAL_LINK_ACTIVE, null)); mNetworkTypeController.sendMessage(EVENT_NR_FREQUENCY_CHANGED); mNetworkTypeController.sendMessage(EVENT_NR_STATE_CHANGED); processAllMessages(); Loading @@ -295,13 +293,11 @@ public class NetworkTypeControllerTest extends TelephonyTest { } @Test public void testEventDataActivityChanged() throws Exception { public void testEventPhysicalLinkStateChanged() throws Exception { testTransitionToCurrentStateLteConnected(); doReturn(ServiceState.FREQUENCY_RANGE_MMWAVE).when(mServiceState).getNrFrequencyRange(); doReturn(PhoneInternalInterface.DataActivityState.DORMANT) .when(mPhone).getDataActivityState(); mNetworkTypeController.sendMessage(EVENT_DATA_ACTIVITY_CHANGED); mNetworkTypeController.sendMessage(EVENT_PHYSICAL_LINK_STATE_CHANGED, new AsyncResult(null, DcController.PHYSICAL_LINK_NOT_ACTIVE, null)); processAllMessages(); assertEquals("not_restricted_rrc_idle", getCurrentState().getName()); } Loading Loading @@ -334,27 +330,6 @@ public class NetworkTypeControllerTest extends TelephonyTest { mNetworkTypeController.getOverrideNetworkType()); } @Test public void testEventDataConnectionStateChanged() throws Exception { testTransitionToCurrentStateNrConnected(); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA, mNetworkTypeController.getOverrideNetworkType()); // TelephonyDisplayInfo can't be mocked since it's final, so create a new one for testing TelephonyDisplayInfo telephonyDisplayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_UNKNOWN, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE); doReturn(NetworkRegistrationInfo.NR_STATE_NONE).when(mServiceState).getNrState(); doReturn(telephonyDisplayInfo).when(mDisplayInfoController).getTelephonyDisplayInfo(); doReturn(TelephonyManager.NETWORK_TYPE_HSPAP).when(mServiceState).getDataNetworkType(); mNetworkTypeController.sendMessage(EVENT_DATA_CONNECTION_STATE_CHANGED); processAllMessages(); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, mNetworkTypeController.getOverrideNetworkType()); } @Test public void testEventPreferredNetworkModeChanged() throws Exception { testTransitionToCurrentStateNrConnected(); Loading