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

Commit eebc479a authored by Pengquan Meng's avatar Pengquan Meng
Browse files

Apply CDNR in SST

This add the CarrierDisplayNameResolver to SST. CDNR is eanbled only
when CarrierConfigManager#KEY_ENABLE_CARRIER_DISPLAY_NAME_RESOLVER_BOOL
is true.

This CL also refactored the OOS and Wifi-Calling override for SPN and
PLMN.

Bug: 122921456
Test: atest ServiceStateTrackerTest
Change-Id: Idbdfb56df6afd0eb9ca8711294bbb8d458ae97ba
parent 554b825b
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -40,7 +40,9 @@ public interface CarrierDisplayNameResolver {
            EF_SOURCE_RUIM,
            EF_SOURCE_VOICE_OPERATOR_SIGNALLING,
            EF_SOURCE_DATA_OPERATOR_SIGNALLING,
            EF_SOURCE_MODEM_CONFIG})
            EF_SOURCE_MODEM_CONFIG,
            EF_SOURCE_ERI
    })
    @interface EFSource {}

    int EF_SOURCE_DEFAULT = 0;
@@ -53,6 +55,7 @@ public interface CarrierDisplayNameResolver {
    int EF_SOURCE_VOICE_OPERATOR_SIGNALLING = 7;
    int EF_SOURCE_DATA_OPERATOR_SIGNALLING = 8;
    int EF_SOURCE_MODEM_CONFIG = 9;
    int EF_SOURCE_ERI = 10;

    /**
     * Update the service provider name for the registered PLMN.
@@ -171,4 +174,3 @@ public interface CarrierDisplayNameResolver {
    @NonNull
    String getServiceProviderName();
}
+89 −39
Original line number Diff line number Diff line
@@ -20,12 +20,15 @@ import android.annotation.NonNull;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.text.TextUtils;
import android.util.LocalLog;
import android.util.SparseArray;

import com.android.internal.telephony.uicc.IccRecords;
import com.android.internal.telephony.uicc.IccRecords.CarrierNameDisplayConditionBitmask;
import com.android.internal.telephony.uicc.IccRecords.OperatorPlmnInfo;
import com.android.internal.telephony.uicc.IccRecords.PlmnNetworkName;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.IndentingPrintWriter;

import java.util.Arrays;
import java.util.Collections;
@@ -52,8 +55,17 @@ public class CarrierDisplayNameResolverImpl implements CarrierDisplayNameResolve
    private final SparseArray<List<PlmnNetworkName>> mPlmnNetworkNames = new SparseArray<>();
    private final SparseArray<List<OperatorPlmnInfo>> mOperatorPlmns = new SparseArray<>();
    private final SparseArray<List<String>> mEhplmns = new SparseArray<>();
    private final LocalLog mLocalLog;

    private ServiceState mServiceState;
    private boolean mShouldShowServiceProviderName;
    private boolean mShouldShowPlmnNetworkName;
    private String mServiceProviderName;
    private String mPlmnNetworkName;
    private String mHomePlmn;

    /** {@code True} if any item is changed after the previous carrier name resolved. */
    private boolean mItemChanged;

    /**
     * The priority of ef source. Lower index means higher priority.
@@ -65,6 +77,7 @@ public class CarrierDisplayNameResolverImpl implements CarrierDisplayNameResolve
            Arrays.asList(
                    EF_SOURCE_CARRIER_API,
                    EF_SOURCE_CARRIER_CONFIG,
                    EF_SOURCE_ERI,
                    EF_SOURCE_USIM,
                    EF_SOURCE_SIM,
                    EF_SOURCE_CSIM,
@@ -74,96 +87,101 @@ public class CarrierDisplayNameResolverImpl implements CarrierDisplayNameResolve
                    EF_SOURCE_MODEM_CONFIG,
                    EF_SOURCE_DEFAULT);

    public CarrierDisplayNameResolverImpl() {
        int defaultSourcePriority = getSourcePriority(EF_SOURCE_DEFAULT);
        mServiceProviderNames.put(defaultSourcePriority, "");
        mSpdi.put(defaultSourcePriority, Collections.EMPTY_LIST);
        mCarrierNameDisplayConditionRules.put(defaultSourcePriority,
    public CarrierDisplayNameResolverImpl(LocalLog localLog) {
        mLocalLog = localLog;
        int key = getSourcePriority(EF_SOURCE_DEFAULT);
        mServiceProviderNames.put(key, "");
        mSpdi.put(key, Collections.EMPTY_LIST);
        mCarrierNameDisplayConditionRules.put(key,
                new CarrierDisplayNameConditionRule(
                        DEFAULT_CARRIER_NAME_DISPLAY_CONDITION_BITMASK));
        mPlmnNetworkNames.put(defaultSourcePriority, Collections.EMPTY_LIST);
        mOperatorPlmns.put(defaultSourcePriority, Collections.EMPTY_LIST);
        mEhplmns.put(defaultSourcePriority, Collections.EMPTY_LIST);
        mPlmnNetworkNames.put(key, Collections.EMPTY_LIST);
        mOperatorPlmns.put(key, Collections.EMPTY_LIST);
        mEhplmns.put(key, Collections.EMPTY_LIST);
    }

    @Override
    public void updateServiceProviderName(@EFSource int source, @NonNull String spn) {
    public void updateServiceProviderName(@EFSource int source, String spn) {
        if (TextUtils.isEmpty(spn)) return;
        mServiceProviderNames.put(getSourcePriority(source), spn);
        resolveCarrierDisplayName();
        mItemChanged = true;
    }

    @Override
    public void updateServiceProviderDisplayInformation(
            @EFSource int source, @NonNull List<String> spdi) {
        if (ArrayUtils.isEmpty(spdi)) return;
        mSpdi.put(getSourcePriority(source), spdi);
        resolveCarrierDisplayName();
        mItemChanged = true;
    }

    @Override
    public void updateServiceProviderNameDisplayCondition(
            @EFSource int source, int condition) {
            @EFSource int source, @CarrierNameDisplayConditionBitmask int condition) {
        if (condition == IccRecords.INVALID_CARRIER_NAME_DISPLAY_CONDITION_BITMASK) return;
        mCarrierNameDisplayConditionRules.put(getSourcePriority(source),
                new CarrierDisplayNameConditionRule(condition));
        resolveCarrierDisplayName();
        mItemChanged = true;
    }

    @Override
    public void updatePlmnNetworkNameList(
            @EFSource int source, @NonNull List<PlmnNetworkName> pnnList) {
        if (ArrayUtils.isEmpty(pnnList)) return;
        mPlmnNetworkNames.put(getSourcePriority(source), pnnList);
        resolveCarrierDisplayName();
        mItemChanged = true;
    }

    @Override
    public void updateEhplmnList(@EFSource int source, List<String> ehplmns) {
    public void updateEhplmnList(@EFSource int source, @NonNull List<String> ehplmns) {
        if (ArrayUtils.isEmpty(ehplmns)) return;
        mEhplmns.put(getSourcePriority(source), ehplmns);
        mItemChanged = true;
    }

    @Override
    public void updateServiceState(ServiceState serviceState) {
    public void updateServiceState(@NonNull ServiceState serviceState) {
        mServiceState = serviceState;
        resolveCarrierDisplayName();
        mItemChanged = true;
    }

    @Override
    public void updateOperatorPlmnList(
            @EFSource int source, @NonNull List<OperatorPlmnInfo> opl) {
    public void updateOperatorPlmnList(@EFSource int source, @NonNull List<OperatorPlmnInfo> opl) {
        if (ArrayUtils.isEmpty(opl)) return;
        mOperatorPlmns.put(getSourcePriority(source), opl);
        resolveCarrierDisplayName();
        mItemChanged = true;
    }

    @Override
    public void updateHomePlmnNumeric(@NonNull String homePlmnNumeric) {
        mHomePlmn = homePlmnNumeric;
        resolveCarrierDisplayName();
        mItemChanged = true;
    }

    @Override
    public boolean shouldShowPlmnNetworkName() {
        if (mItemChanged) resolveCarrierDisplayName();
        return mShouldShowPlmnNetworkName;
    }

    @Override
    public boolean shouldShowServiceProviderName() {
        if (mItemChanged) resolveCarrierDisplayName();
        return mShouldShowServiceProviderName;
    }

    @Override
    public String getPlmnNetworkName() {
        if (mItemChanged) resolveCarrierDisplayName();
        return mPlmnNetworkName;
    }

    @Override
    public String getServiceProviderName() {
        if (mItemChanged) resolveCarrierDisplayName();
        return mServiceProviderName;
    }

    private boolean mShouldShowServiceProviderName;
    private boolean mShouldShowPlmnNetworkName;
    private String mServiceProviderName;
    private String mPlmnNetworkName;
    private String mHomePlmn;

    private void resolveCarrierDisplayName() {
        if (mServiceState == null) return;

@@ -176,6 +194,7 @@ public class CarrierDisplayNameResolverImpl implements CarrierDisplayNameResolve
        // Currently use the roaming state from ServiceState.
        // EF_SPDI is only used when determine the service provider name and PLMN network name
        // display condition rule.
        // All the PLMNs will be considered HOME PLMNs if there is a brand override.
        boolean isRoaming = mServiceState.getRoaming() && !efSpdi.contains(registeredPlmnNumeric);
        mShouldShowServiceProviderName = displayRule.shouldShowSpn(isRoaming);
        mShouldShowPlmnNetworkName = displayRule.shouldShowPnn(isRoaming);
@@ -202,18 +221,49 @@ public class CarrierDisplayNameResolverImpl implements CarrierDisplayNameResolve
            mPlmnNetworkName = registeredPlmnNumeric;
        }

        if (DBG) {
            Rlog.d(TAG, "spnDisplayCondition = " + displayRule
                    + " ,isRoaming = " + isRoaming
        String logInfo = "isRoaming = " + isRoaming
                + " ,registeredPLMN = " + registeredPlmnNumeric
                + " ,displayRule = " + displayRule
                + " ,shouldShowPlmn = " + mShouldShowPlmnNetworkName
                + " ,plmn = " + mPlmnNetworkName
                + " ,shouldShowSpn = " + mShouldShowServiceProviderName
                + " ,spn = " + mServiceProviderName;
        if (DBG) Rlog.d(TAG, logInfo);
        mLocalLog.log(logInfo);

        mItemChanged = false;
    }

    @Override
    public String toString() {
        Boolean roamingFromSS = mServiceState != null ? mServiceState.getRoaming() : null;
        String registeredPLMN = mServiceState != null ? mServiceState.getOperatorNumeric() : null;
        return " { spnDisplayCondition = " + mCarrierNameDisplayConditionRules
                + " ,roamingFromSS = " + roamingFromSS
                + " ,registeredPLMN = " + registeredPLMN
                + " ,homePLMN = " + mHomePlmn
                + " ,spnList = " + mServiceProviderNames
                + " ,spnCondition " + mCarrierNameDisplayConditionRules
                + " ,spdiList = " + mSpdi
                + " ,pnnList = " + mPlmnNetworkNames
                + " ,oplList = " + mOperatorPlmns
                    + " ,ehplmn = " + mEhplmns);
                + " ,ehplmn = " + mEhplmns
                + " }";
    }

    /**
     * Dumps information for carrier display name resolver.
     * @param pw information printer.
     */
    public void dump(IndentingPrintWriter pw) {
        pw.println("CDNRImpl");
        pw.increaseIndent();
        pw.println("fields = " + toString());
        pw.println("shouldShowPlmn = " + mShouldShowPlmnNetworkName);
        pw.println("plmn= " + mPlmnNetworkName);
        pw.println("showShowSpn = " + mShouldShowServiceProviderName);
        pw.println("spn = " + mServiceProviderName);
        pw.decreaseIndent();
    }

    /**
+387 −27

File changed.

Preview size limit exceeded, changes collapsed.

+42 −0
Original line number Diff line number Diff line
@@ -198,6 +198,10 @@ public abstract class IccRecords extends Handler implements IccConstants {
    public static final int CARRIER_NAME_DISPLAY_CONDITION_BITMASK_PLMN = 1;
    public static final int CARRIER_NAME_DISPLAY_CONDITION_BITMASK_SPN = 2;


    // See {@link CarrierConfigManager#KEY_SPN_DISPLAY_CONDITION_OVERRIDE_INT}.
    public static final int INVALID_CARRIER_NAME_DISPLAY_CONDITION_BITMASK = -1;

    // Display SPN only and only if registered to Home PLMNs.
    // Display PLMN only and only if registered to Non-Home PLMNs.
    public static final int DEFAULT_CARRIER_NAME_DISPLAY_CONDITION = 0;
@@ -1121,6 +1125,44 @@ public abstract class IccRecords extends Handler implements IccConstants {
        return android.util.Base64.encodeToString(auth_rsp.payload, android.util.Base64.NO_WRAP);
    }

    /**
     * Convert the spn display condition to a bitmask
     * {@link com.android.internal.telephony.uicc.IccRecords.CarrierNameDisplayConditionBitmask}.
     *
     * b1 is the last bit of the display condition which is used to determine whether display of
     * PLMN network name is required when registered PLMN is **either** HPLMN or a PLMN in the
     * service provider PLMN list.
     *
     * b2 is the second last bit of the display condtion which is used to determine
     * whether display of Service Provider Name is required when registered PLMN is
     * **neither** HPLMN nor PLMN in the service provider PLMN list.
     *
     * Reference: 3GPP TS 31.102 section 4.2.12 EF_SPN
     *
     * @return a carrier name display condtion bitmask.
     */
    @CarrierNameDisplayConditionBitmask
    public static int convertSpnDisplayConditionToBitmask(int condition) {
        int carrierNameDisplayCondition = 0;
        // b1 = 0: display of registered PLMN name not required when registered PLMN is
        // either HPLMN or a PLMN in the service provider PLMN list.
        // b1 = 1: display of registered PLMN name required when registered PLMN is
        // either HPLMN or a PLMN in the service provider PLMN list.
        if ((condition & 0x1) == 0x1) {
            carrierNameDisplayCondition |= CARRIER_NAME_DISPLAY_CONDITION_BITMASK_PLMN;
        }

        // b2 = 0: display of the service provider name is **required** when registered
        // PLMN is neither HPLMN nor a PLMN in the service provider PLMN list.
        // b2 = 1: display of the servier provider name is **not required** when
        // registered PLMN is neither HPLMN nor PLMN in the service provider PLMN list.
        if ((condition & 0x2) == 0) {
            carrierNameDisplayCondition |= CARRIER_NAME_DISPLAY_CONDITION_BITMASK_SPN;
        }

        return carrierNameDisplayCondition;
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("IccRecords: " + this);
        pw.println(" mDestroyed=" + mDestroyed);
+2 −26
Original line number Diff line number Diff line
@@ -1698,32 +1698,8 @@ public class SIMRecords extends IccRecords {

                    // Reference: 3GPP TS 31.102 section 4.2.12 EF_SPN
                    // The first byte is display condition.
                    //
                    // b1 is the last bit of the display condition which is used to determine
                    // whether display of PLMN network name is required when registered PLMN is
                    // **either** HPLMN or a PLMN in the service provider PLMN list.
                    //
                    // b2 is the second last bit of the display condtion which is used to determine
                    // whether display of Service Provider Name is required when registered PLMN is
                    // **neither** HPLMN nor PLMN in the service provider PLMN list.
                    int displayCondition = data[0] & 0xff;
                    mCarrierNameDisplayCondition = 0;

                    // b1 = 0: display of registered PLMN name not required when registered PLMN is
                    // either HPLMN or a PLMN in the service provider PLMN list.
                    // b1 = 1: display of registered PLMN name required when registered PLMN is
                    // either HPLMN or a PLMN in the service provider PLMN list.
                    if ((displayCondition & 0x1) == 0x1) {
                        mCarrierNameDisplayCondition |= CARRIER_NAME_DISPLAY_CONDITION_BITMASK_PLMN;
                    }

                    // b2 = 0: display of the service provider name is **required** when registered
                    // PLMN is neither HPLMN nor a PLMN in the service provider PLMN list.
                    // b2 = 1: display of the servier provider name is **not required** when
                    // registered PLMN is neither HPLMN nor PLMN in the service provider PLMN list.
                    if ((displayCondition & 0x2) == 0) {
                        mCarrierNameDisplayCondition |= CARRIER_NAME_DISPLAY_CONDITION_BITMASK_SPN;
                    }
                    mCarrierNameDisplayCondition =
                            convertSpnDisplayConditionToBitmask(data[0] & 0xff);

                    setServiceProviderName(IccUtils.adnStringFieldToString(
                                data, 1, data.length - 1));
Loading