Add Manual Provisioning Support

* Add status variable in SubInfoRecord.
* Add new APIs in SubscriptionManager to activate/deactivate sub.
* Add new APIs to get and set subStatus.

Conflicts:
	telephony/java/android/telephony/SubInfoRecord.java
	telephony/java/android/telephony/SubscriptionManager.java

Change-Id: I8098c46ced297cda748946caab86a5010cc0a255
diff --git a/telephony/java/android/telephony/SubInfoRecord.java b/telephony/java/android/telephony/SubInfoRecord.java
old mode 100644
new mode 100755
index 805f787..76af399
--- a/telephony/java/android/telephony/SubInfoRecord.java
+++ b/telephony/java/android/telephony/SubInfoRecord.java
@@ -75,6 +75,7 @@
      * Mobile Network Code
      */
     public int mnc;
+    public int mStatus;
 
     public SubInfoRecord() {
         this.subId = SubscriptionManager.INVALID_SUB_ID;
@@ -89,11 +90,12 @@
         this.simIconRes = new int[2];
         this.mcc = 0;
         this.mnc = 0;
+        this.mStatus = SubscriptionManager.INACTIVE;
     }
 
     public SubInfoRecord(long subId, String iccId, int slotId, String displayName, int nameSource,
             int color, String number, int displayFormat, int roaming, int[] iconRes,
-            int mcc, int mnc) {
+            int mcc, int mnc, int status) {
         this.subId = subId;
         this.iccId = iccId;
         this.slotId = slotId;
@@ -106,6 +108,7 @@
         this.simIconRes = iconRes;
         this.mcc = mcc;
         this.mnc = mnc;
+        this.mStatus = status;
     }
 
     public static final Parcelable.Creator<SubInfoRecord> CREATOR = new Parcelable.Creator<SubInfoRecord>() {
@@ -124,9 +127,10 @@
             source.readIntArray(iconRes);
             int mcc = source.readInt();
             int mnc = source.readInt();
+            int status = source.readInt();
 
             return new SubInfoRecord(subId, iccId, slotId, displayName, nameSource, color, number,
-                displayNumberFormat, dataRoaming, iconRes, mcc, mnc);
+                displayNumberFormat, dataRoaming, iconRes, mcc, mnc, status);
         }
 
         @Override
@@ -149,6 +153,7 @@
         dest.writeIntArray(simIconRes);
         dest.writeInt(mcc);
         dest.writeInt(mnc);
+        dest.writeInt(mStatus);
     }
 
     @Override
@@ -162,6 +167,7 @@
                 + " mDisplayName=" + displayName + " mNameSource=" + nameSource
                 + " mColor=" + color + " mNumber=" + number
                 + " mDisplayNumberFormat=" + displayNumberFormat + " mDataRoaming=" + dataRoaming
-                + " mSimIconRes=" + simIconRes + " mMcc " + mcc + " mMnc " + mnc + "}";
+                + " mSimIconRes=" + simIconRes + " mMcc " + mcc + " mMnc " + mnc
+                + " mStatus=" + mStatus + "}";
     }
 }
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
old mode 100644
new mode 100755
index 4557501..e7a16c6
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -118,6 +118,16 @@
     public static final int SIM_NOT_INSERTED = -1;
 
     /**
+     * The activation state of SIM/sub.
+     * <P>Type: INTEGER (int)</P>
+     */
+    public static final String SUB_STATE = "sub_state";
+
+    public static final int INACTIVE = 0;
+    public static final int ACTIVE = 1;
+    public static final int SUB_CONFIGURATION_IN_PROGRESS = 2;
+
+    /**
      * TelephonyProvider column name for user displayed name.
      * <P>Type: TEXT (String)</P>
      */
@@ -971,6 +981,49 @@
     }
 
     /** @hide */
+    public static void activateSubId(long subId) {
+        logd("activateSubId sub id = " + subId);
+        try {
+            getISubInfo().activateSubId(subId);
+        } catch (RemoteException ex) {
+            return;
+        }
+    }
+
+    public static void deactivateSubId(long subId) {
+        logd("deactivateSubId sub id = " + subId);
+        try {
+            getISubInfo().deactivateSubId(subId);
+        } catch (RemoteException ex) {
+            return;
+        }
+    }
+
+    public static int getSubState(long subId) {
+        logd("getSubState sub id = " + subId);
+        try {
+            return getISubInfo().getSubState(subId);
+        } catch (RemoteException ex) {
+            return INACTIVE;
+        }
+    }
+
+    public static int setSubState(long subId, int subState) {
+        logd("setSubState sub id = " + subId + " state = " + subState);
+        try {
+            return getISubInfo().setSubState(subId, subState);
+        } catch (RemoteException ex) {
+            return INACTIVE;
+        }
+    }
+
+   /**
+    @hide
+    */
+    private static ISub getISubInfo() {
+        return ISub.Stub.asInterface(ServiceManager.getService("isub"));
+    }
+
     public static void putPhoneIdAndSubIdExtra(Intent intent, int phoneId) {
         long[] subIds = SubscriptionManager.getSubId(phoneId);
         if (subIds != null && subIds.length > 0) {
diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl
index c5ecd85..7eb53af 100755
--- a/telephony/java/com/android/internal/telephony/ISub.aidl
+++ b/telephony/java/com/android/internal/telephony/ISub.aidl
@@ -159,4 +159,12 @@
     boolean isVoicePromptEnabled();
 
     void setVoicePromptEnabled(boolean enabled);
+
+    void activateSubId(long subId);
+
+    void deactivateSubId(long subId);
+
+    int setSubState(long subId, int subStatus);
+
+    int getSubState(long subId);
 }
diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java
old mode 100644
new mode 100755
index 8886e84..93a796a
--- a/telephony/java/com/android/internal/telephony/PhoneConstants.java
+++ b/telephony/java/com/android/internal/telephony/PhoneConstants.java
@@ -185,7 +185,8 @@
     public enum CardUnavailableReason {
         REASON_CARD_REMOVED,
         REASON_RADIO_UNAVAILABLE,
-        REASON_SIM_REFRESH_RESET
+        REASON_SIM_REFRESH_RESET,
+        REASON_APM_SIM_POWER_DOWN
     };
 
     // Initial MTU value.