From 51a1245def86369d6d3ae21e3c06dd86ee99d8d3 Mon Sep 17 00:00:00 2001 From: Bonian Chen Date: Fri, 15 Oct 2021 09:47:16 +0800 Subject: [PATCH] [Settings] Refactor MobileNetworkUtils Code refactor MobileNetworkUtils - Access CarrierConfig API prior to Telephony API Bug: 201757298 Test: presubmit pass Change-Id: I3a0de8bc9c9423cac6d146fdb20071e5526e74bd --- .../network/telephony/MobileNetworkUtils.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java index a5e4197968f..9049a2a300f 100644 --- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java +++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java @@ -355,21 +355,22 @@ public class MobileNetworkUtils { if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { return false; } - final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class) - .createForSubscriptionId(subId); + final PersistableBundle carrierConfig = context.getSystemService( CarrierConfigManager.class).getConfigForSubId(subId); - - - if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) { - 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_CDMA) { + return true; + } + if (isWorldMode(context, subId)) { final int settingsNetworkMode = getNetworkTypeFromRaf( (int) telephonyManager.getAllowedNetworkTypesForReason(