Merge "Replace usages of ServiceState#getDataNetworkType"
This commit is contained in:
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package com.android.systemui.statusbar.policy;
|
||||
|
||||
import static android.telephony.AccessNetworkConstants.TRANSPORT_TYPE_WWAN;
|
||||
import static android.telephony.NetworkRegistrationInfo.DOMAIN_PS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.ContentObserver;
|
||||
@@ -708,7 +711,11 @@ public class MobileSignalController extends SignalController<
|
||||
}
|
||||
mServiceState = state;
|
||||
if (mServiceState != null) {
|
||||
updateDataNetType(mServiceState.getDataNetworkType());
|
||||
NetworkRegistrationInfo regInfo = mServiceState.getNetworkRegistrationInfo(
|
||||
DOMAIN_PS, TRANSPORT_TYPE_WWAN);
|
||||
if (regInfo != null) {
|
||||
updateDataNetType(regInfo.getAccessNetworkTechnology());
|
||||
}
|
||||
}
|
||||
updateTelephony();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.android.systemui.statusbar.policy;
|
||||
|
||||
import static android.telephony.AccessNetworkConstants.TRANSPORT_TYPE_WWAN;
|
||||
import static android.telephony.NetworkRegistrationInfo.DOMAIN_PS;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
|
||||
@@ -39,6 +42,7 @@ import android.net.wifi.WifiManager;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Global;
|
||||
import android.telephony.NetworkRegistrationInfo;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.SignalStrength;
|
||||
@@ -347,7 +351,13 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
public void updateDataConnectionState(int dataState, int dataNetType) {
|
||||
when(mServiceState.getDataNetworkType()).thenReturn(dataNetType);
|
||||
NetworkRegistrationInfo fakeRegInfo = new NetworkRegistrationInfo.Builder()
|
||||
.setTransportType(TRANSPORT_TYPE_WWAN)
|
||||
.setDomain(DOMAIN_PS)
|
||||
.setAccessNetworkTechnology(dataNetType)
|
||||
.build();
|
||||
when(mServiceState.getNetworkRegistrationInfo(DOMAIN_PS, TRANSPORT_TYPE_WWAN))
|
||||
.thenReturn(fakeRegInfo);
|
||||
mPhoneStateListener.onDataConnectionStateChanged(dataState, dataNetType);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.android.systemui.statusbar.policy;
|
||||
|
||||
import static android.telephony.AccessNetworkConstants.TRANSPORT_TYPE_WWAN;
|
||||
import static android.telephony.NetworkRegistrationInfo.DOMAIN_PS;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
@@ -418,7 +421,13 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest {
|
||||
|
||||
// State from NR_5G to NONE NR_STATE_RESTRICTED, showing corresponding icon
|
||||
doReturn(NetworkRegistrationInfo.NR_STATE_RESTRICTED).when(mServiceState).getNrState();
|
||||
doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType();
|
||||
NetworkRegistrationInfo fakeRegInfo = new NetworkRegistrationInfo.Builder()
|
||||
.setTransportType(TRANSPORT_TYPE_WWAN)
|
||||
.setDomain(DOMAIN_PS)
|
||||
.setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
|
||||
.build();
|
||||
doReturn(fakeRegInfo).when(mServiceState)
|
||||
.getNetworkRegistrationInfo(DOMAIN_PS, TRANSPORT_TYPE_WWAN);
|
||||
mPhoneStateListener.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED,
|
||||
TelephonyManager.NETWORK_TYPE_LTE);
|
||||
|
||||
@@ -480,8 +489,13 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest {
|
||||
|
||||
verifyDataIndicators(TelephonyIcons.ICON_LTE);
|
||||
|
||||
when(mServiceState.getDataNetworkType())
|
||||
.thenReturn(TelephonyManager.NETWORK_TYPE_HSPA);
|
||||
NetworkRegistrationInfo fakeRegInfo = new NetworkRegistrationInfo.Builder()
|
||||
.setTransportType(TRANSPORT_TYPE_WWAN)
|
||||
.setDomain(DOMAIN_PS)
|
||||
.setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_HSPA)
|
||||
.build();
|
||||
when(mServiceState.getNetworkRegistrationInfo(DOMAIN_PS, TRANSPORT_TYPE_WWAN))
|
||||
.thenReturn(fakeRegInfo);
|
||||
updateServiceState();
|
||||
verifyDataIndicators(TelephonyIcons.ICON_H);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.android.server.connectivity;
|
||||
|
||||
import static android.telephony.AccessNetworkConstants.TRANSPORT_TYPE_WWAN;
|
||||
import static android.telephony.NetworkRegistrationInfo.DOMAIN_PS;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -24,6 +27,7 @@ import android.net.ConnectivityManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
import android.telephony.NetworkRegistrationInfo;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.SignalStrength;
|
||||
@@ -91,7 +95,10 @@ public class DataConnectionStats extends BroadcastReceiver {
|
||||
boolean visible = (simReadyOrUnknown || isCdma()) // we only check the sim state for GSM
|
||||
&& hasService()
|
||||
&& mDataState == TelephonyManager.DATA_CONNECTED;
|
||||
int networkType = mServiceState.getDataNetworkType();
|
||||
NetworkRegistrationInfo regInfo =
|
||||
mServiceState.getNetworkRegistrationInfo(DOMAIN_PS, TRANSPORT_TYPE_WWAN);
|
||||
int networkType = regInfo == null ? TelephonyManager.NETWORK_TYPE_UNKNOWN
|
||||
: regInfo.getAccessNetworkTechnology();
|
||||
if (DEBUG) Log.d(TAG, String.format("Noting data connection for network type %s: %svisible",
|
||||
networkType, visible ? "" : "not "));
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user