static void dispatchInts (Parcel& p, RequestInfo *pRI);
static void dispatchDial (Parcel& p, RequestInfo *pRI);
static void dispatchSIM_IO (Parcel& p, RequestInfo *pRI);
+static void dispatchSIM_APDU (Parcel& p, RequestInfo *pRI);
static void dispatchCallForward(Parcel& p, RequestInfo *pRI);
static void dispatchRaw(Parcel& p, RequestInfo *pRI);
static void dispatchSmsWrite (Parcel &p, RequestInfo *pRI);
}
/**
+ * Callee expects const RIL_SIM_APDU *
+ * Payload is:
+ * int32_t sessionid
+ * int32_t cla
+ * int32_t instruction
+ * int32_t p1, p2, p3
+ * String data
+ */
+static void
+dispatchSIM_APDU (Parcel &p, RequestInfo *pRI) {
+ int32_t t;
+ status_t status;
+ RIL_SIM_APDU apdu;
+
+ memset (&apdu, 0, sizeof(RIL_SIM_APDU));
+
+ // Note we only check status at the end. Any single failure leads to
+ // subsequent reads filing.
+ status = p.readInt32(&t);
+ apdu.sessionid = (int)t;
+
+ status = p.readInt32(&t);
+ apdu.cla = (int)t;
+
+ status = p.readInt32(&t);
+ apdu.instruction = (int)t;
+
+ status = p.readInt32(&t);
+ apdu.p1 = (int)t;
+
+ status = p.readInt32(&t);
+ apdu.p2 = (int)t;
+
+ status = p.readInt32(&t);
+ apdu.p3 = (int)t;
+
+ apdu.data = strdupReadString(p);
+
+ startRequest;
+ appendPrintBuf("%ssessionid=%d,cla=%d,ins=%d,p1=%d,p2=%d,p3=%d,data=%s",
+ printBuf, apdu.sessionid, apdu.cla, apdu.instruction, apdu.p1, apdu.p2,
+ apdu.p3, (char*)apdu.data);
+ closeRequest;
+ printRequest(pRI->token, pRI->pCI->requestNumber);
+
+ if (status != NO_ERROR) {
+ goto invalid;
+ }
+
+ s_callbacks.onRequest(pRI->pCI->requestNumber, &apdu, sizeof(RIL_SIM_APDU), pRI);
+
+#ifdef MEMSET_FREED
+ memsetString(apdu.data);
+#endif
+ free(apdu.data);
+
+#ifdef MEMSET_FREED
+ memset(&apdu, 0, sizeof(RIL_SIM_APDU));
+#endif
+
+ return;
+invalid:
+ invalidCommandBlock(pRI);
+ return;
+}
+
+
+/**
* Callee expects const RIL_CallForwardInfo *
* Payload is:
* int32_t status/action
extern "C" void
RIL_startEventLoop(void) {
- int ret;
- pthread_attr_t attr;
-
/* spin up eventLoop thread and wait for it to get started */
s_started = 0;
pthread_mutex_lock(&s_startupMutex);
- pthread_attr_init (&attr);
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- ret = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL);
+
+ int result = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL);
+ if (result != 0) {
+ RLOGE("Failed to create dispatch thread: %s", strerror(result));
+ goto done;
+ }
while (s_started == 0) {
pthread_cond_wait(&s_startupCond, &s_startupMutex);
}
+done:
pthread_mutex_unlock(&s_startupMutex);
-
- if (ret < 0) {
- RLOGE("Failed to create dispatch thread errno:%d", errno);
- return;
- }
}
// Used for testing purpose only.
}
extern "C"
-void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
+void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
size_t datalen)
{
int unsolResponseIndex;
p.writeInt32 (unsolResponse);
ret = s_unsolResponses[unsolResponseIndex]
- .responseFunction(p, data, datalen);
+ .responseFunction(p, const_cast<void*>(data), datalen);
if (ret != 0) {
// Problem with the response. Don't continue;
goto error_exit;
case RIL_REQUEST_SET_INITIAL_ATTACH_APN: return "RIL_REQUEST_SET_INITIAL_ATTACH_APN";
case RIL_REQUEST_IMS_REGISTRATION_STATE: return "IMS_REGISTRATION_STATE";
case RIL_REQUEST_IMS_SEND_SMS: return "IMS_SEND_SMS";
+ case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: return "SIM_TRANSMIT_APDU_BASIC";
+ case RIL_REQUEST_SIM_OPEN_CHANNEL: return "SIM_OPEN_CHANNEL";
+ case RIL_REQUEST_SIM_CLOSE_CHANNEL: return "SIM_CLOSE_CHANNEL";
+ case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: return "SIM_TRANSMIT_APDU_CHANNEL";
case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";