[Android T][MEP]: HAL changes for MEP feature

Test: build
Bug: 199559065
Change-Id: I533c73bed0235fe58a583f04ca66d4bc9e08ced0
diff --git a/radio/aidl/Android.bp b/radio/aidl/Android.bp
index 88bdc2e..c5a3a8b 100644
--- a/radio/aidl/Android.bp
+++ b/radio/aidl/Android.bp
@@ -137,7 +137,10 @@
     vendor_available: true,
     srcs: ["android/hardware/radio/sim/*.aidl"],
     stability: "vintf",
-    imports: ["android.hardware.radio"],
+    imports: [
+        "android.hardware.radio",
+        "android.hardware.radio.config",
+    ],
     backend: {
         cpp: {
             enabled: false,
diff --git a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfig.aidl b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfig.aidl
index 85106b8..a48a89b 100644
--- a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfig.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfig.aidl
@@ -49,5 +49,5 @@
   oneway void setNumOfLiveModems(in int serial, in byte numOfLiveModems);
   oneway void setPreferredDataModem(in int serial, in byte modemId);
   oneway void setResponseFunctions(in android.hardware.radio.config.IRadioConfigResponse radioConfigResponse, in android.hardware.radio.config.IRadioConfigIndication radioConfigIndication);
-  oneway void setSimSlotsMapping(in int serial, in int[] slotMap);
+  oneway void setSimSlotsMapping(in int serial, in android.hardware.radio.config.SlotPortMapping[] slotMap);
 }
diff --git a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/SimPortInfo.aidl b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/SimPortInfo.aidl
new file mode 100644
index 0000000..2cfb8d0
--- /dev/null
+++ b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/SimPortInfo.aidl
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.radio.config;
+@VintfStability
+parcelable SimPortInfo {
+  String iccId;
+  int logicalSlotId;
+  int portState;
+  const int PORT_STATE_INACTIVE = 0;
+  const int PORT_STATE_ACTIVE = 1;
+}
diff --git a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/SimSlotStatus.aidl b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/SimSlotStatus.aidl
index 3a716cf..60eabc7 100644
--- a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/SimSlotStatus.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/SimSlotStatus.aidl
@@ -36,9 +36,7 @@
 parcelable SimSlotStatus {
   boolean cardActive;
   int cardState;
-  int slotState;
   String atr;
-  int logicalSlotId;
-  String iccid;
   String eid;
+  android.hardware.radio.config.SimPortInfo[] portInfo;
 }
diff --git a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/SlotPortMapping.aidl b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/SlotPortMapping.aidl
new file mode 100644
index 0000000..f38c421
--- /dev/null
+++ b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/SlotPortMapping.aidl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.radio.config;
+@VintfStability
+parcelable SlotPortMapping {
+  int physicalSlotId;
+  int portId;
+}
diff --git a/radio/aidl/aidl_api/android.hardware.radio.sim/current/android/hardware/radio/sim/CardStatus.aidl b/radio/aidl/aidl_api/android.hardware.radio.sim/current/android/hardware/radio/sim/CardStatus.aidl
index 2d95b97..cf37a0d 100644
--- a/radio/aidl/aidl_api/android.hardware.radio.sim/current/android/hardware/radio/sim/CardStatus.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.sim/current/android/hardware/radio/sim/CardStatus.aidl
@@ -40,10 +40,10 @@
   int cdmaSubscriptionAppIndex;
   int imsSubscriptionAppIndex;
   android.hardware.radio.sim.AppStatus[] applications;
-  int physicalSlotId;
   String atr;
   String iccid;
   String eid;
+  android.hardware.radio.config.SlotPortMapping slotMap;
   const int STATE_ABSENT = 0;
   const int STATE_PRESENT = 1;
   const int STATE_ERROR = 2;
diff --git a/radio/aidl/android/hardware/radio/config/IRadioConfig.aidl b/radio/aidl/android/hardware/radio/config/IRadioConfig.aidl
index bfff16a..85c2cee 100644
--- a/radio/aidl/android/hardware/radio/config/IRadioConfig.aidl
+++ b/radio/aidl/android/hardware/radio/config/IRadioConfig.aidl
@@ -26,6 +26,7 @@
 
 import android.hardware.radio.config.IRadioConfigIndication;
 import android.hardware.radio.config.IRadioConfigResponse;
+import android.hardware.radio.config.SlotPortMapping;
 
 @VintfStability
 oneway interface IRadioConfig {
@@ -120,30 +121,57 @@
     /**
      * Set SIM Slot mapping.
      *
-     * Maps the logical slots to the physical slots. Logical slot is the slot that is seen by modem.
-     * Physical slot is the actual physical slot. Request maps the physical slot to logical slot.
-     * Logical slots that are already mapped to the requested physical slot are not impacted.
+     * Maps the logical slots to the SlotPortMapping which consist of both physical slot id and port
+     * id. Logical slot is the slot that is seen by modem. Physical slot is the actual physical
+     * slot. PortId is the id (enumerated value) for the associated port available on the SIM. Each
+     * physical slot can have multiple ports which enables multi-enabled profile(MEP). If eUICC
+     * physical slot supports 2 ports, then the portId is numbered 0,1 and if eUICC2 supports 4
+     * ports then the portID is numbered 0,1,2,3. Each portId is unique within a UICC physical slot
+     * but not necessarily unique across UICC’s. SEP(Single enabled profile) eUICC and non-eUICC
+     * will only have portId 0.
      *
-     * Example no. of logical slots 1 and physical slots 2:
-     * The only logical slot (index 0) can be mapped to first physical slot (value 0) or second
-     * physical slot(value 1), while the other physical slot remains unmapped and inactive.
-     * slotMap[0] = 1 or slotMap[0] = 0
+     * Logical slots that are already mapped to the requested SlotPortMapping are not impacted.
      *
-     * Example no. of logical slots 2 and physical slots 2:
-     * First logical slot (index 0) can be mapped to physical slot 1 or 2 and other logical slot
-     * can be mapped to other physical slot. Each logical slot must be mapped to a physical slot.
-     * slotMap[0] = 0 and slotMap[1] = 1 or slotMap[0] = 1 and slotMap[1] = 0
+     * Example no. of logical slots 1 and physical slots 2 do not support MEP, each physical slot
+     * has one port:
+     * The only logical slot (index 0) can be mapped to first physical slot (value 0), port(index
+     * 0). or second
+     * physical slot(value 1), port (index 0), while the other physical slot remains unmapped and
+     * inactive.
+     * slotMap[0] = SlotPortMapping{0 //physical slot//, 0 //port//}
+     * slotMap[0] = SlotPortMapping{1 //physical slot//, 0 //port//}
+     *
+     * Example no. of logical slots 2 and physical slots 2 supports MEP with 2 ports available:
+     * Each logical slot must be mapped to a port (physical slot and port combination).
+     * First logical slot (index 0) can be mapped to physical slot 1 and the second logical slot
+     * can be mapped to either port from physical slot 2.
+     *
+     * slotMap[0] = SlotPortMapping{0, 0} and slotMap[1] = SlotPortMapping{1, 0} or
+     * slotMap[0] = SlotPortMapping{0, 0} and slotMap[1] = SlotPortMapping{1, 1}
+     *
+     * or the other way around, the second logical slot(index 1) can be mapped to physical slot 1
+     * and the first logical slot can be mapped to either port from physical slot 2.
+     *
+     * slotMap[1] = SlotPortMapping{0, 0} and slotMap[0] = SlotPortMapping{1, 0} or
+     * slotMap[1] = SlotPortMapping{0, 0} and slotMap[0] = SlotPortMapping{1, 1}
+     *
+     * another possible mapping is each logical slot maps to each port of physical slot 2 and there
+     * is no active logical modem mapped to physical slot 1.
+     *
+     * slotMap[0] = SlotPortMapping{1, 0} and slotMap[1] = SlotPortMapping{1, 1} or
+     * slotMap[0] = SlotPortMapping{1, 1} and slotMap[1] = SlotPortMapping{1, 0}
      *
      * @param serial Serial number of request
-     * @param slotMap Logical to physical slot mapping, size == no. of radio instances. Index is
-     *        mapping to logical slot and value to physical slot, need to provide all the slots
-     *        mapping when sending request in case of multi slot device.
-     *        EX: uint32_t slotMap[logical slot] = physical slot
+     * @param slotMap Logical to physical slot and port mapping.
+     *        Index is mapping to logical slot and value to physical slot and port id, need to
+     *        provide all the slots mapping when sending request in case of multi slot device.
+     *
+     *        EX: SlotPortMapping(physical slot, port id)
      *        index 0 is the first logical_slot number of logical slots is equal to number of Radio
      *        instances and number of physical slots is equal to size of slotStatus in
      *        getSimSlotsStatusResponse
      *
      * Response callback is IRadioConfigResponse.setSimSlotsMappingResponse()
      */
-    void setSimSlotsMapping(in int serial, in int[] slotMap);
+    void setSimSlotsMapping(in int serial, in SlotPortMapping[] slotMap);
 }
diff --git a/radio/aidl/android/hardware/radio/config/SimPortInfo.aidl b/radio/aidl/android/hardware/radio/config/SimPortInfo.aidl
new file mode 100644
index 0000000..78f1309
--- /dev/null
+++ b/radio/aidl/android/hardware/radio/config/SimPortInfo.aidl
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2021 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 android.hardware.radio.config;
+
+@VintfStability
+parcelable SimPortInfo {
+    /**
+     * Integrated Circuit Card IDentifier (ICCID) is unique identifier of the SIM card. File is
+     * located in the SIM card at EFiccid (0x2FE2) as per ETSI 102.221. The ICCID is defined by
+     * the ITU-T recommendation E.118 ISO/IEC 7816.
+     *
+     * This data is applicable only when cardState is CardStatus.STATE_PRESENT.
+     *
+     * This is the ICCID of the currently enabled profile. If no profile is enabled,
+     * then it will contain the default boot profile’s ICCID.
+     * If the EFiccid does not exist in the default boot profile, it will be null.
+     */
+    String iccId;
+    /**
+     * Logical slot id is identifier of the active slot
+     */
+    int logicalSlotId;
+    /*
+     * Port is Inactive
+     * Inactive means logical modem is no longer associated to the port
+     */
+    const int PORT_STATE_INACTIVE = 0;
+    /*
+     * Port is Active
+     * Active means logical modem is associated to the port
+     */
+    const int PORT_STATE_ACTIVE = 1;
+    /**
+     * Port state in the slot. Values are portState.[PORT_STATE_INACTIVE, PORT_STATE_ACTIVE].
+     */
+    int portState;
+}
diff --git a/radio/aidl/android/hardware/radio/config/SimSlotStatus.aidl b/radio/aidl/android/hardware/radio/config/SimSlotStatus.aidl
index f5ea8f9..4ab955a 100644
--- a/radio/aidl/android/hardware/radio/config/SimSlotStatus.aidl
+++ b/radio/aidl/android/hardware/radio/config/SimSlotStatus.aidl
@@ -16,6 +16,8 @@
 
 package android.hardware.radio.config;
 
+import android.hardware.radio.config.SimPortInfo;
+
 @VintfStability
 parcelable SimSlotStatus {
     boolean cardActive;
@@ -25,10 +27,6 @@
      */
     int cardState;
     /**
-     * Slot state Active/Inactive
-     */
-    int slotState;
-    /**
      * An Answer To Reset (ATR) is a message output by a Smart Card conforming to ISO/IEC 7816
      * standards, following electrical reset of the card's chip. The ATR conveys information about
      * the communication parameters proposed by the card, and the card's nature and state.
@@ -36,15 +34,6 @@
      * This data is applicable only when cardState is CardStatus.STATE_PRESENT.
      */
     String atr;
-    int logicalSlotId;
-    /**
-     * Integrated Circuit Card IDentifier (ICCID) is Unique Identifier of the SIM CARD. File is
-     * located in the SIM card at EFiccid (0x2FE2) as per ETSI 102.221. The ICCID is defined by
-     * the ITU-T recommendation E.118 ISO/IEC 7816.
-     *
-     * This data is applicable only when cardState is CardStatus.STATE_PRESENT.
-     */
-    String iccid;
     /**
      * The EID is the eUICC identifier. The EID shall be stored within the ECASD and can be
      * retrieved by the Device at any time using the standard GlobalPlatform GET DATA command.
@@ -53,4 +42,8 @@
      * card supports eUICC.
      */
     String eid;
+    /**
+     * PortInfo contains the ICCID, logical slot ID, and port state
+     */
+    SimPortInfo[] portInfo;
 }
diff --git a/radio/aidl/android/hardware/radio/config/SlotPortMapping.aidl b/radio/aidl/android/hardware/radio/config/SlotPortMapping.aidl
new file mode 100644
index 0000000..3046d4f
--- /dev/null
+++ b/radio/aidl/android/hardware/radio/config/SlotPortMapping.aidl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2021 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 android.hardware.radio.config;
+
+@VintfStability
+parcelable SlotPortMapping {
+    /**
+     * Physical slot id is the index of the slots
+     **/
+    int physicalSlotId;
+    /**
+     * PortId is the id (enumerated value) for the associated port available on the SIM.
+     * Example:
+     * if eUICC1 supports 2 ports, then the portId is numbered 0,1.
+     * if eUICC2 supports 4 ports, then the portId is numbered: 0,1,2,3.
+     * Each portId is unique within a UICC, but not necessarily unique across UICC’s.
+     * SEP(Single enabled profile) eUICC and non-eUICC will only have portId 0.
+     **/
+    int portId;
+}
diff --git a/radio/aidl/android/hardware/radio/sim/CardStatus.aidl b/radio/aidl/android/hardware/radio/sim/CardStatus.aidl
index 629f403..3098c4d 100644
--- a/radio/aidl/android/hardware/radio/sim/CardStatus.aidl
+++ b/radio/aidl/android/hardware/radio/sim/CardStatus.aidl
@@ -16,6 +16,7 @@
 
 package android.hardware.radio.sim;
 
+import android.hardware.radio.config.SlotPortMapping;
 import android.hardware.radio.sim.AppStatus;
 import android.hardware.radio.sim.PinState;
 
@@ -61,7 +62,6 @@
      * size <= RadioConst::CARD_MAX_APPS
      */
     AppStatus[] applications;
-    int physicalSlotId;
     /**
      * An Answer To Reset (ATR) is a message output by a Smart Card conforming to ISO/IEC 7816
      * standards, following electrical reset of the card's chip. The ATR conveys information about
@@ -86,4 +86,10 @@
      * supports eUICC.
      */
     String eid;
+    /* SlotPortMapping:
+     * SlotPortMapping consists of physical slot id and port id.
+     * Physical slot is the actual physical slot.
+     * PortId is the id (enumerated value) for the associated port available on the SIM.
+     */
+    SlotPortMapping slotMap;
 }