Add iUICC switch FR81002 support

 - Add get/set SimType APIs over IExtPhone.aidl
 - Add onSimTypeChanged() callback method over
   IExtPhoneCallback.aidl

Change-Id: Id75e56a333d7e8a21db66a76197f01dc6bf12173
CRs-Fixed: 3319861
diff --git a/extphone/src/com/qti/extphone/ExtPhoneCallbackBase.java b/extphone/src/com/qti/extphone/ExtPhoneCallbackBase.java
index 3a77c0a..38bb777 100644
--- a/extphone/src/com/qti/extphone/ExtPhoneCallbackBase.java
+++ b/extphone/src/com/qti/extphone/ExtPhoneCallbackBase.java
@@ -261,4 +261,12 @@
     public void onQosParametersChanged(int slotId, int cid, QosParametersResult result)
             throws RemoteException {
     }
+
+    @Override
+    public void setSimTypeResponse(Token token, Status status) throws RemoteException {
+    }
+
+    @Override
+    public void onSimTypeChanged(QtiSimType[] simtype) throws RemoteException {
+    }
 }
diff --git a/extphone/src/com/qti/extphone/ExtTelephonyManager.java b/extphone/src/com/qti/extphone/ExtTelephonyManager.java
index 8390999..525589f 100644
--- a/extphone/src/com/qti/extphone/ExtTelephonyManager.java
+++ b/extphone/src/com/qti/extphone/ExtTelephonyManager.java
@@ -1019,6 +1019,72 @@
         return token;
     }
 
