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 Original line Diff line number Diff line
@@ -124,13 +124,6 @@ public class CarrierPrivilegesTracker extends Handler {
                    | PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS
                    | PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS
                    | PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_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.
     * Action to register a Registrant with this Tracker.
     * obj: Registrant that will be notified of Carrier Privileged UID changes.
     * obj: Registrant that will be notified of Carrier Privileged UID changes.
@@ -469,13 +462,9 @@ public class CarrierPrivilegesTracker extends Handler {


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

        // CarrierConfigManager#isConfigForIdentifiedCarrier can handle null or empty bundle
        // CarrierConfigManager#isConfigForIdentifiedCarrier can handle null or empty bundle
        if (!mCarrierConfigManager.isConfigForIdentifiedCarrier(carrierConfigs)) {
        if (!mCarrierConfigManager.isConfigForIdentifiedCarrier(carrierConfigs)) {
            return Collections.EMPTY_LIST;
            return Collections.EMPTY_LIST;
+6 −13
Original line number Original line Diff line number Diff line
@@ -571,7 +571,9 @@ public class DataServiceManager extends Handler {
        // Read package name from resource overlay
        // Read package name from resource overlay
        packageName = mPhone.getContext().getResources().getString(resourceId);
        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 (!b.isEmpty() && !TextUtils.isEmpty(b.getString(carrierConfig))) {
            // If carrier config overrides it, use the one from carrier config
            // If carrier config overrides it, use the one from carrier config
            packageName = b.getString(carrierConfig, packageName);
            packageName = b.getString(carrierConfig, packageName);
@@ -619,7 +621,9 @@ public class DataServiceManager extends Handler {
        // Read package name from resource overlay
        // Read package name from resource overlay
        className = mPhone.getContext().getResources().getString(resourceId);
        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 (!b.isEmpty() && !TextUtils.isEmpty(b.getString(carrierConfig))) {
            // If carrier config overrides it, use the one from carrier config
            // If carrier config overrides it, use the one from carrier config
            className = b.getString(carrierConfig, className);
            className = b.getString(carrierConfig, className);
@@ -628,17 +632,6 @@ public class DataServiceManager extends Handler {
        return className;
        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) {
    private void sendCompleteMessage(Message msg, @DataServiceCallback.ResultCode int code) {
        if (msg != null) {
        if (msg != null) {
            msg.arg1 = code;
            msg.arg1 = code;
+6 −20
Original line number Original line Diff line number Diff line
@@ -186,7 +186,9 @@ public class EmergencyNumberTracker extends Handler {
            CarrierConfigManager configMgr = (CarrierConfigManager)
            CarrierConfigManager configMgr = (CarrierConfigManager)
                    mPhone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
                    mPhone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
            if (configMgr != null) {
            if (configMgr != null) {
                PersistableBundle b = getCarrierConfigSubset(
                PersistableBundle b = CarrierConfigManager.getCarrierConfigSubset(
                        mPhone.getContext(),
                        mPhoneId,
                        CarrierConfigManager.KEY_EMERGENCY_NUMBER_PREFIX_STRING_ARRAY);
                        CarrierConfigManager.KEY_EMERGENCY_NUMBER_PREFIX_STRING_ARRAY);
                if (!b.isEmpty()) {
                if (!b.isEmpty()) {
                    mEmergencyNumberPrefix = b.getStringArray(
                    mEmergencyNumberPrefix = b.getStringArray(
@@ -355,7 +357,9 @@ public class EmergencyNumberTracker extends Handler {
            if (slotIndex != mPhone.getPhoneId()) return;
            if (slotIndex != mPhone.getPhoneId()) return;


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


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


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


        PersistableBundle config =
        PersistableBundle config =
                getCarrierConfigSubset(
                CarrierConfigManager.getCarrierConfigSubset(
                        subId, CarrierConfigManager.KEY_SIM_COUNTRY_ISO_OVERRIDE_STRING);
                        mContext, subId, CarrierConfigManager.KEY_SIM_COUNTRY_ISO_OVERRIDE_STRING);
        if (config.isEmpty()) {
        if (config.isEmpty()) {
            loge("handleSimCountryIsoOverride: fail to get carrier configs.");
            loge("handleSimCountryIsoOverride: fail to get carrier configs.");
            return;
            return;
@@ -1817,17 +1817,6 @@ public class UiccProfile extends IccCard {
        return null;
        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) {
    private static String eventToString(int event) {
        switch (event) {
        switch (event) {
            case EVENT_RADIO_OFF_OR_UNAVAILABLE: return "RADIO_OFF_OR_UNAVAILABLE";
            case EVENT_RADIO_OFF_OR_UNAVAILABLE: return "RADIO_OFF_OR_UNAVAILABLE";