Expose sendEnvelope method to ITelephony interface.

The NovaSwitcher app will call it to trigger REFRESH command from UICC.

Change-Id: I4696ec89226c0c701b6031e93b3389c0312b2619
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 2d0597d..d8b0d30 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -91,7 +91,8 @@
     private static final int EVENT_NV_RESET_CONFIG_DONE = 20;
     private static final int CMD_SET_RADIO_MODE = 21;
     private static final int EVENT_SET_RADIO_MODE_DONE = 22;
-
+    private static final int CMD_SEND_ENVELOPE = 23;
+    private static final int EVENT_SEND_ENVELOPE_DONE = 24;
 
     /** The singleton instance. */
     private static PhoneInterfaceManager sInstance;
@@ -271,6 +272,26 @@
                     }
                     break;
 
+                case CMD_SEND_ENVELOPE:
+                    request = (MainThreadRequest) msg.obj;
+                    onCompleted = obtainMessage(EVENT_SEND_ENVELOPE_DONE, request);
+                    UiccController.getInstance().getUiccCard().sendEnvelope(
+                            (String)request.argument, onCompleted);
+                    break;
+
+                case EVENT_SEND_ENVELOPE_DONE:
+                    ar = (AsyncResult) msg.obj;
+                    request = (MainThreadRequest) ar.userObj;
+                    if (ar.exception == null) {
+                        request.result = (ar.result == null) ? "" : ar.result;
+                    } else {
+                        loge("sendEnvelope: Unknown exception " + ar.exception);
+                    }
+                    synchronized (request) {
+                        request.notifyAll();
+                    }
+                    break;
+
                 case CMD_OPEN_CHANNEL:
                     request = (MainThreadRequest) msg.obj;
                     onCompleted = obtainMessage(EVENT_OPEN_CHANNEL_DONE, request);
@@ -1230,6 +1251,15 @@
         return s;
     }
 
+    @Override
+    public String sendEnvelope(String content) {
+        enforceSimCommunicationPermission();
+
+        String response = (String)sendRequest(CMD_SEND_ENVELOPE, content);
+
+        return response;
+    }
+
     /**
      * Read one of the NV items defined in {@link com.android.internal.telephony.RadioNVItems}
      * and {@code ril_nv_items.h}. Used for device configuration by some CDMA operators.