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

Commit 84e67f38 authored by Muralidhar Reddy Mule's avatar Muralidhar Reddy Mule Committed by Android (Google) Code Review
Browse files

Merge "Clean up usage of multiple MEP flags in uicc module." into udc-dev

parents 0eb34adc a274cb8f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -58,6 +58,10 @@ public class IccSlotStatus {
        public boolean isMepA1Mode() {
            return this == MEP_A1;
        }

        public boolean isMepMode() {
            return this != NONE;
        }
    }

    public IccCardStatus.CardState  cardState;
+4 −10
Original line number Diff line number Diff line
@@ -52,19 +52,16 @@ public class UiccCard {
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private CardState mCardState;
    protected String mCardId;
    protected boolean mIsSupportsMultipleEnabledProfiles;
    protected MultipleEnabledProfilesMode mSupportedMepMode;

    protected LinkedHashMap<Integer, UiccPort> mUiccPorts = new LinkedHashMap<>();
    private HashMap<Integer, Integer> mPhoneIdToPortIdx = new HashMap<>();

    public UiccCard(Context c, CommandsInterface ci, IccCardStatus ics, int phoneId, Object lock,
            boolean isSupportsMultipleEnabledProfiles,
            MultipleEnabledProfilesMode supportedMepMode) {
        if (DBG) log("Creating");
        mCardState = ics.mCardState;
        mLock = lock;
        mIsSupportsMultipleEnabledProfiles = isSupportsMultipleEnabledProfiles;
        mSupportedMepMode = supportedMepMode;
        update(c, ci, ics, phoneId);
    }
@@ -115,7 +112,7 @@ public class UiccCard {
                if (port == null) {
                    if (this instanceof EuiccCard) {
                        port = new EuiccPort(c, ci, ics, phoneId, mLock, this,
                                mIsSupportsMultipleEnabledProfiles, mSupportedMepMode); // eSim
                                mSupportedMepMode); // eSim
                    } else {
                        port = new UiccPort(c, ci, ics, phoneId, mLock, this); // pSim
                    }
@@ -149,15 +146,12 @@ public class UiccCard {


    /**
     * Updates MEP(Multiple Enabled Profile) support and supported mode flags.
     * Updates MEP(Multiple Enabled Profile) supported mode flag.
     *
     * <p>If IccSlotStatus comes later, the number of ports reported is only known after the
     * UiccCard creation which will impact UICC MEP capability.
     */
    public void updateSupportMepProperties(boolean supported,
            MultipleEnabledProfilesMode supportedMepMode) {
        // TODO(b/262449536): Handle with single MEP flag to avoid inconsistency.
        mIsSupportsMultipleEnabledProfiles = supported;
    public void updateSupportedMepMode(MultipleEnabledProfilesMode supportedMepMode) {
        mSupportedMepMode = supportedMepMode;
    }

@@ -224,7 +218,7 @@ public class UiccCard {
        pw.println(" mCardState=" + mCardState);
        pw.println(" mCardId=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, mCardId));
        pw.println(" mNumberOfPorts=" + mUiccPorts.size());
        pw.println( "mIsSupportsMultipleEnabledProfiles=" + mIsSupportsMultipleEnabledProfiles);
        pw.println(" mSupportedMepMode=" + mSupportedMepMode);
        pw.println();
        for (UiccPort uiccPort : mUiccPorts.values()) {
            uiccPort.dump(fd, pw, args);
+27 −12
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.WindowManager;

import com.android.internal.R;
@@ -123,7 +124,7 @@ public class UiccSlot extends Handler {
            mIsRemovable = isSlotRemovable(slotIndex);
            // Update supported MEP mode in IccCardStatus if the CardState is present.
            if (ics.mCardState.isCardPresent()) {
                mSupportedMepMode = ics.mSupportedMepMode;
                updateSupportedMepMode(ics.mSupportedMepMode);
            }

            int radioState = ci.getRadioState();
@@ -160,7 +161,7 @@ public class UiccSlot extends Handler {

                if (!mIsEuicc) {
                    // Uicc does not support MEP, passing false by default.
                    mUiccCard = new UiccCard(mContext, ci, ics, phoneId, mLock, false,
                    mUiccCard = new UiccCard(mContext, ci, ics, phoneId, mLock,
                            MultipleEnabledProfilesMode.NONE);
                } else {
                    // The EID should be reported with the card status, but in case it's not we want
@@ -171,7 +172,7 @@ public class UiccSlot extends Handler {
                    }
                    if (mUiccCard == null) {
                        mUiccCard = new EuiccCard(mContext, ci, ics, phoneId, mLock,
                                isMultipleEnabledProfileSupported(), getSupportedMepMode());
                                getSupportedMepMode());
                    } else {
                        // In MEP case, UiccCard instance is already created, just call update API.
                        // UiccPort initialization is handled inside UiccCard.
@@ -196,7 +197,6 @@ public class UiccSlot extends Handler {
            parseAtr(iss.atr);
            mEid = iss.eid;
            mIsRemovable = isSlotRemovable(slotIndex);
            mSupportedMepMode = iss.mSupportedMepMode;

            for (int i = 0; i < simPortInfos.length; i++) {
                int phoneId = iss.mSimPortInfos[i].mLogicalSlotIndex;
@@ -248,11 +248,28 @@ public class UiccSlot extends Handler {
                mPortIdxToPhoneId.put(i, simPortInfos[i].mPortActive ?
                        simPortInfos[i].mLogicalSlotIndex : INVALID_PHONE_ID);
            }
            // Since the MEP capability is related with number ports reported, thus need to
            updateSupportedMepMode(iss.mSupportedMepMode);
            // Since the MEP capability is related to supported MEP mode, thus need to
            // update the flag after UiccCard creation.
            if (mUiccCard != null) {
                mUiccCard.updateSupportMepProperties(isMultipleEnabledProfileSupported(),
                        getSupportedMepMode());
                mUiccCard.updateSupportedMepMode(getSupportedMepMode());
            }
        }
    }

    private void updateSupportedMepMode(MultipleEnabledProfilesMode mode) {
        mSupportedMepMode = mode;
        // If SupportedMepMode is MultipleEnabledProfilesMode.NONE, validate ATR and
        // num of ports to handle backward compatibility for < RADIO_HAL_VERSION_2_1.
        if (mode == MultipleEnabledProfilesMode.NONE) {
            // Even ATR suggest UICC supports multiple enabled profiles, MEP can be disabled per
            // carrier restrictions, so checking the real number of ports reported from modem is
            // necessary.
            if (mPortIdxToPhoneId.size() > 1
                    && mAtr != null && mAtr.isMultipleEnabledProfilesSupported()) {
                // Set MEP-B mode in case if modem sends wrong mode even though supports MEP.
                Log.i(TAG, "Modem does not send proper supported MEP mode or older HAL version");
                mSupportedMepMode = MultipleEnabledProfilesMode.MEP_B;
            }
        }
    }
@@ -326,11 +343,9 @@ public class UiccSlot extends Handler {

    /* Returns true if multiple enabled profiles are supported */
    public boolean isMultipleEnabledProfileSupported() {
        // even ATR suggest UICC supports multiple enabled profiles, MEP can be disabled per
        // carrier restrictions, so checking the real number of ports reported from modem is
        // necessary.
        return mPortIdxToPhoneId.size() > 1 && mAtr != null &&
                mAtr.isMultipleEnabledProfilesSupported();
        synchronized (mLock) {
            return mSupportedMepMode.isMepMode();
        }
    }

    private boolean absentStateUpdateNeeded(CardState oldState, int portIndex) {
+5 −8
Original line number Diff line number Diff line
@@ -44,9 +44,8 @@ public class EuiccCard extends UiccCard {
    private RegistrantList mEidReadyRegistrants;

    public EuiccCard(Context c, CommandsInterface ci, IccCardStatus ics, int phoneId, Object lock,
            boolean isSupportsMultipleEnabledProfiles,
            MultipleEnabledProfilesMode supportedMepMode) {
        super(c, ci, ics, phoneId, lock, isSupportsMultipleEnabledProfiles, supportedMepMode);
        super(c, ci, ics, phoneId, lock, supportedMepMode);
        if (TextUtils.isEmpty(ics.eid)) {
            loge("no eid given in constructor for phone " + phoneId);
            loadEidAndNotifyRegistrants();
@@ -57,19 +56,17 @@ public class EuiccCard extends UiccCard {
    }

    /**
     * Updates MEP(Multiple Enabled Profile) support flag.
     * Updates MEP(Multiple Enabled Profile) supported mode flag.
     *
     * <p>If IccSlotStatus comes later, the number of ports reported is only known after the
     * UiccCard creation which will impact UICC MEP capability.
     * UiccCard creation which will impact UICC MEP capability in case of old HAL version.
     */
    @Override
    public void updateSupportMepProperties(boolean supported,
            MultipleEnabledProfilesMode supportedMepMode) {
        mIsSupportsMultipleEnabledProfiles = supported;
    public void updateSupportedMepMode(MultipleEnabledProfilesMode supportedMepMode) {
        mSupportedMepMode = supportedMepMode;
        for (UiccPort port : mUiccPorts.values()) {
            if (port instanceof EuiccPort) {
                ((EuiccPort) port).updateSupportMepProperties(supported, supportedMepMode);
                ((EuiccPort) port).updateSupportedMepMode(supportedMepMode);
            } else {
                loge("eUICC card has non-euicc port object:" + port.toString());
            }
+8 −13
Original line number Diff line number Diff line
@@ -126,12 +126,10 @@ public class EuiccPort extends UiccPort {
    private EuiccSpecVersion mSpecVersion;
    private volatile String mEid;
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    public boolean mIsSupportsMultipleEnabledProfiles;
    private MultipleEnabledProfilesMode mSupportedMepMode;
    public MultipleEnabledProfilesMode mSupportedMepMode;

    public EuiccPort(Context c, CommandsInterface ci, IccCardStatus ics, int phoneId, Object lock,
            UiccCard card, boolean isSupportsMultipleEnabledProfiles,
            MultipleEnabledProfilesMode supportedMepMode) {
            UiccCard card, MultipleEnabledProfilesMode supportedMepMode) {
        super(c, ci, ics, phoneId, lock, card);
        // TODO: Set supportExtendedApdu based on ATR.
        mApduSender = new ApduSender(ci, ISD_R_AID, false /* supportExtendedApdu */);
@@ -141,7 +139,6 @@ public class EuiccPort extends UiccPort {
            mEid = ics.eid;
            mCardId = ics.eid;
        }
        mIsSupportsMultipleEnabledProfiles = isSupportsMultipleEnabledProfiles;
        mSupportedMepMode = supportedMepMode;
    }

@@ -170,13 +167,11 @@ public class EuiccPort extends UiccPort {
    }

    /**
     * Updates MEP(Multiple Enabled Profile) support and mode flags.
     * Updates MEP(Multiple Enabled Profile) supported mode flag.
     * The flag can be updated after the port creation.
     */
    public void updateSupportMepProperties(boolean supported,
            MultipleEnabledProfilesMode supportedMepMode) {
        logd("updateSupportMultipleEnabledProfile");
        mIsSupportsMultipleEnabledProfiles = supported;
    public void updateSupportedMepMode(MultipleEnabledProfilesMode supportedMepMode) {
        logd("updateSupportedMepMode");
        mSupportedMepMode = supportedMepMode;
    }

@@ -188,7 +183,7 @@ public class EuiccPort extends UiccPort {
     * @since 1.1.0 [GSMA SGP.22]
     */
    public void getAllProfiles(AsyncResultCallback<EuiccProfileInfo[]> callback, Handler handler) {
        byte[] profileTags = mIsSupportsMultipleEnabledProfiles ? Tags.EUICC_PROFILE_MEP_TAGS
        byte[] profileTags = mSupportedMepMode.isMepMode() ? Tags.EUICC_PROFILE_MEP_TAGS
                : Tags.EUICC_PROFILE_TAGS;
        sendApdu(
                newRequestProvider((RequestBuilder requestBuilder) ->
@@ -230,7 +225,7 @@ public class EuiccPort extends UiccPort {
     */
    public final void getProfile(String iccid, AsyncResultCallback<EuiccProfileInfo> callback,
            Handler handler) {
        byte[] profileTags = mIsSupportsMultipleEnabledProfiles ? Tags.EUICC_PROFILE_MEP_TAGS
        byte[] profileTags = mSupportedMepMode.isMepMode() ? Tags.EUICC_PROFILE_MEP_TAGS
                : Tags.EUICC_PROFILE_TAGS;
        sendApdu(
                newRequestProvider((RequestBuilder requestBuilder) ->
@@ -1432,6 +1427,6 @@ public class EuiccPort extends UiccPort {
        super.dump(fd, pw, args);
        pw.println("EuiccPort:");
        pw.println(" mEid=" + mEid);
        pw.println(" mIsSupportsMultipleEnabledProfiles=" + mIsSupportsMultipleEnabledProfiles);
        pw.println(" mSupportedMepMode=" + mSupportedMepMode);
    }
}
Loading