Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 112a2e60 authored by Rambo Wang's avatar Rambo Wang Committed by Android (Google) Code Review
Browse files

Merge "Update telephony lib components to remove dupplication"

parents dd886588 3867a2b7
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
@@ -124,13 +124,6 @@ public class CarrierPrivilegesTracker extends Handler {
                    | PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS
                    | PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS;

    /**
     * All carrier config keys used in this class should list here in alphabetical order.
     */
    private static final String[] CARRIER_CONFIG_KEYS = {
            KEY_CARRIER_CERTIFICATE_STRING_ARRAY,
    };

    /**
     * Action to register a Registrant with this Tracker.
     * obj: Registrant that will be notified of Carrier Privileged UID changes.
@@ -469,13 +462,9 @@ public class CarrierPrivilegesTracker extends Handler {

    @NonNull
    private List<UiccAccessRule> getCarrierConfigRules(int subId) {
        PersistableBundle carrierConfigs = null;
        try {
            carrierConfigs = mCarrierConfigManager.getConfigForSubId(subId, CARRIER_CONFIG_KEYS);
        } catch (RuntimeException e) {
            mLocalLog.log("CarrierConfigLoader is not available, try it later.");
        }

        PersistableBundle carrierConfigs =
                CarrierConfigManager.getCarrierConfigSubset(
                        mContext, subId, KEY_CARRIER_CERTIFICATE_STRING_ARRAY);
        // CarrierConfigManager#isConfigForIdentifiedCarrier can handle null or empty bundle
        if (!mCarrierConfigManager.isConfigForIdentifiedCarrier(carrierConfigs)) {
            return Collections.EMPTY_LIST;
+6 −13
Original line number Diff line number Diff line
@@ -571,7 +571,9 @@ public class DataServiceManager extends Handler {
        // Read package name from resource overlay
        packageName = mPhone.getContext().getResources().getString(resourceId);

        PersistableBundle b = getCarrierConfigSubset(carrierConfig);
        PersistableBundle b =
                CarrierConfigManager.getCarrierConfigSubset(
                        mPhone.getContext(), mPhone.getSubId(), carrierConfig);
        if (!b.isEmpty() && !TextUtils.isEmpty(b.getString(carrierConfig))) {
            // If carrier config overrides it, use the one from carrier config
            packageName = b.getString(carrierConfig, packageName);
@@ -619,7 +621,9 @@ public class DataServiceManager extends Handler {
        // Read package name from resource overlay
        className = mPhone.getContext().getResources().getString(resourceId);

        PersistableBundle b = getCarrierConfigSubset(carrierConfig);
        PersistableBundle b =
                CarrierConfigManager.getCarrierConfigSubset(
                        mPhone.getContext(), mPhone.getSubId(), carrierConfig);
        if (!b.isEmpty() && !TextUtils.isEmpty(b.getString(carrierConfig))) {
            // If carrier config overrides it, use the one from carrier config
            className = b.getString(carrierConfig, className);
@@ -628,17 +632,6 @@ public class DataServiceManager extends Handler {
        return className;
    }

    @NonNull
    private PersistableBundle getCarrierConfigSubset(String key) {
        PersistableBundle configs = null;
        try {
            configs = mCarrierConfigManager.getConfigForSubId(mPhone.getSubId(), key);
        } catch (RuntimeException e) {
            loge("CarrierConfigLoader is not available.");
        }
        return configs != null ? configs : new PersistableBundle();
    }

    private void sendCompleteMessage(Message msg, @DataServiceCallback.ResultCode int code) {
        if (msg != null) {
            msg.arg1 = code;
+6 −20
Original line number Diff line number Diff line
@@ -186,7 +186,9 @@ public class EmergencyNumberTracker extends Handler {
            CarrierConfigManager configMgr = (CarrierConfigManager)
                    mPhone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
            if (configMgr != null) {
                PersistableBundle b = getCarrierConfigSubset(
                PersistableBundle b = CarrierConfigManager.getCarrierConfigSubset(
                        mPhone.getContext(),
                        mPhoneId,
                        CarrierConfigManager.KEY_EMERGENCY_NUMBER_PREFIX_STRING_ARRAY);
                if (!b.isEmpty()) {
                    mEmergencyNumberPrefix = b.getStringArray(
@@ -355,7 +357,9 @@ public class EmergencyNumberTracker extends Handler {
            if (slotIndex != mPhone.getPhoneId()) return;

            PersistableBundle b =
                    getCarrierConfigSubset(
                    CarrierConfigManager.getCarrierConfigSubset(
                            mPhone.getContext(),
                            mPhone.getPhoneId(),
                            CarrierConfigManager.KEY_EMERGENCY_NUMBER_PREFIX_STRING_ARRAY);
            if (!b.isEmpty()) {
                String[] emergencyNumberPrefix =
@@ -371,24 +375,6 @@ public class EmergencyNumberTracker extends Handler {
        }
    }

    @NonNull
    private PersistableBundle getCarrierConfigSubset(String key) {
        PersistableBundle bundle = null;

        if (mPhone != null) {
            CarrierConfigManager ccm =
                    mPhone.getContext().getSystemService(CarrierConfigManager.class);
            try {
                if (ccm != null) {
                    bundle = ccm.getConfigForSubId(mPhone.getPhoneId(), key);
                }
            } catch (RuntimeException e) {
                loge("CarrierConfigLoader is not available.");
            }
        }
        return bundle != null ? bundle : new PersistableBundle();
    }

    private String getInitialCountryIso() {
        if (mPhone != null) {
            ServiceStateTracker sst = mPhone.getServiceStateTracker();
+7 −9
Original line number Diff line number Diff line
@@ -991,15 +991,13 @@ public class PinStorage extends Handler {
        PersistableBundle config = null;
        CarrierConfigManager configManager =
                mContext.getSystemService(CarrierConfigManager.class);
        if (configManager != null) {
        Phone phone = PhoneFactory.getPhone(slotId);
            try {
                // If an invalid subId is used, this bundle will contain default values.
                config = configManager.getConfigForSubId(phone.getSubId(),
        if (configManager != null && phone != null) {
            config =
                    CarrierConfigManager.getCarrierConfigSubset(
                            mContext,
                            phone.getSubId(),
                            CarrierConfigManager.KEY_STORE_SIM_PIN_FOR_UNATTENDED_REBOOT_BOOL);
            } catch (RuntimeException e) {
                loge("Can't get carrier config subset.");
            }
        }
        if (config == null || config.isEmpty()) {
            config = CarrierConfigManager.getDefaultConfig();
+4 −15
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static com.android.internal.telephony.TelephonyStatsLog.PIN_STORAGE_EVENT
import static com.android.internal.telephony.TelephonyStatsLog.PIN_STORAGE_EVENT__EVENT__PIN_VERIFICATION_FAILURE;
import static com.android.internal.telephony.TelephonyStatsLog.PIN_STORAGE_EVENT__EVENT__PIN_VERIFICATION_SUCCESS;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.usage.UsageStatsManager;
@@ -462,7 +461,8 @@ public class UiccProfile extends IccCard {
        }

        PersistableBundle config =
                getCarrierConfigSubset(
                CarrierConfigManager.getCarrierConfigSubset(
                        mContext,
                        subId,
                        CarrierConfigManager.KEY_CARRIER_NAME_OVERRIDE_BOOL,
                        CarrierConfigManager.KEY_CARRIER_NAME_STRING);
@@ -534,8 +534,8 @@ public class UiccProfile extends IccCard {
        }

        PersistableBundle config =
                getCarrierConfigSubset(
                        subId, CarrierConfigManager.KEY_SIM_COUNTRY_ISO_OVERRIDE_STRING);
                CarrierConfigManager.getCarrierConfigSubset(
                        mContext, subId, CarrierConfigManager.KEY_SIM_COUNTRY_ISO_OVERRIDE_STRING);
        if (config.isEmpty()) {
            loge("handleSimCountryIsoOverride: fail to get carrier configs.");
            return;
@@ -1817,17 +1817,6 @@ public class UiccProfile extends IccCard {
        return null;
    }

    @NonNull
    private PersistableBundle getCarrierConfigSubset(int subId, String... keys) {
        PersistableBundle bundle = null;
        try {
            bundle = mCarrierConfigManager.getConfigForSubId(subId, keys);
        } catch (RuntimeException e) {
            loge("CarrierConfigLoader is not available.");
        }
        return bundle != null ? bundle : new PersistableBundle();
    }

    private static String eventToString(int event) {
        switch (event) {
            case EVENT_RADIO_OFF_OR_UNAVAILABLE: return "RADIO_OFF_OR_UNAVAILABLE";