Merge "Add UNSUPPORTED option to CiwlanConfig"
diff --git a/extphone/src/com/qti/extphone/ExtPhoneCallbackBase.java b/extphone/src/com/qti/extphone/ExtPhoneCallbackBase.java
index 49e1ccf..cc31b58 100644
--- a/extphone/src/com/qti/extphone/ExtPhoneCallbackBase.java
+++ b/extphone/src/com/qti/extphone/ExtPhoneCallbackBase.java
@@ -30,7 +30,7 @@
 /*
  * Changes from Qualcomm Innovation Center are provided under the following license:
  *
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  * SPDX-License-Identifier: BSD-3-Clause-Clear
  */
 
@@ -285,4 +285,9 @@
     public void onDualDataRecommendation(DualDataRecommendation rec)
             throws RemoteException {
     }
+
+    @Override
+    public void onSimPersoUnlockStatusChange(int slotId, QtiPersoUnlockStatus persoUnlockStatus)
+            throws RemoteException {
+    }
 }
diff --git a/extphone/src/com/qti/extphone/ExtPhoneCallbackListener.java b/extphone/src/com/qti/extphone/ExtPhoneCallbackListener.java
index e3016e2..d4b006e 100644
--- a/extphone/src/com/qti/extphone/ExtPhoneCallbackListener.java
+++ b/extphone/src/com/qti/extphone/ExtPhoneCallbackListener.java
@@ -22,6 +22,7 @@
 import com.qti.extphone.NrConfigType;
 import com.qti.extphone.NrIconType;
 import com.qti.extphone.QRadioResponseInfo;
+import com.qti.extphone.QtiPersoUnlockStatus;
 import com.qti.extphone.SignalStrength;
 import com.qti.extphone.Status;
 import com.qti.extphone.Token;
@@ -76,6 +77,7 @@
     public static final int EVENT_ON_DUAL_DATA_CAPABILITY_CHANGED = 39;
     public static final int EVENT_SET_DUAL_DATA_USER_PREFERENCE_RESPONSE = 40;
     public static final int EVENT_ON_DUAL_DATA_RECOMMENDATION = 41;
+    public static final int EVENT_ON_SIM_PERSO_UNLOCK_STATUS_CHANGE = 42;
 
     private Handler mHandler;
     IExtPhoneCallback mCallback = new IExtPhoneCallbackStub(this);
@@ -518,6 +520,17 @@
                             Log.e(TAG, "EVENT_ON_DUAL_DATA_RECOMMENDATION : Exception = " + e);
                         }
                         break;
+                    case EVENT_ON_SIM_PERSO_UNLOCK_STATUS_CHANGE:
+                        try {
+                            IExtPhoneCallbackStub.Result result =
+                                    (IExtPhoneCallbackStub.Result) msg.obj;
+                            ExtPhoneCallbackListener.this.onSimPersoUnlockStatusChange(
+                                    result.mSlotId, (QtiPersoUnlockStatus)result.mData);
+                        } catch (RemoteException e) {
+                            Log.e(TAG,
+                                    "EVENT_ON_SIM_PERSO_UNLOCK_STATUS_CHANGE : Exception = " + e);
+                        }
+                        break;
                     default :
                         Log.d(TAG, "default : " + msg.what);
                 }
@@ -755,6 +768,12 @@
         Log.d(TAG, "UNIMPLEMENTED: onDualDataRecommendation: rec = " + rec);
     }
 
+    public void onSimPersoUnlockStatusChange(int slotId, QtiPersoUnlockStatus persoUnlockStatus)
+            throws RemoteException {
+        Log.d(TAG, "UNIMPLEMENTED: onSimPersoUnlockStatusChange: slotId = "
+                + slotId + " persoUnlockStatus = " + persoUnlockStatus);
+    }
+
     private static class IExtPhoneCallbackStub extends IExtPhoneCallback.Stub {
         private WeakReference<ExtPhoneCallbackListener> mExtPhoneCallbackListenerWeakRef;
 
@@ -1032,6 +1051,13 @@
                     new Result(-1, null, null, -1, rec));
         }
 
+        @Override
+        public void onSimPersoUnlockStatusChange(int slotId, QtiPersoUnlockStatus persoUnlockStatus)
+                throws RemoteException {
+            send(EVENT_ON_SIM_PERSO_UNLOCK_STATUS_CHANGE, 0, 0,
+                    new Result(slotId, null, null, -1, persoUnlockStatus));
+        }
+
         class Result {
             int mSlotId;
             Token mToken;
diff --git a/extphone/src/com/qti/extphone/ExtTelephonyManager.java b/extphone/src/com/qti/extphone/ExtTelephonyManager.java
index 5d85322..b77a58d 100644
--- a/extphone/src/com/qti/extphone/ExtTelephonyManager.java
+++ b/extphone/src/com/qti/extphone/ExtTelephonyManager.java
@@ -1143,6 +1143,20 @@
         return token;
     }
 
