Merge "Primary IMEI FR70532 changes"
diff --git a/extphone/src/com/qti/extphone/ExtPhoneCallbackBase.java b/extphone/src/com/qti/extphone/ExtPhoneCallbackBase.java
index 934887b..791579c 100644
--- a/extphone/src/com/qti/extphone/ExtPhoneCallbackBase.java
+++ b/extphone/src/com/qti/extphone/ExtPhoneCallbackBase.java
@@ -165,4 +165,8 @@
             RemoteException {
         Log.d(TAG, "setSmartDdsSwitchToggleResponse: token = " + token +  " result = " + result);
     }
+
+    @Override
+    public void onImeiTypeChanged(QtiImeiInfo[] imeiInfo) throws RemoteException {
+    }
 }
diff --git a/extphone/src/com/qti/extphone/ExtTelephonyManager.java b/extphone/src/com/qti/extphone/ExtTelephonyManager.java
index b5a992c..9d74c74 100644
--- a/extphone/src/com/qti/extphone/ExtTelephonyManager.java
+++ b/extphone/src/com/qti/extphone/ExtTelephonyManager.java
@@ -754,6 +754,26 @@
         }
     }
 
+   /**
+    * To get the IMEI information of all slots on device.
+    * @return
+    *        QtiImeiInfo[], contains array of imeiInfo(i.e slotId, IMEI string and IMEI type).
+    *
+    * The calling application should not assume returned array index as slotId, instead the
+    * application has to use the slotId that present in QtiImeiInfo object to know the IMEI
+    * corresponds to a slot.
+    *
+    * Requires Permission: android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE
+    */
+    public QtiImeiInfo[] getImeiInfo() {
+        try {
+            return mExtTelephonyService.getImeiInfo();
+        } catch (RemoteException e) {
+            Log.e(LOG_TAG, "getImeiInfo ended in remote exception");
+            e.printStackTrace();
+        }
+        return null;
+    }
 
     public boolean isSmartDdsSwitchFeatureAvailable() throws RemoteException {
         try {
diff --git a/extphone/src/com/qti/extphone/IExtPhone.aidl b/extphone/src/com/qti/extphone/IExtPhone.aidl
index 0a0f20a..e5e901f 100644
--- a/extphone/src/com/qti/extphone/IExtPhone.aidl
+++ b/extphone/src/com/qti/extphone/IExtPhone.aidl
@@ -36,6 +36,7 @@
 import com.qti.extphone.IDepersoResCallback;
 import com.qti.extphone.IExtPhoneCallback;
 import com.qti.extphone.NrConfig;
+import com.qti.extphone.QtiImeiInfo;
 
 interface IExtPhone {
 
@@ -340,4 +341,12 @@
     void setSmartDdsSwitchToggle(boolean isEnabled, in Client client);
 
     boolean isFeatureSupported(int feature);
+
+   /**
+    * To get the IMEI information of all slots on device
+    * @return
+    *        QtiImeiInfo[], contains array imeiInfo(i.e slotId, IMEI string and type)
+    * Requires Permission: android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE
+    */
+    QtiImeiInfo[] getImeiInfo();
 }
diff --git a/extphone/src/com/qti/extphone/IExtPhoneCallback.aidl b/extphone/src/com/qti/extphone/IExtPhoneCallback.aidl
index 483c57b..5923db5 100644
--- a/extphone/src/com/qti/extphone/IExtPhoneCallback.aidl
+++ b/extphone/src/com/qti/extphone/IExtPhoneCallback.aidl
@@ -36,6 +36,7 @@
 import com.qti.extphone.NrIconType;
 import com.qti.extphone.QtiCallForwardInfo;
 import com.qti.extphone.QRadioResponseInfo;
+import com.qti.extphone.QtiImeiInfo;
 import com.qti.extphone.SignalStrength;
 import com.qti.extphone.SmsResult;
 import com.qti.extphone.Status;
@@ -167,4 +168,15 @@
     * @param - result SUCCESS/FAILURE based on the CnE HAL response
     */
     void setSmartDdsSwitchToggleResponse(in Token token, boolean result);
+
+   /**
+    * Indication would be sent whenever Primary IMEI mapping changes
+    * @param - imeiInfo, array of imeiInfo object which contains
+    *          slotId, IMEI string and type
+    *
+    * The calling application should not assume received array index as slotId, instead the
+    * application has to use the slotId that present in QtiImeiInfo object to know the IMEI
+    * corresponds to a slot.
+    */
+    void onImeiTypeChanged(in QtiImeiInfo[] imeiInfo);
 }
diff --git a/extphone/src/com/qti/extphone/QtiImeiInfo.aidl b/extphone/src/com/qti/extphone/QtiImeiInfo.aidl
new file mode 100644
index 0000000..cc66fe1
--- /dev/null
+++ b/extphone/src/com/qti/extphone/QtiImeiInfo.aidl
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2021, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of The Linux Foundation nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.qti.extphone;
+
+parcelable QtiImeiInfo;
diff --git a/extphone/src/com/qti/extphone/QtiImeiInfo.java b/extphone/src/com/qti/extphone/QtiImeiInfo.java
new file mode 100644
index 0000000..5bfc78e
--- /dev/null
+++ b/extphone/src/com/qti/extphone/QtiImeiInfo.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2021, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of The Linux Foundation nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.qti.extphone;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Objects;
+
+public class QtiImeiInfo implements Parcelable {
+    private static final String TAG = "QtiImeiInfo";
+
+    public static final int IMEI_TYPE_INVALID = -1;
+    public static final int IMEI_TYPE_PRIMARY = 0;
+    public static final int IMEI_TYPE_SECONDARY = 1;
+
+    private int mSlotId;
+    private String mImei;
+    private int mImeiType;
+
+    public QtiImeiInfo(int slotId, String imei, int imeiType) {
+        mSlotId = slotId;
+        mImei = imei;
+        mImeiType = imeiType;
+    }
+
+    public QtiImeiInfo(Parcel in) {
+        mSlotId = in.readInt();
+        mImei = in.readString();
+        mImeiType = in.readInt();
+    }
+
+    public int getSlotId() {
+        return mSlotId;
+    }
+
+    public String getImei() {
+        return mImei;
+    }
+
+    public int getImeiType() {
+        return mImeiType;
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel out, int flags) {
+        out.writeInt(mSlotId);
+        out.writeString(mImei);
+        out.writeInt(mImeiType);
+    }
+
+    public static final Parcelable.Creator<QtiImeiInfo> CREATOR = new Parcelable.Creator() {
+        public QtiImeiInfo createFromParcel(Parcel in) {
+            return new QtiImeiInfo(in);
+        }
+
+        public QtiImeiInfo[] newArray(int size) {
+            return new QtiImeiInfo[size];
+        }
+    };
+
+    public void readFromParcel(Parcel in) {
+        mSlotId = in.readInt();
+        mImei = in.readString();
+        mImeiType = in.readInt();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        QtiImeiInfo imeiInfo = (QtiImeiInfo) o;
+
+        return this.mSlotId == imeiInfo.mSlotId &&
+                this.mImeiType == imeiInfo.mImeiType &&
+                Objects.equals(this.mImei, imeiInfo.mImei);
+    }
+
+    @Override
+    public String toString() {
+        return "QtiImeiInfo{" + " slotId=" + mSlotId + " mImeiType=" + getImeiType() +  "}";
+    }
+}