aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Yu <jackyu@google.com>2020-06-23 01:47:07 -0700
committerJack Yu <jackyu@google.com>2020-06-23 14:45:48 -0700
commit1559a6e2f4b41deb542b17ea4b04ed1f0f263680 (patch)
tree4a9891a11881d2904aad3a41ca5621c5d3248d4a
parenta44841eadca4e952de5746f13463f34083007c26 (diff)
downloadtelephony-1559a6e2f4b41deb542b17ea4b04ed1f0f263680.tar.gz
Fixed incorrect 5G icon
The incorrect 5G icon was trigerred by the incorrect data activity state in telephony. The telephony data activity is derived from TrafficStats, not directly from the unsolicited data call status event from modem. The excessive and frequent polling requests from telephony resulted in no-delta traffic between the pollings, which makes network type controller think the device enters RRC idle state. The fix is not touching the existing data activity algorithm, but making network type controller directly use the data activity signal from the modem. The data activity signal from the modem reflects the RRC state of the device. In S, we should derive the RRC state directly from PhysicalChannelConfig, because data connection activity and RRC state are different layer concepts. Fix: 157610910 Test: NetworkTypeControllerTest Change-Id: I53c010608dd8796003b33f8ba0f4249108aecee2
-rw-r--r--src/java/com/android/internal/telephony/NetworkTypeController.java101
-rw-r--r--src/java/com/android/internal/telephony/dataconnection/DcController.java57
-rw-r--r--src/java/com/android/internal/telephony/dataconnection/DcTracker.java19
-rw-r--r--tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java51
4 files changed, 136 insertions, 92 deletions
diff --git a/src/java/com/android/internal/telephony/NetworkTypeController.java b/src/java/com/android/internal/telephony/NetworkTypeController.java
index 4e4d7a9d3e..448c58676d 100644
--- a/src/java/com/android/internal/telephony/NetworkTypeController.java
+++ b/src/java/com/android/internal/telephony/NetworkTypeController.java
@@ -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;
@@ -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;
@@ -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 {
@@ -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
@@ -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 = "";
@@ -149,6 +138,7 @@ public class NetworkTypeController extends StateMachine {
private String mPrimaryTimerState;
private String mSecondaryTimerState;
private String mPreviousState;
+ private @PhysicalLinkState int mPhysicalLinkState;
/**
* NetworkTypeController constructor.
@@ -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;
@@ -171,9 +159,8 @@ public class NetworkTypeController extends StateMachine {
addState(mLteConnectedState, mDefaultState);
addState(mNrConnectedState, mDefaultState);
setInitialState(mDefaultState);
- registerForAllEvents();
- parseCarrierConfigs();
start();
+ sendMessage(EVENT_INIITIALIZE);
}
/**
@@ -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(),
@@ -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);
}
@@ -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();
}
@@ -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:
@@ -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;
@@ -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();
@@ -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();
}
@@ -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:
@@ -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 {
@@ -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 {
@@ -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);
}
@@ -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);
@@ -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 {
@@ -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) {
diff --git a/src/java/com/android/internal/telephony/dataconnection/DcController.java b/src/java/com/android/internal/telephony/dataconnection/DcController.java
index e383f6bfea..f2125d173b 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DcController.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DcController.java
@@ -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;
@@ -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;
@@ -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;
@@ -77,6 +99,16 @@ public class DcController extends StateMachine {
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.
*
* @param name to be used for the Controller
@@ -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
@@ -437,6 +475,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
*/
diff --git a/src/java/com/android/internal/telephony/dataconnection/DcTracker.java b/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
index b0b2675fc1..7b1560ffb7 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
@@ -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);
+ }
}
diff --git a/tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java
index b34821e702..95ec5cd18c 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java
@@ -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;
@@ -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;
@@ -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
@@ -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());
@@ -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());
@@ -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();
@@ -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());
}
@@ -335,27 +331,6 @@ public class NetworkTypeControllerTest extends TelephonyTest {
}
@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();
assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA,