From e75cac81d6a94c45b0e488a17ac18c3ab90357ff Mon Sep 17 00:00:00 2001 From: Bonian Chen Date: Fri, 15 Oct 2021 15:04:07 +0800 Subject: [PATCH] [Settings] Refactor MobileNetworkUtils Code refactor MobileNetworkUtils - Access CarrierConfig API prior to Telephony API Bug: 201757298 Test: presubmit pass Change-Id: I0b9c05d1d45bdf26dd456172976a0994719fab86 --- .../network/telephony/MobileNetworkUtils.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java index 9049a2a300f..894eb68ebf7 100644 --- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java +++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java @@ -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; }