aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/android/internal/telephony/uicc
diff options
context:
space:
mode:
authorMuralidhar Reddy <muralidharm@google.com>2022-12-06 13:14:18 +0000
committerMuralidhar Reddy <muralidharm@google.com>2022-12-18 08:46:27 +0000
commit63f47bb93858da5837d264baff122843f4dfe340 (patch)
tree077f51d96101d0b3d5abf1280dc7146cffff0da4 /src/java/com/android/internal/telephony/uicc
parenta6574642239e273dee649c62af08169ae51fb7d7 (diff)
downloadtelephony-63f47bb93858da5837d264baff122843f4dfe340.tar.gz
Add MEP-A1 support in platform
Test: Manual test on Pixel 7, atest FrameworksTelephonyTests Bug: 254866604 Change-Id: Ieef6c320d70ad8433af00444aff365a58a2a2d4c
Diffstat (limited to 'src/java/com/android/internal/telephony/uicc')
-rw-r--r--src/java/com/android/internal/telephony/uicc/IccCardStatus.java26
-rw-r--r--src/java/com/android/internal/telephony/uicc/IccSlotStatus.java54
-rw-r--r--src/java/com/android/internal/telephony/uicc/PortUtils.java77
-rw-r--r--src/java/com/android/internal/telephony/uicc/UiccCard.java15
-rw-r--r--src/java/com/android/internal/telephony/uicc/UiccController.java12
-rw-r--r--src/java/com/android/internal/telephony/uicc/UiccSlot.java26
-rw-r--r--src/java/com/android/internal/telephony/uicc/euicc/EuiccCard.java12
-rw-r--r--src/java/com/android/internal/telephony/uicc/euicc/EuiccPort.java28
-rw-r--r--src/java/com/android/internal/telephony/uicc/euicc/apdu/ApduCommand.java11
-rw-r--r--src/java/com/android/internal/telephony/uicc/euicc/apdu/TransmitApduLogicalChannelInvocation.java3
10 files changed, 245 insertions, 19 deletions
diff --git a/src/java/com/android/internal/telephony/uicc/IccCardStatus.java b/src/java/com/android/internal/telephony/uicc/IccCardStatus.java
index ec07780c8f..e2cc9e9632 100644
--- a/src/java/com/android/internal/telephony/uicc/IccCardStatus.java
+++ b/src/java/com/android/internal/telephony/uicc/IccCardStatus.java
@@ -20,6 +20,7 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build;
import android.telephony.SubscriptionInfo;
+import com.android.internal.telephony.uicc.IccSlotStatus.MultipleEnabledProfilesMode;
import com.android.internal.telephony.util.TelephonyUtils;
import com.android.telephony.Rlog;
@@ -90,6 +91,30 @@ public class IccCardStatus {
public IccSlotPortMapping mSlotPortMapping;
+ public MultipleEnabledProfilesMode mSupportedMepMode = MultipleEnabledProfilesMode.NONE;
+
+ /**
+ * Set the MultipleEnabledProfilesMode according to the input mode.
+ */
+ public void setMultipleEnabledProfilesMode(int mode) {
+ switch(mode) {
+ case 0:
+ mSupportedMepMode = MultipleEnabledProfilesMode.NONE;
+ break;
+ case 1:
+ mSupportedMepMode = MultipleEnabledProfilesMode.MEP_A1;
+ break;
+ case 2:
+ mSupportedMepMode = MultipleEnabledProfilesMode.MEP_A2;
+ break;
+ case 3:
+ mSupportedMepMode = MultipleEnabledProfilesMode.MEP_B;
+ break;
+ default:
+ throw new RuntimeException("Unrecognized RIL_MultipleEnabledProfilesMode: " + mode);
+ }
+ }
+
public void setCardState(int state) {
switch(state) {
case 0:
@@ -174,6 +199,7 @@ public class IccCardStatus {
sb.append(",atr=").append(atr);
sb.append(",iccid=").append(SubscriptionInfo.givePrintableIccid(iccid));
sb.append(",eid=").append(Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, eid));
+ sb.append(",SupportedMepMode=").append(mSupportedMepMode);
sb.append(",SlotPortMapping=").append(mSlotPortMapping);
sb.append("}");
diff --git a/src/java/com/android/internal/telephony/uicc/IccSlotStatus.java b/src/java/com/android/internal/telephony/uicc/IccSlotStatus.java
index 96a3a33ffd..3bbef23518 100644
--- a/src/java/com/android/internal/telephony/uicc/IccSlotStatus.java
+++ b/src/java/com/android/internal/telephony/uicc/IccSlotStatus.java
@@ -30,11 +30,42 @@ public class IccSlotStatus {
/* Added state active to check slotState in old HAL case.*/
public static final int STATE_ACTIVE = 1;
+ public enum MultipleEnabledProfilesMode {
+ /**
+ * If there is no jointly supported MEP mode, set supported MEP mode to NONE.
+ */
+ NONE,
+ /**
+ * In case of MEP-A1, the ISD-R is selected on eSIM port 0 only and profiles are selected
+ * on eSIM ports 1 and higher, with the eSIM port being assigned by the LPA or platform.
+ */
+ MEP_A1,
+ /**
+ * In case of MEP-A2, the ISD-R is selected on eSIM port 0 only and profiles are selected
+ * on eSIM ports 1 and higher, with the eSIM port being assigned by the eUICC.
+ */
+ MEP_A2,
+ /**
+ * In case of MEP-B, profiles are selected on eSIM ports 0 and higher, with the ISD-R being
+ * selectable on any of these eSIM ports.
+ */
+ MEP_B;
+
+ public boolean isMepAMode() {
+ return (this == MEP_A1 || this == MEP_A2);
+ }
+
+ public boolean isMepA1Mode() {
+ return this == MEP_A1;
+ }
+ }
+
public IccCardStatus.CardState cardState;
public String atr;
public String eid;
public IccSimPortInfo[] mSimPortInfos;
+ public MultipleEnabledProfilesMode mSupportedMepMode = MultipleEnabledProfilesMode.NONE;
/**
* Set the cardState according to the input state.
@@ -58,6 +89,28 @@ public class IccSlotStatus {
}
}
+ /**
+ * Set the MultipleEnabledProfilesMode according to the input mode.
+ */
+ public void setMultipleEnabledProfilesMode(int mode) {
+ switch(mode) {
+ case 0:
+ mSupportedMepMode = MultipleEnabledProfilesMode.NONE;
+ break;
+ case 1:
+ mSupportedMepMode = MultipleEnabledProfilesMode.MEP_A1;
+ break;
+ case 2:
+ mSupportedMepMode = MultipleEnabledProfilesMode.MEP_A2;
+ break;
+ case 3:
+ mSupportedMepMode = MultipleEnabledProfilesMode.MEP_B;
+ break;
+ default:
+ throw new RuntimeException("Unrecognized RIL_MultipleEnabledProfilesMode: " + mode);
+ }
+ }
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -72,6 +125,7 @@ public class IccSlotStatus {
} else {
sb.append("num_ports=null");
}
+ sb.append(", SupportedMepMode=" + mSupportedMepMode);
sb.append("}");
return sb.toString();
}
diff --git a/src/java/com/android/internal/telephony/uicc/PortUtils.java b/src/java/com/android/internal/telephony/uicc/PortUtils.java
new file mode 100644
index 0000000000..4a18b5688d
--- /dev/null
+++ b/src/java/com/android/internal/telephony/uicc/PortUtils.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.telephony.uicc;
+
+import android.annotation.NonNull;
+
+import com.android.internal.telephony.uicc.IccSlotStatus.MultipleEnabledProfilesMode;
+
+/**
+ * Various methods, useful for dealing with port.
+ */
+public class PortUtils {
+
+ /**
+ * Converts the port index to compatible with the HAL.
+ *
+ * @param mepMode supported MultipleEnabledProfilesMode
+ * @param portIndex port index
+ * @return target index according to the MultipleEnabledProfilesMode
+ */
+ public static int convertToHalPortIndex(@NonNull MultipleEnabledProfilesMode mepMode,
+ int portIndex) {
+ // In case of MEP-A1 and MEP-A2, profiles are selected on eSIM Ports 1 and higher, hence
+ // HAL expects the ports are indexed with 1, 2... etc.
+ // So inorder to compatible with HAL, shift the port index.
+ return mepMode.isMepAMode() ? ++portIndex : portIndex;
+ }
+
+ /**
+ * Converts the port index to compatible with the HAL.
+ *
+ * @param slotIndex physical slot index corresponding to the portIndex
+ * @param portIndex port index
+ * @return target port index according to the MultipleEnabledProfilesMode
+ */
+ public static int convertToHalPortIndex(int slotIndex, int portIndex) {
+ return convertToHalPortIndex(UiccController.getInstance().getSupportedMepMode(slotIndex),
+ portIndex);
+ }
+
+ /**
+ * Converts the port index to compatible with the platform.
+ *
+ * @param slotIndex physical slot index corresponding to the portIndex
+ * @param portIndex target port index
+ * @param cardState cardState
+ * @param supportedMepMode supported MEP mode
+ * @return shifted port index according to the MultipleEnabledProfilesMode
+ */
+ public static int convertFromHalPortIndex(int slotIndex, int portIndex,
+ IccCardStatus.CardState cardState, MultipleEnabledProfilesMode supportedMepMode) {
+ // In case of MEP-A1 and MEP-A2, profiles are selected on eSIM Ports 1 and higher.
+ // But inorder to platform code MEP mode agnostic, platform always expects the ports
+ // are indexed with 0, 1... etc. Hence shift the target port index to be compatible
+ // with platform.
+
+ // When the SIM_STATUS is related to CARDSTATE_ABSENT, CardStatus will not contain proper
+ // MEP mode info, fallback onto to the supportedMepMode data available in UiccSlot.
+ MultipleEnabledProfilesMode mepMode = cardState.isCardPresent() ? supportedMepMode
+ : UiccController.getInstance().getSupportedMepMode(slotIndex);
+ return mepMode.isMepAMode() ? --portIndex : portIndex;
+ }
+}
diff --git a/src/java/com/android/internal/telephony/uicc/UiccCard.java b/src/java/com/android/internal/telephony/uicc/UiccCard.java
index 54324b98c5..67f120fd54 100644
--- a/src/java/com/android/internal/telephony/uicc/UiccCard.java
+++ b/src/java/com/android/internal/telephony/uicc/UiccCard.java
@@ -24,6 +24,7 @@ import android.text.TextUtils;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.uicc.IccCardStatus.CardState;
+import com.android.internal.telephony.uicc.IccSlotStatus.MultipleEnabledProfilesMode;
import com.android.internal.telephony.uicc.euicc.EuiccCard;
import com.android.internal.telephony.uicc.euicc.EuiccPort;
import com.android.telephony.Rlog;
@@ -51,16 +52,19 @@ public class UiccCard {
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) {
+ boolean isSupportsMultipleEnabledProfiles,
+ MultipleEnabledProfilesMode supportedMepMode) {
if (DBG) log("Creating");
mCardState = ics.mCardState;
mLock = lock;
mIsSupportsMultipleEnabledProfiles = isSupportsMultipleEnabledProfiles;
+ mSupportedMepMode = supportedMepMode;
update(c, ci, ics, phoneId);
}
@@ -110,7 +114,7 @@ public class UiccCard {
if (port == null) {
if (this instanceof EuiccCard) {
port = new EuiccPort(c, ci, ics, phoneId, mLock, this,
- mIsSupportsMultipleEnabledProfiles); // eSim
+ mIsSupportsMultipleEnabledProfiles, mSupportedMepMode); // eSim
} else {
port = new UiccPort(c, ci, ics, phoneId, mLock, this); // pSim
}
@@ -144,13 +148,16 @@ public class UiccCard {
/**
- * Updates MEP(Multiple Enabled Profile) support flag.
+ * Updates MEP(Multiple Enabled Profile) support and supported mode flags.
*
* <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 updateSupportMultipleEnabledProfile(boolean supported) {
+ public void updateSupportMepProperties(boolean supported,
+ MultipleEnabledProfilesMode supportedMepMode) {
+ // TODO(b/262449536): Handle with single MEP flag to avoid inconsistency.
mIsSupportsMultipleEnabledProfiles = supported;
+ mSupportedMepMode = supportedMepMode;
}
@UnsupportedAppUsage
diff --git a/src/java/com/android/internal/telephony/uicc/UiccController.java b/src/java/com/android/internal/telephony/uicc/UiccController.java
index 4743bce77d..ea99d9a3f6 100644
--- a/src/java/com/android/internal/telephony/uicc/UiccController.java
+++ b/src/java/com/android/internal/telephony/uicc/UiccController.java
@@ -1453,6 +1453,18 @@ public class UiccController extends Handler {
return mUseRemovableEsimAsDefault;
}
+ /**
+ * Returns the MEP mode supported by the UiccSlot associated with slotIndex.
+ * @param slotIndex physical slot index
+ * @return MultipleEnabledProfilesMode supported by the slot
+ */
+ public IccSlotStatus.MultipleEnabledProfilesMode getSupportedMepMode(int slotIndex) {
+ synchronized (mLock) {
+ UiccSlot slot = getUiccSlot(slotIndex);
+ return slot != null ? slot.getSupportedMepMode()
+ : IccSlotStatus.MultipleEnabledProfilesMode.NONE;
+ }
+ }
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private void log(String string) {
diff --git a/src/java/com/android/internal/telephony/uicc/UiccSlot.java b/src/java/com/android/internal/telephony/uicc/UiccSlot.java
index 8de7e0108a..ec4919609c 100644
--- a/src/java/com/android/internal/telephony/uicc/UiccSlot.java
+++ b/src/java/com/android/internal/telephony/uicc/UiccSlot.java
@@ -41,6 +41,7 @@ import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.uicc.IccCardStatus.CardState;
+import com.android.internal.telephony.uicc.IccSlotStatus.MultipleEnabledProfilesMode;
import com.android.internal.telephony.uicc.euicc.EuiccCard;
import com.android.internal.telephony.util.TelephonyUtils;
import com.android.telephony.Rlog;
@@ -87,6 +88,8 @@ public class UiccSlot extends Handler {
private String mEid;
private AnswerToReset mAtr;
private boolean mIsRemovable;
+ private MultipleEnabledProfilesMode mSupportedMepMode;
+
// Map each available portIdx to phoneId
private HashMap<Integer, Integer> mPortIdxToPhoneId = new HashMap<>();
//Map each available portIdx with old radio state for state checking
@@ -102,6 +105,7 @@ public class UiccSlot extends Handler {
mContext = c;
mActive = isActive;
mCardState = null;
+ mSupportedMepMode = MultipleEnabledProfilesMode.NONE;
}
/**
@@ -115,6 +119,10 @@ public class UiccSlot extends Handler {
mIccIds.put(ics.mSlotPortMapping.mPortIndex, ics.iccid);
parseAtr(ics.atr);
mIsRemovable = isSlotRemovable(slotIndex);
+ // Update supported MEP mode in IccCardStatus if the CardState is present.
+ if (ics.mCardState.isCardPresent()) {
+ mSupportedMepMode = ics.mSupportedMepMode;
+ }
int radioState = ci.getRadioState();
if (DBG) {
@@ -147,7 +155,8 @@ 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, false,
+ MultipleEnabledProfilesMode.NONE);
} else {
// The EID should be reported with the card status, but in case it's not we want
// to catch that here
@@ -156,7 +165,7 @@ public class UiccSlot extends Handler {
+ Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, ics.eid));
}
mUiccCard = new EuiccCard(mContext, ci, ics, phoneId, mLock,
- isMultipleEnabledProfileSupported());
+ isMultipleEnabledProfileSupported(), getSupportedMepMode());
}
} else {
if (mUiccCard != null) {
@@ -178,6 +187,7 @@ public class UiccSlot extends Handler {
mCardState = iss.cardState;
mEid = iss.eid;
mIsRemovable = isSlotRemovable(slotIndex);
+ mSupportedMepMode = iss.mSupportedMepMode;
for (int i = 0; i < simPortInfos.length; i++) {
int phoneId = iss.mSimPortInfos[i].mLogicalSlotIndex;
@@ -224,7 +234,8 @@ public class UiccSlot extends Handler {
// Since the MEP capability is related with number ports reported, thus need to
// update the flag after UiccCard creation.
if (mUiccCard != null) {
- mUiccCard.updateSupportMultipleEnabledProfile(isMultipleEnabledProfileSupported());
+ mUiccCard.updateSupportMepProperties(isMultipleEnabledProfileSupported(),
+ getSupportedMepMode());
}
}
}
@@ -567,6 +578,14 @@ public class UiccSlot extends Handler {
}
/**
+ * Returns the supported MEP mode.
+ */
+ public MultipleEnabledProfilesMode getSupportedMepMode() {
+ synchronized (mLock) {
+ return mSupportedMepMode;
+ }
+ }
+ /**
* Processes radio state unavailable event
*/
public void onRadioStateUnavailable(int phoneId) {
@@ -612,6 +631,7 @@ public class UiccSlot extends Handler {
pw.println(" mPortIdxToPhoneId=" + mPortIdxToPhoneId);
pw.println(" mEid=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, mEid));
pw.println(" mCardState=" + mCardState);
+ pw.println(" mSupportedMepMode=" + mSupportedMepMode);
if (mUiccCard != null) {
pw.println(" mUiccCard=" + mUiccCard);
mUiccCard.dump(fd, pw, args);
diff --git a/src/java/com/android/internal/telephony/uicc/euicc/EuiccCard.java b/src/java/com/android/internal/telephony/uicc/euicc/EuiccCard.java
index 75bc3ba710..0d98e185f9 100644
--- a/src/java/com/android/internal/telephony/uicc/euicc/EuiccCard.java
+++ b/src/java/com/android/internal/telephony/uicc/euicc/EuiccCard.java
@@ -27,6 +27,7 @@ import android.text.TextUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.uicc.IccCardStatus;
+import com.android.internal.telephony.uicc.IccSlotStatus.MultipleEnabledProfilesMode;
import com.android.internal.telephony.uicc.UiccCard;
import com.android.internal.telephony.uicc.UiccPort;
import com.android.internal.telephony.uicc.euicc.async.AsyncResultCallback;
@@ -43,8 +44,9 @@ public class EuiccCard extends UiccCard {
private RegistrantList mEidReadyRegistrants;
public EuiccCard(Context c, CommandsInterface ci, IccCardStatus ics, int phoneId, Object lock,
- boolean isSupportsMultipleEnabledProfiles) {
- super(c, ci, ics, phoneId, lock, isSupportsMultipleEnabledProfiles);
+ boolean isSupportsMultipleEnabledProfiles,
+ MultipleEnabledProfilesMode supportedMepMode) {
+ super(c, ci, ics, phoneId, lock, isSupportsMultipleEnabledProfiles, supportedMepMode);
if (TextUtils.isEmpty(ics.eid)) {
loge("no eid given in constructor for phone " + phoneId);
loadEidAndNotifyRegistrants();
@@ -61,11 +63,13 @@ public class EuiccCard extends UiccCard {
* UiccCard creation which will impact UICC MEP capability.
*/
@Override
- public void updateSupportMultipleEnabledProfile(boolean supported) {
+ public void updateSupportMepProperties(boolean supported,
+ MultipleEnabledProfilesMode supportedMepMode) {
mIsSupportsMultipleEnabledProfiles = supported;
+ mSupportedMepMode = supportedMepMode;
for (UiccPort port : mUiccPorts.values()) {
if (port instanceof EuiccPort) {
- ((EuiccPort) port).updateSupportMultipleEnabledProfile(supported);
+ ((EuiccPort) port).updateSupportMepProperties(supported, supportedMepMode);
} else {
loge("eUICC card has non-euicc port object:" + port.toString());
}
diff --git a/src/java/com/android/internal/telephony/uicc/euicc/EuiccPort.java b/src/java/com/android/internal/telephony/uicc/euicc/EuiccPort.java
index 73d5866616..3dd260ecac 100644
--- a/src/java/com/android/internal/telephony/uicc/euicc/EuiccPort.java
+++ b/src/java/com/android/internal/telephony/uicc/euicc/EuiccPort.java
@@ -35,7 +35,9 @@ import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.uicc.IccCardStatus;
import com.android.internal.telephony.uicc.IccIoResult;
+import com.android.internal.telephony.uicc.IccSlotStatus.MultipleEnabledProfilesMode;
import com.android.internal.telephony.uicc.IccUtils;
+import com.android.internal.telephony.uicc.PortUtils;
import com.android.internal.telephony.uicc.UiccCard;
import com.android.internal.telephony.uicc.UiccPort;
import com.android.internal.telephony.uicc.asn1.Asn1Decoder;
@@ -125,9 +127,11 @@ public class EuiccPort extends UiccPort {
private volatile String mEid;
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
public boolean mIsSupportsMultipleEnabledProfiles;
+ private MultipleEnabledProfilesMode mSupportedMepMode;
public EuiccPort(Context c, CommandsInterface ci, IccCardStatus ics, int phoneId, Object lock,
- UiccCard card, boolean isSupportsMultipleEnabledProfiles) {
+ UiccCard card, boolean isSupportsMultipleEnabledProfiles,
+ MultipleEnabledProfilesMode supportedMepMode) {
super(c, ci, ics, phoneId, lock, card);
// TODO: Set supportExtendedApdu based on ATR.
mApduSender = new ApduSender(ci, ISD_R_AID, false /* supportExtendedApdu */);
@@ -138,6 +142,7 @@ public class EuiccPort extends UiccPort {
mCardId = ics.eid;
}
mIsSupportsMultipleEnabledProfiles = isSupportsMultipleEnabledProfiles;
+ mSupportedMepMode = supportedMepMode;
}
/**
@@ -165,12 +170,14 @@ public class EuiccPort extends UiccPort {
}
/**
- * Updates MEP(Multiple Enabled Profile) support flag.
+ * Updates MEP(Multiple Enabled Profile) support and mode flags.
* The flag can be updated after the port creation.
*/
- public void updateSupportMultipleEnabledProfile(boolean supported) {
+ public void updateSupportMepProperties(boolean supported,
+ MultipleEnabledProfilesMode supportedMepMode) {
logd("updateSupportMultipleEnabledProfile");
mIsSupportsMultipleEnabledProfiles = supported;
+ mSupportedMepMode = supportedMepMode;
}
/**
@@ -303,11 +310,20 @@ public class EuiccPort extends UiccPort {
sendApduWithSimResetErrorWorkaround(
newRequestProvider((RequestBuilder requestBuilder) -> {
byte[] iccidBytes = IccUtils.bcdToBytes(padTrailingFs(iccid));
- requestBuilder.addStoreData(Asn1Node.newBuilder(Tags.TAG_ENABLE_PROFILE)
+ Asn1Node.Builder builder = Asn1Node.newBuilder(Tags.TAG_ENABLE_PROFILE)
.addChild(Asn1Node.newBuilder(Tags.TAG_CTX_COMP_0)
.addChildAsBytes(Tags.TAG_ICCID, iccidBytes))
- .addChildAsBoolean(Tags.TAG_CTX_1, refresh)
- .build().toHex());
+ .addChildAsBoolean(Tags.TAG_CTX_1, refresh);
+ // Port index should be added only in case of MEP-A1 mode.
+ if (mSupportedMepMode.isMepA1Mode()) {
+ // In case of MEP-A1 and MEP-A2, profiles are selected on eSIM Ports 1 and
+ // higher (refer as target port). Hence, convert the portIndex to
+ // target port index before adding.
+ builder.addChildAsInteger(Tags.TAG_CTX_2,
+ PortUtils.convertToHalPortIndex(mSupportedMepMode,
+ super.getPortIdx()));
+ }
+ requestBuilder.addStoreData(builder.build().toHex());
}),
response -> {
int result;
diff --git a/src/java/com/android/internal/telephony/uicc/euicc/apdu/ApduCommand.java b/src/java/com/android/internal/telephony/uicc/euicc/apdu/ApduCommand.java
index 7a8978f822..8fbeb4450f 100644
--- a/src/java/com/android/internal/telephony/uicc/euicc/apdu/ApduCommand.java
+++ b/src/java/com/android/internal/telephony/uicc/euicc/apdu/ApduCommand.java
@@ -43,6 +43,12 @@ class ApduCommand {
/** Command data of an APDU as defined in GlobalPlatform Card Specification v.2.3. */
public final String cmdHex;
+ /**
+ * isEs10 indicates that the current streaming APDU contains an ES10 command or it is a regular
+ * APDU. (As per spec SGP.22 V3.0, ES10 commands needs to be sent over command port of MEP-A1)
+ */
+ public final boolean isEs10;
+
/** The parameters are defined as in GlobalPlatform Card Specification v.2.3. */
ApduCommand(int channel, int cla, int ins, int p1, int p2, int p3, String cmdHex) {
this.channel = channel;
@@ -52,11 +58,14 @@ class ApduCommand {
this.p2 = p2;
this.p3 = p3;
this.cmdHex = cmdHex;
+ // TODO: Currently ApduCommand is used for ES10 commands, so updating to true by default.
+ // Modify it in case used for non ES10 commands in future.
+ this.isEs10 = true;
}
@Override
public String toString() {
return "ApduCommand(channel=" + channel + ", cla=" + cla + ", ins=" + ins + ", p1=" + p1
- + ", p2=" + p2 + ", p3=" + p3 + ", cmd=" + cmdHex + ")";
+ + ", p2=" + p2 + ", p3=" + p3 + ", cmd=" + cmdHex + ", isEs10=" + isEs10 + ")";
}
}
diff --git a/src/java/com/android/internal/telephony/uicc/euicc/apdu/TransmitApduLogicalChannelInvocation.java b/src/java/com/android/internal/telephony/uicc/euicc/apdu/TransmitApduLogicalChannelInvocation.java
index 09de54a804..ca75beb55f 100644
--- a/src/java/com/android/internal/telephony/uicc/euicc/apdu/TransmitApduLogicalChannelInvocation.java
+++ b/src/java/com/android/internal/telephony/uicc/euicc/apdu/TransmitApduLogicalChannelInvocation.java
@@ -48,7 +48,8 @@ public class TransmitApduLogicalChannelInvocation
protected void sendRequestMessage(ApduCommand command, Message msg) {
Rlog.v(LOG_TAG, "Send: " + command);
mCi.iccTransmitApduLogicalChannel(command.channel, command.cla | command.channel,
- command.ins, command.p1, command.p2, command.p3, command.cmdHex, msg);
+ command.ins, command.p1, command.p2, command.p3, command.cmdHex, command.isEs10,
+ msg);
}
@Override