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:
Weng Su
2022-01-11 06:44:40 +08:00
parent 7b5f806734
commit 7822750c31
30 changed files with 430 additions and 151 deletions

View File

@@ -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);