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

Commit 8541c04f authored by Rambo Wang's avatar Rambo Wang Committed by Automerger Merge Worker
Browse files

Merge "Update telephony lib components to remove dupplication" into main am: b18d9d6e

parents c5dfab09 b18d9d6e
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
@@ -127,13 +127,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.
@@ -472,13 +465,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 −21
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.internal.telephony.emergency;

import android.annotation.NonNull;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -166,7 +165,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(),
                        mPhone.getSubId(),
                        CarrierConfigManager.KEY_EMERGENCY_NUMBER_PREFIX_STRING_ARRAY);
                if (!b.isEmpty()) {
                    mEmergencyNumberPrefix = b.getStringArray(
@@ -332,7 +333,9 @@ public class EmergencyNumberTracker extends Handler {
            if (slotIndex != mPhone.getPhoneId()) return;

            PersistableBundle b =
                    getCarrierConfigSubset(
                    CarrierConfigManager.getCarrierConfigSubset(
                            mPhone.getContext(),
                            mPhone.getSubId(),
                            CarrierConfigManager.KEY_EMERGENCY_NUMBER_PREFIX_STRING_ARRAY);
            if (!b.isEmpty()) {
                String[] emergencyNumberPrefix =
@@ -348,24 +351,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
@@ -992,15 +992,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";