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

@@ -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,