[Settings] Refactor Telephony PreferenceController

Refactor TelephonyBasePreferenceController and TelephonyTogglePreferenceController

Bug: 150352656
Test: make
Change-Id: I3d52054fd9fbc5597db6266686d155a12d5a88d6
This commit is contained in:
Bonian Chen
2020-03-12 17:34:20 +08:00
parent 291ff22d7b
commit b7891e879f
3 changed files with 44 additions and 3 deletions

View File

@@ -17,6 +17,8 @@
package com.android.settings.network.telephony;
import android.content.Context;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import com.android.settings.core.BasePreferenceController;
@@ -37,4 +39,20 @@ public abstract class TelephonyBasePreferenceController extends BasePreferenceCo
public int getAvailabilityStatus() {
return MobileNetworkUtils.getAvailability(mContext, mSubId, this::getAvailabilityStatus);
}
/**
* Get carrier config based on specific subscription id.
*
* @param subId is the subscription id
* @return {@link PersistableBundle} of carrier config, or {@code null} when carrier config
* is not available.
*/
public PersistableBundle getCarrierConfigForSubId(int subId) {
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
return null;
}
final CarrierConfigManager carrierConfigMgr =
mContext.getSystemService(CarrierConfigManager.class);
return carrierConfigMgr.getConfigForSubId(subId);
}
}