[Settings] Refactor MobileNetworkUtils

Code refactor MobileNetworkUtils
  - Access CarrierConfig API prior to Telephony API

Bug: 201757298
Test: presubmit pass
Change-Id: I0b9c05d1d45bdf26dd456172976a0994719fab86
This commit is contained in:
Bonian Chen
2021-10-15 15:04:07 +08:00
parent 96b9e1560a
commit e75cac81d6

View File

@@ -421,20 +421,21 @@ public class MobileNetworkUtils {
}
private static boolean isGsmBasicOptions(Context context, int subId) {
final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class)
.createForSubscriptionId(subId);
final PersistableBundle carrierConfig = context.getSystemService(
CarrierConfigManager.class).getConfigForSubId(subId);
if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
return true;
} else if (carrierConfig != null
if (carrierConfig != null
&& !carrierConfig.getBoolean(
CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL)
&& carrierConfig.getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL)) {
return true;
}
final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class)
.createForSubscriptionId(subId);
if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
return true;
}
return false;
}