- 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
57 lines
1.9 KiB
Java
57 lines
1.9 KiB
Java
/*
|
|
* Copyright (C) 2019 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.telephony;
|
|
|
|
import android.content.Context;
|
|
import android.os.PersistableBundle;
|
|
import android.telephony.CarrierConfigManager;
|
|
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 CarrierConfigCache mCarrierConfigCache;
|
|
|
|
public CarrierSettingsVersionPreferenceController(Context context, String preferenceKey) {
|
|
super(context, preferenceKey);
|
|
mCarrierConfigCache = CarrierConfigCache.getInstance(context);
|
|
mSubscriptionId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
|
}
|
|
|
|
public void init(int subscriptionId) {
|
|
mSubscriptionId = subscriptionId;
|
|
}
|
|
|
|
@Override
|
|
public CharSequence getSummary() {
|
|
final PersistableBundle config = mCarrierConfigCache.getConfigForSubId(mSubscriptionId);
|
|
if (config == null) {
|
|
return null;
|
|
}
|
|
return config.getString(CarrierConfigManager.KEY_CARRIER_CONFIG_VERSION_STRING);
|
|
}
|
|
|
|
@Override
|
|
public int getAvailabilityStatus() {
|
|
return TextUtils.isEmpty(getSummary()) ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
|
|
}
|
|
}
|