Merge "Hide network select in some situations" into qt-dev
This commit is contained in:
@@ -277,8 +277,7 @@ public class MobileNetworkUtils {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA
|
if (shouldSpeciallyUpdateGsmCdma(context, subId)) {
|
||||||
&& !isTdscdmaSupported(context, telephonyManager)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -296,16 +295,15 @@ public class MobileNetworkUtils {
|
|||||||
if (isGsmBasicOptions(context, subId)) {
|
if (isGsmBasicOptions(context, subId)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final int settingsNetworkMode = android.provider.Settings.Global.getInt(
|
final int networkMode = android.provider.Settings.Global.getInt(
|
||||||
context.getContentResolver(),
|
context.getContentResolver(),
|
||||||
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
|
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
|
||||||
Phone.PREFERRED_NT_MODE);
|
Phone.PREFERRED_NT_MODE);
|
||||||
if (isWorldMode(context, subId)) {
|
if (isWorldMode(context, subId)) {
|
||||||
if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO
|
if (networkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO
|
||||||
|| settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
|
|| networkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
|
||||||
return true;
|
return true;
|
||||||
} else if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA
|
} else if (shouldSpeciallyUpdateGsmCdma(context, subId)) {
|
||||||
&& !MobileNetworkUtils.isTdscdmaSupported(context, subId)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -362,16 +360,24 @@ public class MobileNetworkUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final int networkMode = android.provider.Settings.Global.getInt(
|
||||||
|
context.getContentResolver(),
|
||||||
|
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
|
||||||
|
Phone.PREFERRED_NT_MODE);
|
||||||
|
if (networkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO
|
||||||
|
&& isWorldMode(context, subId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (shouldSpeciallyUpdateGsmCdma(context, subId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (isGsmBasicOptions(context, subId)) {
|
if (isGsmBasicOptions(context, subId)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int settingsNetworkMode = android.provider.Settings.Global.getInt(
|
|
||||||
context.getContentResolver(),
|
|
||||||
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
|
|
||||||
Phone.PREFERRED_NT_MODE);
|
|
||||||
if (isWorldMode(context, subId)) {
|
if (isWorldMode(context, subId)) {
|
||||||
if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
|
if (networkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -414,7 +420,6 @@ public class MobileNetworkUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return subId that supported by search. If there are more than one, return first one,
|
* Return subId that supported by search. If there are more than one, return first one,
|
||||||
* otherwise return {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID}
|
* otherwise return {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID}
|
||||||
@@ -461,4 +466,33 @@ public class MobileNetworkUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is migrated from {@link com.android.phone.MobileNetworkSettings} and we should
|
||||||
|
* use it carefully. This code snippet doesn't have very clear meaning however we should
|
||||||
|
* update GSM or CDMA differently based on what it returns.
|
||||||
|
*
|
||||||
|
* 1. For all CDMA settings, make them visible if it return {@code true}
|
||||||
|
* 2. For GSM settings, make them visible if it return {@code true} unless 3
|
||||||
|
* 3. For network select settings, make it invisible if it return {@code true}
|
||||||
|
*/
|
||||||
|
@VisibleForTesting
|
||||||
|
static boolean shouldSpeciallyUpdateGsmCdma(Context context, int subId) {
|
||||||
|
final int networkMode = android.provider.Settings.Global.getInt(
|
||||||
|
context.getContentResolver(),
|
||||||
|
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
|
||||||
|
Phone.PREFERRED_NT_MODE);
|
||||||
|
if (networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM
|
||||||
|
|| networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA
|
||||||
|
|| networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA
|
||||||
|
|| networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_WCDMA
|
||||||
|
|| networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA
|
||||||
|
|| networkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA) {
|
||||||
|
if (!isTdscdmaSupported(context, subId) && isWorldMode(context, subId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -219,4 +219,86 @@ public class MobileNetworkUtilsTest {
|
|||||||
assertThat(MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, SUB_ID_1))
|
assertThat(MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, SUB_ID_1))
|
||||||
.isTrue();
|
.isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldSpeciallyUpdateGsmCdma_notWorldMode_returnFalse() {
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, false);
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
|
||||||
|
|
||||||
|
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldSpeciallyUpdateGsmCdma_supportTdscdma_returnFalse() {
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, true);
|
||||||
|
|
||||||
|
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaGsm_returnTrue() {
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
|
||||||
|
|
||||||
|
Settings.Global.putInt(mContext.getContentResolver(),
|
||||||
|
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
|
||||||
|
TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM);
|
||||||
|
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaGsmWcdma_returnTrue() {
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
|
||||||
|
|
||||||
|
Settings.Global.putInt(mContext.getContentResolver(),
|
||||||
|
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
|
||||||
|
TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA);
|
||||||
|
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdma_returnTrue() {
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
|
||||||
|
|
||||||
|
Settings.Global.putInt(mContext.getContentResolver(),
|
||||||
|
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
|
||||||
|
TelephonyManager.NETWORK_MODE_LTE_TDSCDMA);
|
||||||
|
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaWcdma_returnTrue() {
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
|
||||||
|
|
||||||
|
Settings.Global.putInt(mContext.getContentResolver(),
|
||||||
|
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
|
||||||
|
TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_WCDMA);
|
||||||
|
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaCdmaEvdoGsmWcdma_returnTrue() {
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
|
||||||
|
|
||||||
|
Settings.Global.putInt(mContext.getContentResolver(),
|
||||||
|
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
|
||||||
|
TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA);
|
||||||
|
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldSpeciallyUpdateGsmCdma_ModeLteCdmaEvdoGsmWcdma_returnTrue() {
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
|
||||||
|
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
|
||||||
|
|
||||||
|
Settings.Global.putInt(mContext.getContentResolver(),
|
||||||
|
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
|
||||||
|
TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
|
||||||
|
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user