+    public QtiPersoUnlockStatus getSimPersoUnlockStatus(int slotId) {
+        QtiPersoUnlockStatus persoUnlockStatus = null;
+        if (!isServiceConnected()) {
+            Log.e(LOG_TAG, "service not connected!");
+            return persoUnlockStatus;
+        }
+        try {
+            persoUnlockStatus = mExtTelephonyService.getSimPersoUnlockStatus(slotId);
+        } catch (RemoteException e) {
+            Log.e(LOG_TAG, "Remote exception for getSimPersoUnlockStatus", e);
+        }
+        return persoUnlockStatus;
+    }
+
     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 3ff300d..72641ce 100644
--- a/extphone/src/com/qti/extphone/IExtPhone.aidl
+++ b/extphone/src/com/qti/extphone/IExtPhone.aidl
@@ -45,6 +45,7 @@
 import com.qti.extphone.MsimPreference;
 import com.qti.extphone.NrConfig;
 import com.qti.extphone.QtiImeiInfo;
+import com.qti.extphone.QtiPersoUnlockStatus;
 import com.qti.extphone.QtiSetNetworkSelectionMode;
 import com.qti.extphone.QtiSimType;
 import com.qti.extphone.Token;
@@ -616,4 +617,12 @@
      * Response function is IExtPhoneCallback#setDualDataUserPreferenceResponse().
      */
     Token setDualDataUserPreference(in Client client, in boolean enable);
+
+    /**
+     * Query the SIM Perso unlock Status
+     *
+     * @param - slotId slot ID
+     * @return - persoUnlockStatus which can be generally temporary or permanent.
+     */
+    QtiPersoUnlockStatus getSimPersoUnlockStatus(int slotId);
 }
diff --git a/extphone/src/com/qti/extphone/IExtPhoneCallback.aidl b/extphone/src/com/qti/extphone/IExtPhoneCallback.aidl
index 751bffc..5434618 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.QosParametersResult;
 import com.qti.extphone.QtiCallForwardInfo;
 import com.qti.extphone.QtiImeiInfo;
+import com.qti.extphone.QtiPersoUnlockStatus;
 import com.qti.extphone.SignalStrength;
 import com.qti.extphone.QtiSimType;
 import com.qti.extphone.SmsResult;
@@ -395,4 +396,12 @@
      * @param rec <DualDataRecommendation> to allow/disallow internet pdn on nDDS.
      */
     void onDualDataRecommendation(in DualDataRecommendation rec);
+
+    /**
+     * Indication received when persoSubState is unlocked either temporarily or permanently
+     *
+     * @param - slotId on which the persoSubState changed
+     * @param - persoUnlockStatus which can be generally temporary or permanent.
+     */
+    void onSimPersoUnlockStatusChange(int slotId, in QtiPersoUnlockStatus persoUnlockStatus);
 }
diff --git a/extphone/src/com/qti/extphone/QtiPersoUnlockStatus.aidl b/extphone/src/com/qti/extphone/QtiPersoUnlockStatus.aidl
new file mode 100644
index 0000000..bfad957
--- /dev/null
+++ b/extphone/src/com/qti/extphone/QtiPersoUnlockStatus.aidl
@@ -0,0 +1,8 @@
+/*
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+package com.qti.extphone;
+
+parcelable QtiPersoUnlockStatus;
\ No newline at end of file
diff --git a/extphone/src/com/qti/extphone/QtiPersoUnlockStatus.java b/extphone/src/com/qti/extphone/QtiPersoUnlockStatus.java
new file mode 100644
index 0000000..9d86524
--- /dev/null
+++ b/extphone/src/com/qti/extphone/QtiPersoUnlockStatus.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2023 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 QtiPersoUnlockStatus implements Parcelable {
+    private static final String TAG = "QtiPersoUnlockStatus";
+
+    public static final int UNKNOWN = 0;
+    public static final int TEMPORARY_UNLOCKED  = 1;
+    public static final int PERMANENT_UNLOCKED  = 2;
+
+    private int mPersoUnlockStatus;
+
+    public QtiPersoUnlockStatus(int status) {
+        mPersoUnlockStatus = status;
+    }
+
+    public QtiPersoUnlockStatus(Parcel in) {
+        mPersoUnlockStatus = in.readInt();
+    }
+
+    public int get() {
+        return mPersoUnlockStatus;
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel out, int flags) {
+        out.writeInt(mPersoUnlockStatus);
+    }
+
+    public static final Parcelable.Creator<QtiPersoUnlockStatus> CREATOR =
+            new Parcelable.Creator() {
+        public QtiPersoUnlockStatus createFromParcel(Parcel in) {
+            return new QtiPersoUnlockStatus(in);
+        }
+
+        public QtiPersoUnlockStatus[] newArray(int size) {
+            return new QtiPersoUnlockStatus[size];
+        }
+    };
+
+    @Override
+    public String toString() {
+        return TAG + ": " + get();
+    }
+}