Enable Carrier-Config cache for Settings
- Since the "Mobile-Data Details Settings" (NETWORK_OPERATOR_SETTINGS) will query Carrier-Config around 70 times during launching, use the Carrier-Config cache to reduce 69 times to speed up the launching time. - It takes about 3ms to query a Carrier-Config each time. - Create a singleton class to share the Carrier-Config for all sub-settings. Bug: 204135235 Test: manual test atest -c ApnPreferenceControllerTest \ AutoSelectPreferenceControllerTest \ BackupCallingPreferenceControllerTest \ CarrierConfigCacheTest \ CarrierPreferenceControllerTest \ CarrierSettingsVersionPreferenceControllerTest \ DataServiceSetupPreferenceControllerTest \ Enable2gPreferenceControllerTest \ EnabledNetworkModePreferenceControllerTest \ Enhanced4gBasePreferenceControllerTest \ MobileNetworkUtilsTest \ NetworkProviderBackupCallingGroupTest \ NrAdvancedCallingPreferenceControllerTest \ PreferredNetworkModePreferenceControllerTest \ TelephonyTogglePreferenceControllerTest \ WifiPickerTrackerHelperTest make RunSettingsRoboTests \ ROBOTEST_FILTER=ContactDiscoveryPreferenceControllerTest make RunSettingsRoboTests \ ROBOTEST_FILTER=VideoCallingPreferenceControllerTest Change-Id: I26f9ac115a754910b5d59e820703f1a0e701bb7f
This commit is contained in:
182
src/com/android/settings/network/CarrierConfigCache.java
Normal file
182
src/com/android/settings/network/CarrierConfigCache.java
Normal file
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.network;
|
||||
|
||||
import static android.telephony.CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED;
|
||||
import static android.telephony.SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX;
|
||||
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.TestApi;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.PersistableBundle;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.GuardedBy;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* This is a singleton class for Carrier-Configuration cache.
|
||||
*/
|
||||
public class CarrierConfigCache {
|
||||
private static final String TAG = "CarrConfCache";
|
||||
|
||||
private static final Object sInstanceLock = new Object();
|
||||
/**
|
||||
* A singleton {@link CarrierConfigCache} object is used to share with all sub-settings.
|
||||
*/
|
||||
@GuardedBy("sInstanceLock")
|
||||
private static CarrierConfigCache sInstance;
|
||||
@TestApi
|
||||
@GuardedBy("sInstanceLock")
|
||||
private static Map<Context, CarrierConfigCache> sTestInstances;
|
||||
|
||||
/**
|
||||
* Manages mapping data from the subscription ID to the Carrier-Configuration
|
||||
* {@link PersistableBundle} object.
|
||||
*
|
||||
* The Carrier-Configurations are used to share with all sub-settings.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
protected static final Map<Integer, PersistableBundle> sCarrierConfigs =
|
||||
new ConcurrentHashMap<>();
|
||||
@VisibleForTesting
|
||||
protected static CarrierConfigManager sCarrierConfigManager;
|
||||
|
||||
/**
|
||||
* Static method to create a singleton class for Carrier-Configuration cache.
|
||||
*
|
||||
* @param context The Context this is associated with.
|
||||
* @return an instance of {@link CarrierConfigCache} object.
|
||||
*/
|
||||
@NonNull
|
||||
public static CarrierConfigCache getInstance(@NonNull Context context) {
|
||||
synchronized (sInstanceLock) {
|
||||
if (sTestInstances != null && sTestInstances.containsKey(context)) {
|
||||
CarrierConfigCache testInstance = sTestInstances.get(context);
|
||||
Log.w(TAG, "The context owner try to use a test instance:" + testInstance);
|
||||
return testInstance;
|
||||
}
|
||||
|
||||
if (sInstance != null) return sInstance;
|
||||
|
||||
sInstance = new CarrierConfigCache();
|
||||
final CarrierConfigChangeReceiver receiver = new CarrierConfigChangeReceiver();
|
||||
final Context appContext = context.getApplicationContext();
|
||||
sCarrierConfigManager = appContext.getSystemService(CarrierConfigManager.class);
|
||||
appContext.registerReceiver(receiver, new IntentFilter(ACTION_CARRIER_CONFIG_CHANGED));
|
||||
return sInstance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A convenience method to set pre-prepared instance or mock(CarrierConfigCache.class) for
|
||||
* testing.
|
||||
*
|
||||
* @param context The Context this is associated with.
|
||||
* @param instance of {@link CarrierConfigCache} object.
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@VisibleForTesting
|
||||
public static void setTestInstance(@NonNull Context context, CarrierConfigCache instance) {
|
||||
synchronized (sInstanceLock) {
|
||||
if (sTestInstances == null) sTestInstances = new ConcurrentHashMap<>();
|
||||
|
||||
Log.w(TAG, "Try to set a test instance by context:" + context);
|
||||
sTestInstances.put(context, instance);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The constructor can only be accessed from static method inside the class itself, this is
|
||||
* to avoid creating a class by adding a private constructor.
|
||||
*/
|
||||
private CarrierConfigCache() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the boolean If the system service is successfully obtained.
|
||||
*
|
||||
* @return true value, if the system service is successfully obtained.
|
||||
*/
|
||||
public boolean hasCarrierConfigManager() {
|
||||
return (sCarrierConfigManager != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Carrier-Configuration for a particular subscription, which is associated with a
|
||||
* specific SIM card. If an invalid subId is used, the returned config will contain default
|
||||
* values.
|
||||
*
|
||||
* @param subId the subscription ID, normally obtained from {@link SubscriptionManager}.
|
||||
* @return A {@link PersistableBundle} containing the config for the given subId, or default
|
||||
* values for an invalid subId.
|
||||
*/
|
||||
public PersistableBundle getConfigForSubId(int subId) {
|
||||
if (sCarrierConfigManager == null) return null;
|
||||
|
||||
synchronized (sCarrierConfigs) {
|
||||
if (sCarrierConfigs.containsKey(subId)) {
|
||||
return sCarrierConfigs.get(subId);
|
||||
}
|
||||
final PersistableBundle config = sCarrierConfigManager.getConfigForSubId(subId);
|
||||
if (config == null) {
|
||||
Log.e(TAG, "Could not get carrier config, subId:" + subId);
|
||||
return null;
|
||||
}
|
||||
sCarrierConfigs.put(subId, config);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Carrier-Configuration for the default subscription.
|
||||
*
|
||||
* @see #getConfigForSubId
|
||||
*/
|
||||
public PersistableBundle getConfig() {
|
||||
if (sCarrierConfigManager == null) return null;
|
||||
|
||||
return getConfigForSubId(SubscriptionManager.getDefaultSubscriptionId());
|
||||
}
|
||||
|
||||
private static class CarrierConfigChangeReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (!ACTION_CARRIER_CONFIG_CHANGED.equals(intent.getAction())) return;
|
||||
|
||||
final int subId = intent.getIntExtra(EXTRA_SUBSCRIPTION_INDEX, INVALID_SUBSCRIPTION_ID);
|
||||
synchronized (sCarrierConfigs) {
|
||||
if (SubscriptionManager.isValidSubscriptionId(subId)) {
|
||||
sCarrierConfigs.remove(subId);
|
||||
} else {
|
||||
sCarrierConfigs.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -32,6 +32,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
import com.android.settings.network.apn.ApnSettings;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
@@ -46,19 +47,19 @@ public class ApnPreferenceController extends TelephonyBasePreferenceController i
|
||||
LifecycleObserver, OnStart, OnStop {
|
||||
|
||||
@VisibleForTesting
|
||||
CarrierConfigManager mCarrierConfigManager;
|
||||
CarrierConfigCache mCarrierConfigCache;
|
||||
private Preference mPreference;
|
||||
private DpcApnEnforcedObserver mDpcApnEnforcedObserver;
|
||||
|
||||
public ApnPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
|
||||
mCarrierConfigCache = CarrierConfigCache.getInstance(context);
|
||||
mDpcApnEnforcedObserver = new DpcApnEnforcedObserver(new Handler(Looper.getMainLooper()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus(int subId) {
|
||||
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
|
||||
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
|
||||
final boolean isCdmaApn = MobileNetworkUtils.isCdmaOptions(mContext, subId)
|
||||
&& carrierConfig != null
|
||||
&& carrierConfig.getBoolean(CarrierConfigManager.KEY_SHOW_APN_SETTING_CDMA_BOOL);
|
||||
|
@@ -28,17 +28,19 @@ import android.telephony.SubscriptionManager;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
|
||||
/**
|
||||
* Preference controller for "Carrier Settings"
|
||||
*/
|
||||
public class CarrierPreferenceController extends TelephonyBasePreferenceController {
|
||||
|
||||
@VisibleForTesting
|
||||
CarrierConfigManager mCarrierConfigManager;
|
||||
CarrierConfigCache mCarrierConfigCache;
|
||||
|
||||
public CarrierPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
|
||||
mCarrierConfigCache = CarrierConfigCache.getInstance(context);
|
||||
}
|
||||
|
||||
public void init(int subId) {
|
||||
@@ -47,7 +49,7 @@ public class CarrierPreferenceController extends TelephonyBasePreferenceControll
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus(int subId) {
|
||||
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
|
||||
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
|
||||
|
||||
// Return available if it is in CDMA or GSM mode, and the flag is on
|
||||
return carrierConfig != null
|
||||
@@ -72,7 +74,7 @@ public class CarrierPreferenceController extends TelephonyBasePreferenceControll
|
||||
}
|
||||
|
||||
private Intent getCarrierSettingsActivityIntent(int subId) {
|
||||
final PersistableBundle config = mCarrierConfigManager.getConfigForSubId(subId);
|
||||
final PersistableBundle config = mCarrierConfigCache.getConfigForSubId(subId);
|
||||
final ComponentName cn = ComponentName.unflattenFromString(
|
||||
config == null ? "" : config.getString(
|
||||
CarrierConfigManager.KEY_CARRIER_SETTINGS_ACTIVITY_COMPONENT_NAME_STRING,
|
||||
|
@@ -23,15 +23,16 @@ import android.telephony.SubscriptionManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
|
||||
public class CarrierSettingsVersionPreferenceController extends BasePreferenceController {
|
||||
|
||||
private int mSubscriptionId;
|
||||
private CarrierConfigManager mManager;
|
||||
private CarrierConfigCache mCarrierConfigCache;
|
||||
|
||||
public CarrierSettingsVersionPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mManager = context.getSystemService(CarrierConfigManager.class);
|
||||
mCarrierConfigCache = CarrierConfigCache.getInstance(context);
|
||||
mSubscriptionId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
}
|
||||
|
||||
@@ -41,7 +42,7 @@ public class CarrierSettingsVersionPreferenceController extends BasePreferenceCo
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
final PersistableBundle config = mManager.getConfigForSubId(mSubscriptionId);
|
||||
final PersistableBundle config = mCarrierConfigCache.getConfigForSubId(mSubscriptionId);
|
||||
if (config == null) {
|
||||
return null;
|
||||
}
|
||||
|
@@ -35,6 +35,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
import com.android.settings.network.SubscriptionUtil;
|
||||
|
||||
/**
|
||||
@@ -47,7 +48,7 @@ public class ContactDiscoveryPreferenceController extends TelephonyTogglePrefere
|
||||
Telephony.SimInfo.COLUMN_IMS_RCS_UCE_ENABLED);
|
||||
|
||||
private ImsManager mImsManager;
|
||||
private CarrierConfigManager mCarrierConfigManager;
|
||||
private CarrierConfigCache mCarrierConfigCache;
|
||||
private ContentObserver mUceSettingObserver;
|
||||
private FragmentManager mFragmentManager;
|
||||
|
||||
@@ -57,7 +58,7 @@ public class ContactDiscoveryPreferenceController extends TelephonyTogglePrefere
|
||||
public ContactDiscoveryPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mImsManager = mContext.getSystemService(ImsManager.class);
|
||||
mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);
|
||||
mCarrierConfigCache = CarrierConfigCache.getInstance(context);
|
||||
}
|
||||
|
||||
public ContactDiscoveryPreferenceController init(FragmentManager fragmentManager, int subId,
|
||||
@@ -96,7 +97,7 @@ public class ContactDiscoveryPreferenceController extends TelephonyTogglePrefere
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus(int subId) {
|
||||
PersistableBundle bundle = mCarrierConfigManager.getConfigForSubId(subId);
|
||||
PersistableBundle bundle = mCarrierConfigCache.getConfigForSubId(subId);
|
||||
boolean shouldShowPresence = bundle != null
|
||||
&& (bundle.getBoolean(
|
||||
CarrierConfigManager.KEY_USE_RCS_PRESENCE_BOOL, false /*default*/)
|
||||
|
@@ -28,18 +28,20 @@ import android.text.TextUtils;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
|
||||
/**
|
||||
* Preference controller for "Data service setup"
|
||||
*/
|
||||
public class DataServiceSetupPreferenceController extends TelephonyBasePreferenceController {
|
||||
|
||||
private CarrierConfigManager mCarrierConfigManager;
|
||||
private CarrierConfigCache mCarrierConfigCache;
|
||||
private TelephonyManager mTelephonyManager;
|
||||
private String mSetupUrl;
|
||||
|
||||
public DataServiceSetupPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
|
||||
mCarrierConfigCache = CarrierConfigCache.getInstance(context);
|
||||
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
||||
mSetupUrl = Settings.Global.getString(mContext.getContentResolver(),
|
||||
Settings.Global.SETUP_PREPAID_DATA_SERVICE_URL);
|
||||
@@ -47,7 +49,7 @@ public class DataServiceSetupPreferenceController extends TelephonyBasePreferenc
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus(int subId) {
|
||||
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
|
||||
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
|
||||
return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
|
||||
&& carrierConfig != null
|
||||
&& !carrierConfig.getBoolean(
|
||||
|
@@ -27,6 +27,7 @@ import android.util.Log;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
import com.android.settings.network.SubscriptionUtil;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
@@ -45,7 +46,7 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
|
||||
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
|
||||
private CarrierConfigManager mCarrierConfigManager;
|
||||
private CarrierConfigCache mCarrierConfigCache;
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private TelephonyManager mTelephonyManager;
|
||||
|
||||
@@ -57,7 +58,7 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
|
||||
*/
|
||||
public Enable2gPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
|
||||
mCarrierConfigCache = CarrierConfigCache.getInstance(context);
|
||||
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
|
||||
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
|
||||
}
|
||||
@@ -81,7 +82,7 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
|
||||
if (preference == null || !SubscriptionManager.isUsableSubscriptionId(mSubId)) {
|
||||
return;
|
||||
}
|
||||
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
|
||||
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(mSubId);
|
||||
boolean isDisabledByCarrier =
|
||||
carrierConfig != null
|
||||
&& carrierConfig.getBoolean(CarrierConfigManager.KEY_HIDE_ENABLE_2G);
|
||||
@@ -107,7 +108,7 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus(int subId) {
|
||||
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
|
||||
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
|
||||
if (mTelephonyManager == null) {
|
||||
Log.w(LOG_TAG, "Telephony manager not yet initialized");
|
||||
mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
|
||||
|
@@ -37,6 +37,7 @@ import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.network.AllowedNetworkTypesListener;
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
import com.android.settings.network.SubscriptionsChangeListener;
|
||||
import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
|
||||
|
||||
@@ -58,7 +59,7 @@ public class EnabledNetworkModePreferenceController extends
|
||||
private Preference mPreference;
|
||||
private PreferenceScreen mPreferenceScreen;
|
||||
private TelephonyManager mTelephonyManager;
|
||||
private CarrierConfigManager mCarrierConfigManager;
|
||||
private CarrierConfigCache mCarrierConfigCache;
|
||||
private PreferenceEntriesBuilder mBuilder;
|
||||
private SubscriptionsChangeListener mSubscriptionsListener;
|
||||
private int mCallState = TelephonyManager.CALL_STATE_IDLE;
|
||||
@@ -67,7 +68,7 @@ public class EnabledNetworkModePreferenceController extends
|
||||
public EnabledNetworkModePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mSubscriptionsListener = new SubscriptionsChangeListener(context, this);
|
||||
mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);
|
||||
mCarrierConfigCache = CarrierConfigCache.getInstance(context);
|
||||
if (mTelephonyCallback == null) {
|
||||
mTelephonyCallback = new PhoneCallStateTelephonyCallback();
|
||||
}
|
||||
@@ -80,7 +81,7 @@ public class EnabledNetworkModePreferenceController extends
|
||||
return AVAILABLE_UNSEARCHABLE;
|
||||
}
|
||||
|
||||
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
|
||||
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
|
||||
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||
visible = false;
|
||||
} else if (carrierConfig == null) {
|
||||
@@ -202,7 +203,7 @@ public class EnabledNetworkModePreferenceController extends
|
||||
}
|
||||
|
||||
private final class PreferenceEntriesBuilder {
|
||||
private CarrierConfigManager mCarrierConfigManager;
|
||||
private CarrierConfigCache mCarrierConfigCache;
|
||||
private Context mContext;
|
||||
private TelephonyManager mTelephonyManager;
|
||||
|
||||
@@ -221,7 +222,7 @@ public class EnabledNetworkModePreferenceController extends
|
||||
PreferenceEntriesBuilder(Context context, int subId) {
|
||||
this.mContext = context;
|
||||
this.mSubId = subId;
|
||||
mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);
|
||||
mCarrierConfigCache = CarrierConfigCache.getInstance(context);
|
||||
mTelephonyManager = mContext.getSystemService(TelephonyManager.class)
|
||||
.createForSubscriptionId(mSubId);
|
||||
updateConfig();
|
||||
@@ -229,7 +230,7 @@ public class EnabledNetworkModePreferenceController extends
|
||||
|
||||
public void updateConfig() {
|
||||
mTelephonyManager = mTelephonyManager.createForSubscriptionId(mSubId);
|
||||
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
|
||||
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(mSubId);
|
||||
mAllowed5gNetworkType = checkSupportedRadioBitmask(
|
||||
mTelephonyManager.getAllowedNetworkTypesForReason(
|
||||
TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_CARRIER),
|
||||
@@ -413,7 +414,7 @@ public class EnabledNetworkModePreferenceController extends
|
||||
private EnabledNetworks getEnabledNetworkType() {
|
||||
EnabledNetworks enabledNetworkType = EnabledNetworks.ENABLED_NETWORKS_UNKNOWN;
|
||||
final int phoneType = mTelephonyManager.getPhoneType();
|
||||
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
|
||||
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(mSubId);
|
||||
|
||||
if (phoneType == TelephonyManager.PHONE_TYPE_CDMA) {
|
||||
final int lteForced = android.provider.Settings.Global.getInt(
|
||||
|
@@ -75,6 +75,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
import com.android.settings.network.SubscriptionUtil;
|
||||
import com.android.settings.network.ims.WifiCallingQueryImsState;
|
||||
import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
|
||||
@@ -204,13 +205,12 @@ public class MobileNetworkUtils {
|
||||
* should be shown to the user, false if the option should be hidden.
|
||||
*/
|
||||
public static boolean isContactDiscoveryVisible(Context context, int subId) {
|
||||
CarrierConfigManager carrierConfigManager = context.getSystemService(
|
||||
CarrierConfigManager.class);
|
||||
if (carrierConfigManager == null) {
|
||||
CarrierConfigCache carrierConfigCache = CarrierConfigCache.getInstance(context);
|
||||
if (!carrierConfigCache.hasCarrierConfigManager()) {
|
||||
Log.w(TAG, "isContactDiscoveryVisible: Could not resolve carrier config");
|
||||
return false;
|
||||
}
|
||||
PersistableBundle bundle = carrierConfigManager.getConfigForSubId(subId);
|
||||
PersistableBundle bundle = carrierConfigCache.getConfigForSubId(subId);
|
||||
return bundle.getBoolean(
|
||||
CarrierConfigManager.KEY_USE_RCS_PRESENCE_BOOL, false /*default*/)
|
||||
|| bundle.getBoolean(CarrierConfigManager.Ims.KEY_RCS_BULK_CAPABILITY_EXCHANGE_BOOL,
|
||||
@@ -358,9 +358,8 @@ public class MobileNetworkUtils {
|
||||
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final PersistableBundle carrierConfig = context.getSystemService(
|
||||
CarrierConfigManager.class).getConfigForSubId(subId);
|
||||
final PersistableBundle carrierConfig =
|
||||
CarrierConfigCache.getInstance(context).getConfigForSubId(subId);
|
||||
if (carrierConfig != null
|
||||
&& !carrierConfig.getBoolean(
|
||||
CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL)
|
||||
@@ -424,8 +423,8 @@ public class MobileNetworkUtils {
|
||||
}
|
||||
|
||||
private static boolean isGsmBasicOptions(Context context, int subId) {
|
||||
final PersistableBundle carrierConfig = context.getSystemService(
|
||||
CarrierConfigManager.class).getConfigForSubId(subId);
|
||||
final PersistableBundle carrierConfig =
|
||||
CarrierConfigCache.getInstance(context).getConfigForSubId(subId);
|
||||
if (carrierConfig != null
|
||||
&& !carrierConfig.getBoolean(
|
||||
CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL)
|
||||
@@ -447,8 +446,8 @@ public class MobileNetworkUtils {
|
||||
* settings
|
||||
*/
|
||||
public static boolean isWorldMode(Context context, int subId) {
|
||||
final PersistableBundle carrierConfig = context.getSystemService(
|
||||
CarrierConfigManager.class).getConfigForSubId(subId);
|
||||
final PersistableBundle carrierConfig =
|
||||
CarrierConfigCache.getInstance(context).getConfigForSubId(subId);
|
||||
return carrierConfig == null
|
||||
? false
|
||||
: carrierConfig.getBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL);
|
||||
@@ -460,8 +459,8 @@ public class MobileNetworkUtils {
|
||||
public static boolean shouldDisplayNetworkSelectOptions(Context context, int subId) {
|
||||
final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class)
|
||||
.createForSubscriptionId(subId);
|
||||
final PersistableBundle carrierConfig = context.getSystemService(
|
||||
CarrierConfigManager.class).getConfigForSubId(subId);
|
||||
final PersistableBundle carrierConfig =
|
||||
CarrierConfigCache.getInstance(context).getConfigForSubId(subId);
|
||||
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID
|
||||
|| carrierConfig == null
|
||||
|| !carrierConfig.getBoolean(
|
||||
@@ -502,8 +501,7 @@ public class MobileNetworkUtils {
|
||||
|
||||
//TODO(b/117651939): move it to telephony
|
||||
private static boolean isTdscdmaSupported(Context context, TelephonyManager telephonyManager) {
|
||||
final PersistableBundle carrierConfig = context.getSystemService(
|
||||
CarrierConfigManager.class).getConfig();
|
||||
final PersistableBundle carrierConfig = CarrierConfigCache.getInstance(context).getConfig();
|
||||
|
||||
if (carrierConfig == null) {
|
||||
return false;
|
||||
|
@@ -26,6 +26,7 @@ import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
|
||||
|
||||
/**
|
||||
@@ -34,19 +35,18 @@ import com.android.settings.network.telephony.TelephonyConstants.TelephonyManage
|
||||
public class PreferredNetworkModePreferenceController extends TelephonyBasePreferenceController
|
||||
implements ListPreference.OnPreferenceChangeListener {
|
||||
|
||||
private CarrierConfigManager mCarrierConfigManager;
|
||||
private CarrierConfigCache mCarrierConfigCache;
|
||||
private TelephonyManager mTelephonyManager;
|
||||
private PersistableBundle mPersistableBundle;
|
||||
private boolean mIsGlobalCdma;
|
||||
|
||||
public PreferredNetworkModePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
|
||||
mCarrierConfigCache = CarrierConfigCache.getInstance(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus(int subId) {
|
||||
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
|
||||
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
|
||||
boolean visible;
|
||||
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||
visible = false;
|
||||
@@ -90,7 +90,7 @@ public class PreferredNetworkModePreferenceController extends TelephonyBasePrefe
|
||||
|
||||
public void init(int subId) {
|
||||
mSubId = subId;
|
||||
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
|
||||
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(mSubId);
|
||||
mTelephonyManager = mContext.getSystemService(TelephonyManager.class)
|
||||
.createForSubscriptionId(mSubId);
|
||||
|
||||
|
@@ -19,10 +19,10 @@ package com.android.settings.network.telephony;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.PersistableBundle;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.SubscriptionManager;
|
||||
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -82,9 +82,7 @@ public abstract class TelephonyTogglePreferenceController extends TogglePreferen
|
||||
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
|
||||
return null;
|
||||
}
|
||||
final CarrierConfigManager carrierConfigMgr =
|
||||
mContext.getSystemService(CarrierConfigManager.class);
|
||||
return carrierConfigMgr.getConfigForSubId(subId);
|
||||
return CarrierConfigCache.getInstance(mContext).getConfigForSubId(subId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -30,6 +30,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
import com.android.settings.network.MobileDataEnabledListener;
|
||||
import com.android.settings.network.ims.VolteQueryImsState;
|
||||
import com.android.settings.network.ims.VtQueryImsState;
|
||||
@@ -48,7 +49,6 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC
|
||||
private static final String TAG = "VideoCallingPreference";
|
||||
|
||||
private Preference mPreference;
|
||||
private CarrierConfigManager mCarrierConfigManager;
|
||||
private PhoneTelephonyCallback mTelephonyCallback;
|
||||
@VisibleForTesting
|
||||
Integer mCallState;
|
||||
@@ -56,7 +56,6 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC
|
||||
|
||||
public VideoCallingPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
|
||||
mDataContentObserver = new MobileDataEnabledListener(context, this);
|
||||
mTelephonyCallback = new PhoneTelephonyCallback();
|
||||
}
|
||||
@@ -142,17 +141,8 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC
|
||||
return false;
|
||||
}
|
||||
|
||||
// When called within Settings Search, this variable may still be null.
|
||||
if (mCarrierConfigManager == null) {
|
||||
Log.e(TAG, "CarrierConfigManager set to null.");
|
||||
mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);
|
||||
if (mCarrierConfigManager == null) {
|
||||
Log.e(TAG, "Unable to reinitialize CarrierConfigManager.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
|
||||
final PersistableBundle carrierConfig =
|
||||
CarrierConfigCache.getInstance(mContext).getConfigForSubId(subId);
|
||||
if (carrierConfig == null) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -43,6 +43,7 @@ import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.network.AllowedNetworkTypesListener;
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
import com.android.settings.network.telephony.MobileNetworkUtils;
|
||||
import com.android.settings.network.telephony.TelephonyTogglePreferenceController;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
@@ -191,8 +192,8 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon
|
||||
mSubId = subId;
|
||||
mTelephonyManager = mContext.getSystemService(TelephonyManager.class)
|
||||
.createForSubscriptionId(mSubId);
|
||||
final PersistableBundle carrierConfig = mContext.getSystemService(
|
||||
CarrierConfigManager.class).getConfigForSubId(mSubId);
|
||||
final PersistableBundle carrierConfig =
|
||||
CarrierConfigCache.getInstance(mContext).getConfigForSubId(mSubId);
|
||||
mOnlyAutoSelectInHome = carrierConfig != null
|
||||
? carrierConfig.getBoolean(
|
||||
CarrierConfigManager.KEY_ONLY_AUTO_SELECT_IN_HOME_NETWORK_BOOL)
|
||||
|
Reference in New Issue
Block a user