Revert "EnabledNetworkModePreferenceController Remove AllowedNetworkType"
This reverts commit 259e6288c9
.
Reason for revert: Sooraj will implement another API for power manager.
Bug: 156709797
Change-Id: I15ee2799574cdf0318e593500f0dbfbf135d71f8
This commit is contained in:
@@ -168,6 +168,7 @@ public class EnabledNetworkModePreferenceController extends
|
||||
private Context mContext;
|
||||
private TelephonyManager mTelephonyManager;
|
||||
|
||||
private boolean mAllowed5gNetworkType;
|
||||
private boolean mIsGlobalCdma;
|
||||
private boolean mIs5gEntryDisplayed;
|
||||
private boolean mShow4gForLTE;
|
||||
@@ -205,6 +206,9 @@ public class EnabledNetworkModePreferenceController extends
|
||||
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
|
||||
final boolean isNrEnabledFromCarrierConfig = carrierConfig != null
|
||||
&& carrierConfig.getBoolean(CarrierConfigManager.KEY_NR_ENABLED_BOOL);
|
||||
mAllowed5gNetworkType = checkSupportedRadioBitmask(
|
||||
mTelephonyManager.getAllowedNetworkTypes(),
|
||||
TelephonyManager.NETWORK_TYPE_BITMASK_NR);
|
||||
mSupported5gRadioAccessFamily = isNrEnabledFromCarrierConfig
|
||||
&& checkSupportedRadioBitmask(mTelephonyManager.getSupportedRadioAccessFamily(),
|
||||
TelephonyManager.NETWORK_TYPE_BITMASK_NR);
|
||||
@@ -568,7 +572,7 @@ public class EnabledNetworkModePreferenceController extends
|
||||
}
|
||||
|
||||
/**
|
||||
* Add 5G option. Only show the UI when device supported 5G.
|
||||
* Add 5G option. Only show the UI when device supported 5G and allowed 5G.
|
||||
*/
|
||||
private void add5gEntry(int value) {
|
||||
boolean isNRValue = value >= TelephonyManagerConstants.NETWORK_MODE_NR_ONLY;
|
||||
@@ -581,13 +585,15 @@ public class EnabledNetworkModePreferenceController extends
|
||||
mIs5gEntryDisplayed = false;
|
||||
Log.d(LOG_TAG, "Hide 5G option. "
|
||||
+ " supported5GRadioAccessFamily: " + mSupported5gRadioAccessFamily
|
||||
+ " allowed5GNetworkType: " + mAllowed5gNetworkType
|
||||
+ " isNRValue: " + isNRValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void addGlobalEntry() {
|
||||
Log.d(LOG_TAG, "addGlobalEntry. "
|
||||
+ " supported5GRadioAccessFamily: " + mSupported5gRadioAccessFamily);
|
||||
+ " supported5GRadioAccessFamily: " + mSupported5gRadioAccessFamily
|
||||
+ " allowed5GNetworkType: " + mAllowed5gNetworkType);
|
||||
mEntries.add(mContext.getString(R.string.network_global));
|
||||
if (showNrList()) {
|
||||
mEntriesValue.add(
|
||||
@@ -599,7 +605,7 @@ public class EnabledNetworkModePreferenceController extends
|
||||
}
|
||||
|
||||
private boolean showNrList() {
|
||||
return mSupported5gRadioAccessFamily;
|
||||
return mSupported5gRadioAccessFamily && mAllowed5gNetworkType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -60,6 +60,7 @@ 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
|
||||
@@ -97,6 +98,7 @@ 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());
|
||||
@@ -182,6 +184,76 @@ 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);
|
||||
@@ -279,6 +351,10 @@ public class EnabledNetworkModePreferenceControllerTest {
|
||||
}
|
||||
}
|
||||
|
||||
private void mockAllowedNetworkTypes(long allowedNetworkType) {
|
||||
doReturn(allowedNetworkType).when(mTelephonyManager).getAllowedNetworkTypes();
|
||||
}
|
||||
|
||||
private void mockAccessFamily(int networkMode) {
|
||||
doReturn(MobileNetworkUtils.getRafFromNetworkType(networkMode))
|
||||
.when(mTelephonyManager)
|
||||
|
Reference in New Issue
Block a user