+   /**
+    * Get the supported Sim Type information on all available slots
+    *
+    * @return - Array of SimType corresponds to each Slot, the supported
+    *           Sim Types are Physical/eSIM or iUICC or both.
+    *
+    * Requires Permission: android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE
+    */
+    public QtiSimType[] getSupportedSimTypes() {
+        if (isServiceConnected()) {
+            try {
+                return mExtTelephonyService.getSupportedSimTypes();
+            } catch (RemoteException e) {
+                Log.e(LOG_TAG, "getSupportedSimTypes ended in remote exception", e);
+            }
+        } else {
+            Log.e(LOG_TAG, "service not connected!");
+        }
+        return null;
+    }
+
+   /**
+    * Get current active Sim Type, Physical/eSIM or iUICC
+    *
+    * @return - Array of SimType corresponds to each Slot.
+    *
+    * Requires Permission: android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE
+    */
+    public QtiSimType[] getCurrentSimType() {
+        if (isServiceConnected()) {
+            try {
+                return mExtTelephonyService.getCurrentSimType();
+            } catch (RemoteException e) {
+                Log.e(LOG_TAG, "getCurrentSimType ended in remote exception", e);
+            }
+        } else {
+            Log.e(LOG_TAG, "getCurrentSimType, service not connected!");
+        }
+        return null;
+    }
+
+   /**
+    * Set SIM Type to either Physical/eSIM or iUICC
+    *
+    * @param client - Client registered with package name to receive callbacks.
+    * @param simType - QtiSimType array contains the SimType to be set for all the slots.
+    * @return - Integer Token can be used to compare with the response, null Token value
+    *        can be returned if request cannot be processed.
+    *
+    * @Response would be sent over IExtPhoneCallback.setSimTypeResponse()
+    *
+    * Requires Permission: android.Manifest.permission.MODIFY_PHONE_STATE
+    */
+    public Token setSimType(Client client, QtiSimType[] simType) throws RemoteException {
+        if (isServiceConnected()) {
+            try {
+                return mExtTelephonyService.setSimType(client, simType);
+            } catch (RemoteException e) {
+                Log.e(LOG_TAG, "setSimType ended in remote exception", e);
+            }
+        } else {
+            Log.e(LOG_TAG, "setSimType, service not connected!");
+        }
+        return null;
+    }
+
     public Client registerCallback(String packageName, IExtPhoneCallback callback) {
         Client client = null;
         if (!isServiceConnected()) {
diff --git a/extphone/src/com/qti/extphone/IExtPhone.aidl b/extphone/src/com/qti/extphone/IExtPhone.aidl
index 5bc5345..5c5a0c6 100644
--- a/extphone/src/com/qti/extphone/IExtPhone.aidl
+++ b/extphone/src/com/qti/extphone/IExtPhone.aidl
@@ -46,6 +46,7 @@
 import com.qti.extphone.NrConfig;
 import com.qti.extphone.QtiImeiInfo;
 import com.qti.extphone.QtiSetNetworkSelectionMode;
+import com.qti.extphone.QtiSimType;
 
 interface IExtPhone {
 
@@ -543,4 +544,28 @@
      * @return - Integer Token can be used to compare with the response.
      */
     Token setMsimPreference(in Client client, in MsimPreference pref);
+
+    /**
+     * Get current active Sim Type, Physical/eSIM or iUICC
+     *
+     * @return - Array of SimType corresponds to each Slot.
+     */
+    QtiSimType[] getCurrentSimType();
+
+    /**
+     * Get the supported Sim Type information on all available slots
+     *
+     * @return - Array of SimType corresponds to each Slot, the supported
+     *           Sim Types are Physical/eSIM or iUICC or both.
+     */
+    QtiSimType[] getSupportedSimTypes();
+
+    /**
+     * Set SIM Type to either Physical/eSIM or iUICC
+     *
+     * @param client - Client registered with package name to receive callbacks.
+     * @param simType - QtiSimType array contains the SimType to be set for all the slots.
+     * @return - Integer Token can be used to compare with the response.
+     */
+    Token setSimType(in Client client, in QtiSimType[] simType);
 }
diff --git a/extphone/src/com/qti/extphone/IExtPhoneCallback.aidl b/extphone/src/com/qti/extphone/IExtPhoneCallback.aidl
index 90d6f6b..484cedd 100644
--- a/extphone/src/com/qti/extphone/IExtPhoneCallback.aidl
+++ b/extphone/src/com/qti/extphone/IExtPhoneCallback.aidl
@@ -48,6 +48,7 @@
 import com.qti.extphone.QtiCallForwardInfo;
 import com.qti.extphone.QtiImeiInfo;
 import com.qti.extphone.SignalStrength;
+import com.qti.extphone.QtiSimType;
 import com.qti.extphone.SmsResult;
 import com.qti.extphone.Status;
 import com.qti.extphone.Token;
@@ -342,4 +343,20 @@
      * @param - status SUCCESS/FAILURE based on RIL NAS module response
      */
     void setMsimPreferenceResponse(in Token token, in Status status);
+
+
+    /**
+     * Response to setSimType
+     *
+     * @param - token is the same token which is received in setSimType
+     * @param - status SUCCESS/FAILURE based on below layers response
+     */
+    void setSimTypeResponse(in Token token, in Status status);
+
+    /**
+     * Indication sent when Sim Type on a slot changes.
+     *
+     * @param - simtype array contains the current Sim Type on each Slot
+     */
+    void onSimTypeChanged(in QtiSimType[] simtype);
 }
diff --git a/extphone/src/com/qti/extphone/QtiSimType.aidl b/extphone/src/com/qti/extphone/QtiSimType.aidl
new file mode 100644
index 0000000..9f72b98
--- /dev/null
+++ b/extphone/src/com/qti/extphone/QtiSimType.aidl
@@ -0,0 +1,8 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+package com.qti.extphone;
+
+parcelable QtiSimType;
diff --git a/extphone/src/com/qti/extphone/QtiSimType.java b/extphone/src/com/qti/extphone/QtiSimType.java
new file mode 100644
index 0000000..94283b9
--- /dev/null
+++ b/extphone/src/com/qti/extphone/QtiSimType.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+package com.qti.extphone;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public class QtiSimType implements Parcelable {
+    private static final String TAG = "QtiSimType";
+
+    /**
+     * For completeness added eSIM related constants below but, currently they are not used.
+     * At present, PHYSICAL type is used for both Physical and eSIM Type cards.
+     */
+    public static final int SIM_TYPE_INVALID = -1;
+    public static final int SIM_TYPE_PHYSICAL = 0;
+    public static final int SIM_TYPE_ESIM = 1;
+    public static final int SIM_TYPE_IUICC = 2;
+    public static final int SIM_TYPE_PHYSICAL_ESIM = 3;
+    public static final int SIM_TYPE_PHYSICAL_IUICC = 4;
+    public static final int SIM_TYPE_ESIM_IUICC = 5;
+    public static final int SIM_TYPE_PHYSICAL_ESIM_IUICC = 6;
+
+    private int mType;
+
+    public QtiSimType(int val) {
+        mType = val;
+    }
+
+    public QtiSimType(Parcel in) {
+        mType = in.readInt();
+    }
+
+    public int get() {
+        return mType;
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel out, int flags) {
+        out.writeInt(mType);
+    }
+
+    public static final Parcelable.Creator<QtiSimType> CREATOR = new Parcelable.Creator() {
+        public QtiSimType createFromParcel(Parcel in) {
+            return new QtiSimType(in);
+        }
+
+        public QtiSimType[] newArray(int size) {
+            return new QtiSimType[size];
+        }
+    };
+
+    @Override
+    public String toString() {
+        return TAG + ": " + get();
+    }
+}