EnabledNetworkModePreferenceController Remove AllowedNetworkType

Power manager decision do enable/disable NR by AllowedNetworkType,
and it will effect the PreferredNetworkMode UI. The
PreferredNetworkMode list no 5G item when AllowedNetworkType
disabled.

Bug: 156709797
Test: make RunSettingsRoboTests ROBOTEST_FILTER=\
EnabledNetworkModePreferenceControllerTest  (pass)

Change-Id: I3ab9eca0956c4cce1b79e518942063b681eb96cd
This commit is contained in:
SongFerngWang
2020-05-28 20:37:51 +08:00
parent f5056a03e3
commit 259e6288c9
2 changed files with 3 additions and 85 deletions

View File

@@ -60,7 +60,6 @@ public class EnabledNetworkModePreferenceControllerTest {
private static final int SUB_ID = 2;
public static final String KEY = "enabled_network";
private static final long ALLOWED_ALL_NETWORK_TYPE = -1;
private static final long DISABLED_5G_NETWORK_TYPE = ~TelephonyManager.NETWORK_TYPE_BITMASK_NR;
@Mock
@@ -98,7 +97,6 @@ public class EnabledNetworkModePreferenceControllerTest {
doReturn(mPersistableBundle).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
mPreference = new ListPreference(mContext);
mController = new EnabledNetworkModePreferenceController(mContext, KEY);
mockAllowedNetworkTypes(ALLOWED_ALL_NETWORK_TYPE);
mockAccessFamily(TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
mController.init(mLifecycle, SUB_ID);
mPreference.setKey(mController.getPreferenceKey());
@@ -184,76 +182,6 @@ public class EnabledNetworkModePreferenceControllerTest {
TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA));
}
@Test
public void updateState_disAllowed5g_5gOptionHidden() {
mockEnabledNetworkMode(TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
mockAccessFamily(TelephonyManager.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
mockAllowedNetworkTypes(DISABLED_5G_NETWORK_TYPE);
mController.init(mLifecycle, SUB_ID);
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
mController.updateState(mPreference);
assertThat(mPreference.getEntryValues())
.asList()
.doesNotContain(
String.valueOf(TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA));
}
@Test
public void updateState_disAllowed5g_selectOn4gOption() {
mockEnabledNetworkMode(TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
mockAccessFamily(TelephonyManager.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
mockAllowedNetworkTypes(DISABLED_5G_NETWORK_TYPE);
mController.init(mLifecycle, SUB_ID);
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
mController.updateState(mPreference);
assertThat(mPreference.getValue()).isEqualTo(
String.valueOf(
TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA));
}
@Test
public void updateState_GlobalDisAllowed5g_GlobalWithoutNR() {
mockAccessFamily(TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA);
mockAllowedNetworkTypes(DISABLED_5G_NETWORK_TYPE);
mController.init(mLifecycle, SUB_ID);
mPersistableBundle.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
TelephonyManagerConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA);
mController.updateState(mPreference);
assertThat(mPreference.getEntryValues())
.asList()
.doesNotContain(
String.valueOf(TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA));
}
@Test
public void updateState_GlobalDisAllowed5g_SelectOnGlobal() {
mockAccessFamily(TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA);
mockAllowedNetworkTypes(DISABLED_5G_NETWORK_TYPE);
mController.init(mLifecycle, SUB_ID);
mPersistableBundle.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
TelephonyManagerConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA);
mController.updateState(mPreference);
assertThat(mPreference.getValue()).isEqualTo(
String.valueOf(
TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA));
}
@Test
public void updateState_updateByNetworkMode() {
mockEnabledNetworkMode(TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
@@ -351,10 +279,6 @@ public class EnabledNetworkModePreferenceControllerTest {
}
}
private void mockAllowedNetworkTypes(long allowedNetworkType) {
doReturn(allowedNetworkType).when(mTelephonyManager).getAllowedNetworkTypes();
}
private void mockAccessFamily(int networkMode) {
doReturn(MobileNetworkUtils.getRafFromNetworkType(networkMode))
.when(mTelephonyManager)