OSDN Git Service

Adding simple radio service and callbacks.
authorAmit Mahajan <amitmahajan@google.com>
Thu, 25 Aug 2016 18:19:21 +0000 (11:19 -0700)
committerAmit Mahajan <amitmahajan@google.com>
Thu, 5 Jan 2017 01:25:57 +0000 (17:25 -0800)
Test: Sanity tests by telephony test team.
Bug: 32020264
Change-Id: Ib2b3abb54084a1b48c5fd74042fe534e3d9fb69f

include/telephony/ril.h
libril/Android.mk
libril/ril.cpp
libril/ril_commands.h
libril/ril_internal.h [new file with mode: 0644]
libril/ril_service.cpp [new file with mode: 0644]
libril/ril_service.h [new file with mode: 0644]
rild/rild.c

index c4fc638..fe55c0a 100644 (file)
@@ -6073,6 +6073,8 @@ const RIL_RadioFunctions *RIL_SAP_Init(const struct RIL_Env *env, int argc, char
  */
 void RIL_register (const RIL_RadioFunctions *callbacks);
 
+void rilc_thread_pool();
+
 
 /**
  *
index f23bfec..7d68c52 100644 (file)
@@ -8,6 +8,7 @@ LOCAL_SRC_FILES:= \
     ril_event.cpp\
     RilSocket.cpp \
     RilSapSocket.cpp \
+    ril_service.cpp
 
 LOCAL_SHARED_LIBRARIES := \
     liblog \
@@ -16,6 +17,10 @@ LOCAL_SHARED_LIBRARIES := \
     libcutils \
     libhardware_legacy \
     librilutils \
+    android.hardware.radio@1.0 \
+    libhidlbase  \
+    libhidltransport \
+    libhwbinder
 
 LOCAL_STATIC_LIBRARIES := \
     libprotobuf-c-nano-enable_malloc \
index 762d2da..6a7e694 100644 (file)
@@ -26,7 +26,6 @@
 #include <utils/Log.h>
 #include <utils/SystemClock.h>
 #include <pthread.h>
-#include <binder/Parcel.h>
 #include <cutils/jstring.h>
 #include <sys/types.h>
 #include <sys/limits.h>
@@ -47,6 +46,7 @@
 #include <netinet/in.h>
 #include <cutils/properties.h>
 #include <RilSapSocket.h>
+#include <ril_service.h>
 
 extern "C" void
 RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen);
@@ -58,11 +58,6 @@ namespace android {
 #define PHONE_PROCESS "radio"
 #define BLUETOOTH_PROCESS "bluetooth"
 
-#define SOCKET_NAME_RIL "rild"
-#define SOCKET2_NAME_RIL "rild2"
-#define SOCKET3_NAME_RIL "rild3"
-#define SOCKET4_NAME_RIL "rild4"
-
 #define SOCKET_NAME_RIL_DEBUG "rild-debug"
 
 #define ANDROID_WAKE_LOCK_NAME "radio-interface"
@@ -84,13 +79,6 @@ namespace android {
 
 #define MIN(a,b) ((a)<(b) ? (a) : (b))
 
-/* Constants for response types */
-#define RESPONSE_SOLICITED 0
-#define RESPONSE_UNSOLICITED 1
-#define RESPONSE_SOLICITED_ACK 2
-#define RESPONSE_SOLICITED_ACK_EXP 3
-#define RESPONSE_UNSOLICITED_ACK_EXP 4
-
 /* Negative values for private RIL errno's */
 #define RIL_ERRNO_INVALID_RESPONSE (-1)
 #define RIL_ERRNO_NO_MEMORY (-12)
@@ -133,26 +121,11 @@ enum WakeType {DONT_WAKE, WAKE_PARTIAL};
 
 typedef struct {
     int requestNumber;
-    void (*dispatchFunction) (Parcel &p, struct RequestInfo *pRI);
-    int(*responseFunction) (Parcel &p, void *response, size_t responselen);
-} CommandInfo;
-
-typedef struct {
-    int requestNumber;
-    int (*responseFunction) (Parcel &p, void *response, size_t responselen);
+    int (*responseFunction) (Parcel &p, int slotId, int requestNumber, int responseType, int token,
+            RIL_Errno e, void *response, size_t responselen);
     WakeType wakeType;
 } UnsolResponseInfo;
 
-typedef struct RequestInfo {
-    int32_t token;      //this is not RIL_Token
-    CommandInfo *pCI;
-    struct RequestInfo *p_next;
-    char cancelled;
-    char local;         // responses to local commands do not go back to command process
-    RIL_SOCKET_ID socket_id;
-    int wasAckSent;    // Indicates whether an ack was sent earlier
-} RequestInfo;
-
 typedef struct UserCallbackInfo {
     RIL_TimedCallback p_callback;
     void *userParam;
@@ -160,7 +133,6 @@ typedef struct UserCallbackInfo {
     struct UserCallbackInfo *p_next;
 } UserCallbackInfo;
 
-extern "C" const char * requestToString(int request);
 extern "C" const char * failCauseToString(RIL_Errno);
 extern "C" const char * callStateToString(RIL_CallState);
 extern "C" const char * radioStateToString(RIL_RadioState);
@@ -280,40 +252,72 @@ static void dispatchSimAuthentication(Parcel &p, RequestInfo *pRI);
 static void dispatchDataProfile(Parcel &p, RequestInfo *pRI);
 static void dispatchRadioCapability(Parcel &p, RequestInfo *pRI);
 static void dispatchCarrierRestrictions(Parcel &p, RequestInfo *pRI);
-static int responseInts(Parcel &p, void *response, size_t responselen);
-static int responseFailCause(Parcel &p, void *response, size_t responselen);
-static int responseStrings(Parcel &p, void *response, size_t responselen);
-static int responseString(Parcel &p, void *response, size_t responselen);
-static int responseVoid(Parcel &p, void *response, size_t responselen);
-static int responseCallList(Parcel &p, void *response, size_t responselen);
-static int responseSMS(Parcel &p, void *response, size_t responselen);
-static int responseSIM_IO(Parcel &p, void *response, size_t responselen);
-static int responseCallForwards(Parcel &p, void *response, size_t responselen);
-static int responseDataCallList(Parcel &p, void *response, size_t responselen);
-static int responseSetupDataCall(Parcel &p, void *response, size_t responselen);
-static int responseRaw(Parcel &p, void *response, size_t responselen);
-static int responseSsn(Parcel &p, void *response, size_t responselen);
-static int responseSimStatus(Parcel &p, void *response, size_t responselen);
-static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen);
-static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen);
-static int responseCdmaSms(Parcel &p, void *response, size_t responselen);
-static int responseCellList(Parcel &p, void *response, size_t responselen);
-static int responseCdmaInformationRecords(Parcel &p,void *response, size_t responselen);
-static int responseRilSignalStrength(Parcel &p,void *response, size_t responselen);
-static int responseCallRing(Parcel &p, void *response, size_t responselen);
-static int responseCdmaSignalInfoRecord(Parcel &p,void *response, size_t responselen);
-static int responseCdmaCallWaiting(Parcel &p,void *response, size_t responselen);
-static int responseSimRefresh(Parcel &p, void *response, size_t responselen);
-static int responseCellInfoList(Parcel &p, void *response, size_t responselen);
-static int responseHardwareConfig(Parcel &p, void *response, size_t responselen);
-static int responseDcRtInfo(Parcel &p, void *response, size_t responselen);
-static int responseRadioCapability(Parcel &p, void *response, size_t responselen);
-static int responseSSData(Parcel &p, void *response, size_t responselen);
-static int responseLceStatus(Parcel &p, void *response, size_t responselen);
-static int responseLceData(Parcel &p, void *response, size_t responselen);
-static int responseActivityData(Parcel &p, void *response, size_t responselen);
-static int responseCarrierRestrictions(Parcel &p, void *response, size_t responselen);
-static int responsePcoData(Parcel &p, void *response, size_t responselen);
+static int responseInts(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseFailCause(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseStrings(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseString(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseVoid(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseCallList(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseSMS(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseSIM_IO(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseCallForwards(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen);
+static int responseDataCallList(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen);
+static int responseSetupDataCall(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen);
+static int responseRaw(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseSsn(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseGsmBrSmsCnf(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen);
+static int responseCdmaBrSmsCnf(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen);
+static int responseCdmaSms(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseCellList(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseCdmaInformationRecords(Parcel &p, int slotId, int requestNumber,
+        int responseType, int token, RIL_Errno e,void *response, size_t responselen);
+static int responseRilSignalStrength(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e,void *response, size_t responselen);
+static int responseCallRing(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseCdmaSignalInfoRecord(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e,void *response, size_t responselen);
+static int responseCdmaCallWaiting(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e,void *response, size_t responselen);
+static int responseSimRefresh(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseCellInfoList(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen);
+static int responseHardwareConfig(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen);
+static int responseDcRtInfo(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseRadioCapability(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen);
+static int responseSSData(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseLceStatus(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseLceData(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
+static int responseActivityData(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen);
+static int responseCarrierRestrictions(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen);
+static int responsePcoData(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen);
 
 static void grabPartialWakeLock();
 static void releaseWakeLock();
@@ -356,7 +360,7 @@ static UnsolResponseInfo s_unsolResponses[] = {
 #include "ril_unsol_commands.h"
 };
 
-static char * RIL_getRilSocketName() {
+char * RIL_getRilSocketName() {
     return rild;
 }
 
@@ -548,13 +552,59 @@ processCommandBuffer(void *buffer, size_t buflen, RIL_SOCKET_ID socket_id) {
     ret = pthread_mutex_unlock(pendingRequestsMutexHook);
     assert (ret == 0);
 
-/*    sLastDispatchedToken = token; */
-
     pRI->pCI->dispatchFunction(p, pRI);
 
     return 0;
 }
 
+int
+addRequestToList(RequestInfo *pRI, int request, int token, RIL_SOCKET_ID socket_id) {
+    status_t status;
+    int ret;
+    /* Hook for current context */
+    /* pendingRequestsMutextHook refer to &s_pendingRequestsMutex */
+    pthread_mutex_t* pendingRequestsMutexHook = &s_pendingRequestsMutex;
+    /* pendingRequestsHook refer to &s_pendingRequests */
+    RequestInfo**    pendingRequestsHook = &s_pendingRequests;
+
+#if (SIM_COUNT >= 2)
+    if (socket_id == RIL_SOCKET_2) {
+        pendingRequestsMutexHook = &s_pendingRequestsMutex_socket2;
+        pendingRequestsHook = &s_pendingRequests_socket2;
+    }
+#if (SIM_COUNT >= 3)
+    else if (socket_id == RIL_SOCKET_3) {
+        pendingRequestsMutexHook = &s_pendingRequestsMutex_socket3;
+        pendingRequestsHook = &s_pendingRequests_socket3;
+    }
+#endif
+#if (SIM_COUNT >= 4)
+    else if (socket_id == RIL_SOCKET_4) {
+        pendingRequestsMutexHook = &s_pendingRequestsMutex_socket4;
+        pendingRequestsHook = &s_pendingRequests_socket4;
+    }
+#endif
+#endif
+
+    // Received an Ack for the previous result sent to RIL.java,
+    // so release wakelock and exit
+    if (request == RIL_RESPONSE_ACKNOWLEDGEMENT) {
+        releaseWakeLock();
+        return 0;
+    }
+
+    ret = pthread_mutex_lock(pendingRequestsMutexHook);
+    assert (ret == 0);
+
+    pRI->p_next = *pendingRequestsHook;
+    *pendingRequestsHook = pRI;
+
+    ret = pthread_mutex_unlock(pendingRequestsMutexHook);
+    assert (ret == 0);
+
+    return 0;
+}
+
 static void
 invalidCommandBlock (RequestInfo *pRI) {
     RLOGE("invalid command block for token %d request %s",
@@ -2261,7 +2311,8 @@ sendResponse (Parcel &p, RIL_SOCKET_ID socket_id) {
 /** response is an int* pointing to an array of ints */
 
 static int
-responseInts(Parcel &p, void *response, size_t responselen) {
+responseInts(Parcel &p, int slotId, int requestNumber, int responseType, int token, RIL_Errno e,
+        void *response, size_t responselen) {
     int numInts;
 
     if (response == NULL && responselen != 0) {
@@ -2294,7 +2345,8 @@ responseInts(Parcel &p, void *response, size_t responselen) {
 // Response is an int or RIL_LastCallFailCauseInfo.
 // Currently, only Shamu plans to use RIL_LastCallFailCauseInfo.
 // TODO(yjl): Let all implementations use RIL_LastCallFailCauseInfo.
-static int responseFailCause(Parcel &p, void *response, size_t responselen) {
+static int responseFailCause(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL && responselen != 0) {
         RLOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -2327,13 +2379,15 @@ static int responseFailCause(Parcel &p, void *response, size_t responselen) {
 
 /** response is a char **, pointing to an array of char *'s
     The parcel will begin with the version */
-static int responseStringsWithVersion(int version, Parcel &p, void *response, size_t responselen) {
+static int responseStringsWithVersion(int version, Parcel &p, int slotId, int requestNumber,
+        int responseType, int token, RIL_Errno e, void *response, size_t responselen) {
     p.writeInt32(version);
-    return responseStrings(p, response, responselen);
+    return responseStrings(p, slotId, requestNumber, responseType, token, e, response, responselen);
 }
 
 /** response is a char **, pointing to an array of char *'s */
-static int responseStrings(Parcel &p, void *response, size_t responselen) {
+static int responseStrings(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
     int numStrings;
 
     if (response == NULL && responselen != 0) {
@@ -2371,7 +2425,8 @@ static int responseStrings(Parcel &p, void *response, size_t responselen) {
  * NULL strings are accepted
  * FIXME currently ignores responselen
  */
-static int responseString(Parcel &p, void *response, size_t responselen) {
+static int responseString(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
     /* one string only */
     startResponse;
     appendPrintBuf("%s%s", printBuf, (char*)response);
@@ -2382,13 +2437,15 @@ static int responseString(Parcel &p, void *response, size_t responselen) {
     return 0;
 }
 
-static int responseVoid(Parcel &p, void *response, size_t responselen) {
+static int responseVoid(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
     startResponse;
     removeLastChar;
     return 0;
 }
 
-static int responseCallList(Parcel &p, void *response, size_t responselen) {
+static int responseCallList(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
     int num;
 
     if (response == NULL && responselen != 0) {
@@ -2423,7 +2480,7 @@ static int responseCallList(Parcel &p, void *response, size_t responselen) {
         writeStringToParcel(p, p_cur->name);
         p.writeInt32(p_cur->namePresentation);
         // Remove when partners upgrade to version 3
-        if ((s_callbacks.version < 3) || (p_cur->uusInfo == NULL || p_cur->uusInfo->uusData == NULL)) {
+        if (s_callbacks.version < 3 || p_cur->uusInfo == NULL || p_cur->uusInfo->uusData == NULL) {
             p.writeInt32(0); /* UUS Information is absent */
         } else {
             RIL_UUS_Info *uusInfo = p_cur->uusInfo;
@@ -2458,7 +2515,8 @@ static int responseCallList(Parcel &p, void *response, size_t responselen) {
     return 0;
 }
 
-static int responseSMS(Parcel &p, void *response, size_t responselen) {
+static int responseSMS(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL) {
         RLOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -2484,8 +2542,8 @@ static int responseSMS(Parcel &p, void *response, size_t responselen) {
     return 0;
 }
 
-static int responseDataCallListV4(Parcel &p, void *response, size_t responselen)
-{
+static int responseDataCallListV4(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL && responselen != 0) {
         RLOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -2524,8 +2582,8 @@ static int responseDataCallListV4(Parcel &p, void *response, size_t responselen)
     return 0;
 }
 
-static int responseDataCallListV6(Parcel &p, void *response, size_t responselen)
-{
+static int responseDataCallListV6(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL && responselen != 0) {
         RLOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -2573,8 +2631,8 @@ static int responseDataCallListV6(Parcel &p, void *response, size_t responselen)
     return 0;
 }
 
-static int responseDataCallListV9(Parcel &p, void *response, size_t responselen)
-{
+static int responseDataCallListV9(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL && responselen != 0) {
         RLOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -2624,7 +2682,8 @@ static int responseDataCallListV9(Parcel &p, void *response, size_t responselen)
     return 0;
 }
 
-static int responseDataCallListV11(Parcel &p, void *response, size_t responselen) {
+static int responseDataCallListV11(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL && responselen != 0) {
                 RLOGE("invalid response: NULL");
                 return RIL_ERRNO_INVALID_RESPONSE;
@@ -2676,18 +2735,22 @@ static int responseDataCallListV11(Parcel &p, void *response, size_t responselen
     return 0;
 }
 
-static int responseDataCallList(Parcel &p, void *response, size_t responselen)
-{
+static int responseDataCallList(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     if (s_callbacks.version <= LAST_IMPRECISE_RIL_VERSION) {
         if (s_callbacks.version < 5) {
             RLOGD("responseDataCallList: v4");
-            return responseDataCallListV4(p, response, responselen);
+            return responseDataCallListV4(p, slotId, requestNumber, responseType, token, e,
+                    response, responselen);
         } else if (responselen % sizeof(RIL_Data_Call_Response_v6) == 0) {
-            return responseDataCallListV6(p, response, responselen);
+            return responseDataCallListV6(p, slotId, requestNumber, responseType, token, e,
+                    response, responselen);
         } else if (responselen % sizeof(RIL_Data_Call_Response_v9) == 0) {
-            return responseDataCallListV9(p, response, responselen);
+            return responseDataCallListV9(p, slotId, requestNumber, responseType, token, e,
+                    response, responselen);
         } else {
-            return responseDataCallListV11(p, response, responselen);
+            return responseDataCallListV11(p, slotId, requestNumber, responseType, token, e,
+                    response, responselen);
         }
     } else { // RIL version >= 13
         if (responselen % sizeof(RIL_Data_Call_Response_v11) != 0) {
@@ -2698,20 +2761,24 @@ static int responseDataCallList(Parcel &p, void *response, size_t responselen)
                 assert(0);
             }
         }
-        return responseDataCallListV11(p, response, responselen);
+        return responseDataCallListV11(p, slotId, requestNumber, responseType, token, e, response,
+                responselen);
     }
 }
 
-static int responseSetupDataCall(Parcel &p, void *response, size_t responselen)
-{
+static int responseSetupDataCall(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     if (s_callbacks.version < 5) {
-        return responseStringsWithVersion(s_callbacks.version, p, response, responselen);
+        return responseStringsWithVersion(s_callbacks.version, p, slotId, requestNumber,
+                responseType, token, e, response, responselen);
     } else {
-        return responseDataCallList(p, response, responselen);
+        return responseDataCallList(p, slotId, requestNumber, responseType, token, e, response,
+                responselen);
     }
 }
 
-static int responseRaw(Parcel &p, void *response, size_t responselen) {
+static int responseRaw(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL && responselen != 0) {
         RLOGE("invalid response: NULL with responselen != 0");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -2729,7 +2796,8 @@ static int responseRaw(Parcel &p, void *response, size_t responselen) {
 }
 
 
-static int responseSIM_IO(Parcel &p, void *response, size_t responselen) {
+static int responseSIM_IO(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL) {
         RLOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -2755,7 +2823,8 @@ static int responseSIM_IO(Parcel &p, void *response, size_t responselen) {
     return 0;
 }
 
-static int responseCallForwards(Parcel &p, void *response, size_t responselen) {
+static int responseCallForwards(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     int num;
 
     if (response == NULL && responselen != 0) {
@@ -2795,7 +2864,8 @@ static int responseCallForwards(Parcel &p, void *response, size_t responselen) {
     return 0;
 }
 
-static int responseSsn(Parcel &p, void *response, size_t responselen) {
+static int responseSsn(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL) {
         RLOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -2824,7 +2894,8 @@ static int responseSsn(Parcel &p, void *response, size_t responselen) {
     return 0;
 }
 
-static int responseCellList(Parcel &p, void *response, size_t responselen) {
+static int responseCellList(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
     int num;
 
     if (response == NULL && responselen != 0) {
@@ -2861,16 +2932,15 @@ static int responseCellList(Parcel &p, void *response, size_t responselen) {
 /**
  * Marshall the signalInfoRecord into the parcel if it exists.
  */
-static void marshallSignalInfoRecord(Parcel &p,
-            RIL_CDMA_SignalInfoRecord &p_signalInfoRecord) {
+static void marshallSignalInfoRecord(Parcel &p, RIL_CDMA_SignalInfoRecord &p_signalInfoRecord) {
     p.writeInt32(p_signalInfoRecord.isPresent);
     p.writeInt32(p_signalInfoRecord.signalType);
     p.writeInt32(p_signalInfoRecord.alertPitch);
     p.writeInt32(p_signalInfoRecord.signal);
 }
 
-static int responseCdmaInformationRecords(Parcel &p,
-            void *response, size_t responselen) {
+static int responseCdmaInformationRecords(Parcel &p, int slotId, int requestNumber,
+        int responseType, int token, RIL_Errno e, void *response, size_t responselen) {
     int num;
     char* string8 = NULL;
     int buffer_lenght;
@@ -2882,8 +2952,8 @@ static int responseCdmaInformationRecords(Parcel &p,
     }
 
     if (responselen != sizeof (RIL_CDMA_InformationRecords)) {
-        RLOGE("responseCdmaInformationRecords: invalid response length %d expected multiple of %d\n",
-            (int)responselen, (int)sizeof (RIL_CDMA_InformationRecords *));
+        RLOGE("responseCdmaInformationRecords: invalid response length %d expected multiple of \
+                %d\n", (int)responselen, (int)sizeof (RIL_CDMA_InformationRecords *));
         return RIL_ERRNO_INVALID_RESPONSE;
     }
 
@@ -3039,7 +3109,8 @@ static int responseCdmaInformationRecords(Parcel &p,
     return 0;
 }
 
-static void responseRilSignalStrengthV5(Parcel &p, RIL_SignalStrength_v10 *p_cur) {
+static void responseRilSignalStrengthV5(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, RIL_SignalStrength_v10 *p_cur) {
     p.writeInt32(p_cur->GW_SignalStrength.signalStrength);
     p.writeInt32(p_cur->GW_SignalStrength.bitErrorRate);
     p.writeInt32(p_cur->CDMA_SignalStrength.dbm);
@@ -3049,7 +3120,8 @@ static void responseRilSignalStrengthV5(Parcel &p, RIL_SignalStrength_v10 *p_cur
     p.writeInt32(p_cur->EVDO_SignalStrength.signalNoiseRatio);
 }
 
-static void responseRilSignalStrengthV6Extra(Parcel &p, RIL_SignalStrength_v10 *p_cur) {
+static void responseRilSignalStrengthV6Extra(Parcel &p, int slotId, int requestNumber,
+        int responseType, int token, RIL_Errno e, RIL_SignalStrength_v10 *p_cur) {
     /*
      * Fixup LTE for backwards compatibility
      */
@@ -3082,14 +3154,15 @@ static void responseRilSignalStrengthV6Extra(Parcel &p, RIL_SignalStrength_v10 *
     p.writeInt32(p_cur->LTE_SignalStrength.cqi);
 }
 
-static void responseRilSignalStrengthV10(Parcel &p, RIL_SignalStrength_v10 *p_cur) {
-    responseRilSignalStrengthV5(p, p_cur);
-    responseRilSignalStrengthV6Extra(p, p_cur);
+static void responseRilSignalStrengthV10(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, RIL_SignalStrength_v10 *p_cur) {
+    responseRilSignalStrengthV5(p, slotId, requestNumber, responseType, token, e, p_cur);
+    responseRilSignalStrengthV6Extra(p, slotId, requestNumber, responseType, token, e, p_cur);
     p.writeInt32(p_cur->TD_SCDMA_SignalStrength.rscp);
 }
 
-static int responseRilSignalStrength(Parcel &p,
-                    void *response, size_t responselen) {
+static int responseRilSignalStrength(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL && responselen != 0) {
         RLOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -3100,10 +3173,11 @@ static int responseRilSignalStrength(Parcel &p,
         if (responselen >= sizeof (RIL_SignalStrength_v5)) {
             p_cur = ((RIL_SignalStrength_v10 *) response);
 
-            responseRilSignalStrengthV5(p, p_cur);
+            responseRilSignalStrengthV5(p, slotId, requestNumber, responseType, token, e, p_cur);
 
             if (responselen >= sizeof (RIL_SignalStrength_v6)) {
-                responseRilSignalStrengthV6Extra(p, p_cur);
+                responseRilSignalStrengthV6Extra(p, slotId, requestNumber, responseType, token, e,
+                        p_cur);
                 if (responselen >= sizeof (RIL_SignalStrength_v10)) {
                     p.writeInt32(p_cur->TD_SCDMA_SignalStrength.rscp);
                 } else {
@@ -3131,7 +3205,7 @@ static int responseRilSignalStrength(Parcel &p,
             }
         }
         p_cur = ((RIL_SignalStrength_v10 *) response);
-        responseRilSignalStrengthV10(p, p_cur);
+        responseRilSignalStrengthV10(p, slotId, requestNumber, responseType, token, e, p_cur);
     }
     startResponse;
     appendPrintBuf("%s[signalStrength=%d,bitErrorRate=%d,\
@@ -3158,15 +3232,19 @@ static int responseRilSignalStrength(Parcel &p,
     return 0;
 }
 
-static int responseCallRing(Parcel &p, void *response, size_t responselen) {
+static int responseCallRing(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
     if ((response == NULL) || (responselen == 0)) {
-        return responseVoid(p, response, responselen);
+        return responseVoid(p, slotId, requestNumber, responseType, token, e, response,
+                responselen);
     } else {
-        return responseCdmaSignalInfoRecord(p, response, responselen);
+        return responseCdmaSignalInfoRecord(p, slotId, requestNumber, responseType, token, e,
+                response, responselen);
     }
 }
 
-static int responseCdmaSignalInfoRecord(Parcel &p, void *response, size_t responselen) {
+static int responseCdmaSignalInfoRecord(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL || responselen == 0) {
         RLOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -3195,8 +3273,8 @@ static int responseCdmaSignalInfoRecord(Parcel &p, void *response, size_t respon
     return 0;
 }
 
-static int responseCdmaCallWaiting(Parcel &p, void *response,
-            size_t responselen) {
+static int responseCdmaCallWaiting(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL && responselen != 0) {
         RLOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -3253,7 +3331,8 @@ static int responseCdmaCallWaiting(Parcel &p, void *response,
     return 0;
 }
 
-static void responseSimRefreshV7(Parcel &p, void *response) {
+static void responseSimRefreshV7(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response) {
       RIL_SimRefreshResponse_v7 *p_cur = ((RIL_SimRefreshResponse_v7 *) response);
       p.writeInt32(p_cur->result);
       p.writeInt32(p_cur->ef_id);
@@ -3267,7 +3346,8 @@ static void responseSimRefreshV7(Parcel &p, void *response) {
 
 }
 
-static int responseSimRefresh(Parcel &p, void *response, size_t responselen) {
+static int responseSimRefresh(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL && responselen != 0) {
         RLOGE("responseSimRefresh: invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -3276,7 +3356,7 @@ static int responseSimRefresh(Parcel &p, void *response, size_t responselen) {
     startResponse;
     if (s_callbacks.version <= LAST_IMPRECISE_RIL_VERSION) {
         if (s_callbacks.version >= 7) {
-            responseSimRefreshV7(p, response);
+            responseSimRefreshV7(p, slotId, requestNumber, responseType, token, e, response);
         } else {
             int *p_cur = ((int *) response);
             p.writeInt32(p_cur[0]);
@@ -3297,7 +3377,7 @@ static int responseSimRefresh(Parcel &p, void *response, size_t responselen) {
                 assert(0);
             }
         }
-        responseSimRefreshV7(p, response);
+        responseSimRefreshV7(p, slotId, requestNumber, responseType, token, e, response);
 
     }
     closeResponse;
@@ -3305,7 +3385,8 @@ static int responseSimRefresh(Parcel &p, void *response, size_t responselen) {
     return 0;
 }
 
-static int responseCellInfoListV6(Parcel &p, void *response, size_t responselen) {
+static int responseCellInfoListV6(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL && responselen != 0) {
         RLOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -3395,7 +3476,8 @@ static int responseCellInfoListV6(Parcel &p, void *response, size_t responselen)
     return 0;
 }
 
-static int responseCellInfoListV12(Parcel &p, void *response, size_t responselen) {
+static int responseCellInfoListV12(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL && responselen != 0) {
         RLOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -3489,15 +3571,17 @@ static int responseCellInfoListV12(Parcel &p, void *response, size_t responselen
     return 0;
 }
 
-static int responseCellInfoList(Parcel &p, void *response, size_t responselen)
-{
+static int responseCellInfoList(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     if (s_callbacks.version <= LAST_IMPRECISE_RIL_VERSION) {
         if (s_callbacks.version < 12) {
             RLOGD("responseCellInfoList: v6");
-            return responseCellInfoListV6(p, response, responselen);
+            return responseCellInfoListV6(p, slotId, requestNumber, responseType, token, e,
+                    response, responselen);
         } else {
             RLOGD("responseCellInfoList: v12");
-            return responseCellInfoListV12(p, response, responselen);
+            return responseCellInfoListV12(p, slotId, requestNumber, responseType, token, e,
+                    response, responselen);
         }
     } else { // RIL version >= 13
         if (responselen % sizeof(RIL_CellInfo_v12) != 0) {
@@ -3508,14 +3592,15 @@ static int responseCellInfoList(Parcel &p, void *response, size_t responselen)
                 assert(0);
             }
         }
-        return responseCellInfoListV12(p, response, responselen);
+        return responseCellInfoListV12(p, slotId, requestNumber, responseType, token, e, response,
+                responselen);
     }
 
     return 0;
 }
 
-static int responseHardwareConfig(Parcel &p, void *response, size_t responselen)
-{
+static int responseHardwareConfig(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
    if (response == NULL && responselen != 0) {
        RLOGE("invalid response: NULL");
        return RIL_ERRNO_INVALID_RESPONSE;
@@ -3545,8 +3630,9 @@ static int responseHardwareConfig(Parcel &p, void *response, size_t responselen)
             p.writeInt32(p_cur[i].cfg.modem.maxStandby);
 
             appendPrintBuf("%s modem: uuid=%s,state=%d,rat=%08x,maxV=%d,maxD=%d,maxS=%d", printBuf,
-               p_cur[i].uuid, (int)p_cur[i].state, p_cur[i].cfg.modem.rat,
-               p_cur[i].cfg.modem.maxVoice, p_cur[i].cfg.modem.maxData, p_cur[i].cfg.modem.maxStandby);
+                    p_cur[i].uuid, (int)p_cur[i].state, p_cur[i].cfg.modem.rat,
+                    p_cur[i].cfg.modem.maxVoice, p_cur[i].cfg.modem.maxData,
+                    p_cur[i].cfg.modem.maxStandby);
             break;
          }
          case RIL_HARDWARE_CONFIG_SIM: {
@@ -3565,7 +3651,8 @@ static int responseHardwareConfig(Parcel &p, void *response, size_t responselen)
    return 0;
 }
 
-static int responseRadioCapability(Parcel &p, void *response, size_t responselen) {
+static int responseRadioCapability(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     if (response == NULL) {
         RLOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -3599,7 +3686,8 @@ static int responseRadioCapability(Parcel &p, void *response, size_t responselen
     return 0;
 }
 
-static int responseSSData(Parcel &p, void *response, size_t responselen) {
+static int responseSSData(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
     RLOGD("In responseSSData");
     int num;
 
@@ -3693,91 +3781,8 @@ static void rilEventAddWakeup(struct ril_event *ev) {
     triggerEvLoop();
 }
 
-static void sendSimStatusAppInfo(Parcel &p, int num_apps, RIL_AppStatus appStatus[]) {
-        p.writeInt32(num_apps);
-        startResponse;
-        for (int i = 0; i < num_apps; i++) {
-            p.writeInt32(appStatus[i].app_type);
-            p.writeInt32(appStatus[i].app_state);
-            p.writeInt32(appStatus[i].perso_substate);
-            writeStringToParcel(p, (const char*)(appStatus[i].aid_ptr));
-            writeStringToParcel(p, (const char*)
-                                          (appStatus[i].app_label_ptr));
-            p.writeInt32(appStatus[i].pin1_replaced);
-            p.writeInt32(appStatus[i].pin1);
-            p.writeInt32(appStatus[i].pin2);
-            appendPrintBuf("%s[app_type=%d,app_state=%d,perso_substate=%d,\
-                    aid_ptr=%s,app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],",
-                    printBuf,
-                    appStatus[i].app_type,
-                    appStatus[i].app_state,
-                    appStatus[i].perso_substate,
-                    appStatus[i].aid_ptr,
-                    appStatus[i].app_label_ptr,
-                    appStatus[i].pin1_replaced,
-                    appStatus[i].pin1,
-                    appStatus[i].pin2);
-        }
-        closeResponse;
-}
-
-static void responseSimStatusV5(Parcel &p, void *response) {
-    RIL_CardStatus_v5 *p_cur = ((RIL_CardStatus_v5 *) response);
-
-    p.writeInt32(p_cur->card_state);
-    p.writeInt32(p_cur->universal_pin_state);
-    p.writeInt32(p_cur->gsm_umts_subscription_app_index);
-    p.writeInt32(p_cur->cdma_subscription_app_index);
-    p.writeInt32(-1);
-
-    sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications);
-}
-
-static void responseSimStatusV6(Parcel &p, void *response) {
-    RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
-
-    p.writeInt32(p_cur->card_state);
-    p.writeInt32(p_cur->universal_pin_state);
-    p.writeInt32(p_cur->gsm_umts_subscription_app_index);
-    p.writeInt32(p_cur->cdma_subscription_app_index);
-    p.writeInt32(p_cur->ims_subscription_app_index);
-
-    sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications);
-}
-
-static int responseSimStatus(Parcel &p, void *response, size_t responselen) {
-    int i;
-
-    if (response == NULL && responselen != 0) {
-        RLOGE("invalid response: NULL");
-        return RIL_ERRNO_INVALID_RESPONSE;
-    }
-
-    if (s_callbacks.version <= LAST_IMPRECISE_RIL_VERSION) {
-        if (responselen == sizeof (RIL_CardStatus_v6)) {
-            responseSimStatusV6(p, response);
-        } else if (responselen == sizeof (RIL_CardStatus_v5)) {
-            responseSimStatusV5(p, response);
-        } else {
-            RLOGE("responseSimStatus: A RilCardStatus_v6 or _v5 expected\n");
-            return RIL_ERRNO_INVALID_RESPONSE;
-        }
-    } else { // RIL version >= 13
-        if (responselen % sizeof(RIL_CardStatus_v6) != 0) {
-            RLOGE("Data structure expected is RIL_CardStatus_v6");
-            if (!isDebuggable()) {
-                return RIL_ERRNO_INVALID_RESPONSE;
-            } else {
-                assert(0);
-            }
-        }
-        responseSimStatusV6(p, response);
-    }
-
-    return 0;
-}
-
-static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen) {
+static int responseGsmBrSmsCnf(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     int num = responselen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
     p.writeInt32(num);
 
@@ -3802,7 +3807,8 @@ static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen) {
     return 0;
 }
 
-static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen) {
+static int responseCdmaBrSmsCnf(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
     RIL_CDMA_BroadcastSmsConfigInfo **p_cur =
                (RIL_CDMA_BroadcastSmsConfigInfo **) response;
 
@@ -3825,7 +3831,8 @@ static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen) {
     return 0;
 }
 
-static int responseCdmaSms(Parcel &p, void *response, size_t responselen) {
+static int responseCdmaSms(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
     int num;
     int digitCount;
     int digitLimit;
@@ -3883,7 +3890,8 @@ static int responseCdmaSms(Parcel &p, void *response, size_t responselen) {
     return 0;
 }
 
-static int responseDcRtInfo(Parcel &p, void *response, size_t responselen)
+static int responseDcRtInfo(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen)
 {
     int num = responselen / sizeof(RIL_DcRtInfo);
     if ((responselen % sizeof(RIL_DcRtInfo) != 0) || (num != 1)) {
@@ -3904,7 +3912,8 @@ static int responseDcRtInfo(Parcel &p, void *response, size_t responselen)
     return 0;
 }
 
-static int responseLceStatus(Parcel &p, void *response, size_t responselen) {
+static int responseLceStatus(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
   if (response == NULL || responselen != sizeof(RIL_LceStatusInfo)) {
     if (response == NULL) {
       RLOGE("invalid response: NULL");
@@ -3928,7 +3937,8 @@ static int responseLceStatus(Parcel &p, void *response, size_t responselen) {
   return 0;
 }
 
-static int responseLceData(Parcel &p, void *response, size_t responselen) {
+static int responseLceData(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
   if (response == NULL || responselen != sizeof(RIL_LceDataInfo)) {
     if (response == NULL) {
       RLOGE("invalid response: NULL");
@@ -3957,7 +3967,8 @@ static int responseLceData(Parcel &p, void *response, size_t responselen) {
   return 0;
 }
 
-static int responseActivityData(Parcel &p, void *response, size_t responselen) {
+static int responseActivityData(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
   if (response == NULL || responselen != sizeof(RIL_ActivityStatsInfo)) {
     if (response == NULL) {
       RLOGE("invalid response: NULL");
@@ -3988,7 +3999,8 @@ static int responseActivityData(Parcel &p, void *response, size_t responselen) {
   return 0;
 }
 
-static int responseCarrierRestrictions(Parcel &p, void *response, size_t responselen) {
+static int responseCarrierRestrictions(Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen) {
   if (response == NULL) {
     RLOGE("invalid response: NULL");
     return RIL_ERRNO_INVALID_RESPONSE;
@@ -4034,7 +4046,8 @@ static int responseCarrierRestrictions(Parcel &p, void *response, size_t respons
   return 0;
 }
 
-static int responsePcoData(Parcel &p, void *response, size_t responselen) {
+static int responsePcoData(Parcel &p, int slotId, int requestNumber, int responseType, int token,
+        RIL_Errno e, void *response, size_t responselen) {
   if (response == NULL) {
     RLOGE("responsePcoData: invalid NULL response");
     return RIL_ERRNO_INVALID_RESPONSE;
@@ -4794,6 +4807,9 @@ RIL_register (const RIL_RadioFunctions *callbacks) {
     startListen(RIL_SOCKET_4, &s_ril_param_socket4);
 #endif /* (SIM_COUNT == 4) */
 
+    RLOGI("RILHIDL calling registerService");
+    radio::registerService(&s_callbacks, s_commands);
+    RLOGI("RILHIDL called registerService");
 
 #if 1
     // start debug interface socket
@@ -4831,7 +4847,8 @@ RIL_register (const RIL_RadioFunctions *callbacks) {
 }
 
 extern "C" void
-RIL_register_socket (RIL_RadioFunctions *(*Init)(const struct RIL_Env *, int, char **),RIL_SOCKET_TYPE socketType, int argc, char **argv) {
+RIL_register_socket (RIL_RadioFunctions *(*Init)(const struct RIL_Env *, int, char **),
+        RIL_SOCKET_TYPE socketType, int argc, char **argv) {
 
     RIL_RadioFunctions* UimFuncs = NULL;
 
@@ -4974,7 +4991,6 @@ RIL_onRequestAck(RIL_Token t) {
         sendResponse(p, socket_id);
     }
 }
-
 extern "C" void
 RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) {
     RequestInfo *pRI;
@@ -4992,7 +5008,6 @@ RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responsel
 
     socket_id = pRI->socket_id;
     fd = findFd(socket_id);
-
 #if VDBG
     RLOGD("RequestComplete, %s", rilSocketIdToString(socket_id));
 #endif
@@ -5011,14 +5026,17 @@ RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responsel
     if (pRI->cancelled == 0) {
         Parcel p;
 
+        int responseType;
         if (s_callbacks.version >= 13 && pRI->wasAckSent == 1) {
             // If ack was already sent, then this call is an asynchronous response. So we need to
             // send id indicating that we expect an ack from RIL.java as we acquire wakelock here.
-            p.writeInt32 (RESPONSE_SOLICITED_ACK_EXP);
+            responseType = RESPONSE_SOLICITED_ACK_EXP;
             grabPartialWakeLock();
         } else {
-            p.writeInt32 (RESPONSE_SOLICITED);
+            responseType = RESPONSE_SOLICITED;
         }
+        p.writeInt32 (responseType);
+
         p.writeInt32 (pRI->token);
         errorOffset = p.dataPosition();
 
@@ -5026,7 +5044,13 @@ RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responsel
 
         if (response != NULL) {
             // there is a response payload, no matter success or not.
-            ret = pRI->pCI->responseFunction(p, response, responselen);
+            RLOGE ("Calling responseFunction() for token %d", pRI->token);
+            ret = pRI->pCI->responseFunction(p, (int) socket_id, pRI->pCI->requestNumber,
+                    responseType, pRI->token, e, response, responselen);
+
+            if (pRI->pCI->requestNumber == RIL_REQUEST_GET_SIM_STATUS) {
+                return;
+            }
 
             /* if an error occurred, rewind and mark it */
             if (ret != 0) {
@@ -5186,16 +5210,19 @@ void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
     appendPrintBuf("[UNSL]< %s", requestToString(unsolResponse));
 
     Parcel p;
+    int responseType;
     if (s_callbacks.version >= 13
                 && s_unsolResponses[unsolResponseIndex].wakeType == WAKE_PARTIAL) {
-        p.writeInt32 (RESPONSE_UNSOLICITED_ACK_EXP);
+        responseType = RESPONSE_UNSOLICITED_ACK_EXP;
     } else {
-        p.writeInt32 (RESPONSE_UNSOLICITED);
+        responseType = RESPONSE_UNSOLICITED;
     }
+    p.writeInt32 (responseType);
     p.writeInt32 (unsolResponse);
 
-    ret = s_unsolResponses[unsolResponseIndex]
-                .responseFunction(p, const_cast<void*>(data), datalen);
+    ret = s_unsolResponses[unsolResponseIndex].responseFunction(
+            p, (int) soc_id, unsolResponse, responseType, 0, RIL_E_SUCCESS, const_cast<void*>(data),
+            datalen);
     if (ret != 0) {
         // Problem with the response. Don't continue;
         goto error_exit;
@@ -5238,9 +5265,19 @@ void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
     }
 
 #if VDBG
-    RLOGI("%s UNSOLICITED: %s length:%d", rilSocketIdToString(soc_id), requestToString(unsolResponse), p.dataSize());
+    RLOGI("%s UNSOLICITED: %s length:%d", rilSocketIdToString(soc_id),
+            requestToString(unsolResponse), p.dataSize());
 #endif
-    ret = sendResponse(p, soc_id);
+    ret = 0;
+    switch (unsolResponse) {
+        case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
+            radio::radioStateChanged(soc_id, responseType, newState);
+            break;
+        default:
+            ret = sendResponse(p, soc_id);
+            break;
+    }
+
     if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
 
         // Unfortunately, NITZ time is not poll/update like everything
index 3c77a28..0f70c3d 100644 (file)
@@ -15,7 +15,7 @@
 ** limitations under the License.
 */
     {0, NULL, NULL},                   //none
-    {RIL_REQUEST_GET_SIM_STATUS, dispatchVoid, responseSimStatus},
+    {RIL_REQUEST_GET_SIM_STATUS, dispatchVoid, radio::iccCardStatusResponse},
     {RIL_REQUEST_ENTER_SIM_PIN, dispatchStrings, responseInts},
     {RIL_REQUEST_ENTER_SIM_PUK, dispatchStrings, responseInts},
     {RIL_REQUEST_ENTER_SIM_PIN2, dispatchStrings, responseInts},
diff --git a/libril/ril_internal.h b/libril/ril_internal.h
new file mode 100644 (file)
index 0000000..0d77eb0
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_RIL_INTERNAL_H
+#define ANDROID_RIL_INTERNAL_H
+
+#include <binder/Parcel.h>
+
+namespace android {
+
+#define SOCKET_NAME_RIL "rild"
+#define SOCKET2_NAME_RIL "rild2"
+#define SOCKET3_NAME_RIL "rild3"
+#define SOCKET4_NAME_RIL "rild4"
+
+/* Constants for response types */
+#define RESPONSE_SOLICITED 0
+#define RESPONSE_UNSOLICITED 1
+#define RESPONSE_SOLICITED_ACK 2
+#define RESPONSE_SOLICITED_ACK_EXP 3
+#define RESPONSE_UNSOLICITED_ACK_EXP 4
+
+typedef struct CommandInfo CommandInfo;
+
+extern "C" const char * requestToString(int request);
+
+typedef struct RequestInfo {
+    int32_t token;      //this is not RIL_Token
+    CommandInfo *pCI;
+    struct RequestInfo *p_next;
+    char cancelled;
+    char local;         // responses to local commands do not go back to command process
+    RIL_SOCKET_ID socket_id;
+    int wasAckSent;    // Indicates whether an ack was sent earlier
+} RequestInfo;
+
+typedef struct CommandInfo {
+    int requestNumber;
+    // todo: remove
+    void (*dispatchFunction) (Parcel &p, struct RequestInfo *pRI);
+    // todo: change parcel to serial
+    int(*responseFunction) (Parcel &p, int slotId, int requestNumber, int responseType, int token,
+            RIL_Errno e, void *response, size_t responselen);
+} CommandInfo;
+
+int addRequestToList(RequestInfo *pRI, int request, int token, RIL_SOCKET_ID socket_id);
+
+char * RIL_getRilSocketName();
+
+}   // namespace android
+
+#endif //ANDROID_RIL_INTERNAL_H
diff --git a/libril/ril_service.cpp b/libril/ril_service.cpp
new file mode 100644 (file)
index 0000000..3d61f5e
--- /dev/null
@@ -0,0 +1,875 @@
+/*
+ * Copyright (c) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android/hardware/radio/1.0/IRadio.h>
+
+#include <hwbinder/IPCThreadState.h>
+#include <hwbinder/ProcessState.h>
+#include <ril_service.h>
+#include <hidl/HidlTransportSupport.h>
+
+using namespace android::hardware::radio::V1_0;
+using ::android::hardware::configureRpcThreadpool;
+using ::android::hardware::joinRpcThreadpool;
+using ::android::hardware::Return;
+using ::android::hardware::Status;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_array;
+using ::android::hardware::Void;
+using android::CommandInfo;
+using android::RequestInfo;
+using android::requestToString;
+using android::sp;
+
+RIL_RadioFunctions *s_callbacks = NULL;
+static CommandInfo *s_commands;
+
+struct RadioImpl;
+
+#if (SIM_COUNT >= 2)
+sp<RadioImpl> radioService[SIM_COUNT];
+#else
+sp<RadioImpl> radioService[1];
+#endif
+
+struct RadioImpl : public IRadio {
+    int32_t slotId;
+    sp<IRadioResponse> radioResponse;
+    sp<IRadioIndication> radioIndication;
+
+    Return<void> setResponseFunctions(
+            const ::android::sp<IRadioResponse>& radioResponse,
+            const ::android::sp<IRadioIndication>& radioIndication);
+
+    Return<void> getIccCardStatus(int32_t serial);
+
+    Return<void> supplyIccPinForApp(int32_t serial,
+            const ::android::hardware::hidl_string& pin,
+            const ::android::hardware::hidl_string& aid);
+
+    Return<void> supplyIccPukForApp(int32_t serial,
+            const ::android::hardware::hidl_string& puk,
+            const ::android::hardware::hidl_string& pin,
+            const ::android::hardware::hidl_string& aid);
+
+    Return<void> supplyIccPin2ForApp(int32_t serial,
+            const ::android::hardware::hidl_string& pin2,
+            const ::android::hardware::hidl_string& aid);
+
+    Return<void> supplyIccPuk2ForApp(int32_t serial,
+            const ::android::hardware::hidl_string& puk2,
+            const ::android::hardware::hidl_string& pin2,
+            const ::android::hardware::hidl_string& aid);
+
+    Return<void> changeIccPinForApp(int32_t serial,
+            const ::android::hardware::hidl_string& oldPin,
+            const ::android::hardware::hidl_string& newPin,
+            const ::android::hardware::hidl_string& aid);
+
+    Return<void> changeIccPin2ForApp(int32_t serial,
+            const ::android::hardware::hidl_string& oldPin2,
+            const ::android::hardware::hidl_string& newPin2,
+            const ::android::hardware::hidl_string& aid);
+
+    Return<void> supplyNetworkDepersonalization(int32_t serial,
+            const ::android::hardware::hidl_string& netPin);
+
+    Return<void> getCurrentCalls(int32_t serial);
+
+    Return<void> dial(int32_t serial,
+            const Dial& dialInfo);
+
+    Return<void> getImsiForApp(int32_t serial,
+            const ::android::hardware::hidl_string& aid);
+
+    Return<void> hangup(int32_t serial, int32_t gsmIndex);
+
+    Return<void> hangupWaitingOrBackground(int32_t serial);
+
+    Return<void> hangupForegroundResumeBackground(int32_t serial);
+
+    Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
+
+    Return<void> conference(int32_t serial);
+
+    Return<void> rejectCall(int32_t serial);
+
+    Return<void> getLastCallFailCause(int32_t serial);
+
+    Return<void> getSignalStrength(int32_t serial);
+
+    Return<void> getVoiceRegistrationState(int32_t serial);
+
+    Return<void> getDataRegistrationState(int32_t serial);
+
+    Return<void> getOperator(int32_t serial);
+
+    Return<void> setRadioPower(int32_t serial, bool on);
+
+    Return<void> sendDtmf(int32_t serial,
+            const ::android::hardware::hidl_string& s);
+
+    Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
+
+    Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
+
+    Return<void> setupDataCall(int32_t serial,
+            int32_t radioTechnology,
+            int32_t profile,
+            const ::android::hardware::hidl_string& apn,
+            const ::android::hardware::hidl_string& user,
+            const ::android::hardware::hidl_string& password,
+            ApnAuthType authType,
+            const ::android::hardware::hidl_string& protocol);
+
+    Return<void> iccIOForApp(int32_t serial,
+            const IccIo& iccIo);
+
+    Return<void> sendUssd(int32_t serial,
+            const ::android::hardware::hidl_string& ussd);
+
+    Return<void> cancelPendingUssd(int32_t serial);
+
+    Return<void> getClir(int32_t serial);
+
+    Return<void> setClir(int32_t serial, int32_t status);
+
+    Return<void> getCallForwardStatus(int32_t serial,
+            const CallForwardInfo& callInfo);
+
+    Return<void> setCallForward(int32_t serial,
+            const CallForwardInfo& callInfo);
+
+    Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
+
+    Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
+
+    Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
+            bool success, SmsAcknowledgeFailCause cause);
+
+    Return<void> acceptCall(int32_t serial);
+
+    Return<void> deactivateDataCall(int32_t serial,
+            int32_t cid, bool reasonRadioShutDown);
+
+    Return<void> getFacilityLockForApp(int32_t serial,
+            const ::android::hardware::hidl_string& facility,
+            const ::android::hardware::hidl_string& password,
+            int32_t serviceClass,
+            const ::android::hardware::hidl_string& appId);
+
+    Return<void> setFacilityLockForApp(int32_t serial,
+            const ::android::hardware::hidl_string& facility,
+            bool lockState,
+            const ::android::hardware::hidl_string& password,
+            int32_t serviceClass,
+            const ::android::hardware::hidl_string& appId);
+
+    Return<void> setBarringPassword(int32_t serial,
+            const ::android::hardware::hidl_string& facility,
+            const ::android::hardware::hidl_string& oldPassword,
+            const ::android::hardware::hidl_string& newPassword);
+
+    Return<void> getNetworkSelectionMode(int32_t serial);
+
+    Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
+
+    Return<void> setNetworkSelectionModeManual(int32_t serial,
+            const ::android::hardware::hidl_string& operatorNumeric);
+
+    Return<void> getAvailableNetworks(int32_t serial);
+
+    Return<void> startDtmf(int32_t serial,
+            const ::android::hardware::hidl_string& s);
+
+    Return<void> stopDtmf(int32_t serial);
+
+    Return<void> getBasebandVersion(int32_t serial);
+
+    Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
+
+    Return<void> setMute(int32_t serial, bool enable);
+
+    Return<void> getMute(int32_t serial);
+
+    Return<void> getClip(int32_t serial);
+
+    Return<void> getDataCallList(int32_t serial);
+
+    Return<void> sendOemRadioRequestRaw(int32_t serial,
+            const ::android::hardware::hidl_vec<uint8_t>& data);
+
+    Return<void> sendOemRadioRequestStrings(int32_t serial,
+            const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
+
+    Return<void> sendScreenState(int32_t serial, bool enable);
+
+    Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
+
+    Return<void> writeSmsToSim(int32_t serial,
+            const SmsWriteArgs& smsWriteArgs);
+
+    Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
+
+    Return<void> setBandMode(int32_t serial, RadioBandMode mode);
+
+    Return<void> getAvailableBandModes(int32_t serial);
+
+    Return<void> sendEnvelope(int32_t serial,
+            const ::android::hardware::hidl_string& command);
+
+    Return<void> sendTerminalResponseToSim(int32_t serial,
+            const ::android::hardware::hidl_string& commandResponse);
+
+    Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
+
+    Return<void> explicitCallTransfer(int32_t serial);
+
+    Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
+
+    Return<void> getPreferredNetworkType(int32_t serial);
+
+    Return<void> getNeighboringCids(int32_t serial);
+
+    Return<void> setLocationUpdates(int32_t serial, bool enable);
+
+    Return<void> setCdmaSubscriptionSource(int32_t serial,
+            CdmaSubscriptionSource cdmaSub);
+
+    Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
+
+    Return<void> getCdmaRoamingPreference(int32_t serial);
+
+    Return<void> setTTYMode(int32_t serial, TtyMode mode);
+
+    Return<void> getTTYMode(int32_t serial);
+
+    Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
+
+    Return<void> getPreferredVoicePrivacy(int32_t serial);
+
+    Return<void> sendCDMAFeatureCode(int32_t serial,
+            const ::android::hardware::hidl_string& featureCode);
+
+    Return<void> sendBurstDtmf(int32_t serial,
+            const ::android::hardware::hidl_string& dtmf,
+            int32_t on,
+            int32_t off);
+
+    Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
+
+    Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
+            const CdmaSmsAck& smsAck);
+
+    Return<void> getGsmBroadcastConfig(int32_t serial);
+
+    Return<void> setGsmBroadcastConfig(int32_t serial,
+            const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
+
+    Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
+
+    Return<void> getCdmaBroadcastConfig(int32_t serial);
+
+    Return<void> setCdmaBroadcastConfig(int32_t serial,
+            const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
+
+    Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
+
+    Return<void> getCDMASubscription(int32_t serial);
+
+    Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
+
+    Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
+
+    Return<void> getDeviceIdentity(int32_t serial);
+
+    Return<void> exitEmergencyCallbackMode(int32_t serial);
+
+    Return<void> getSmscAddress(int32_t serial);
+
+    Return<void> setSmscAddress(int32_t serial,
+            const ::android::hardware::hidl_string& smsc);
+
+    Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
+
+    Return<void> reportStkServiceIsRunning(int32_t serial);
+
+    Return<void> getCdmaSubscriptionSource(int32_t serial);
+
+    Return<void> requestIsimAuthentication(int32_t serial,
+            const ::android::hardware::hidl_string& challenge);
+
+    Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
+            bool success,
+            const ::android::hardware::hidl_string& ackPdu);
+
+    Return<void> sendEnvelopeWithStatus(int32_t serial,
+            const ::android::hardware::hidl_string& contents);
+
+    Return<void> getVoiceRadioTechnology(int32_t serial);
+
+    Return<void> getCellInfoList(int32_t serial);
+
+    Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
+
+    Return<void> setInitialAttachApn(int32_t serial,
+            const ::android::hardware::hidl_string& apn,
+            const ::android::hardware::hidl_string& protocol,
+            ApnAuthType authType,
+            const ::android::hardware::hidl_string& username,
+            const ::android::hardware::hidl_string& password);
+
+    Return<void> getImsRegistrationState(int32_t serial);
+
+    Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
+
+    Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
+
+    Return<void> iccOpenLogicalChannel(int32_t serial,
+            const ::android::hardware::hidl_string& aid);
+
+    Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
+
+    Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
+
+    Return<void> nvReadItem(int32_t serial, NvItem itemId);
+
+    Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
+
+    Return<void> nvWriteCdmaPrl(int32_t serial,
+            const ::android::hardware::hidl_vec<uint8_t>& prl);
+
+    Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
+
+    Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
+
+    Return<void> setDataAllowed(int32_t serial, bool allow);
+
+    Return<void> getHardwareConfig(int32_t serial);
+
+    Return<void> requestIccSimAuthentication(int32_t serial,
+            int32_t authContext,
+            const ::android::hardware::hidl_string& authData,
+            const ::android::hardware::hidl_string& aid);
+
+    Return<void> setDataProfile(int32_t serial,
+            const ::android::hardware::hidl_vec<DataProfileInfo>& profiles);
+
+    Return<void> requestShutdown(int32_t serial);
+
+    Return<void> getRadioCapability(int32_t serial);
+
+    Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
+
+    Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
+
+    Return<void> stopLceService(int32_t serial);
+
+    Return<void> pullLceData(int32_t serial);
+
+    Return<void> getModemActivityInfo(int32_t serial);
+
+    Return<void> setAllowedCarriers(int32_t serial,
+            bool allAllowed,
+            const CarrierRestrictions& carriers);
+
+    Return<void> getAllowedCarriers(int32_t serial);
+
+    Return<void> responseAcknowledgement();
+};
+
+Return<void> RadioImpl::setResponseFunctions(
+        const ::android::sp<IRadioResponse>& radioResponseParam,
+        const ::android::sp<IRadioIndication>& radioIndicationParam) {
+    RLOGD("RadioImpl::setResponseFunctions");
+    radioResponse = radioResponseParam;
+    radioIndication = radioIndicationParam;
+    return Status::ok();
+}
+
+Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
+    RLOGD("RadioImpl::getIccCardStatus: serial %d", serial);
+    RequestInfo *pRI;
+    pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo));
+    if (pRI == NULL) {
+        RLOGE("RadioImpl::getIccCardStatus: Memory allocation failed for request %s",
+                requestToString(RIL_REQUEST_GET_SIM_STATUS));
+        return Void();
+    }
+
+    pRI->token = serial;
+    pRI->pCI = &(s_commands[RIL_REQUEST_GET_SIM_STATUS]);
+    pRI->socket_id = (RIL_SOCKET_ID) slotId;
+    android::addRequestToList(pRI, RIL_REQUEST_GET_SIM_STATUS, serial, pRI->socket_id);
+
+    s_callbacks->onRequest(RIL_REQUEST_GET_SIM_STATUS, NULL, 0, pRI);
+
+    return Status::ok();
+}
+
+Return<void> RadioImpl::supplyIccPinForApp(int32_t serial,
+        const ::android::hardware::hidl_string& pin,
+        const ::android::hardware::hidl_string& aid) {return Status::ok();}
+
+Return<void> RadioImpl::supplyIccPukForApp(int32_t serial,
+        const ::android::hardware::hidl_string& puk,
+        const ::android::hardware::hidl_string& pin,
+        const ::android::hardware::hidl_string& aid) {return Status::ok();}
+
+Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial,
+        const ::android::hardware::hidl_string& pin2,
+        const ::android::hardware::hidl_string& aid) {return Status::ok();}
+
+Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial,
+        const ::android::hardware::hidl_string& puk2,
+        const ::android::hardware::hidl_string& pin2,
+        const ::android::hardware::hidl_string& aid) {return Status::ok();}
+
+Return<void> RadioImpl::changeIccPinForApp(int32_t serial,
+        const ::android::hardware::hidl_string& oldPin,
+        const ::android::hardware::hidl_string& newPin,
+        const ::android::hardware::hidl_string& aid) {return Status::ok();}
+
+Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial,
+        const ::android::hardware::hidl_string& oldPin2,
+        const ::android::hardware::hidl_string& newPin2,
+        const ::android::hardware::hidl_string& aid) {return Status::ok();}
+
+Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
+        const ::android::hardware::hidl_string& netPin) {return Status::ok();}
+
+Return<void> RadioImpl::getCurrentCalls(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::dial(int32_t serial,
+        const Dial& dialInfo) {return Status::ok();}
+
+Return<void> RadioImpl::getImsiForApp(int32_t serial,
+        const ::android::hardware::hidl_string& aid) {return Status::ok();}
+
+Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {return Status::ok();}
+
+Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::conference(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::rejectCall(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::getSignalStrength(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::getOperator(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {return Status::ok();}
+
+Return<void> RadioImpl::sendDtmf(int32_t serial,
+        const ::android::hardware::hidl_string& s) {return Status::ok();}
+
+Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {return Status::ok();}
+
+Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {return Status::ok();}
+
+Return<void> RadioImpl::setupDataCall(int32_t serial,
+        int32_t radioTechnology,
+        int32_t profile,
+        const ::android::hardware::hidl_string& apn,
+        const ::android::hardware::hidl_string& user,
+        const ::android::hardware::hidl_string& password,
+        ApnAuthType authType,
+        const ::android::hardware::hidl_string& protocol) {return Status::ok();}
+
+Return<void> RadioImpl::iccIOForApp(int32_t serial,
+        const IccIo& iccIo) {return Status::ok();}
+
+Return<void> RadioImpl::sendUssd(int32_t serial,
+        const ::android::hardware::hidl_string& ussd) {return Status::ok();}
+
+Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::getClir(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {return Status::ok();}
+
+Return<void> RadioImpl::getCallForwardStatus(int32_t serial,
+        const CallForwardInfo& callInfo) {return Status::ok();}
+
+Return<void> RadioImpl::setCallForward(int32_t serial,
+        const CallForwardInfo& callInfo) {return Status::ok();}
+
+Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {return Status::ok();}
+
+Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {return Status::ok();}
+
+Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
+        bool success, SmsAcknowledgeFailCause cause) {return Status::ok();}
+
+Return<void> RadioImpl::acceptCall(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::deactivateDataCall(int32_t serial,
+        int32_t cid, bool reasonRadioShutDown) {return Status::ok();}
+
+Return<void> RadioImpl::getFacilityLockForApp(int32_t serial,
+        const ::android::hardware::hidl_string& facility,
+        const ::android::hardware::hidl_string& password,
+        int32_t serviceClass,
+        const ::android::hardware::hidl_string& appId) {return Status::ok();}
+
+Return<void> RadioImpl::setFacilityLockForApp(int32_t serial,
+        const ::android::hardware::hidl_string& facility,
+        bool lockState,
+        const ::android::hardware::hidl_string& password,
+        int32_t serviceClass,
+        const ::android::hardware::hidl_string& appId) {return Status::ok();}
+
+Return<void> RadioImpl::setBarringPassword(int32_t serial,
+        const ::android::hardware::hidl_string& facility,
+        const ::android::hardware::hidl_string& oldPassword,
+        const ::android::hardware::hidl_string& newPassword) {return Status::ok();}
+
+Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
+        const ::android::hardware::hidl_string& operatorNumeric) {return Status::ok();}
+
+Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::startDtmf(int32_t serial,
+        const ::android::hardware::hidl_string& s) {return Status::ok();}
+
+Return<void> RadioImpl::stopDtmf(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::getBasebandVersion(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {return Status::ok();}
+
+Return<void> RadioImpl::setMute(int32_t serial, bool enable) {return Status::ok();}
+
+Return<void> RadioImpl::getMute(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::getClip(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::getDataCallList(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::sendOemRadioRequestRaw(int32_t serial,
+        const ::android::hardware::hidl_vec<uint8_t>& data) {return Status::ok();}
+
+Return<void> RadioImpl::sendOemRadioRequestStrings(int32_t serial,
+        const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data) {return Status::ok();}
+
+Return<void> RadioImpl::sendScreenState(int32_t serial, bool enable) {return Status::ok();}
+
+Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {return Status::ok();}
+
+Return<void> RadioImpl::writeSmsToSim(int32_t serial,
+        const SmsWriteArgs& smsWriteArgs) {return Status::ok();}
+
+Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {return Status::ok();}
+
+Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {return Status::ok();}
+
+Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::sendEnvelope(int32_t serial,
+        const ::android::hardware::hidl_string& command) {return Status::ok();}
+
+Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
+        const ::android::hardware::hidl_string& commandResponse) {return Status::ok();}
+
+Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {return Status::ok();}
+
+Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {return Status::ok();}
+
+Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::getNeighboringCids(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {return Status::ok();}
+
+Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {return Status::ok();}
+
+Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {return Status::ok();}
+
+Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {return Status::ok();}
+
+Return<void> RadioImpl::getTTYMode(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {return Status::ok();}
+
+Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial,
+        const ::android::hardware::hidl_string& featureCode) {return Status::ok();}
+
+Return<void> RadioImpl::sendBurstDtmf(int32_t serial,
+        const ::android::hardware::hidl_string& dtmf,
+        int32_t on,
+        int32_t off) {return Status::ok();}
+
+Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {return Status::ok();}
+
+Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {return Status::ok();}
+
+Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
+        const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo) {return Status::ok();}
+
+Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {return Status::ok();}
+
+Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
+        const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo) {return Status::ok();}
+
+Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {return Status::ok();}
+
+Return<void> RadioImpl::getCDMASubscription(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {return Status::ok();}
+
+Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {return Status::ok();}
+
+Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::getSmscAddress(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::setSmscAddress(int32_t serial,
+        const ::android::hardware::hidl_string& smsc) {return Status::ok();}
+
+Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {return Status::ok();}
+
+Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::requestIsimAuthentication(int32_t serial,
+        const ::android::hardware::hidl_string& challenge) {return Status::ok();}
+
+Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
+        bool success,
+        const ::android::hardware::hidl_string& ackPdu) {return Status::ok();}
+
+Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial,
+        const ::android::hardware::hidl_string& contents) {return Status::ok();}
+
+Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::getCellInfoList(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {return Status::ok();}
+
+Return<void> RadioImpl::setInitialAttachApn(int32_t serial,
+        const ::android::hardware::hidl_string& apn,
+        const ::android::hardware::hidl_string& protocol,
+        ApnAuthType authType,
+        const ::android::hardware::hidl_string& username,
+        const ::android::hardware::hidl_string& password) {return Status::ok();}
+
+Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {return Status::ok();}
+
+Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {return Status::ok();}
+
+Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial,
+        const ::android::hardware::hidl_string& aid) {return Status::ok();}
+
+Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {return Status::ok();}
+
+Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {return Status::ok();}
+
+Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {return Status::ok();}
+
+Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {return Status::ok();}
+
+Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial,
+        const ::android::hardware::hidl_vec<uint8_t>& prl) {return Status::ok();}
+
+Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {return Status::ok();}
+
+Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {return Status::ok();}
+
+Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {return Status::ok();}
+
+Return<void> RadioImpl::getHardwareConfig(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial,
+        int32_t authContext,
+        const ::android::hardware::hidl_string& authData,
+        const ::android::hardware::hidl_string& aid) {return Status::ok();}
+
+Return<void> RadioImpl::setDataProfile(int32_t serial,
+        const ::android::hardware::hidl_vec<DataProfileInfo>& profiles) {return Status::ok();}
+
+Return<void> RadioImpl::requestShutdown(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::getRadioCapability(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {return Status::ok();}
+
+Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {return Status::ok();}
+
+Return<void> RadioImpl::stopLceService(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::pullLceData(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::setAllowedCarriers(int32_t serial,
+        bool allAllowed,
+        const CarrierRestrictions& carriers) {return Status::ok();}
+
+Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {return Status::ok();}
+
+Return<void> RadioImpl::responseAcknowledgement() {return Status::ok();}
+
+hidl_string convertCharPtrToHidlString(char *ptr) {
+    hidl_string ret;
+    if (ptr != NULL) {
+        ret.setToExternal(ptr, strlen(ptr));
+    }
+    return ret;
+}
+
+int radio::iccCardStatusResponse(android::Parcel &p, int slotId, int requestNumber,
+        int responseType, int serial, RIL_Errno e, void *response, size_t responselen) {
+    RLOGD("iccCardStatusResponse: serial %d", serial);
+
+    if (radioService[slotId]->radioResponse != NULL) {
+        RadioResponseInfo responseInfo;
+        CardStatus cardStatus;
+        responseInfo.serial = serial;
+
+        switch (responseType) {
+            case RESPONSE_SOLICITED:
+                responseInfo.type = RadioResponseType::SOLICITED;
+                break;
+            case RESPONSE_SOLICITED_ACK:
+                responseInfo.type = RadioResponseType::SOLICITED_ACK;
+                break;
+            case RESPONSE_SOLICITED_ACK_EXP:
+                responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
+                break;
+        }
+
+        if (response == NULL && responselen != 0) {
+            RLOGE("iccCardStatusResponse: invalid response: NULL");
+            //todo: it used to be -1 (RIL_ERRNO_INVALID_RESPONSE) but adding that to interface
+            // doesn't make sense since this will eventually be part of vendor ril. Options to
+            // handle this:
+            // 1. Add -1 to interface and use that, and update interface to say it's a valid error
+            // 2. Add GENERIC_FAILURE as valid error to interface
+            // 3. Assume this will never happen and not handle it
+            responseInfo.error = RadioError::GENERIC_FAILURE;
+        } else {
+            responseInfo.error = (RadioError) e;
+
+            RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
+            cardStatus.cardState = (CardState) p_cur->card_state;
+            cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
+            cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
+            cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
+            cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
+
+            RIL_AppStatus *rilAppStatus = p_cur->applications;
+            cardStatus.applications.resize(p_cur->num_applications);
+            AppStatus *appStatus = cardStatus.applications.data();
+            RLOGD("iccCardStatusResponse: num_applications %d", p_cur->num_applications);
+            for (int i = 0; i < p_cur->num_applications; i++) {
+                appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
+                appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
+                appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
+                appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
+                appStatus[i].appLabelPtr = convertCharPtrToHidlString(
+                        rilAppStatus[i].app_label_ptr);
+                appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
+                appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
+                appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
+            }
+        }
+
+        radioService[slotId]->radioResponse->getIccCardStatusResponse(responseInfo, cardStatus);
+    } else {
+        RLOGE("iccCardStatusResponse: radioService[%d]->radioResponse == NULL", slotId);
+    }
+
+    return 0;
+}
+
+void radio::radioStateChanged(int slotId, int indicationType, RIL_RadioState radioState) {
+    RLOGD("radioStateChanged: radioState %d", radioState);
+    if (radioService[slotId]->radioIndication != NULL) {
+        RadioIndicationType type = indicationType == RESPONSE_UNSOLICITED ?
+                (RadioIndicationType::UNSOLICITED) :
+                (RadioIndicationType::UNSOLICITED_ACK_EXP);
+        radioService[slotId]->radioIndication->radioStateChanged(type, (RadioState) radioState);
+    } else {
+        RLOGE("radioStateChanged: radioService[%d]->radioIndication == NULL", slotId);
+    }
+}
+
+void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
+    using namespace android::hardware;
+    int simCount = 1;
+    char *serviceNames[] = {
+            android::RIL_getRilSocketName()
+            #if (SIM_COUNT >= 2)
+            , SOCKET2_NAME_RIL
+            #if (SIM_COUNT >= 3)
+            , SOCKET3_NAME_RIL
+            #if (SIM_COUNT >= 4)
+            , SOCKET4_NAME_RIL
+            #endif
+            #endif
+            #endif
+            };
+
+    #if (SIM_COUNT >= 2)
+    simCount = SIM_COUNT;
+    #endif
+
+    configureRpcThreadpool(1, true /* callerWillJoin */);
+    for (int i = 0; i < simCount; i++) {
+        radioService[i] = new RadioImpl;
+        radioService[i]->slotId = i;
+        RLOGD("registerService: starting IRadio %s", serviceNames[i]);
+        android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
+    }
+
+    s_callbacks = callbacks;
+    s_commands = commands;
+}
+
+void rilc_thread_pool() {
+    joinRpcThreadpool();
+}
\ No newline at end of file
diff --git a/libril/ril_service.h b/libril/ril_service.h
new file mode 100644 (file)
index 0000000..ef8e9e8
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RIL_SERVICE_H
+#define RIL_SERVICE_H
+
+#include <telephony/ril.h>
+#include <ril_internal.h>
+
+namespace radio {
+
+void registerService(RIL_RadioFunctions *callbacks, android::CommandInfo *commands);
+int iccCardStatusResponse(android::Parcel &p, int slotId, int requestNumber, int responseType,
+        int token, RIL_Errno e, void *response, size_t responselen);
+void radioStateChanged(int slotId, int indicationType, RIL_RadioState radioState);
+
+}   // namespace android
+
+#endif  // RIL_SERVICE_H
\ No newline at end of file
index 50710d6..0ce9eaf 100644 (file)
@@ -49,6 +49,7 @@ static void usage(const char *argv0) {
 extern char rild[MAX_SOCKET_NAME_LENGTH];
 
 extern void RIL_register (const RIL_RadioFunctions *callbacks);
+extern void rilc_thread_pool ();
 
 extern void RIL_register_socket (RIL_RadioFunctions *(*rilUimInit)
         (const struct RIL_Env *, int, char **), RIL_SOCKET_TYPE socketType, int argc, char **argv);
@@ -96,19 +97,29 @@ static int make_argv(char * args, char ** argv) {
 }
 
 int main(int argc, char **argv) {
+    // vendor ril lib path either passed in as -l parameter, or read from rild.libpath property
     const char *rilLibPath = NULL;
+    // ril arguments either passed in as -- parameter, or read from rild.libargs property
     char **rilArgv;
+    // handle for vendor ril lib
     void *dlHandle;
+    // Pointer to ril init function in vendor ril
     const RIL_RadioFunctions *(*rilInit)(const struct RIL_Env *, int, char **);
+    // Pointer to sap init function in vendor ril
     RIL_RadioFunctions *(*rilUimInit)(const struct RIL_Env *, int, char **);
     const char *err_str = NULL;
 
+    // functions returned by ril init function in vendor ril
     const RIL_RadioFunctions *funcs;
+    // lib path from rild.libpath property (if it's read)
     char libPath[PROPERTY_VALUE_MAX];
+    // flat to indicate if -- parameters are present
     unsigned char hasLibArgs = 0;
 
     int i;
+    // ril/socket id received as -c parameter, otherwise set to 0
     const char *clientId = NULL;
+
     RLOGD("**RIL Daemon Started**");
     RLOGD("**RILd param count=%d**", argc);
 
@@ -213,6 +224,8 @@ int main(int argc, char **argv) {
 
 done:
 
+    rilc_thread_pool();
+
     RLOGD("RIL_Init starting sleep loop");
     while (true) {
         sleep(UINT32_MAX);