Merge "Change the condition for showing "no connection"" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7429fd1315
@@ -24,6 +24,8 @@ import android.graphics.Color;
|
|||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.telephony.AccessNetworkConstants;
|
||||||
|
import android.telephony.NetworkRegistrationInfo;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SignalStrength;
|
import android.telephony.SignalStrength;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
@@ -106,7 +108,12 @@ public class ProviderModelSliceHelper {
|
|||||||
* @return whether the ServiceState's data state is in-service.
|
* @return whether the ServiceState's data state is in-service.
|
||||||
*/
|
*/
|
||||||
public boolean isDataStateInService() {
|
public boolean isDataStateInService() {
|
||||||
return mTelephonyManager.getDataState() == mTelephonyManager.DATA_CONNECTED;
|
final ServiceState serviceState = mTelephonyManager.getServiceState();
|
||||||
|
NetworkRegistrationInfo regInfo =
|
||||||
|
(serviceState == null) ? null : serviceState.getNetworkRegistrationInfo(
|
||||||
|
NetworkRegistrationInfo.DOMAIN_PS,
|
||||||
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||||
|
return (regInfo == null) ? false : regInfo.isRegistered();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -31,6 +31,8 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.telephony.AccessNetworkConstants;
|
||||||
|
import android.telephony.NetworkRegistrationInfo;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SignalStrength;
|
import android.telephony.SignalStrength;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
@@ -274,9 +276,16 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
|||||||
if (!tmForSubId.isDataEnabled()) {
|
if (!tmForSubId.isDataEnabled()) {
|
||||||
return mContext.getString(R.string.mobile_data_off_summary);
|
return mContext.getString(R.string.mobile_data_off_summary);
|
||||||
}
|
}
|
||||||
|
final ServiceState serviceState = tmForSubId.getServiceState();
|
||||||
|
final NetworkRegistrationInfo regInfo = (serviceState == null)
|
||||||
|
? null
|
||||||
|
: serviceState.getNetworkRegistrationInfo(
|
||||||
|
NetworkRegistrationInfo.DOMAIN_PS,
|
||||||
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||||
|
|
||||||
final boolean isDataInService = tmForSubId.getDataState()
|
final boolean isDataInService = (regInfo == null)
|
||||||
== TelephonyManager.DATA_CONNECTED;
|
? false
|
||||||
|
: regInfo.isRegistered();
|
||||||
final boolean isCarrierNetworkActive =
|
final boolean isCarrierNetworkActive =
|
||||||
(mWifiPickerTrackerHelper != null)
|
(mWifiPickerTrackerHelper != null)
|
||||||
&& mWifiPickerTrackerHelper.isCarrierNetworkActive();
|
&& mWifiPickerTrackerHelper.isCarrierNetworkActive();
|
||||||
@@ -311,9 +320,16 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
|||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean isDataInService = tmForSubId.getDataState()
|
|
||||||
== TelephonyManager.DATA_CONNECTED;
|
|
||||||
final ServiceState serviceState = tmForSubId.getServiceState();
|
final ServiceState serviceState = tmForSubId.getServiceState();
|
||||||
|
final NetworkRegistrationInfo regInfo = (serviceState == null)
|
||||||
|
? null
|
||||||
|
: serviceState.getNetworkRegistrationInfo(
|
||||||
|
NetworkRegistrationInfo.DOMAIN_PS,
|
||||||
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||||
|
|
||||||
|
final boolean isDataInService = (regInfo == null)
|
||||||
|
? false
|
||||||
|
: regInfo.isRegistered();
|
||||||
final boolean isVoiceInService = (serviceState == null)
|
final boolean isVoiceInService = (serviceState == null)
|
||||||
? false
|
? false
|
||||||
: (serviceState.getState() == ServiceState.STATE_IN_SERVICE);
|
: (serviceState.getState() == ServiceState.STATE_IN_SERVICE);
|
||||||
|
@@ -35,7 +35,9 @@ import android.net.NetworkCapabilities;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.PersistableBundle;
|
import android.os.PersistableBundle;
|
||||||
|
import android.telephony.AccessNetworkConstants;
|
||||||
import android.telephony.CarrierConfigManager;
|
import android.telephony.CarrierConfigManager;
|
||||||
|
import android.telephony.NetworkRegistrationInfo;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
@@ -169,7 +171,7 @@ public class ProviderModelSliceHelperTest {
|
|||||||
CharSequence expectedSubtitle = Html.fromHtml("5G", Html.FROM_HTML_MODE_LEGACY);
|
CharSequence expectedSubtitle = Html.fromHtml("5G", Html.FROM_HTML_MODE_LEGACY);
|
||||||
String networkType = "5G";
|
String networkType = "5G";
|
||||||
mockConnections(true, ServiceState.STATE_IN_SERVICE, expectDisplayName,
|
mockConnections(true, ServiceState.STATE_IN_SERVICE, expectDisplayName,
|
||||||
mTelephonyManager.DATA_CONNECTED, true);
|
true, true);
|
||||||
addNetworkTransportType(NetworkCapabilities.TRANSPORT_WIFI);
|
addNetworkTransportType(NetworkCapabilities.TRANSPORT_WIFI);
|
||||||
|
|
||||||
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
|
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
|
||||||
@@ -189,7 +191,7 @@ public class ProviderModelSliceHelperTest {
|
|||||||
"preference_summary_default_combination", connectedText, networkType),
|
"preference_summary_default_combination", connectedText, networkType),
|
||||||
Html.FROM_HTML_MODE_LEGACY);
|
Html.FROM_HTML_MODE_LEGACY);
|
||||||
mockConnections(true, ServiceState.STATE_IN_SERVICE, expectDisplayName,
|
mockConnections(true, ServiceState.STATE_IN_SERVICE, expectDisplayName,
|
||||||
mTelephonyManager.DATA_CONNECTED, true);
|
true, true);
|
||||||
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
|
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
|
||||||
|
|
||||||
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
|
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
|
||||||
@@ -208,7 +210,7 @@ public class ProviderModelSliceHelperTest {
|
|||||||
String networkType = "";
|
String networkType = "";
|
||||||
|
|
||||||
mockConnections(true, ServiceState.STATE_OUT_OF_SERVICE, expectDisplayName,
|
mockConnections(true, ServiceState.STATE_OUT_OF_SERVICE, expectDisplayName,
|
||||||
mTelephonyManager.DATA_DISCONNECTED, false);
|
false, false);
|
||||||
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
|
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
|
||||||
|
|
||||||
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
|
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
|
||||||
@@ -221,7 +223,7 @@ public class ProviderModelSliceHelperTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getMobileDrawable_noCarrierData_getMobileDrawable() throws Throwable {
|
public void getMobileDrawable_noCarrierData_getMobileDrawable() throws Throwable {
|
||||||
mockConnections(false, ServiceState.STATE_OUT_OF_SERVICE, "",
|
mockConnections(false, ServiceState.STATE_OUT_OF_SERVICE, "",
|
||||||
mTelephonyManager.DATA_DISCONNECTED, true);
|
false, true);
|
||||||
when(mConnectivityManager.getActiveNetwork()).thenReturn(null);
|
when(mConnectivityManager.getActiveNetwork()).thenReturn(null);
|
||||||
Drawable expectDrawable = mock(Drawable.class);
|
Drawable expectDrawable = mock(Drawable.class);
|
||||||
|
|
||||||
@@ -232,7 +234,7 @@ public class ProviderModelSliceHelperTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getMobileDrawable_hasCarrierDataAndDataIsOnCellular_getMobileDrawable()
|
public void getMobileDrawable_hasCarrierDataAndDataIsOnCellular_getMobileDrawable()
|
||||||
throws Throwable {
|
throws Throwable {
|
||||||
mockConnections(true, ServiceState.STATE_IN_SERVICE, "", mTelephonyManager.DATA_CONNECTED,
|
mockConnections(true, ServiceState.STATE_IN_SERVICE, "", true,
|
||||||
true);
|
true);
|
||||||
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
|
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
|
||||||
Drawable drawable = mock(Drawable.class);
|
Drawable drawable = mock(Drawable.class);
|
||||||
@@ -246,7 +248,7 @@ public class ProviderModelSliceHelperTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getMobileDrawable_hasCarrierDataAndDataIsOnWifi_getMobileDrawable()
|
public void getMobileDrawable_hasCarrierDataAndDataIsOnWifi_getMobileDrawable()
|
||||||
throws Throwable {
|
throws Throwable {
|
||||||
mockConnections(true, ServiceState.STATE_IN_SERVICE, "", mTelephonyManager.DATA_CONNECTED,
|
mockConnections(true, ServiceState.STATE_IN_SERVICE, "", true,
|
||||||
true);
|
true);
|
||||||
Drawable drawable = mock(Drawable.class);
|
Drawable drawable = mock(Drawable.class);
|
||||||
addNetworkTransportType(NetworkCapabilities.TRANSPORT_WIFI);
|
addNetworkTransportType(NetworkCapabilities.TRANSPORT_WIFI);
|
||||||
@@ -263,12 +265,22 @@ public class ProviderModelSliceHelperTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void mockConnections(boolean isDataEnabled, int serviceState, String expectDisplayName,
|
private void mockConnections(boolean isDataEnabled, int serviceState, String expectDisplayName,
|
||||||
int getDataState, boolean isWifiEnabled) {
|
boolean dataRegState, boolean isWifiEnabled) {
|
||||||
when(mTelephonyManager.isDataEnabled()).thenReturn(isDataEnabled);
|
when(mTelephonyManager.isDataEnabled()).thenReturn(isDataEnabled);
|
||||||
when(mWifiManager.isWifiEnabled()).thenReturn(isWifiEnabled);
|
when(mWifiManager.isWifiEnabled()).thenReturn(isWifiEnabled);
|
||||||
when(mTelephonyManager.getDataState()).thenReturn(getDataState);
|
|
||||||
|
|
||||||
when(mServiceState.getState()).thenReturn(serviceState);
|
when(mServiceState.getState()).thenReturn(serviceState);
|
||||||
|
|
||||||
|
NetworkRegistrationInfo regInfo = new NetworkRegistrationInfo.Builder()
|
||||||
|
.setDomain(NetworkRegistrationInfo.DOMAIN_PS)
|
||||||
|
.setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
|
||||||
|
.setRegistrationState(dataRegState ? NetworkRegistrationInfo.REGISTRATION_STATE_HOME
|
||||||
|
: NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_SEARCHING)
|
||||||
|
.setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
|
||||||
|
.build();
|
||||||
|
when(mServiceState.getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS,
|
||||||
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN)).thenReturn(regInfo);
|
||||||
|
|
||||||
when(mDefaultDataSubscriptionInfo.getDisplayName()).thenReturn(expectDisplayName);
|
when(mDefaultDataSubscriptionInfo.getDisplayName()).thenReturn(expectDisplayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,6 +42,8 @@ import android.net.NetworkCapabilities;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.telephony.AccessNetworkConstants;
|
||||||
|
import android.telephony.NetworkRegistrationInfo;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SignalStrength;
|
import android.telephony.SignalStrength;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
@@ -430,7 +432,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), true, true,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), true, true,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
||||||
@@ -451,7 +453,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(true));
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(true));
|
||||||
@@ -476,7 +478,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, false,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, false,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
||||||
|
|
||||||
@@ -496,7 +498,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
||||||
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
|
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
|
||||||
@@ -532,7 +534,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), true, true,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), true, true,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
||||||
@@ -558,7 +560,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
||||||
@@ -585,7 +587,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
||||||
TelephonyManager.DATA_DISCONNECTED, ServiceState.STATE_OUT_OF_SERVICE);
|
false, ServiceState.STATE_OUT_OF_SERVICE);
|
||||||
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
||||||
@@ -665,7 +667,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
Drawable icon = mock(Drawable.class);
|
Drawable icon = mock(Drawable.class);
|
||||||
doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false));
|
doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false));
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), true, true,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), true, true,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
|
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
@@ -683,7 +685,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
Drawable icon = mock(Drawable.class);
|
Drawable icon = mock(Drawable.class);
|
||||||
doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false));
|
doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false));
|
||||||
setupGetIconConditions(subId, false, true,
|
setupGetIconConditions(subId, false, true,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
Drawable actualIcon = mPreferenceCategory.getPreference(0).getIcon();
|
Drawable actualIcon = mPreferenceCategory.getPreference(0).getIcon();
|
||||||
@@ -702,12 +704,22 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false));
|
doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false));
|
||||||
|
|
||||||
setupGetIconConditions(subId, false, false,
|
setupGetIconConditions(subId, false, false,
|
||||||
TelephonyManager.DATA_DISCONNECTED, ServiceState.STATE_IN_SERVICE);
|
false, ServiceState.STATE_IN_SERVICE);
|
||||||
|
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
Drawable actualIcon = mPreferenceCategory.getPreference(0).getIcon();
|
Drawable actualIcon = mPreferenceCategory.getPreference(0).getIcon();
|
||||||
doReturn(TelephonyManager.DATA_CONNECTED).when(mTelephonyManagerForSub).getDataState();
|
ServiceState ss = mock(ServiceState.class);
|
||||||
|
NetworkRegistrationInfo regInfo = new NetworkRegistrationInfo.Builder()
|
||||||
|
.setDomain(NetworkRegistrationInfo.DOMAIN_PS)
|
||||||
|
.setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
|
||||||
|
.setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
|
||||||
|
.setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
|
||||||
|
.build();
|
||||||
|
doReturn(ss).when(mTelephonyManagerForSub).getServiceState();
|
||||||
|
doReturn(regInfo).when(ss).getNetworkRegistrationInfo(
|
||||||
|
NetworkRegistrationInfo.DOMAIN_PS,
|
||||||
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||||
|
|
||||||
assertThat(icon).isEqualTo(actualIcon);
|
assertThat(icon).isEqualTo(actualIcon);
|
||||||
}
|
}
|
||||||
@@ -733,14 +745,23 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupGetIconConditions(int subId, boolean isActiveCellularNetwork,
|
private void setupGetIconConditions(int subId, boolean isActiveCellularNetwork,
|
||||||
boolean isDataEnable, int dataState, int servicestate) {
|
boolean isDataEnable, boolean dataState, int servicestate) {
|
||||||
doReturn(mTelephonyManagerForSub).when(mTelephonyManager).createForSubscriptionId(subId);
|
doReturn(mTelephonyManagerForSub).when(mTelephonyManager).createForSubscriptionId(subId);
|
||||||
doReturn(isActiveCellularNetwork).when(sInjector).isActiveCellularNetwork(mContext);
|
doReturn(isActiveCellularNetwork).when(sInjector).isActiveCellularNetwork(mContext);
|
||||||
doReturn(isDataEnable).when(mTelephonyManagerForSub).isDataEnabled();
|
doReturn(isDataEnable).when(mTelephonyManagerForSub).isDataEnabled();
|
||||||
doReturn(dataState).when(mTelephonyManagerForSub).getDataState();
|
|
||||||
ServiceState ss = mock(ServiceState.class);
|
ServiceState ss = mock(ServiceState.class);
|
||||||
|
NetworkRegistrationInfo regInfo = new NetworkRegistrationInfo.Builder()
|
||||||
|
.setDomain(NetworkRegistrationInfo.DOMAIN_PS)
|
||||||
|
.setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
|
||||||
|
.setRegistrationState(dataState ? NetworkRegistrationInfo.REGISTRATION_STATE_HOME
|
||||||
|
: NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_SEARCHING)
|
||||||
|
.setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
|
||||||
|
.build();
|
||||||
doReturn(ss).when(mTelephonyManagerForSub).getServiceState();
|
doReturn(ss).when(mTelephonyManagerForSub).getServiceState();
|
||||||
doReturn(servicestate).when(ss).getState();
|
doReturn(servicestate).when(ss).getState();
|
||||||
|
doReturn(regInfo).when(ss).getNetworkRegistrationInfo(
|
||||||
|
NetworkRegistrationInfo.DOMAIN_PS,
|
||||||
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SubscriptionInfo> setupMockSubscriptions(int count) {
|
private List<SubscriptionInfo> setupMockSubscriptions(int count) {
|
||||||
|
Reference in New Issue
Block a user