ril: import Oreo AOSP libril

Change-Id: I00750bad812dc263e9c74a504b48512a892376c8
tirimbino
Martin Bouchet 7 years ago committed by Christopher N. Hesse
parent e4a1c59a0b
commit 0d4bbaf7f1
  1. 2
      ril/include/libril/ril_ex.h
  2. 60
      ril/libril/Android.mk
  3. 266
      ril/libril/RilSapSocket.cpp
  4. 66
      ril/libril/RilSapSocket.h
  5. 177
      ril/libril/RilSocket.cpp
  6. 212
      ril/libril/RilSocket.h
  7. 69
      ril/libril/include/telephony/ril_commands_vendor.h
  8. 55
      ril/libril/include/telephony/ril_unsol_commands_vendor.h
  9. 5376
      ril/libril/ril.cpp
  10. 287
      ril/libril/ril_commands.h
  11. 98
      ril/libril/ril_internal.h
  12. 8240
      ril/libril/ril_service.cpp
  13. 716
      ril/libril/ril_service.h
  14. 95
      ril/libril/ril_unsol_commands.h
  15. 958
      ril/libril/sap_service.cpp
  16. 33
      ril/libril/sap_service.h

@ -22,6 +22,8 @@
#define NUM_ELEMS_SOCKET(a) (sizeof (a) / sizeof (a)[0]) #define NUM_ELEMS_SOCKET(a) (sizeof (a) / sizeof (a)[0])
struct ril_event;
void rilEventAddWakeup_helper(struct ril_event *ev); void rilEventAddWakeup_helper(struct ril_event *ev);
void listenCallback_helper(int fd, short flags, void *param); void listenCallback_helper(int fd, short flags, void *param);
int blockingWrite_helper(int fd, void* data, size_t len); int blockingWrite_helper(int fd, void* data, size_t len);

@ -1,49 +1,41 @@
# Copyright 2006 The Android Open Source Project # Copyright 2006 The Android Open Source Project
ifeq ($(BOARD_PROVIDES_LIBRIL),true) ifneq ($(BOARD_PROVIDES_LIBRIL),true)
LOCAL_PATH:= $(call my-dir) LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_VENDOR_MODULE := true
LOCAL_SRC_FILES:= \ LOCAL_SRC_FILES:= \
ril.cpp \ ril.cpp \
ril_event.cpp\ ril_event.cpp\
RilSocket.cpp \
RilSapSocket.cpp \ RilSapSocket.cpp \
ril_service.cpp \
sap_service.cpp
LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \
liblog \ liblog \
libutils \ libutils \
libbinder \
libcutils \ libcutils \
libhardware_legacy \ libhardware_legacy \
librilutils \ librilutils \
android.hardware.radio@1.0 \
android.hardware.radio.deprecated@1.0 \
libhidlbase \
libhidltransport \
libhwbinder
LOCAL_STATIC_LIBRARIES := \ LOCAL_STATIC_LIBRARIES := \
libprotobuf-c-nano-enable_malloc \ libprotobuf-c-nano-enable_malloc \
LOCAL_CFLAGS := LOCAL_CFLAGS += -Wno-unused-parameter
ifeq ($(SIM_COUNT), 2) ifeq ($(SIM_COUNT), 2)
LOCAL_CFLAGS += -DANDROID_MULTI_SIM LOCAL_CFLAGS += -DANDROID_MULTI_SIM -DDSDA_RILD1
LOCAL_CFLAGS += -DANDROID_SIM_COUNT_2 LOCAL_CFLAGS += -DANDROID_SIM_COUNT_2
endif endif
ifneq ($(filter xmm6262 xmm6360,$(BOARD_MODEM_TYPE)),)
LOCAL_CFLAGS += -DMODEM_TYPE_XMM6262
endif
ifeq ($(BOARD_MODEM_TYPE),xmm6260)
LOCAL_CFLAGS += -DMODEM_TYPE_XMM6260
endif
ifneq ($(filter m7450 mdm9x35 ss333 tss310 xmm7260,$(BOARD_MODEM_TYPE)),)
LOCAL_CFLAGS += -DSAMSUNG_NEXT_GEN_MODEM
endif
ifeq ($(BOARD_MODEM_NEEDS_VIDEO_CALL_FIELD), true)
LOCAL_CFLAGS += -DNEEDS_VIDEO_CALL_FIELD
endif
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
LOCAL_C_INCLUDES += external/nanopb-c LOCAL_C_INCLUDES += external/nanopb-c
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include
@ -54,32 +46,4 @@ LOCAL_SANITIZE := integer
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
# For RdoServD which needs a static library
# =========================================
ifneq ($(ANDROID_BIONIC_TRANSITION),)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
ril.cpp
LOCAL_STATIC_LIBRARIES := \
libutils_static \
libcutils \
librilutils_static \
libprotobuf-c-nano-enable_malloc
LOCAL_CFLAGS :=
ifneq ($(filter xmm6262 xmm6360,$(BOARD_MODEM_TYPE)),)
LOCAL_CFLAGS += -DMODEM_TYPE_XMM6262
endif
ifeq ($(BOARD_MODEM_TYPE),xmm6260)
LOCAL_CFLAGS += -DMODEM_TYPE_XMM6260
endif
LOCAL_MODULE:= libril_static
include $(BUILD_STATIC_LIBRARY)
endif # ANDROID_BIONIC_TRANSITION
endif # BOARD_PROVIDES_LIBRIL endif # BOARD_PROVIDES_LIBRIL

@ -26,18 +26,10 @@
#include <utils/Log.h> #include <utils/Log.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <errno.h> #include <errno.h>
#include <sap_service.h>
static RilSapSocket::RilSapSocketList *head = NULL; static RilSapSocket::RilSapSocketList *head = NULL;
void ril_sap_on_request_complete (
RIL_Token t, RIL_Errno e,
void *response, size_t responselen
);
void ril_sap_on_unsolicited_response (
int unsolResponse, const void *data,
size_t datalen
);
extern "C" void extern "C" void
RIL_requestTimedCallback (RIL_TimedCallback callback, void *param, RIL_requestTimedCallback (RIL_TimedCallback callback, void *param,
const struct timeval *relativeTime); const struct timeval *relativeTime);
@ -86,7 +78,9 @@ void RilSapSocket::sOnUnsolicitedResponse(int unsolResponse,
const void *data, const void *data,
size_t datalen) { size_t datalen) {
RilSapSocket *sap_socket = getSocketById(RIL_SOCKET_1); RilSapSocket *sap_socket = getSocketById(RIL_SOCKET_1);
sap_socket->onUnsolicitedResponse(unsolResponse, (void *)data, datalen); if(sap_socket){
sap_socket->onUnsolicitedResponse(unsolResponse, (void *)data, datalen);
}
} }
#endif #endif
@ -120,14 +114,14 @@ RilSapSocket *RilSapSocket::getSocketById(RIL_SOCKET_ID socketId) {
void RilSapSocket::initSapSocket(const char *socketName, void RilSapSocket::initSapSocket(const char *socketName,
RIL_RadioFunctions *uimFuncs) { RIL_RadioFunctions *uimFuncs) {
if (strcmp(socketName, "sap_uim_socket1") == 0) { if (strcmp(socketName, RIL1_SERVICE_NAME) == 0) {
if(!SocketExists(socketName)) { if(!SocketExists(socketName)) {
addSocketToList(socketName, RIL_SOCKET_1, uimFuncs); addSocketToList(socketName, RIL_SOCKET_1, uimFuncs);
} }
} }
#if (SIM_COUNT >= 2) #if (SIM_COUNT >= 2)
if (strcmp(socketName, "sap_uim_socket2") == 0) { if (strcmp(socketName, RIL2_SERVICE_NAME) == 0) {
if(!SocketExists(socketName)) { if(!SocketExists(socketName)) {
addSocketToList(socketName, RIL_SOCKET_2, uimFuncs); addSocketToList(socketName, RIL_SOCKET_2, uimFuncs);
} }
@ -135,7 +129,7 @@ void RilSapSocket::initSapSocket(const char *socketName,
#endif #endif
#if (SIM_COUNT >= 3) #if (SIM_COUNT >= 3)
if (strcmp(socketName, "sap_uim_socket3") == 0) { if (strcmp(socketName, RIL3_SERVICE_NAME) == 0) {
if(!SocketExists(socketName)) { if(!SocketExists(socketName)) {
addSocketToList(socketName, RIL_SOCKET_3, uimFuncs); addSocketToList(socketName, RIL_SOCKET_3, uimFuncs);
} }
@ -143,7 +137,7 @@ void RilSapSocket::initSapSocket(const char *socketName,
#endif #endif
#if (SIM_COUNT >= 4) #if (SIM_COUNT >= 4)
if (strcmp(socketName, "sap_uim_socket4") == 0) { if (strcmp(socketName, RIL4_SERVICE_NAME) == 0) {
if(!SocketExists(socketName)) { if(!SocketExists(socketName)) {
addSocketToList(socketName, RIL_SOCKET_4, uimFuncs); addSocketToList(socketName, RIL_SOCKET_4, uimFuncs);
} }
@ -161,6 +155,7 @@ void RilSapSocket::addSocketToList(const char *socketName, RIL_SOCKET_ID socketi
RilSapSocketList* listItem = (RilSapSocketList*)malloc(sizeof(RilSapSocketList)); RilSapSocketList* listItem = (RilSapSocketList*)malloc(sizeof(RilSapSocketList));
if (!listItem) { if (!listItem) {
RLOGE("addSocketToList: OOM"); RLOGE("addSocketToList: OOM");
delete socket;
return; return;
} }
listItem->socket = socket; listItem->socket = socket;
@ -179,7 +174,6 @@ void RilSapSocket::addSocketToList(const char *socketName, RIL_SOCKET_ID socketi
} }
current->next = listItem; current->next = listItem;
} }
socket->socketInit();
} }
} }
@ -195,24 +189,6 @@ bool RilSapSocket::SocketExists(const char *socketName) {
return false; return false;
} }
void* RilSapSocket::processRequestsLoop(void) {
RLOGI("UIM_SOCKET:Request loop started");
while(true) {
SapSocketRequest *req = dispatchQueue.dequeue();
RLOGI("New request from the dispatch Queue");
if (req != NULL) {
dispatchRequest(req->curr);
free(req);
} else {
RLOGE("Fetched null buffer from queue!");
}
}
return NULL;
}
RilSapSocket::RilSapSocket(const char *socketName, RilSapSocket::RilSapSocket(const char *socketName,
RIL_SOCKET_ID socketId, RIL_SOCKET_ID socketId,
RIL_RadioFunctions *inputUimFuncs): RIL_RadioFunctions *inputUimFuncs):
@ -222,49 +198,6 @@ RilSapSocket::RilSapSocket(const char *socketName,
} }
} }
#define BYTES_PER_LINE 16
#define NIBBLE_TO_HEX(n) ({ \
uint8_t __n = (uint8_t) n & 0x0f; \
__nibble >= 10 ? 'A' + __n - 10: '0' + __n; \
})
#define HEX_HIGH(b) ({ \
uint8_t __b = (uint8_t) b; \
uint8_t __nibble = (__b >> 4) & 0x0f; \
NIBBLE_TO_HEX(__nibble); \
})
#define HEX_LOW(b) ({ \
uint8_t __b = (uint8_t) b; \
uint8_t __nibble = __b & 0x0f; \
NIBBLE_TO_HEX(__nibble); \
})
void log_hex(const char *who, const uint8_t *buffer, int length) {
char out[80];
int source = 0;
int dest = 0;
int dest_len = sizeof(out);
int per_line = 0;
do {
dest += sprintf(out, "%8.8s [%8.8x] ", who, source);
for(; source < length && dest_len - dest > 3 && per_line < BYTES_PER_LINE; source++,
per_line ++) {
out[dest++] = HEX_HIGH(buffer[source]);
out[dest++] = HEX_LOW(buffer[source]);
out[dest++] = ' ';
}
if (dest < dest_len && (per_line == BYTES_PER_LINE || source >= length)) {
out[dest++] = 0;
per_line = 0;
dest = 0;
RLOGD("%s\n", out);
}
} while(source < length && dest < dest_len);
}
void RilSapSocket::dispatchRequest(MsgHeader *req) { void RilSapSocket::dispatchRequest(MsgHeader *req) {
// SapSocketRequest will be deallocated in onRequestComplete() // SapSocketRequest will be deallocated in onRequestComplete()
SapSocketRequest* currRequest=(SapSocketRequest*)malloc(sizeof(SapSocketRequest)); SapSocketRequest* currRequest=(SapSocketRequest*)malloc(sizeof(SapSocketRequest));
@ -282,11 +215,13 @@ void RilSapSocket::dispatchRequest(MsgHeader *req) {
pendingResponseQueue.enqueue(currRequest); pendingResponseQueue.enqueue(currRequest);
if (uimFuncs) { if (uimFuncs) {
RLOGI("[%d] > SAP REQUEST type: %d. id: %d. error: %d", RLOGI("RilSapSocket::dispatchRequest [%d] > SAP REQUEST type: %d. id: %d. error: %d, \
req->token, token 0x%p",
req->type, req->token,
req->id, req->type,
req->error ); req->id,
req->error,
currRequest );
#if defined(ANDROID_MULTI_SIM) #if defined(ANDROID_MULTI_SIM)
uimFuncs->onRequest(req->id, req->payload->bytes, req->payload->size, currRequest, id); uimFuncs->onRequest(req->id, req->payload->bytes, req->payload->size, currRequest, id);
@ -317,9 +252,10 @@ void RilSapSocket::onRequestComplete(RIL_Token t, RIL_Errno e, void *response,
rsp.payload->size = 0; rsp.payload->size = 0;
} }
RLOGE("Token:%d, MessageId:%d", hdr->token, hdr->id); RLOGE("RilSapSocket::onRequestComplete: Token:%d, MessageId:%d ril token 0x%p",
hdr->token, hdr->id, t);
sendResponse(&rsp); sap::processResponse(&rsp, this);
free(rsp.payload); free(rsp.payload);
} }
@ -333,54 +269,6 @@ void RilSapSocket::onRequestComplete(RIL_Token t, RIL_Errno e, void *response,
free(hdr); free(hdr);
} }
void RilSapSocket::sendResponse(MsgHeader* hdr) {
size_t encoded_size = 0;
uint32_t written_size;
size_t buffer_size = 0;
pb_ostream_t ostream;
bool success = false;
pthread_mutex_lock(&write_lock);
if ((success = pb_get_encoded_size(&encoded_size, MsgHeader_fields,
hdr)) && encoded_size <= INT32_MAX && commandFd != -1) {
buffer_size = encoded_size + sizeof(uint32_t);
uint8_t* buffer = (uint8_t*)malloc(buffer_size);
if (!buffer) {
RLOGE("sendResponse: OOM");
pthread_mutex_unlock(&write_lock);
return;
}
written_size = htonl((uint32_t) encoded_size);
ostream = pb_ostream_from_buffer(buffer, buffer_size);
pb_write(&ostream, (uint8_t *)&written_size, sizeof(written_size));
success = pb_encode(&ostream, MsgHeader_fields, hdr);
if (success) {
RLOGD("Size: %zu (0x%zx) Size as written: 0x%x", encoded_size,
encoded_size, written_size);
log_hex("onRequestComplete", &buffer[sizeof(written_size)], encoded_size);
RLOGI("[%d] < SAP RESPONSE type: %d. id: %d. error: %d",
hdr->token, hdr->type, hdr->id,hdr->error );
if ( 0 != blockingWrite_helper(commandFd, buffer, buffer_size)) {
RLOGE("Error %d while writing to fd", errno);
} else {
RLOGD("Write successful");
}
} else {
RLOGE("Error while encoding response of type %d id %d buffer_size: %zu: %s.",
hdr->type, hdr->id, buffer_size, PB_GET_ERROR(&ostream));
}
free(buffer);
} else {
RLOGE("Not sending response type %d: encoded_size: %zu. commandFd: %d. encoded size result:\
%d", hdr->type, encoded_size, commandFd, success);
}
pthread_mutex_unlock(&write_lock);
}
void RilSapSocket::onUnsolicitedResponse(int unsolResponse, void *data, size_t datalen) { void RilSapSocket::onUnsolicitedResponse(int unsolResponse, void *data, size_t datalen) {
if (data && datalen > 0) { if (data && datalen > 0) {
pb_bytes_array_t *payload = (pb_bytes_array_t *)calloc(1, pb_bytes_array_t *payload = (pb_bytes_array_t *)calloc(1,
@ -396,119 +284,7 @@ void RilSapSocket::onUnsolicitedResponse(int unsolResponse, void *data, size_t d
rsp.type = MsgType_UNSOL_RESPONSE; rsp.type = MsgType_UNSOL_RESPONSE;
rsp.id = (MsgId)unsolResponse; rsp.id = (MsgId)unsolResponse;
rsp.error = Error_RIL_E_SUCCESS; rsp.error = Error_RIL_E_SUCCESS;
sendResponse(&rsp); sap::processUnsolResponse(&rsp, this);
free(payload); free(payload);
} }
} }
void RilSapSocket::pushRecord(void *p_record, size_t recordlen) {
pb_istream_t stream = pb_istream_from_buffer((uint8_t *)p_record, recordlen);
// MsgHeader will be deallocated in onRequestComplete()
MsgHeader *reqHeader = (MsgHeader *)malloc(sizeof (MsgHeader));
if (!reqHeader) {
RLOGE("pushRecord: OOM");
return;
}
memset(reqHeader, 0, sizeof(MsgHeader));
log_hex("BtSapTest-Payload", (const uint8_t*)p_record, recordlen);
if (!pb_decode(&stream, MsgHeader_fields, reqHeader) ) {
RLOGE("Error decoding protobuf buffer : %s", PB_GET_ERROR(&stream));
free(reqHeader);
} else {
// SapSocketRequest will be deallocated in processRequestsLoop()
SapSocketRequest *recv = (SapSocketRequest*)malloc(sizeof(SapSocketRequest));
if (!recv) {
RLOGE("pushRecord: OOM");
free(reqHeader);
return;
}
recv->token = reqHeader->token;
recv->curr = reqHeader;
recv->socketId = id;
dispatchQueue.enqueue(recv);
}
}
void RilSapSocket::sendDisconnect() {
size_t encoded_size = 0;
uint32_t written_size;
size_t buffer_size = 0;
pb_ostream_t ostream;
bool success = false;
RIL_SIM_SAP_DISCONNECT_REQ disconnectReq;
if ((success = pb_get_encoded_size(&encoded_size, RIL_SIM_SAP_DISCONNECT_REQ_fields,
&disconnectReq)) && encoded_size <= INT32_MAX) {
buffer_size = encoded_size + sizeof(uint32_t);
uint8_t* buffer = (uint8_t*)malloc(buffer_size);
if (!buffer) {
RLOGE("sendDisconnect: OOM");
return;
}
written_size = htonl((uint32_t) encoded_size);
ostream = pb_ostream_from_buffer(buffer, buffer_size);
pb_write(&ostream, (uint8_t *)&written_size, sizeof(written_size));
success = pb_encode(&ostream, RIL_SIM_SAP_DISCONNECT_REQ_fields, buffer);
if(success) {
// Buffer will be deallocated in sOnRequestComplete()
pb_bytes_array_t *payload = (pb_bytes_array_t *)calloc(1,
sizeof(pb_bytes_array_t) + written_size);
if (!payload) {
RLOGE("sendDisconnect: OOM");
return;
}
memcpy(payload->bytes, buffer, written_size);
payload->size = written_size;
// MsgHeader will be deallocated in sOnRequestComplete()
MsgHeader *hdr = (MsgHeader *)malloc(sizeof(MsgHeader));
if (!hdr) {
RLOGE("sendDisconnect: OOM");
free(payload);
return;
}
hdr->payload = payload;
hdr->type = MsgType_REQUEST;
hdr->id = MsgId_RIL_SIM_SAP_DISCONNECT;
hdr->error = Error_RIL_E_SUCCESS;
dispatchDisconnect(hdr);
}
else {
RLOGE("Encode failed in send disconnect!");
}
free(buffer);
}
}
void RilSapSocket::dispatchDisconnect(MsgHeader *req) {
// SapSocketRequest will be deallocated in sOnRequestComplete()
SapSocketRequest* currRequest=(SapSocketRequest*)malloc(sizeof(SapSocketRequest));
if (!currRequest) {
RLOGE("dispatchDisconnect: OOM");
// Free memory allocated in sendDisconnect
free(req->payload);
free(req);
return;
}
currRequest->token = -1;
currRequest->curr = req;
currRequest->p_next = NULL;
currRequest->socketId = (RIL_SOCKET_ID)99;
RLOGD("Sending disconnect on command close!");
#if defined(ANDROID_MULTI_SIM)
uimFuncs->onRequest(req->id, req->payload->bytes, req->payload->size, currRequest, id);
#else
uimFuncs->onRequest(req->id, req->payload->bytes, req->payload->size, currRequest);
#endif
}
void RilSapSocket::onCommandsSocketClosed() {
sendDisconnect();
RLOGE("Socket command closed");
}

@ -99,9 +99,20 @@ class RilSapSocket : public RilSocket {
static void printList(); static void printList();
/** /**
* Clean up method to be called on command close. * Dispatches the request to the lower layers.
* It calls the on request function.
*
* @param request The request message.
*/ */
void onCommandsSocketClosed(void); void dispatchRequest(MsgHeader *request);
/**
* Class method to get the socket from the socket list.
*
* @param socketId Socket id.
* @return the sap socket.
*/
static RilSapSocket* getSocketById(RIL_SOCKET_ID socketId);
/** /**
* Datatype to handle the socket list. * Datatype to handle the socket list.
@ -112,16 +123,6 @@ class RilSapSocket : public RilSocket {
} RilSapSocketList; } RilSapSocketList;
protected: protected:
/**
* Process each record read from the socket and
* push a new request created from that record to
* the dispatch request queue.
*
* @param The record data.
* @param The record length.
*/
void pushRecord(void *record, size_t recordlen);
/** /**
* Socket handler to be called when a request has * Socket handler to be called when a request has
* been completed. * been completed.
@ -145,27 +146,6 @@ class RilSapSocket : public RilSocket {
void onUnsolicitedResponse(int unsolResponse, void onUnsolicitedResponse(int unsolResponse,
void *data, size_t datalen); void *data, size_t datalen);
/**
* Class method to get the socket from the socket list.
*
* @param Socket id.
* @return the sap socket.
*/
static RilSapSocket* getSocketById(RIL_SOCKET_ID socketId);
/**
* Method to send response to SAP. It does an atomic write operation on the
* socket.
*
* @param the response header with the payload.
*/
void sendResponse(MsgHeader *hdr);
/**
* A loop for processing the requests in the request dispatch queue.
*/
void *processRequestsLoop(void);
/** /**
* Class method to add the sap socket to the list of sockets. * Class method to add the sap socket to the list of sockets.
* Does nothing if the socket is already present in the list. * Does nothing if the socket is already present in the list.
@ -183,18 +163,6 @@ class RilSapSocket : public RilSocket {
*/ */
static bool SocketExists(const char *socketName); static bool SocketExists(const char *socketName);
/**
* Send a clean up SAP DISCONNECT if the socket disconnects before doing a SAP
* disconnect.
*/
void sendDisconnect(void);
/**
* Dispatch the clean up disconnect request.
*/
void dispatchDisconnect(MsgHeader *req);
private: private:
/** /**
* Constructor. * Constructor.
@ -207,14 +175,6 @@ class RilSapSocket : public RilSocket {
RIL_SOCKET_ID socketId, RIL_SOCKET_ID socketId,
RIL_RadioFunctions *inputUimFuncs); RIL_RadioFunctions *inputUimFuncs);
/**
* Dispatches the request to the lower layers.
* It calls the on request function.
*
* @param The request message.
*/
void dispatchRequest(MsgHeader *request);
/** /**
* Class method that selects the socket on which the onRequestComplete * Class method that selects the socket on which the onRequestComplete
* is called. * is called.

@ -1,177 +0,0 @@
/*
* Copyright (C) 2014 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.
*/
extern "C"
void *ril_socket_process_requests_loop(void *arg);
#include "RilSocket.h"
#include <cutils/sockets.h>
#include <utils/Log.h>
#include <assert.h>
#define SOCKET_LISTEN_BACKLOG 0
int RilSocket::socketInit(void) {
int ret;
listenCb = &RilSocket::sSocketListener;
commandCb = &RilSocket::sSocketRequestsHandler;
listenFd = android_get_control_socket(name);
//Start listening
ret = listen(listenFd, SOCKET_LISTEN_BACKLOG);
if (ret < 0) {
RLOGE("Failed to listen on %s socket '%d': %s",
name, listenFd, strerror(errno));
return ret;
}
//Add listen event to the event loop
ril_event_set(&listenEvent, listenFd, false, listenCb, this);
rilEventAddWakeup_helper(&listenEvent);
return ret;
}
void RilSocket::sSocketListener(int fd, short flags, void *param) {
RilSocket *theSocket = (RilSocket *) param;
MySocketListenParam listenParam;
listenParam.socket = theSocket;
listenParam.sListenParam.type = RIL_SAP_SOCKET;
listenCallback_helper(fd, flags, (void*)&listenParam);
}
void RilSocket::onNewCommandConnect() {
pthread_attr_t attr;
PthreadPtr pptr = ril_socket_process_requests_loop;
int result;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
//Start socket request processing loop thread
result = pthread_create(&socketThreadId, &attr, pptr, this);
if(result < 0) {
RLOGE("pthread_create failed with result:%d",result);
}
RLOGE("New socket command connected and socket request thread started");
}
void RilSocket::sSocketRequestsHandler(int fd, short flags, void *param) {
socketClient *sc = (socketClient *) param;
RilSocket *theSocket = sc->socketPtr;
RecordStream *rs = sc->rs;
theSocket->socketRequestsHandler(fd, flags, rs);
}
void RilSocket::socketRequestsHandler(int fd, short flags, RecordStream *p_rs) {
int ret;
assert(fd == commandFd);
void *p_record;
size_t recordlen;
for (;;) {
/* loop until EAGAIN/EINTR, end of stream, or other error */
ret = record_stream_get_next(p_rs, &p_record, &recordlen);
if (ret == 0 && p_record == NULL) {
/* end-of-stream */
break;
} else if (ret < 0) {
break;
} else if (ret == 0) {
pushRecord(p_record, recordlen);
}
}
if (ret == 0 || !(errno == EAGAIN || errno == EINTR)) {
/* fatal error or end-of-stream */
if (ret != 0) {
RLOGE("error on reading command socket errno:%d\n", errno);
} else {
RLOGW("EOS. Closing command socket.");
}
close(commandFd);
commandFd = -1;
ril_event_del(&callbackEvent);
record_stream_free(p_rs);
/* start listening for new connections again */
rilEventAddWakeup_helper(&listenEvent);
onCommandsSocketClosed();
}
}
void RilSocket::setListenFd(int fd) {
listenFd = fd;
}
void RilSocket::setCommandFd(int fd) {
commandFd = fd;
}
int RilSocket::getListenFd(void) {
return listenFd;
}
int RilSocket::getCommandFd(void) {
return commandFd;
}
void RilSocket::setListenCb(ril_event_cb cb) {
listenCb = cb;
}
void RilSocket::setCommandCb(ril_event_cb cb) {
commandCb = cb;
}
ril_event_cb RilSocket::getListenCb(void) {
return listenCb;
}
ril_event_cb RilSocket::getCommandCb(void) {
return commandCb;
}
void RilSocket::setListenEvent(ril_event event) {
listenEvent = event;
}
void RilSocket::setCallbackEvent(ril_event event) {
callbackEvent = event;
}
ril_event* RilSocket::getListenEvent(void) {
return &listenEvent;
}
ril_event* RilSocket::getCallbackEvent(void) {
return &callbackEvent;
}
extern "C"
void *ril_socket_process_requests_loop(void *arg) {
RilSocket *socket = (RilSocket *)arg;
socket->processRequestsLoop();
return NULL;
}

@ -20,10 +20,6 @@
#include "rilSocketQueue.h" #include "rilSocketQueue.h"
#include <ril_event.h> #include <ril_event.h>
using namespace std;
extern "C" void *ril_socket_process_requests_loop(void *arg);
/** /**
* Abstract socket class representing sockets in rild. * Abstract socket class representing sockets in rild.
* <p> * <p>
@ -46,81 +42,6 @@ class RilSocket {
*/ */
RIL_SOCKET_ID id; RIL_SOCKET_ID id;
/**
* Listen socket file descriptor.
*/
int listenFd = -1;
/**
* Commands socket file descriptor.
*/
int commandFd = -1;
/**
* Socket request loop thread id.
*/
pthread_t socketThreadId;
/**
* Listen event callack. Callback called when the other ends does accept.
*/
ril_event_cb listenCb;
/**
* Commands event callack.Callback called when there are requests from the other side.
*/
ril_event_cb commandCb;
/**
* Listen event to be added to eventloop after socket listen.
*/
struct ril_event listenEvent;
/**
* Commands event to be added to eventloop after accept.
*/
struct ril_event callbackEvent;
/**
* Static socket listen handler. Chooses the socket to call the listen callback
* from ril.cpp.
*
* @param Listen fd.
* @param flags.
* @param Parameter for the listen handler.
*/
static void sSocketListener(int fd, short flags, void *param);
/**
* Static socket request handler. Chooses the socket to call the request handler on.
*
* @param Commands fd.
* @param flags.
* @param Parameter for the request handler.
*/
static void sSocketRequestsHandler(int fd, short flags, void *param);
/**
* Process record from the record stream and push the requests onto the queue.
*
* @param record data.
* @param record length.
*/
virtual void pushRecord(void *record, size_t recordlen) = 0;
/**
* Socket lock for writing data on the socket.
*/
pthread_mutex_t write_lock = PTHREAD_MUTEX_INITIALIZER;
/**
* The loop to process the incoming requests.
*/
virtual void *processRequestsLoop(void) = 0;
private:
friend void *::ril_socket_process_requests_loop(void *arg);
public: public:
/** /**
@ -135,138 +56,15 @@ class RilSocket {
} }
/** /**
* Clean up function on commands socket close. * Get socket id.
*/
virtual void onCommandsSocketClosed(void) = 0;
/**
* Function called on new commands socket connect. Request loop thread is started here.
*/
void onNewCommandConnect(void);
/**
* Set listen socket fd.
*
* @param Input fd.
*/
void setListenFd(int listenFd);
/**
* Set commands socket fd.
*
* @param Input fd.
*/
void setCommandFd(int commandFd);
/**
* Get listen socket fd.
*
* @return Listen fd.
*/
int getListenFd(void);
/**
* Get commands socket fd.
* *
* @return Commands fd. * @return RIL_SOCKET_ID socket id.
*/ */
int getCommandFd(void); RIL_SOCKET_ID getSocketId(void) {
return id;
/** }
* Set listen event callback.
*
* @param Input event callback.
*/
void setListenCb(ril_event_cb listenCb);
/**
* Set command event callback.
*
* @param Input event callback.
*/
void setCommandCb(ril_event_cb commandCb);
/**
* Get listen event callback.
*
* @return Listen event callback.
*/
ril_event_cb getListenCb(void);
/**
* Gey command event callback.
*
* @return Command event callback.
*/
ril_event_cb getCommandCb(void);
/**
* Set listen event.
*
* @param Input event.
*/
void setListenEvent(ril_event listenEvent);
/**
* Set command callback event.
*
* @param Input event.
*/
void setCallbackEvent(ril_event commandEvent);
/**
* Get listen event.
*
* @return Listen event.
*/
ril_event* getListenEvent(void);
/**
* Get commands callback event.
*
* @return Commands callback event.
*/
ril_event* getCallbackEvent(void);
virtual ~RilSocket(){} virtual ~RilSocket(){}
protected:
/**
* Start listening on the socket and add the socket listen callback event.
*
* @return Result of the socket listen.
*/
int socketInit(void);
/**
* Socket request handler
*
* @param Commands fd.
* @param flags.
* @param Record stream.
*/
void socketRequestsHandler(int fd, short flags, RecordStream *rs);
};
class socketClient {
public:
RilSocket *socketPtr;
RecordStream *rs;
socketClient(RilSocket *socketPtr, RecordStream *rs) {
this->socketPtr = socketPtr;
this->rs = rs;
}
}; };
typedef struct MySocketListenParam {
SocketListenParam sListenParam;
RilSocket *socket;
} MySocketListenParam;
typedef void* (RilSocket::*RilSocketFuncPtr)(void);
typedef void (RilSocket::*RilSocketEventPtr)(int fd,short flags, void *param);
typedef void* (*PthreadPtr)(void*);
#endif #endif

@ -1,69 +0,0 @@
/* //device/libs/telephony/ril_commands.h
**
** Copyright 2006, 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.
*/
{10000, NULL, NULL},
{10001, NULL, NULL},
{RIL_REQUEST_GET_CELL_BROADCAST_CONFIG, dispatchVoid, responseVoid},
{10003, NULL, NULL},
{10004, NULL, NULL},
{RIL_REQUEST_SEND_ENCODED_USSD, dispatchVoid, responseVoid},
{RIL_REQUEST_SET_PDA_MEMORY_STATUS, dispatchVoid, responseVoid},
{RIL_REQUEST_GET_PHONEBOOK_STORAGE_INFO, dispatchVoid, responseVoid},
{RIL_REQUEST_GET_PHONEBOOK_ENTRY, dispatchVoid, responseVoid},
{RIL_REQUEST_ACCESS_PHONEBOOK_ENTRY, dispatchVoid, responseVoid},
{RIL_REQUEST_DIAL_VIDEO_CALL, dispatchVoid, responseVoid},
{RIL_REQUEST_CALL_DEFLECTION, dispatchVoid, responseVoid},
{RIL_REQUEST_READ_SMS_FROM_SIM, dispatchVoid, responseVoid},
{RIL_REQUEST_USIM_PB_CAPA, dispatchVoid, responseVoid},
{RIL_REQUEST_LOCK_INFO, dispatchVoid, responseVoid},
{10015, NULL, NULL},
{RIL_REQUEST_DIAL_EMERGENCY, dispatchDial, responseVoid},
{RIL_REQUEST_GET_STOREAD_MSG_COUNT, dispatchVoid, responseVoid},
{RIL_REQUEST_STK_SIM_INIT_EVENT, dispatchVoid, responseVoid},
{RIL_REQUEST_GET_LINE_ID, dispatchVoid, responseVoid},
{RIL_REQUEST_SET_LINE_ID, dispatchVoid, responseVoid},
{RIL_REQUEST_GET_SERIAL_NUMBER, dispatchVoid, responseVoid},
{RIL_REQUEST_GET_MANUFACTURE_DATE_NUMBER, dispatchVoid, responseVoid},
{RIL_REQUEST_GET_BARCODE_NUMBER, dispatchVoid, responseVoid},
{RIL_REQUEST_UICC_GBA_AUTHENTICATE_BOOTSTRAP, dispatchVoid, responseVoid},
{RIL_REQUEST_UICC_GBA_AUTHENTICATE_NAF, dispatchVoid, responseVoid},
{RIL_REQUEST_SIM_TRANSMIT_BASIC, dispatchVoid, responseVoid},
{RIL_REQUEST_SIM_OPEN_CHANNEL, dispatchVoid, responseVoid},
{RIL_REQUEST_SIM_CLOSE_CHANNEL, dispatchVoid, responseVoid},
{RIL_REQUEST_SIM_TRANSMIT_CHANNEL, dispatchVoid, responseVoid},
{RIL_REQUEST_SIM_AUTH, dispatchVoid, responseVoid},
{RIL_REQUEST_PS_ATTACH, dispatchVoid, responseVoid},
{RIL_REQUEST_PS_DETACH, dispatchVoid, responseVoid},
{RIL_REQUEST_ACTIVATE_DATA_CALL, dispatchVoid, responseVoid},
{RIL_REQUEST_CHANGE_SIM_PERSO, dispatchVoid, responseVoid},
{RIL_REQUEST_ENTER_SIM_PERSO, dispatchVoid, responseVoid},
{RIL_REQUEST_GET_TIME_INFO, dispatchVoid, responseVoid},
{RIL_REQUEST_OMADM_SETUP_SESSION, dispatchVoid, responseVoid},
{RIL_REQUEST_OMADM_SERVER_START_SESSION, dispatchVoid, responseVoid},
{RIL_REQUEST_OMADM_CLIENT_START_SESSION, dispatchVoid, responseVoid},
{RIL_REQUEST_OMADM_SEND_DATA, dispatchVoid, responseVoid},
{RIL_REQUEST_CDMA_GET_DATAPROFILE, dispatchVoid, responseVoid},
{RIL_REQUEST_CDMA_SET_DATAPROFILE, dispatchVoid, responseVoid},
{RIL_REQUEST_CDMA_GET_SYSTEMPROPERTIES, dispatchVoid, responseVoid},
{RIL_REQUEST_CDMA_SET_SYSTEMPROPERTIES, dispatchVoid, responseVoid},
{RIL_REQUEST_SEND_SMS_COUNT, dispatchVoid, responseVoid},
{RIL_REQUEST_SEND_SMS_MSG, dispatchVoid, responseVoid},
{RIL_REQUEST_SEND_SMS_MSG_READ_STATUS, dispatchVoid, responseVoid},
{RIL_REQUEST_MODEM_HANGUP, dispatchVoid, responseVoid},
{RIL_REQUEST_SET_SIM_POWER, dispatchVoid, responseVoid},
{RIL_REQUEST_SET_PREFERRED_NETWORK_LIST, dispatchVoid, responseVoid},
{RIL_REQUEST_GET_PREFERRED_NETWORK_LIST, dispatchVoid, responseVoid},
{RIL_REQUEST_HANGUP_VT, dispatchVoid, responseVoid},

@ -1,55 +0,0 @@
/* //device/libs/telephony/ril_unsol_commands.h
**
** Copyright 2006, 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.
*/
{SAMSUNG_UNSOL_RESPONSE_BASE, NULL, WAKE_PARTIAL},
{RIL_UNSOL_RELEASE_COMPLETE_MESSAGE, responseVoid, WAKE_PARTIAL}, // 11001
{RIL_UNSOL_STK_SEND_SMS_RESULT, responseInts, WAKE_PARTIAL}, // 11002
{RIL_UNSOL_STK_CALL_CONTROL_RESULT, responseVoid, WAKE_PARTIAL}, // 11003
{RIL_UNSOL_DUN_CALL_STATUS, responseVoid, WAKE_PARTIAL}, // 11004
{11005, NULL, WAKE_PARTIAL},
{11006, NULL, WAKE_PARTIAL},
{RIL_UNSOL_O2_HOME_ZONE_INFO, responseVoid, WAKE_PARTIAL}, // 11007
{RIL_UNSOL_DEVICE_READY_NOTI, responseVoid, WAKE_PARTIAL}, // 11008
{RIL_UNSOL_GPS_NOTI, responseVoid, WAKE_PARTIAL}, // 11009
{RIL_UNSOL_AM, responseString, WAKE_PARTIAL}, // 11010
{RIL_UNSOL_DUN_PIN_CONTROL_SIGNAL, responseVoid, WAKE_PARTIAL}, // 11011
{RIL_UNSOL_DATA_SUSPEND_RESUME, responseInts, WAKE_PARTIAL}, // 11012
{RIL_UNSOL_SAP, responseVoid, WAKE_PARTIAL}, // 11013
{11014, NULL, WAKE_PARTIAL},
{RIL_UNSOL_SIM_SMS_STORAGE_AVAILALE, responseVoid, WAKE_PARTIAL}, // 11015
{RIL_UNSOL_HSDPA_STATE_CHANGED, responseVoid, WAKE_PARTIAL}, // 11016
{RIL_UNSOL_WB_AMR_STATE, responseInts, WAKE_PARTIAL}, // 11017
{RIL_UNSOL_TWO_MIC_STATE, responseInts, WAKE_PARTIAL}, // 11018
{RIL_UNSOL_DHA_STATE, responseVoid, WAKE_PARTIAL}, // 11019
{RIL_UNSOL_UART, responseVoid, WAKE_PARTIAL}, // 11020
{RIL_UNSOL_RESPONSE_HANDOVER, responseVoid, WAKE_PARTIAL}, // 11021
{RIL_UNSOL_IPV6_ADDR, responseVoid, WAKE_PARTIAL}, // 11022
{RIL_UNSOL_NWK_INIT_DISC_REQUEST, responseVoid, WAKE_PARTIAL}, // 11023
{RIL_UNSOL_RTS_INDICATION, responseVoid, WAKE_PARTIAL}, // 11024
{RIL_UNSOL_OMADM_SEND_DATA, responseVoid, WAKE_PARTIAL}, // 11025
{RIL_UNSOL_DUN, responseVoid, WAKE_PARTIAL}, // 11026
{RIL_UNSOL_SYSTEM_REBOOT, responseVoid, WAKE_PARTIAL}, // 11027
{RIL_UNSOL_VOICE_PRIVACY_CHANGED, responseVoid, WAKE_PARTIAL}, // 11028
{RIL_UNSOL_UTS_GETSMSCOUNT, responseVoid, WAKE_PARTIAL}, // 11029
{RIL_UNSOL_UTS_GETSMSMSG, responseVoid, WAKE_PARTIAL}, // 11030
{RIL_UNSOL_UTS_GET_UNREAD_SMS_STATUS, responseVoid, WAKE_PARTIAL}, // 11031
{RIL_UNSOL_MIP_CONNECT_STATUS, responseVoid, WAKE_PARTIAL}, // 11032
#ifdef RIL_UNSOL_SNDMGR_WB_AMR_REPORT
{RIL_UNSOL_SNDMGR_WB_AMR_REPORT, responseInts, WAKE_PARTIAL}, // 20017
#endif
#ifdef RIL_UNSOL_SNDMGR_CLOCK_CTRL
{RIL_UNSOL_SNDMGR_CLOCK_CTRL, responseInts, WAKE_PARTIAL}, // 20022
#endif

File diff suppressed because it is too large Load Diff

@ -14,149 +14,144 @@
** See the License for the specific language governing permissions and ** See the License for the specific language governing permissions and
** limitations under the License. ** limitations under the License.
*/ */
{0, NULL, NULL}, //none {0, NULL}, //none
{RIL_REQUEST_GET_SIM_STATUS, dispatchVoid, responseSimStatus}, {RIL_REQUEST_GET_SIM_STATUS, radio::getIccCardStatusResponse},
{RIL_REQUEST_ENTER_SIM_PIN, dispatchStrings, responseInts}, {RIL_REQUEST_ENTER_SIM_PIN, radio::supplyIccPinForAppResponse},
{RIL_REQUEST_ENTER_SIM_PUK, dispatchStrings, responseInts}, {RIL_REQUEST_ENTER_SIM_PUK, radio::supplyIccPukForAppResponse},
{RIL_REQUEST_ENTER_SIM_PIN2, dispatchStrings, responseInts}, {RIL_REQUEST_ENTER_SIM_PIN2, radio::supplyIccPin2ForAppResponse},
{RIL_REQUEST_ENTER_SIM_PUK2, dispatchStrings, responseInts}, {RIL_REQUEST_ENTER_SIM_PUK2, radio::supplyIccPuk2ForAppResponse},
{RIL_REQUEST_CHANGE_SIM_PIN, dispatchStrings, responseInts}, {RIL_REQUEST_CHANGE_SIM_PIN, radio::changeIccPinForAppResponse},
{RIL_REQUEST_CHANGE_SIM_PIN2, dispatchStrings, responseInts}, {RIL_REQUEST_CHANGE_SIM_PIN2, radio::changeIccPin2ForAppResponse},
{RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, dispatchStrings, responseInts}, {RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, radio::supplyNetworkDepersonalizationResponse},
{RIL_REQUEST_GET_CURRENT_CALLS, dispatchVoid, responseCallList}, {RIL_REQUEST_GET_CURRENT_CALLS, radio::getCurrentCallsResponse},
{RIL_REQUEST_DIAL, dispatchDial, responseVoid}, {RIL_REQUEST_DIAL, radio::dialResponse},
{RIL_REQUEST_GET_IMSI, dispatchStrings, responseString}, {RIL_REQUEST_GET_IMSI, radio::getIMSIForAppResponse},
{RIL_REQUEST_HANGUP, dispatchInts, responseVoid}, {RIL_REQUEST_HANGUP, radio::hangupConnectionResponse},
{RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND, dispatchVoid, responseVoid}, {RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND, radio::hangupWaitingOrBackgroundResponse},
{RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND, dispatchVoid, responseVoid}, {RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND, radio::hangupForegroundResumeBackgroundResponse},
{RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE, dispatchVoid, responseVoid}, {RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE, radio::switchWaitingOrHoldingAndActiveResponse},
{RIL_REQUEST_CONFERENCE, dispatchVoid, responseVoid}, {RIL_REQUEST_CONFERENCE, radio::conferenceResponse},
{RIL_REQUEST_UDUB, dispatchVoid, responseVoid}, {RIL_REQUEST_UDUB, radio::rejectCallResponse},
#ifndef EXYNOS4_ENHANCEMENTS {RIL_REQUEST_LAST_CALL_FAIL_CAUSE, radio::getLastCallFailCauseResponse},
{RIL_REQUEST_LAST_CALL_FAIL_CAUSE, dispatchVoid, responseFailCause}, {RIL_REQUEST_SIGNAL_STRENGTH, radio::getSignalStrengthResponse},
#else {RIL_REQUEST_VOICE_REGISTRATION_STATE, radio::getVoiceRegistrationStateResponse},
/* {RIL_REQUEST_DATA_REGISTRATION_STATE, radio::getDataRegistrationStateResponse},
* Exynos4 devices send an extra int for LAST_CALL_FAIL_CAUSE {RIL_REQUEST_OPERATOR, radio::getOperatorResponse},
* which causes responseFailCause to think it's a string and crash. {RIL_REQUEST_RADIO_POWER, radio::setRadioPowerResponse},
*/ {RIL_REQUEST_DTMF, radio::sendDtmfResponse},
{RIL_REQUEST_LAST_CALL_FAIL_CAUSE, dispatchVoid, responseInts}, {RIL_REQUEST_SEND_SMS, radio::sendSmsResponse},
#endif {RIL_REQUEST_SEND_SMS_EXPECT_MORE, radio::sendSMSExpectMoreResponse},
{RIL_REQUEST_SIGNAL_STRENGTH, dispatchVoid, responseRilSignalStrength}, {RIL_REQUEST_SETUP_DATA_CALL, radio::setupDataCallResponse},
{RIL_REQUEST_VOICE_REGISTRATION_STATE, dispatchVoid, responseStrings}, {RIL_REQUEST_SIM_IO, radio::iccIOForAppResponse},
{RIL_REQUEST_DATA_REGISTRATION_STATE, dispatchVoid, responseStrings}, {RIL_REQUEST_SEND_USSD, radio::sendUssdResponse},
{RIL_REQUEST_OPERATOR, dispatchVoid, responseStrings}, {RIL_REQUEST_CANCEL_USSD, radio::cancelPendingUssdResponse},
{RIL_REQUEST_RADIO_POWER, dispatchInts, responseVoid}, {RIL_REQUEST_GET_CLIR, radio::getClirResponse},
{RIL_REQUEST_DTMF, dispatchString, responseVoid}, {RIL_REQUEST_SET_CLIR, radio::setClirResponse},
{RIL_REQUEST_SEND_SMS, dispatchStrings, responseSMS}, {RIL_REQUEST_QUERY_CALL_FORWARD_STATUS, radio::getCallForwardStatusResponse},
{RIL_REQUEST_SEND_SMS_EXPECT_MORE, dispatchStrings, responseSMS}, {RIL_REQUEST_SET_CALL_FORWARD, radio::setCallForwardResponse},
{RIL_REQUEST_SETUP_DATA_CALL, dispatchDataCall, responseSetupDataCall}, {RIL_REQUEST_QUERY_CALL_WAITING, radio::getCallWaitingResponse},
{RIL_REQUEST_SIM_IO, dispatchSIM_IO, responseSIM_IO}, {RIL_REQUEST_SET_CALL_WAITING, radio::setCallWaitingResponse},
{RIL_REQUEST_SEND_USSD, dispatchString, responseVoid}, {RIL_REQUEST_SMS_ACKNOWLEDGE, radio::acknowledgeLastIncomingGsmSmsResponse},
{RIL_REQUEST_CANCEL_USSD, dispatchVoid, responseVoid}, {RIL_REQUEST_GET_IMEI, NULL},
{RIL_REQUEST_GET_CLIR, dispatchVoid, responseInts}, {RIL_REQUEST_GET_IMEISV, NULL},
{RIL_REQUEST_SET_CLIR, dispatchInts, responseVoid}, {RIL_REQUEST_ANSWER, radio::acceptCallResponse},
{RIL_REQUEST_QUERY_CALL_FORWARD_STATUS, dispatchCallForward, responseCallForwards}, {RIL_REQUEST_DEACTIVATE_DATA_CALL, radio::deactivateDataCallResponse},
{RIL_REQUEST_SET_CALL_FORWARD, dispatchCallForward, responseVoid}, {RIL_REQUEST_QUERY_FACILITY_LOCK, radio::getFacilityLockForAppResponse},
{RIL_REQUEST_QUERY_CALL_WAITING, dispatchInts, responseInts}, {RIL_REQUEST_SET_FACILITY_LOCK, radio::setFacilityLockForAppResponse},
{RIL_REQUEST_SET_CALL_WAITING, dispatchInts, responseVoid}, {RIL_REQUEST_CHANGE_BARRING_PASSWORD, radio::setBarringPasswordResponse},
{RIL_REQUEST_SMS_ACKNOWLEDGE, dispatchInts, responseVoid}, {RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE, radio::getNetworkSelectionModeResponse},
{RIL_REQUEST_GET_IMEI, dispatchVoid, responseString}, {RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, radio::setNetworkSelectionModeAutomaticResponse},
{RIL_REQUEST_GET_IMEISV, dispatchVoid, responseString}, {RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL, radio::setNetworkSelectionModeManualResponse},
{RIL_REQUEST_ANSWER,dispatchVoid, responseVoid}, {RIL_REQUEST_QUERY_AVAILABLE_NETWORKS , radio::getAvailableNetworksResponse},
{RIL_REQUEST_DEACTIVATE_DATA_CALL, dispatchStrings, responseVoid}, {RIL_REQUEST_DTMF_START, radio::startDtmfResponse},
{RIL_REQUEST_QUERY_FACILITY_LOCK, dispatchStrings, responseInts}, {RIL_REQUEST_DTMF_STOP, radio::stopDtmfResponse},
{RIL_REQUEST_SET_FACILITY_LOCK, dispatchStrings, responseInts}, {RIL_REQUEST_BASEBAND_VERSION, radio::getBasebandVersionResponse},
{RIL_REQUEST_CHANGE_BARRING_PASSWORD, dispatchStrings, responseVoid}, {RIL_REQUEST_SEPARATE_CONNECTION, radio::separateConnectionResponse},
{RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE, dispatchVoid, responseInts}, {RIL_REQUEST_SET_MUTE, radio::setMuteResponse},
{RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, dispatchVoid, responseVoid}, {RIL_REQUEST_GET_MUTE, radio::getMuteResponse},
{RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL, dispatchString, responseVoid}, {RIL_REQUEST_QUERY_CLIP, radio::getClipResponse},
{RIL_REQUEST_QUERY_AVAILABLE_NETWORKS , dispatchVoid, responseStrings}, {RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE, NULL},
{RIL_REQUEST_DTMF_START, dispatchString, responseVoid}, {RIL_REQUEST_DATA_CALL_LIST, radio::getDataCallListResponse},
{RIL_REQUEST_DTMF_STOP, dispatchVoid, responseVoid}, {RIL_REQUEST_RESET_RADIO, NULL},
{RIL_REQUEST_BASEBAND_VERSION, dispatchVoid, responseString}, {RIL_REQUEST_OEM_HOOK_RAW, radio::sendRequestRawResponse},
{RIL_REQUEST_SEPARATE_CONNECTION, dispatchInts, responseVoid}, {RIL_REQUEST_OEM_HOOK_STRINGS, radio::sendRequestStringsResponse},
{RIL_REQUEST_SET_MUTE, dispatchInts, responseVoid}, {RIL_REQUEST_SCREEN_STATE, radio::sendDeviceStateResponse}, // Note the response function is different.
{RIL_REQUEST_GET_MUTE, dispatchVoid, responseInts}, {RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, radio::setSuppServiceNotificationsResponse},
{RIL_REQUEST_QUERY_CLIP, dispatchVoid, responseInts}, {RIL_REQUEST_WRITE_SMS_TO_SIM, radio::writeSmsToSimResponse},
{RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE, dispatchVoid, responseInts}, {RIL_REQUEST_DELETE_SMS_ON_SIM, radio::deleteSmsOnSimResponse},
{RIL_REQUEST_DATA_CALL_LIST, dispatchVoid, responseDataCallList}, {RIL_REQUEST_SET_BAND_MODE, radio::setBandModeResponse},
{RIL_REQUEST_RESET_RADIO, dispatchVoid, responseVoid}, {RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE, radio::getAvailableBandModesResponse},
{RIL_REQUEST_OEM_HOOK_RAW, dispatchRaw, responseRaw}, {RIL_REQUEST_STK_GET_PROFILE, NULL},
{RIL_REQUEST_OEM_HOOK_STRINGS, dispatchStrings, responseStrings}, {RIL_REQUEST_STK_SET_PROFILE, NULL},
{RIL_REQUEST_SCREEN_STATE, dispatchInts, responseVoid}, {RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND, radio::sendEnvelopeResponse},
{RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, dispatchInts, responseVoid}, {RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE, radio::sendTerminalResponseToSimResponse},
{RIL_REQUEST_WRITE_SMS_TO_SIM, dispatchSmsWrite, responseInts}, {RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM, radio::handleStkCallSetupRequestFromSimResponse},
{RIL_REQUEST_DELETE_SMS_ON_SIM, dispatchInts, responseVoid}, {RIL_REQUEST_EXPLICIT_CALL_TRANSFER, radio::explicitCallTransferResponse},
{RIL_REQUEST_SET_BAND_MODE, dispatchInts, responseVoid}, {RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, radio::setPreferredNetworkTypeResponse},
{RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE, dispatchVoid, responseInts}, {RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, radio::getPreferredNetworkTypeResponse},
{RIL_REQUEST_STK_GET_PROFILE, dispatchVoid, responseString}, {RIL_REQUEST_GET_NEIGHBORING_CELL_IDS, radio::getNeighboringCidsResponse},
{RIL_REQUEST_STK_SET_PROFILE, dispatchString, responseVoid}, {RIL_REQUEST_SET_LOCATION_UPDATES, radio::setLocationUpdatesResponse},
{RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND, dispatchString, responseString}, {RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, radio::setCdmaSubscriptionSourceResponse},
{RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE, dispatchString, responseVoid}, {RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, radio::setCdmaRoamingPreferenceResponse},
{RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM, dispatchInts, responseVoid}, {RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE, radio::getCdmaRoamingPreferenceResponse},
{RIL_REQUEST_EXPLICIT_CALL_TRANSFER, dispatchVoid, responseVoid}, {RIL_REQUEST_SET_TTY_MODE, radio::setTTYModeResponse},
{RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, dispatchInts, responseVoid}, {RIL_REQUEST_QUERY_TTY_MODE, radio::getTTYModeResponse},
{RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, dispatchVoid, responseInts}, {RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE, radio::setPreferredVoicePrivacyResponse},
{RIL_REQUEST_GET_NEIGHBORING_CELL_IDS, dispatchVoid, responseCellList}, {RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE, radio::getPreferredVoicePrivacyResponse},
{RIL_REQUEST_SET_LOCATION_UPDATES, dispatchInts, responseVoid}, {RIL_REQUEST_CDMA_FLASH, radio::sendCDMAFeatureCodeResponse},
{RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, dispatchInts, responseVoid}, {RIL_REQUEST_CDMA_BURST_DTMF, radio::sendBurstDtmfResponse},
{RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, dispatchInts, responseVoid}, {RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY, NULL},
{RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE, dispatchVoid, responseInts}, {RIL_REQUEST_CDMA_SEND_SMS, radio::sendCdmaSmsResponse},
{RIL_REQUEST_SET_TTY_MODE, dispatchInts, responseVoid}, {RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE, radio::acknowledgeLastIncomingCdmaSmsResponse},
{RIL_REQUEST_QUERY_TTY_MODE, dispatchVoid, responseInts}, {RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG, radio::getGsmBroadcastConfigResponse},
{RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE, dispatchInts, responseVoid}, {RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG, radio::setGsmBroadcastConfigResponse},
{RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE, dispatchVoid, responseInts}, {RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION, radio::setGsmBroadcastActivationResponse},
{RIL_REQUEST_CDMA_FLASH, dispatchString, responseVoid}, {RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG, radio::getCdmaBroadcastConfigResponse},
{RIL_REQUEST_CDMA_BURST_DTMF, dispatchStrings, responseVoid}, {RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG, radio::setCdmaBroadcastConfigResponse},
{RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY, dispatchString, responseVoid}, {RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION, radio::setCdmaBroadcastActivationResponse},
{RIL_REQUEST_CDMA_SEND_SMS, dispatchCdmaSms, responseSMS}, {RIL_REQUEST_CDMA_SUBSCRIPTION, radio::getCDMASubscriptionResponse},
{RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE, dispatchCdmaSmsAck, responseVoid}, {RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM, radio::writeSmsToRuimResponse},
{RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG, dispatchVoid, responseGsmBrSmsCnf}, {RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, radio::deleteSmsOnRuimResponse},
{RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG, dispatchGsmBrSmsCnf, responseVoid}, {RIL_REQUEST_DEVICE_IDENTITY, radio::getDeviceIdentityResponse},
{RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION, dispatchInts, responseVoid}, {RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE, radio::exitEmergencyCallbackModeResponse},
{RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG, dispatchVoid, responseCdmaBrSmsCnf}, {RIL_REQUEST_GET_SMSC_ADDRESS, radio::getSmscAddressResponse},
{RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG, dispatchCdmaBrSmsCnf, responseVoid}, {RIL_REQUEST_SET_SMSC_ADDRESS, radio::setSmscAddressResponse},
{RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION, dispatchInts, responseVoid}, {RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, radio::reportSmsMemoryStatusResponse},
{RIL_REQUEST_CDMA_SUBSCRIPTION, dispatchVoid, responseStrings}, {RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING, radio::reportStkServiceIsRunningResponse},
{RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM, dispatchRilCdmaSmsWriteArgs, responseInts}, {RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE, radio::getCdmaSubscriptionSourceResponse},
{RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, dispatchInts, responseVoid}, {RIL_REQUEST_ISIM_AUTHENTICATION, radio::requestIsimAuthenticationResponse},
{RIL_REQUEST_DEVICE_IDENTITY, dispatchVoid, responseStrings}, {RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, radio::acknowledgeIncomingGsmSmsWithPduResponse},
{RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE, dispatchVoid, responseVoid}, {RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS, radio::sendEnvelopeWithStatusResponse},
{RIL_REQUEST_GET_SMSC_ADDRESS, dispatchVoid, responseString}, {RIL_REQUEST_VOICE_RADIO_TECH, radio::getVoiceRadioTechnologyResponse},
{RIL_REQUEST_SET_SMSC_ADDRESS, dispatchString, responseVoid}, {RIL_REQUEST_GET_CELL_INFO_LIST, radio::getCellInfoListResponse},
{RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, dispatchInts, responseVoid}, {RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, radio::setCellInfoListRateResponse},
{RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING, dispatchVoid, responseVoid}, {RIL_REQUEST_SET_INITIAL_ATTACH_APN, radio::setInitialAttachApnResponse},
{RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE, dispatchCdmaSubscriptionSource, responseInts}, {RIL_REQUEST_IMS_REGISTRATION_STATE, radio::getImsRegistrationStateResponse},
{RIL_REQUEST_ISIM_AUTHENTICATION, dispatchString, responseString}, {RIL_REQUEST_IMS_SEND_SMS, radio::sendImsSmsResponse},
{RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, dispatchStrings, responseVoid}, {RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, radio::iccTransmitApduBasicChannelResponse},
{RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS, dispatchString, responseSIM_IO}, {RIL_REQUEST_SIM_OPEN_CHANNEL, radio::iccOpenLogicalChannelResponse},
{RIL_REQUEST_VOICE_RADIO_TECH, dispatchVoiceRadioTech, responseInts}, {RIL_REQUEST_SIM_CLOSE_CHANNEL, radio::iccCloseLogicalChannelResponse},
{RIL_REQUEST_GET_CELL_INFO_LIST, dispatchVoid, responseCellInfoList}, {RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, radio::iccTransmitApduLogicalChannelResponse},
{RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, dispatchInts, responseVoid}, {RIL_REQUEST_NV_READ_ITEM, radio::nvReadItemResponse},
{RIL_REQUEST_SET_INITIAL_ATTACH_APN, dispatchSetInitialAttachApn, responseVoid}, {RIL_REQUEST_NV_WRITE_ITEM, radio::nvWriteItemResponse},
{RIL_REQUEST_IMS_REGISTRATION_STATE, dispatchVoid, responseInts}, {RIL_REQUEST_NV_WRITE_CDMA_PRL, radio::nvWriteCdmaPrlResponse},
{RIL_REQUEST_IMS_SEND_SMS, dispatchImsSms, responseSMS}, {RIL_REQUEST_NV_RESET_CONFIG, radio::nvResetConfigResponse},
{RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, dispatchSIM_APDU, responseSIM_IO}, {RIL_REQUEST_SET_UICC_SUBSCRIPTION, radio::setUiccSubscriptionResponse},
{RIL_REQUEST_SIM_OPEN_CHANNEL, dispatchString, responseInts}, {RIL_REQUEST_ALLOW_DATA, radio::setDataAllowedResponse},
{RIL_REQUEST_SIM_CLOSE_CHANNEL, dispatchInts, responseVoid}, {RIL_REQUEST_GET_HARDWARE_CONFIG, radio::getHardwareConfigResponse},
{RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, dispatchSIM_APDU, responseSIM_IO}, {RIL_REQUEST_SIM_AUTHENTICATION, radio::requestIccSimAuthenticationResponse},
{RIL_REQUEST_NV_READ_ITEM, dispatchNVReadItem, responseString}, {RIL_REQUEST_GET_DC_RT_INFO, NULL},
{RIL_REQUEST_NV_WRITE_ITEM, dispatchNVWriteItem, responseVoid}, {RIL_REQUEST_SET_DC_RT_INFO_RATE, NULL},
{RIL_REQUEST_NV_WRITE_CDMA_PRL, dispatchRaw, responseVoid}, {RIL_REQUEST_SET_DATA_PROFILE, radio::setDataProfileResponse},
{RIL_REQUEST_NV_RESET_CONFIG, dispatchInts, responseVoid}, {RIL_REQUEST_SHUTDOWN, radio::requestShutdownResponse},
{RIL_REQUEST_SET_UICC_SUBSCRIPTION, dispatchUiccSubscripton, responseVoid}, {RIL_REQUEST_GET_RADIO_CAPABILITY, radio::getRadioCapabilityResponse},
{RIL_REQUEST_ALLOW_DATA, dispatchInts, responseVoid}, {RIL_REQUEST_SET_RADIO_CAPABILITY, radio::setRadioCapabilityResponse},
{RIL_REQUEST_GET_HARDWARE_CONFIG, dispatchVoid, responseHardwareConfig}, {RIL_REQUEST_START_LCE, radio::startLceServiceResponse},
{RIL_REQUEST_SIM_AUTHENTICATION, dispatchSimAuthentication, responseSIM_IO}, {RIL_REQUEST_STOP_LCE, radio::stopLceServiceResponse},
{RIL_REQUEST_GET_DC_RT_INFO, dispatchVoid, responseDcRtInfo}, {RIL_REQUEST_PULL_LCEDATA, radio::pullLceDataResponse},
{RIL_REQUEST_SET_DC_RT_INFO_RATE, dispatchInts, responseVoid}, {RIL_REQUEST_GET_ACTIVITY_INFO, radio::getModemActivityInfoResponse},
{RIL_REQUEST_SET_DATA_PROFILE, dispatchDataProfile, responseVoid}, {RIL_REQUEST_SET_CARRIER_RESTRICTIONS, radio::setAllowedCarriersResponse},
{RIL_REQUEST_SHUTDOWN, dispatchVoid, responseVoid}, {RIL_REQUEST_GET_CARRIER_RESTRICTIONS, radio::getAllowedCarriersResponse},
{RIL_REQUEST_GET_RADIO_CAPABILITY, dispatchVoid, responseRadioCapability}, {RIL_REQUEST_SEND_DEVICE_STATE, radio::sendDeviceStateResponse},
{RIL_REQUEST_SET_RADIO_CAPABILITY, dispatchRadioCapability, responseRadioCapability}, {RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, radio::setIndicationFilterResponse},
{RIL_REQUEST_START_LCE, dispatchInts, responseLceStatus}, {RIL_REQUEST_SET_SIM_CARD_POWER, radio::setSimCardPowerResponse},
{RIL_REQUEST_STOP_LCE, dispatchVoid, responseLceStatus},
{RIL_REQUEST_PULL_LCEDATA, dispatchVoid, responseLceData},
{RIL_REQUEST_GET_ACTIVITY_INFO, dispatchVoid, responseActivityData},
{RIL_REQUEST_SET_CARRIER_RESTRICTIONS, dispatchCarrierRestrictions, responseInts},
{RIL_REQUEST_GET_CARRIER_RESTRICTIONS, dispatchVoid, responseCarrierRestrictions},

@ -0,0 +1,98 @@
/*
* 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
namespace android {
#define RIL_SERVICE_NAME_BASE "slot"
#define RIL1_SERVICE_NAME "slot1"
#define RIL2_SERVICE_NAME "slot2"
#define RIL3_SERVICE_NAME "slot3"
#define RIL4_SERVICE_NAME "slot4"
/* 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
// Enable verbose logging
#define VDBG 0
#define MIN(a,b) ((a)<(b) ? (a) : (b))
// Enable RILC log
#define RILC_LOG 0
#if RILC_LOG
#define startRequest sprintf(printBuf, "(")
#define closeRequest sprintf(printBuf, "%s)", printBuf)
#define printRequest(token, req) \
RLOGD("[%04d]> %s %s", token, requestToString(req), printBuf)
#define startResponse sprintf(printBuf, "%s {", printBuf)
#define closeResponse sprintf(printBuf, "%s}", printBuf)
#define printResponse RLOGD("%s", printBuf)
#define clearPrintBuf printBuf[0] = 0
#define removeLastChar printBuf[strlen(printBuf)-1] = 0
#define appendPrintBuf(x...) snprintf(printBuf, PRINTBUF_SIZE, x)
#else
#define startRequest
#define closeRequest
#define printRequest(token, req)
#define startResponse
#define closeResponse
#define printResponse
#define clearPrintBuf
#define removeLastChar
#define appendPrintBuf(x...)
#endif
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;
int(*responseFunction) (int slotId, int responseType, int token,
RIL_Errno e, void *response, size_t responselen);
} CommandInfo;
RequestInfo * addRequestToList(int serial, int slotId, int request);
char * RIL_getServiceName();
void releaseWakeLock();
void onNewCommandConnect(RIL_SOCKET_ID socket_id);
} // namespace android
#endif //ANDROID_RIL_INTERNAL_H

File diff suppressed because it is too large Load Diff

@ -0,0 +1,716 @@
/*
* 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 getIccCardStatusResponse(int slotId, int responseType,
int token, RIL_Errno e, void *response, size_t responselen);
int supplyIccPinForAppResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int supplyIccPukForAppResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int supplyIccPin2ForAppResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int supplyIccPuk2ForAppResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int changeIccPinForAppResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int changeIccPin2ForAppResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int supplyNetworkDepersonalizationResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int getCurrentCallsResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int dialResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response, size_t responselen);
int getIMSIForAppResponse(int slotId, int responseType,
int serial, RIL_Errno e, void *response, size_t responselen);
int hangupConnectionResponse(int slotId, int responseType,
int serial, RIL_Errno e, void *response, size_t responselen);
int hangupWaitingOrBackgroundResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int hangupForegroundResumeBackgroundResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int switchWaitingOrHoldingAndActiveResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int conferenceResponse(int slotId, int responseType,
int serial, RIL_Errno e, void *response, size_t responselen);
int rejectCallResponse(int slotId, int responseType,
int serial, RIL_Errno e, void *response, size_t responselen);
int getLastCallFailCauseResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getSignalStrengthResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responseLen);
int getVoiceRegistrationStateResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getDataRegistrationStateResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getOperatorResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setRadioPowerResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int sendDtmfResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int sendSmsResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int sendSMSExpectMoreResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setupDataCallResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responseLen);
int iccIOForAppResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int sendUssdResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int cancelPendingUssdResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getClirResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response, size_t responselen);
int setClirResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response, size_t responselen);
int getCallForwardStatusResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setCallForwardResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getCallWaitingResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setCallWaitingResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int acknowledgeLastIncomingGsmSmsResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int acceptCallResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int deactivateDataCallResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getFacilityLockForAppResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setFacilityLockForAppResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setBarringPasswordResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getNetworkSelectionModeResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setNetworkSelectionModeAutomaticResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int setNetworkSelectionModeManualResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getAvailableNetworksResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int startDtmfResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int stopDtmfResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getBasebandVersionResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int separateConnectionResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setMuteResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getMuteResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getClipResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getDataCallListResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responseLen);
int setSuppServiceNotificationsResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int writeSmsToSimResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int deleteSmsOnSimResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setBandModeResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getAvailableBandModesResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int sendEnvelopeResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int sendTerminalResponseToSimResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int handleStkCallSetupRequestFromSimResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int explicitCallTransferResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setPreferredNetworkTypeResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getPreferredNetworkTypeResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getNeighboringCidsResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setLocationUpdatesResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setCdmaSubscriptionSourceResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setCdmaRoamingPreferenceResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getCdmaRoamingPreferenceResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setTTYModeResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getTTYModeResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setPreferredVoicePrivacyResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getPreferredVoicePrivacyResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int sendCDMAFeatureCodeResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int sendBurstDtmfResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int sendCdmaSmsResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int acknowledgeLastIncomingCdmaSmsResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getGsmBroadcastConfigResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setGsmBroadcastConfigResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setGsmBroadcastActivationResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getCdmaBroadcastConfigResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setCdmaBroadcastConfigResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setCdmaBroadcastActivationResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int getCDMASubscriptionResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int writeSmsToRuimResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int deleteSmsOnRuimResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getDeviceIdentityResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int exitEmergencyCallbackModeResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getSmscAddressResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int setCdmaBroadcastActivationResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int setSmscAddressResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int reportSmsMemoryStatusResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int reportStkServiceIsRunningResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responseLen);
int getCdmaSubscriptionSourceResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int requestIsimAuthenticationResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int sendEnvelopeWithStatusResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int getVoiceRadioTechnologyResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int getCellInfoListResponse(int slotId,
int responseType,
int serial, RIL_Errno e, void *response,
size_t responseLen);
int setCellInfoListRateResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int setInitialAttachApnResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int getImsRegistrationStateResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int sendImsSmsResponse(int slotId, int responseType,
int serial, RIL_Errno e, void *response, size_t responselen);
int iccTransmitApduBasicChannelResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int iccOpenLogicalChannelResponse(int slotId,
int responseType, int serial, RIL_Errno e, void *response,
size_t responselen);
int iccCloseLogicalChannelResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int iccTransmitApduLogicalChannelResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int nvReadItemResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int nvWriteItemResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int nvWriteCdmaPrlResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int nvResetConfigResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int setUiccSubscriptionResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int setDataAllowedResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int getHardwareConfigResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responseLen);
int requestIccSimAuthenticationResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int setDataProfileResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int requestShutdownResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int getRadioCapabilityResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responseLen);
int setRadioCapabilityResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responseLen);
int startLceServiceResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int stopLceServiceResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int pullLceDataResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responseLen);
int getModemActivityInfoResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int setAllowedCarriersResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int getAllowedCarriersResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int sendDeviceStateResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int setIndicationFilterResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
int setSimCardPowerResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responselen);
void acknowledgeRequest(int slotId, int serial);
int radioStateChangedInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen);
int callStateChangedInd(int slotId, int indType, int token,
RIL_Errno e, void *response, size_t responselen);
int networkStateChangedInd(int slotId, int indType,
int token, RIL_Errno e, void *response, size_t responselen);
int newSmsInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int newSmsStatusReportInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int newSmsOnSimInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int onUssdInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int nitzTimeReceivedInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int currentSignalStrengthInd(int slotId,
int indicationType, int token, RIL_Errno e,
void *response, size_t responselen);
int dataCallListChangedInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int suppSvcNotifyInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int stkSessionEndInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int stkProactiveCommandInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int stkEventNotifyInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int stkCallSetupInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int simSmsStorageFullInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int simRefreshInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int callRingInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int simStatusChangedInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int cdmaNewSmsInd(int slotId, int indicationType,
int token, RIL_Errno e, void *response, size_t responselen);
int newBroadcastSmsInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int cdmaRuimSmsStorageFullInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int restrictedStateChangedInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int enterEmergencyCallbackModeInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int cdmaCallWaitingInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int cdmaOtaProvisionStatusInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int cdmaInfoRecInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int oemHookRawInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int indicateRingbackToneInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int resendIncallMuteInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int cdmaSubscriptionSourceChangedInd(int slotId,
int indicationType, int token, RIL_Errno e,
void *response, size_t responselen);
int cdmaPrlChangedInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int exitEmergencyCallbackModeInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int rilConnectedInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int voiceRadioTechChangedInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int cellInfoListInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int imsNetworkStateChangedInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int subscriptionStatusChangedInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int srvccStateNotifyInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int hardwareConfigChangedInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int radioCapabilityIndicationInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int onSupplementaryServiceIndicationInd(int slotId,
int indicationType, int token, RIL_Errno e,
void *response, size_t responselen);
int stkCallControlAlphaNotifyInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int lceDataInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int pcoDataInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int modemResetInd(int slotId,
int indicationType, int token, RIL_Errno e, void *response,
size_t responselen);
int sendRequestRawResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responseLen);
int sendRequestStringsResponse(int slotId,
int responseType, int serial, RIL_Errno e,
void *response, size_t responseLen);
pthread_rwlock_t * getRadioServiceRwlock(int slotId);
} // namespace radio
#endif // RIL_SERVICE_H

@ -14,50 +14,51 @@
** See the License for the specific language governing permissions and ** See the License for the specific language governing permissions and
** limitations under the License. ** limitations under the License.
*/ */
{RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, responseVoid, WAKE_PARTIAL}, {RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, radio::radioStateChangedInd, WAKE_PARTIAL},
{RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, responseVoid, WAKE_PARTIAL}, {RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, radio::callStateChangedInd, WAKE_PARTIAL},
{RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, responseVoid, WAKE_PARTIAL}, {RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, radio::networkStateChangedInd, WAKE_PARTIAL},
{RIL_UNSOL_RESPONSE_NEW_SMS, responseString, WAKE_PARTIAL}, {RIL_UNSOL_RESPONSE_NEW_SMS, radio::newSmsInd, WAKE_PARTIAL},
{RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT, responseString, WAKE_PARTIAL}, {RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT, radio::newSmsStatusReportInd, WAKE_PARTIAL},
{RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM, responseInts, WAKE_PARTIAL}, {RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM, radio::newSmsOnSimInd, WAKE_PARTIAL},
{RIL_UNSOL_ON_USSD, responseStrings, WAKE_PARTIAL}, {RIL_UNSOL_ON_USSD, radio::onUssdInd, WAKE_PARTIAL},
{RIL_UNSOL_ON_USSD_REQUEST, responseVoid, DONT_WAKE}, {RIL_UNSOL_ON_USSD_REQUEST, radio::onUssdInd, DONT_WAKE},
{RIL_UNSOL_NITZ_TIME_RECEIVED, responseString, WAKE_PARTIAL}, {RIL_UNSOL_NITZ_TIME_RECEIVED, radio::nitzTimeReceivedInd, WAKE_PARTIAL},
{RIL_UNSOL_SIGNAL_STRENGTH, responseRilSignalStrength, DONT_WAKE}, {RIL_UNSOL_SIGNAL_STRENGTH, radio::currentSignalStrengthInd, DONT_WAKE},
{RIL_UNSOL_DATA_CALL_LIST_CHANGED, responseDataCallList, WAKE_PARTIAL}, {RIL_UNSOL_DATA_CALL_LIST_CHANGED, radio::dataCallListChangedInd, WAKE_PARTIAL},
{RIL_UNSOL_SUPP_SVC_NOTIFICATION, responseSsn, WAKE_PARTIAL}, {RIL_UNSOL_SUPP_SVC_NOTIFICATION, radio::suppSvcNotifyInd, WAKE_PARTIAL},
{RIL_UNSOL_STK_SESSION_END, responseVoid, WAKE_PARTIAL}, {RIL_UNSOL_STK_SESSION_END, radio::stkSessionEndInd, WAKE_PARTIAL},
{RIL_UNSOL_STK_PROACTIVE_COMMAND, responseString, WAKE_PARTIAL}, {RIL_UNSOL_STK_PROACTIVE_COMMAND, radio::stkProactiveCommandInd, WAKE_PARTIAL},
{RIL_UNSOL_STK_EVENT_NOTIFY, responseString, WAKE_PARTIAL}, {RIL_UNSOL_STK_EVENT_NOTIFY, radio::stkEventNotifyInd, WAKE_PARTIAL},
{RIL_UNSOL_STK_CALL_SETUP, responseInts, WAKE_PARTIAL}, {RIL_UNSOL_STK_CALL_SETUP, radio::stkCallSetupInd, WAKE_PARTIAL},
{RIL_UNSOL_SIM_SMS_STORAGE_FULL, responseVoid, WAKE_PARTIAL}, {RIL_UNSOL_SIM_SMS_STORAGE_FULL, radio::simSmsStorageFullInd, WAKE_PARTIAL},
{RIL_UNSOL_SIM_REFRESH, responseSimRefresh, WAKE_PARTIAL}, {RIL_UNSOL_SIM_REFRESH, radio::simRefreshInd, WAKE_PARTIAL},
{RIL_UNSOL_CALL_RING, responseCallRing, WAKE_PARTIAL}, {RIL_UNSOL_CALL_RING, radio::callRingInd, WAKE_PARTIAL},
{RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, responseVoid, WAKE_PARTIAL}, {RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, radio::simStatusChangedInd, WAKE_PARTIAL},
{RIL_UNSOL_RESPONSE_CDMA_NEW_SMS, responseCdmaSms, WAKE_PARTIAL}, {RIL_UNSOL_RESPONSE_CDMA_NEW_SMS, radio::cdmaNewSmsInd, WAKE_PARTIAL},
{RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS, responseRaw, WAKE_PARTIAL}, {RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS, radio::newBroadcastSmsInd, WAKE_PARTIAL},
{RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL, responseVoid, WAKE_PARTIAL}, {RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL, radio::cdmaRuimSmsStorageFullInd, WAKE_PARTIAL},
{RIL_UNSOL_RESTRICTED_STATE_CHANGED, responseInts, WAKE_PARTIAL}, {RIL_UNSOL_RESTRICTED_STATE_CHANGED, radio::restrictedStateChangedInd, WAKE_PARTIAL},
{RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE, responseVoid, WAKE_PARTIAL}, {RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE, radio::enterEmergencyCallbackModeInd, WAKE_PARTIAL},
{RIL_UNSOL_CDMA_CALL_WAITING, responseCdmaCallWaiting, WAKE_PARTIAL}, {RIL_UNSOL_CDMA_CALL_WAITING, radio::cdmaCallWaitingInd, WAKE_PARTIAL},
{RIL_UNSOL_CDMA_OTA_PROVISION_STATUS, responseInts, WAKE_PARTIAL}, {RIL_UNSOL_CDMA_OTA_PROVISION_STATUS, radio::cdmaOtaProvisionStatusInd, WAKE_PARTIAL},
{RIL_UNSOL_CDMA_INFO_REC, responseCdmaInformationRecords, WAKE_PARTIAL}, {RIL_UNSOL_CDMA_INFO_REC, radio::cdmaInfoRecInd, WAKE_PARTIAL},
{RIL_UNSOL_OEM_HOOK_RAW, responseRaw, WAKE_PARTIAL}, {RIL_UNSOL_OEM_HOOK_RAW, radio::oemHookRawInd, WAKE_PARTIAL},
{RIL_UNSOL_RINGBACK_TONE, responseInts, WAKE_PARTIAL}, {RIL_UNSOL_RINGBACK_TONE, radio::indicateRingbackToneInd, WAKE_PARTIAL},
{RIL_UNSOL_RESEND_INCALL_MUTE, responseVoid, WAKE_PARTIAL}, {RIL_UNSOL_RESEND_INCALL_MUTE, radio::resendIncallMuteInd, WAKE_PARTIAL},
{RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED, responseInts, WAKE_PARTIAL}, {RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED, radio::cdmaSubscriptionSourceChangedInd, WAKE_PARTIAL},
{RIL_UNSOL_CDMA_PRL_CHANGED, responseInts, WAKE_PARTIAL}, {RIL_UNSOL_CDMA_PRL_CHANGED, radio::cdmaPrlChangedInd, WAKE_PARTIAL},
{RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE, responseVoid, WAKE_PARTIAL}, {RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE, radio::exitEmergencyCallbackModeInd, WAKE_PARTIAL},
{RIL_UNSOL_RIL_CONNECTED, responseInts, WAKE_PARTIAL}, {RIL_UNSOL_RIL_CONNECTED, radio::rilConnectedInd, WAKE_PARTIAL},
{RIL_UNSOL_VOICE_RADIO_TECH_CHANGED, responseInts, WAKE_PARTIAL}, {RIL_UNSOL_VOICE_RADIO_TECH_CHANGED, radio::voiceRadioTechChangedInd, WAKE_PARTIAL},
{RIL_UNSOL_CELL_INFO_LIST, responseCellInfoList, WAKE_PARTIAL}, {RIL_UNSOL_CELL_INFO_LIST, radio::cellInfoListInd, WAKE_PARTIAL},
{RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED, responseVoid, WAKE_PARTIAL}, {RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED, radio::imsNetworkStateChangedInd, WAKE_PARTIAL},
{RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED, responseInts, WAKE_PARTIAL}, {RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED, radio::subscriptionStatusChangedInd, WAKE_PARTIAL},
{RIL_UNSOL_SRVCC_STATE_NOTIFY, responseInts, WAKE_PARTIAL}, {RIL_UNSOL_SRVCC_STATE_NOTIFY, radio::srvccStateNotifyInd, WAKE_PARTIAL},
{RIL_UNSOL_HARDWARE_CONFIG_CHANGED, responseHardwareConfig, WAKE_PARTIAL}, {RIL_UNSOL_HARDWARE_CONFIG_CHANGED, radio::hardwareConfigChangedInd, WAKE_PARTIAL},
{RIL_UNSOL_DC_RT_INFO_CHANGED, responseDcRtInfo, WAKE_PARTIAL}, {RIL_UNSOL_DC_RT_INFO_CHANGED, NULL, WAKE_PARTIAL},
{RIL_UNSOL_RADIO_CAPABILITY, responseRadioCapability, WAKE_PARTIAL}, {RIL_UNSOL_RADIO_CAPABILITY, radio::radioCapabilityIndicationInd, WAKE_PARTIAL},
{RIL_UNSOL_ON_SS, responseSSData, WAKE_PARTIAL}, {RIL_UNSOL_ON_SS, radio::onSupplementaryServiceIndicationInd, WAKE_PARTIAL},
{RIL_UNSOL_STK_CC_ALPHA_NOTIFY, responseString, WAKE_PARTIAL}, {RIL_UNSOL_STK_CC_ALPHA_NOTIFY, radio::stkCallControlAlphaNotifyInd, WAKE_PARTIAL},
{RIL_UNSOL_LCEDATA_RECV, responseLceData, WAKE_PARTIAL}, {RIL_UNSOL_LCEDATA_RECV, radio::lceDataInd, WAKE_PARTIAL},
{RIL_UNSOL_PCO_DATA, responsePcoData, WAKE_PARTIAL}, {RIL_UNSOL_PCO_DATA, radio::pcoDataInd, WAKE_PARTIAL},
{RIL_UNSOL_MODEM_RESTART, radio::modemResetInd, WAKE_PARTIAL},

@ -0,0 +1,958 @@
/*
* 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.
*/
#define LOG_TAG "RIL_SAP"
#include <android/hardware/radio/1.0/ISap.h>
#include <hwbinder/IPCThreadState.h>
#include <hwbinder/ProcessState.h>
#include <sap_service.h>
#include "pb_decode.h"
#include "pb_encode.h"
using namespace android::hardware::radio::V1_0;
using ::android::hardware::Return;
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;
struct SapImpl;
#if (SIM_COUNT >= 2)
sp<SapImpl> sapService[SIM_COUNT];
#else
sp<SapImpl> sapService[1];
#endif
struct SapImpl : public ISap {
int32_t slotId;
sp<ISapCallback> sapCallback;
RIL_SOCKET_ID rilSocketId;
Return<void> setCallback(const ::android::sp<ISapCallback>& sapCallbackParam);
Return<void> connectReq(int32_t token, int32_t maxMsgSize);
Return<void> disconnectReq(int32_t token);
Return<void> apduReq(int32_t token, SapApduType type, const hidl_vec<uint8_t>& command);
Return<void> transferAtrReq(int32_t token);
Return<void> powerReq(int32_t token, bool state);
Return<void> resetSimReq(int32_t token);
Return<void> transferCardReaderStatusReq(int32_t token);
Return<void> setTransferProtocolReq(int32_t token, SapTransferProtocol transferProtocol);
MsgHeader* createMsgHeader(MsgId msgId, int32_t token);
Return<void> addPayloadAndDispatchRequest(MsgHeader *msg, uint16_t reqLen, uint8_t *reqPtr);
void sendFailedResponse(MsgId msgId, int32_t token, int numPointers, ...);
void checkReturnStatus(Return<void>& ret);
};
void SapImpl::checkReturnStatus(Return<void>& ret) {
if (ret.isOk() == false) {
RLOGE("checkReturnStatus: unable to call response/indication callback: %s",
ret.description().c_str());
// Remote process (SapRilReceiver.java) hosting the callback must be dead. Reset the
// callback object; there's no other recovery to be done here. When the client process is
// back up, it will call setCallback()
sapCallback = NULL;
}
}
Return<void> SapImpl::setCallback(const ::android::sp<ISapCallback>& sapCallbackParam) {
RLOGD("SapImpl::setCallback for slotId %d", slotId);
sapCallback = sapCallbackParam;
return Void();
}
MsgHeader* SapImpl::createMsgHeader(MsgId msgId, int32_t token) {
// Memory for msg will be freed by RilSapSocket::onRequestComplete()
MsgHeader *msg = (MsgHeader *)calloc(1, sizeof(MsgHeader));
if (msg == NULL) {
return NULL;
}
msg->token = token;
msg->type = MsgType_REQUEST;
msg->id = msgId;
msg->error = Error_RIL_E_SUCCESS;
return msg;
}
Return<void> SapImpl::addPayloadAndDispatchRequest(MsgHeader *msg, uint16_t reqLen,
uint8_t *reqPtr) {
msg->payload = (pb_bytes_array_t *)malloc(sizeof(pb_bytes_array_t) - 1 + reqLen);
if (msg->payload == NULL) {
sendFailedResponse(msg->id, msg->token, 2, reqPtr, msg);
return Void();
}
msg->payload->size = reqLen;
memcpy(msg->payload->bytes, reqPtr, reqLen);
RilSapSocket *sapSocket = RilSapSocket::getSocketById(rilSocketId);
if (sapSocket) {
RLOGD("SapImpl::addPayloadAndDispatchRequest: calling dispatchRequest");
sapSocket->dispatchRequest(msg);
} else {
RLOGE("SapImpl::addPayloadAndDispatchRequest: sapSocket is null");
sendFailedResponse(msg->id, msg->token, 3, msg->payload, reqPtr, msg);
return Void();
}
free(msg->payload);
free(reqPtr);
return Void();
}
void SapImpl::sendFailedResponse(MsgId msgId, int32_t token, int numPointers, ...) {
va_list ap;
va_start(ap, numPointers);
for (int i = 0; i < numPointers; i++) {
void *ptr = va_arg(ap, void *);
if (ptr) free(ptr);
}
va_end(ap);
Return<void> retStatus;
switch(msgId) {
case MsgId_RIL_SIM_SAP_CONNECT:
retStatus = sapCallback->connectResponse(token, SapConnectRsp::CONNECT_FAILURE, 0);
break;
case MsgId_RIL_SIM_SAP_DISCONNECT:
retStatus = sapCallback->disconnectResponse(token);
break;
case MsgId_RIL_SIM_SAP_APDU: {
hidl_vec<uint8_t> apduRsp;
retStatus = sapCallback->apduResponse(token, SapResultCode::GENERIC_FAILURE, apduRsp);
break;
}
case MsgId_RIL_SIM_SAP_TRANSFER_ATR: {
hidl_vec<uint8_t> atr;
retStatus = sapCallback->transferAtrResponse(token, SapResultCode::GENERIC_FAILURE,
atr);
break;
}
case MsgId_RIL_SIM_SAP_POWER:
retStatus = sapCallback->powerResponse(token, SapResultCode::GENERIC_FAILURE);
break;
case MsgId_RIL_SIM_SAP_RESET_SIM:
retStatus = sapCallback->resetSimResponse(token, SapResultCode::GENERIC_FAILURE);
break;
case MsgId_RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS:
retStatus = sapCallback->transferCardReaderStatusResponse(token,
SapResultCode::GENERIC_FAILURE, 0);
break;
case MsgId_RIL_SIM_SAP_SET_TRANSFER_PROTOCOL:
retStatus = sapCallback->transferProtocolResponse(token, SapResultCode::NOT_SUPPORTED);
break;
default:
return;
}
sapService[slotId]->checkReturnStatus(retStatus);
}
Return<void> SapImpl::connectReq(int32_t token, int32_t maxMsgSize) {
RLOGD("SapImpl::connectReq");
MsgHeader *msg = createMsgHeader(MsgId_RIL_SIM_SAP_CONNECT, token);
if (msg == NULL) {
RLOGE("SapImpl::connectReq: Error allocating memory for msg");
sendFailedResponse(MsgId_RIL_SIM_SAP_CONNECT, token, 0);
return Void();
}
/***** Encode RIL_SIM_SAP_CONNECT_REQ *****/
RIL_SIM_SAP_CONNECT_REQ req;
memset(&req, 0, sizeof(RIL_SIM_SAP_CONNECT_REQ));
req.max_message_size = maxMsgSize;
size_t encodedSize = 0;
if (!pb_get_encoded_size(&encodedSize, RIL_SIM_SAP_CONNECT_REQ_fields, &req)) {
RLOGE("SapImpl::connectReq: Error getting encoded size for RIL_SIM_SAP_CONNECT_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_CONNECT, token, 1, msg);
return Void();
}
uint8_t *buffer = (uint8_t *)calloc(1, encodedSize);
if (buffer == NULL) {
RLOGE("SapImpl::connectReq: Error allocating memory for buffer");
sendFailedResponse(MsgId_RIL_SIM_SAP_CONNECT, token, 1, msg);
return Void();
}
pb_ostream_t stream = pb_ostream_from_buffer(buffer, encodedSize);
RLOGD("SapImpl::connectReq calling pb_encode");
if (!pb_encode(&stream, RIL_SIM_SAP_CONNECT_REQ_fields, &req)) {
RLOGE("SapImpl::connectReq: Error encoding RIL_SIM_SAP_CONNECT_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_CONNECT, token, 2, buffer, msg);
return Void();
}
/***** Encode RIL_SIM_SAP_CONNECT_REQ done *****/
/* encoded req is payload */
return addPayloadAndDispatchRequest(msg, stream.bytes_written, buffer);
}
Return<void> SapImpl::disconnectReq(int32_t token) {
RLOGD("SapImpl::disconnectReq");
MsgHeader *msg = createMsgHeader(MsgId_RIL_SIM_SAP_DISCONNECT, token);
if (msg == NULL) {
RLOGE("SapImpl::disconnectReq: Error allocating memory for msg");
sendFailedResponse(MsgId_RIL_SIM_SAP_DISCONNECT, token, 0);
return Void();
}
/***** Encode RIL_SIM_SAP_DISCONNECT_REQ *****/
RIL_SIM_SAP_DISCONNECT_REQ req;
memset(&req, 0, sizeof(RIL_SIM_SAP_DISCONNECT_REQ));
size_t encodedSize = 0;
if (!pb_get_encoded_size(&encodedSize, RIL_SIM_SAP_DISCONNECT_REQ_fields, &req)) {
RLOGE("SapImpl::disconnectReq: Error getting encoded size for RIL_SIM_SAP_DISCONNECT_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_DISCONNECT, token, 1, msg);
return Void();
}
uint8_t *buffer = (uint8_t *)calloc(1, encodedSize);
if (buffer == NULL) {
RLOGE("SapImpl::disconnectReq: Error allocating memory for buffer");
sendFailedResponse(MsgId_RIL_SIM_SAP_DISCONNECT, token, 1, msg);
return Void();
}
pb_ostream_t stream = pb_ostream_from_buffer(buffer, encodedSize);
RLOGD("SapImpl::disconnectReq calling pb_encode");
if (!pb_encode(&stream, RIL_SIM_SAP_DISCONNECT_REQ_fields, &req)) {
RLOGE("SapImpl::disconnectReq: Error encoding RIL_SIM_SAP_DISCONNECT_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_DISCONNECT, token, 2, buffer, msg);
return Void();
}
/***** Encode RIL_SIM_SAP_DISCONNECT_REQ done *****/
/* encoded req is payload */
return addPayloadAndDispatchRequest(msg, stream.bytes_written, buffer);
}
Return<void> SapImpl::apduReq(int32_t token, SapApduType type, const hidl_vec<uint8_t>& command) {
RLOGD("SapImpl::apduReq");
MsgHeader *msg = createMsgHeader(MsgId_RIL_SIM_SAP_APDU, token);
if (msg == NULL) {
RLOGE("SapImpl::apduReq: Error allocating memory for msg");
sendFailedResponse(MsgId_RIL_SIM_SAP_APDU, token, 0);
return Void();
}
/***** Encode RIL_SIM_SAP_APDU_REQ *****/
RIL_SIM_SAP_APDU_REQ req;
memset(&req, 0, sizeof(RIL_SIM_SAP_APDU_REQ));
req.type = (RIL_SIM_SAP_APDU_REQ_Type)type;
if (command.size() > 0) {
req.command = (pb_bytes_array_t *)malloc(sizeof(pb_bytes_array_t) - 1 + command.size());
if (req.command == NULL) {
RLOGE("SapImpl::apduReq: Error allocating memory for req.command");
sendFailedResponse(MsgId_RIL_SIM_SAP_APDU, token, 1, msg);
return Void();
}
req.command->size = command.size();
memcpy(req.command->bytes, command.data(), command.size());
}
size_t encodedSize = 0;
if (!pb_get_encoded_size(&encodedSize, RIL_SIM_SAP_APDU_REQ_fields, &req)) {
RLOGE("SapImpl::apduReq: Error getting encoded size for RIL_SIM_SAP_APDU_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_APDU, token, 2, req.command, msg);
return Void();
}
uint8_t *buffer = (uint8_t *)calloc(1, encodedSize);
if (buffer == NULL) {
RLOGE("SapImpl::apduReq: Error allocating memory for buffer");
sendFailedResponse(MsgId_RIL_SIM_SAP_APDU, token, 2, req.command, msg);
return Void();
}
pb_ostream_t stream = pb_ostream_from_buffer(buffer, encodedSize);
RLOGD("SapImpl::apduReq calling pb_encode");
if (!pb_encode(&stream, RIL_SIM_SAP_APDU_REQ_fields, &req)) {
RLOGE("SapImpl::apduReq: Error encoding RIL_SIM_SAP_APDU_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_APDU, token, 3, req.command, buffer, msg);
return Void();
}
/***** Encode RIL_SIM_SAP_APDU_REQ done *****/
/* encoded req is payload */
return addPayloadAndDispatchRequest(msg, stream.bytes_written, buffer);
}
Return<void> SapImpl::transferAtrReq(int32_t token) {
RLOGD("SapImpl::transferAtrReq");
MsgHeader *msg = createMsgHeader(MsgId_RIL_SIM_SAP_TRANSFER_ATR, token);
if (msg == NULL) {
RLOGE("SapImpl::transferAtrReq: Error allocating memory for msg");
sendFailedResponse(MsgId_RIL_SIM_SAP_TRANSFER_ATR, token, 0);
return Void();
}
/***** Encode RIL_SIM_SAP_TRANSFER_ATR_REQ *****/
RIL_SIM_SAP_TRANSFER_ATR_REQ req;
memset(&req, 0, sizeof(RIL_SIM_SAP_TRANSFER_ATR_REQ));
size_t encodedSize = 0;
if (!pb_get_encoded_size(&encodedSize, RIL_SIM_SAP_TRANSFER_ATR_REQ_fields, &req)) {
RLOGE("SapImpl::transferAtrReq: Error getting encoded size for "
"RIL_SIM_SAP_TRANSFER_ATR_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_TRANSFER_ATR, token, 1, msg);
return Void();
}
uint8_t *buffer = (uint8_t *)calloc(1, encodedSize);
if (buffer == NULL) {
RLOGE("SapImpl::transferAtrReq: Error allocating memory for buffer");
sendFailedResponse(MsgId_RIL_SIM_SAP_TRANSFER_ATR, token, 1, msg);
return Void();
}
pb_ostream_t stream = pb_ostream_from_buffer(buffer, encodedSize);
RLOGD("SapImpl::transferAtrReq calling pb_encode");
if (!pb_encode(&stream, RIL_SIM_SAP_TRANSFER_ATR_REQ_fields, &req)) {
RLOGE("SapImpl::transferAtrReq: Error encoding RIL_SIM_SAP_TRANSFER_ATR_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_TRANSFER_ATR, token, 2, buffer, msg);
return Void();
}
/***** Encode RIL_SIM_SAP_TRANSFER_ATR_REQ done *****/
/* encoded req is payload */
return addPayloadAndDispatchRequest(msg, stream.bytes_written, buffer);
}
Return<void> SapImpl::powerReq(int32_t token, bool state) {
RLOGD("SapImpl::powerReq");
MsgHeader *msg = createMsgHeader(MsgId_RIL_SIM_SAP_POWER, token);
if (msg == NULL) {
RLOGE("SapImpl::powerReq: Error allocating memory for msg");
sendFailedResponse(MsgId_RIL_SIM_SAP_POWER, token, 0);
return Void();
}
/***** Encode RIL_SIM_SAP_POWER_REQ *****/
RIL_SIM_SAP_POWER_REQ req;
memset(&req, 0, sizeof(RIL_SIM_SAP_POWER_REQ));
req.state = state;
size_t encodedSize = 0;
if (!pb_get_encoded_size(&encodedSize, RIL_SIM_SAP_POWER_REQ_fields, &req)) {
RLOGE("SapImpl::powerReq: Error getting encoded size for RIL_SIM_SAP_POWER_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_POWER, token, 1, msg);
return Void();
}
uint8_t *buffer = (uint8_t *)calloc(1, encodedSize);
if (buffer == NULL) {
RLOGE("SapImpl::powerReq: Error allocating memory for buffer");
sendFailedResponse(MsgId_RIL_SIM_SAP_POWER, token, 1, msg);
return Void();
}
pb_ostream_t stream = pb_ostream_from_buffer(buffer, encodedSize);
RLOGD("SapImpl::powerReq calling pb_encode");
if (!pb_encode(&stream, RIL_SIM_SAP_POWER_REQ_fields, &req)) {
RLOGE("SapImpl::powerReq: Error encoding RIL_SIM_SAP_POWER_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_POWER, token, 2, buffer, msg);
return Void();
}
/***** Encode RIL_SIM_SAP_POWER_REQ done *****/
/* encoded req is payload */
return addPayloadAndDispatchRequest(msg, stream.bytes_written, buffer);
}
Return<void> SapImpl::resetSimReq(int32_t token) {
RLOGD("SapImpl::resetSimReq");
MsgHeader *msg = createMsgHeader(MsgId_RIL_SIM_SAP_RESET_SIM, token);
if (msg == NULL) {
RLOGE("SapImpl::resetSimReq: Error allocating memory for msg");
sendFailedResponse(MsgId_RIL_SIM_SAP_RESET_SIM, token, 0);
return Void();
}
/***** Encode RIL_SIM_SAP_RESET_SIM_REQ *****/
RIL_SIM_SAP_RESET_SIM_REQ req;
memset(&req, 0, sizeof(RIL_SIM_SAP_RESET_SIM_REQ));
size_t encodedSize = 0;
if (!pb_get_encoded_size(&encodedSize, RIL_SIM_SAP_RESET_SIM_REQ_fields, &req)) {
RLOGE("SapImpl::resetSimReq: Error getting encoded size for RIL_SIM_SAP_RESET_SIM_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_RESET_SIM, token, 1, msg);
return Void();
}
uint8_t *buffer = (uint8_t *)calloc(1, encodedSize);
if (buffer == NULL) {
RLOGE("SapImpl::resetSimReq: Error allocating memory for buffer");
sendFailedResponse(MsgId_RIL_SIM_SAP_RESET_SIM, token, 1, msg);
return Void();
}
pb_ostream_t stream = pb_ostream_from_buffer(buffer, encodedSize);
RLOGD("SapImpl::resetSimReq calling pb_encode");
if (!pb_encode(&stream, RIL_SIM_SAP_RESET_SIM_REQ_fields, &req)) {
RLOGE("SapImpl::resetSimReq: Error encoding RIL_SIM_SAP_RESET_SIM_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_RESET_SIM, token, 2, buffer, msg);
return Void();
}
/***** Encode RIL_SIM_SAP_RESET_SIM_REQ done *****/
/* encoded req is payload */
return addPayloadAndDispatchRequest(msg, stream.bytes_written, buffer);
}
Return<void> SapImpl::transferCardReaderStatusReq(int32_t token) {
RLOGD("SapImpl::transferCardReaderStatusReq");
MsgHeader *msg = createMsgHeader(MsgId_RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS, token);
if (msg == NULL) {
RLOGE("SapImpl::transferCardReaderStatusReq: Error allocating memory for msg");
sendFailedResponse(MsgId_RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS, token, 0);
return Void();
}
/***** Encode RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_REQ *****/
RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_REQ req;
memset(&req, 0, sizeof(RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_REQ));
size_t encodedSize = 0;
if (!pb_get_encoded_size(&encodedSize, RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_REQ_fields,
&req)) {
RLOGE("SapImpl::transferCardReaderStatusReq: Error getting encoded size for "
"RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS, token, 1, msg);
return Void();
}
uint8_t *buffer = (uint8_t *)calloc(1, encodedSize);
if (buffer == NULL) {
RLOGE("SapImpl::transferCardReaderStatusReq: Error allocating memory for buffer");
sendFailedResponse(MsgId_RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS, token, 1, msg);
return Void();
}
pb_ostream_t stream = pb_ostream_from_buffer(buffer, encodedSize);
RLOGD("SapImpl::transferCardReaderStatusReq calling pb_encode");
if (!pb_encode(&stream, RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_REQ_fields, &req)) {
RLOGE("SapImpl::transferCardReaderStatusReq: Error encoding "
"RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS, token, 2, buffer, msg);
return Void();
}
/***** Encode RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_REQ done *****/
/* encoded req is payload */
return addPayloadAndDispatchRequest(msg, stream.bytes_written, buffer);
}
Return<void> SapImpl::setTransferProtocolReq(int32_t token, SapTransferProtocol transferProtocol) {
RLOGD("SapImpl::setTransferProtocolReq");
MsgHeader *msg = createMsgHeader(MsgId_RIL_SIM_SAP_SET_TRANSFER_PROTOCOL, token);
if (msg == NULL) {
RLOGE("SapImpl::setTransferProtocolReq: Error allocating memory for msg");
sendFailedResponse(MsgId_RIL_SIM_SAP_SET_TRANSFER_PROTOCOL, token, 0);
return Void();
}
/***** Encode RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_REQ *****/
RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_REQ req;
memset(&req, 0, sizeof(RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_REQ));
req.protocol = (RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_REQ_Protocol)transferProtocol;
size_t encodedSize = 0;
if (!pb_get_encoded_size(&encodedSize, RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_REQ_fields, &req)) {
RLOGE("SapImpl::setTransferProtocolReq: Error getting encoded size for "
"RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_SET_TRANSFER_PROTOCOL, token, 1, msg);
return Void();
}
uint8_t *buffer = (uint8_t *)calloc(1, encodedSize);
if (buffer == NULL) {
RLOGE("SapImpl::setTransferProtocolReq: Error allocating memory for buffer");
sendFailedResponse(MsgId_RIL_SIM_SAP_SET_TRANSFER_PROTOCOL, token, 1, msg);
return Void();
}
pb_ostream_t stream = pb_ostream_from_buffer(buffer, encodedSize);
RLOGD("SapImpl::setTransferProtocolReq calling pb_encode");
if (!pb_encode(&stream, RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_REQ_fields, &req)) {
RLOGE("SapImpl::setTransferProtocolReq: Error encoding "
"RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_REQ");
sendFailedResponse(MsgId_RIL_SIM_SAP_SET_TRANSFER_PROTOCOL, token, 2, buffer, msg);
return Void();
}
/***** Encode RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_REQ done *****/
/* encoded req is payload */
return addPayloadAndDispatchRequest(msg, stream.bytes_written, buffer);
}
void *sapDecodeMessage(MsgId msgId, MsgType msgType, uint8_t *payloadPtr, size_t payloadLen) {
void *responsePtr = NULL;
bool decodeStatus = false;
pb_istream_t stream;
/* Create the stream */
stream = pb_istream_from_buffer((uint8_t *)payloadPtr, payloadLen);
/* Decode based on the message id */
switch (msgId)
{
case MsgId_RIL_SIM_SAP_CONNECT:
responsePtr = malloc(sizeof(RIL_SIM_SAP_CONNECT_RSP));
if (responsePtr) {
if (!pb_decode(&stream, RIL_SIM_SAP_CONNECT_RSP_fields, responsePtr)) {
RLOGE("Error decoding RIL_SIM_SAP_CONNECT_RSP");
return NULL;
}
}
break;
case MsgId_RIL_SIM_SAP_DISCONNECT:
if (msgType == MsgType_RESPONSE) {
responsePtr = malloc(sizeof(RIL_SIM_SAP_DISCONNECT_RSP));
if (responsePtr) {
if (!pb_decode(&stream, RIL_SIM_SAP_DISCONNECT_RSP_fields, responsePtr)) {
RLOGE("Error decoding RIL_SIM_SAP_DISCONNECT_RSP");
return NULL;
}
}
} else {
responsePtr = malloc(sizeof(RIL_SIM_SAP_DISCONNECT_IND));
if (responsePtr) {
if (!pb_decode(&stream, RIL_SIM_SAP_DISCONNECT_IND_fields, responsePtr)) {
RLOGE("Error decoding RIL_SIM_SAP_DISCONNECT_IND");
return NULL;
}
}
}
break;
case MsgId_RIL_SIM_SAP_APDU:
responsePtr = malloc(sizeof(RIL_SIM_SAP_APDU_RSP));
if (responsePtr) {
if (!pb_decode(&stream, RIL_SIM_SAP_APDU_RSP_fields, responsePtr)) {
RLOGE("Error decoding RIL_SIM_SAP_APDU_RSP");
return NULL;
}
}
break;
case MsgId_RIL_SIM_SAP_TRANSFER_ATR:
responsePtr = malloc(sizeof(RIL_SIM_SAP_TRANSFER_ATR_RSP));
if (responsePtr) {
if (!pb_decode(&stream, RIL_SIM_SAP_TRANSFER_ATR_RSP_fields, responsePtr)) {
RLOGE("Error decoding RIL_SIM_SAP_TRANSFER_ATR_RSP");
return NULL;
}
}
break;
case MsgId_RIL_SIM_SAP_POWER:
responsePtr = malloc(sizeof(RIL_SIM_SAP_POWER_RSP));
if (responsePtr) {
if (!pb_decode(&stream, RIL_SIM_SAP_POWER_RSP_fields, responsePtr)) {
RLOGE("Error decoding RIL_SIM_SAP_POWER_RSP");
return NULL;
}
}
break;
case MsgId_RIL_SIM_SAP_RESET_SIM:
responsePtr = malloc(sizeof(RIL_SIM_SAP_RESET_SIM_RSP));
if (responsePtr) {
if (!pb_decode(&stream, RIL_SIM_SAP_RESET_SIM_RSP_fields, responsePtr)) {
RLOGE("Error decoding RIL_SIM_SAP_RESET_SIM_RSP");
return NULL;
}
}
break;
case MsgId_RIL_SIM_SAP_STATUS:
responsePtr = malloc(sizeof(RIL_SIM_SAP_STATUS_IND));
if (responsePtr) {
if (!pb_decode(&stream, RIL_SIM_SAP_STATUS_IND_fields, responsePtr)) {
RLOGE("Error decoding RIL_SIM_SAP_STATUS_IND");
return NULL;
}
}
break;
case MsgId_RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS:
responsePtr = malloc(sizeof(RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_RSP));
if (responsePtr) {
if (!pb_decode(&stream, RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_RSP_fields,
responsePtr)) {
RLOGE("Error decoding RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_RSP");
return NULL;
}
}
break;
case MsgId_RIL_SIM_SAP_ERROR_RESP:
responsePtr = malloc(sizeof(RIL_SIM_SAP_ERROR_RSP));
if (responsePtr) {
if (!pb_decode(&stream, RIL_SIM_SAP_ERROR_RSP_fields, responsePtr)) {
RLOGE("Error decoding RIL_SIM_SAP_ERROR_RSP");
return NULL;
}
}
break;
case MsgId_RIL_SIM_SAP_SET_TRANSFER_PROTOCOL:
responsePtr = malloc(sizeof(RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_RSP));
if (responsePtr) {
if (!pb_decode(&stream, RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_RSP_fields,
responsePtr)) {
RLOGE("Error decoding RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_RSP");
return NULL;
}
}
break;
default:
break;
}
return responsePtr;
} /* sapDecodeMessage */
sp<SapImpl> getSapImpl(RilSapSocket *sapSocket) {
switch (sapSocket->getSocketId()) {
case RIL_SOCKET_1:
RLOGD("getSapImpl: returning sapService[0]");
return sapService[0];
#if (SIM_COUNT >= 2)
case RIL_SOCKET_2:
return sapService[1];
#if (SIM_COUNT >= 3)
case RIL_SOCKET_3:
return sapService[2];
#if (SIM_COUNT >= 4)
case RIL_SOCKET_4:
return sapService[3];
#endif
#endif
#endif
default:
return NULL;
}
}
SapResultCode convertApduResponseProtoToHal(RIL_SIM_SAP_APDU_RSP_Response responseProto) {
switch(responseProto) {
case RIL_SIM_SAP_APDU_RSP_Response_RIL_E_SUCCESS:
return SapResultCode::SUCCESS;
case RIL_SIM_SAP_APDU_RSP_Response_RIL_E_GENERIC_FAILURE:
return SapResultCode::GENERIC_FAILURE;
case RIL_SIM_SAP_APDU_RSP_Response_RIL_E_SIM_NOT_READY:
return SapResultCode::CARD_NOT_ACCESSSIBLE;
case RIL_SIM_SAP_APDU_RSP_Response_RIL_E_SIM_ALREADY_POWERED_OFF:
return SapResultCode::CARD_ALREADY_POWERED_OFF;
case RIL_SIM_SAP_APDU_RSP_Response_RIL_E_SIM_ABSENT:
return SapResultCode::CARD_REMOVED;
default:
return SapResultCode::GENERIC_FAILURE;
}
}
SapResultCode convertTransferAtrResponseProtoToHal(
RIL_SIM_SAP_TRANSFER_ATR_RSP_Response responseProto) {
switch(responseProto) {
case RIL_SIM_SAP_TRANSFER_ATR_RSP_Response_RIL_E_SUCCESS:
return SapResultCode::SUCCESS;
case RIL_SIM_SAP_TRANSFER_ATR_RSP_Response_RIL_E_GENERIC_FAILURE:
return SapResultCode::GENERIC_FAILURE;
case RIL_SIM_SAP_TRANSFER_ATR_RSP_Response_RIL_E_SIM_ALREADY_POWERED_OFF:
return SapResultCode::CARD_ALREADY_POWERED_OFF;
case RIL_SIM_SAP_TRANSFER_ATR_RSP_Response_RIL_E_SIM_ABSENT:
return SapResultCode::CARD_REMOVED;
case RIL_SIM_SAP_TRANSFER_ATR_RSP_Response_RIL_E_SIM_DATA_NOT_AVAILABLE:
return SapResultCode::DATA_NOT_AVAILABLE;
default:
return SapResultCode::GENERIC_FAILURE;
}
}
SapResultCode convertPowerResponseProtoToHal(RIL_SIM_SAP_POWER_RSP_Response responseProto) {
switch(responseProto) {
case RIL_SIM_SAP_POWER_RSP_Response_RIL_E_SUCCESS:
return SapResultCode::SUCCESS;
case RIL_SIM_SAP_POWER_RSP_Response_RIL_E_GENERIC_FAILURE:
return SapResultCode::GENERIC_FAILURE;
case RIL_SIM_SAP_POWER_RSP_Response_RIL_E_SIM_ABSENT:
return SapResultCode::CARD_REMOVED;
case RIL_SIM_SAP_POWER_RSP_Response_RIL_E_SIM_ALREADY_POWERED_OFF:
return SapResultCode::CARD_ALREADY_POWERED_OFF;
case RIL_SIM_SAP_POWER_RSP_Response_RIL_E_SIM_ALREADY_POWERED_ON:
return SapResultCode::CARD_ALREADY_POWERED_ON;
default:
return SapResultCode::GENERIC_FAILURE;
}
}
SapResultCode convertResetSimResponseProtoToHal(RIL_SIM_SAP_RESET_SIM_RSP_Response responseProto) {
switch(responseProto) {
case RIL_SIM_SAP_RESET_SIM_RSP_Response_RIL_E_SUCCESS:
return SapResultCode::SUCCESS;
case RIL_SIM_SAP_RESET_SIM_RSP_Response_RIL_E_GENERIC_FAILURE:
return SapResultCode::GENERIC_FAILURE;
case RIL_SIM_SAP_RESET_SIM_RSP_Response_RIL_E_SIM_ABSENT:
return SapResultCode::CARD_REMOVED;
case RIL_SIM_SAP_RESET_SIM_RSP_Response_RIL_E_SIM_NOT_READY:
return SapResultCode::CARD_NOT_ACCESSSIBLE;
case RIL_SIM_SAP_RESET_SIM_RSP_Response_RIL_E_SIM_ALREADY_POWERED_OFF:
return SapResultCode::CARD_ALREADY_POWERED_OFF;
}
return SapResultCode::GENERIC_FAILURE;
}
SapResultCode convertTransferCardReaderStatusResponseProtoToHal(
RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_RSP_Response responseProto) {
switch(responseProto) {
case RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_RSP_Response_RIL_E_SUCCESS:
return SapResultCode::SUCCESS;
case RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_RSP_Response_RIL_E_GENERIC_FAILURE:
return SapResultCode::GENERIC_FAILURE;
case RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_RSP_Response_RIL_E_SIM_DATA_NOT_AVAILABLE:
return SapResultCode::DATA_NOT_AVAILABLE;
}
return SapResultCode::GENERIC_FAILURE;
}
void processResponse(MsgHeader *rsp, RilSapSocket *sapSocket, MsgType msgType) {
MsgId msgId = rsp->id;
uint8_t *data = rsp->payload->bytes;
size_t dataLen = rsp->payload->size;
void *messagePtr = sapDecodeMessage(msgId, msgType, data, dataLen);
sp<SapImpl> sapImpl = getSapImpl(sapSocket);
if (sapImpl->sapCallback == NULL) {
RLOGE("processResponse: sapCallback == NULL; msgId = %d; msgType = %d",
msgId, msgType);
return;
}
RLOGD("processResponse: sapCallback != NULL; msgId = %d; msgType = %d",
msgId, msgType);
Return<void> retStatus;
switch (msgId) {
case MsgId_RIL_SIM_SAP_CONNECT: {
RIL_SIM_SAP_CONNECT_RSP *connectRsp = (RIL_SIM_SAP_CONNECT_RSP *)messagePtr;
RLOGD("processResponse: calling sapCallback->connectResponse %d %d %d",
rsp->token,
connectRsp->response,
connectRsp->max_message_size);
retStatus = sapImpl->sapCallback->connectResponse(rsp->token,
(SapConnectRsp)connectRsp->response,
connectRsp->max_message_size);
break;
}
case MsgId_RIL_SIM_SAP_DISCONNECT:
if (msgType == MsgType_RESPONSE) {
RLOGD("processResponse: calling sapCallback->disconnectResponse %d", rsp->token);
retStatus = sapImpl->sapCallback->disconnectResponse(rsp->token);
} else {
RIL_SIM_SAP_DISCONNECT_IND *disconnectInd =
(RIL_SIM_SAP_DISCONNECT_IND *)messagePtr;
RLOGD("processResponse: calling sapCallback->disconnectIndication %d %d",
rsp->token, disconnectInd->disconnectType);
retStatus = sapImpl->sapCallback->disconnectIndication(rsp->token,
(SapDisconnectType)disconnectInd->disconnectType);
}
break;
case MsgId_RIL_SIM_SAP_APDU: {
RIL_SIM_SAP_APDU_RSP *apduRsp = (RIL_SIM_SAP_APDU_RSP *)messagePtr;
SapResultCode apduResponse = convertApduResponseProtoToHal(apduRsp->response);
RLOGD("processResponse: calling sapCallback->apduResponse %d %d",
rsp->token, apduResponse);
hidl_vec<uint8_t> apduRspVec;
if (apduRsp->apduResponse != NULL && apduRsp->apduResponse->size > 0) {
apduRspVec.setToExternal(apduRsp->apduResponse->bytes, apduRsp->apduResponse->size);
}
retStatus = sapImpl->sapCallback->apduResponse(rsp->token, apduResponse, apduRspVec);
break;
}
case MsgId_RIL_SIM_SAP_TRANSFER_ATR: {
RIL_SIM_SAP_TRANSFER_ATR_RSP *transferAtrRsp =
(RIL_SIM_SAP_TRANSFER_ATR_RSP *)messagePtr;
SapResultCode transferAtrResponse =
convertTransferAtrResponseProtoToHal(transferAtrRsp->response);
RLOGD("processResponse: calling sapCallback->transferAtrResponse %d %d",
rsp->token, transferAtrResponse);
hidl_vec<uint8_t> transferAtrRspVec;
if (transferAtrRsp->atr != NULL && transferAtrRsp->atr->size > 0) {
transferAtrRspVec.setToExternal(transferAtrRsp->atr->bytes,
transferAtrRsp->atr->size);
}
retStatus = sapImpl->sapCallback->transferAtrResponse(rsp->token, transferAtrResponse,
transferAtrRspVec);
break;
}
case MsgId_RIL_SIM_SAP_POWER: {
SapResultCode powerResponse = convertPowerResponseProtoToHal(
((RIL_SIM_SAP_POWER_RSP *)messagePtr)->response);
RLOGD("processResponse: calling sapCallback->powerResponse %d %d",
rsp->token, powerResponse);
retStatus = sapImpl->sapCallback->powerResponse(rsp->token, powerResponse);
break;
}
case MsgId_RIL_SIM_SAP_RESET_SIM: {
SapResultCode resetSimResponse = convertResetSimResponseProtoToHal(
((RIL_SIM_SAP_RESET_SIM_RSP *)messagePtr)->response);
RLOGD("processResponse: calling sapCallback->resetSimResponse %d %d",
rsp->token, resetSimResponse);
retStatus = sapImpl->sapCallback->resetSimResponse(rsp->token, resetSimResponse);
break;
}
case MsgId_RIL_SIM_SAP_STATUS: {
RIL_SIM_SAP_STATUS_IND *statusInd = (RIL_SIM_SAP_STATUS_IND *)messagePtr;
RLOGD("processResponse: calling sapCallback->statusIndication %d %d",
rsp->token, statusInd->statusChange);
retStatus = sapImpl->sapCallback->statusIndication(rsp->token,
(SapStatus)statusInd->statusChange);
break;
}
case MsgId_RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS: {
RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_RSP *transferStatusRsp =
(RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_RSP *)messagePtr;
SapResultCode transferCardReaderStatusResponse =
convertTransferCardReaderStatusResponseProtoToHal(
transferStatusRsp->response);
RLOGD("processResponse: calling sapCallback->transferCardReaderStatusResponse %d %d %d",
rsp->token,
transferCardReaderStatusResponse,
transferStatusRsp->CardReaderStatus);
retStatus = sapImpl->sapCallback->transferCardReaderStatusResponse(rsp->token,
transferCardReaderStatusResponse,
transferStatusRsp->CardReaderStatus);
break;
}
case MsgId_RIL_SIM_SAP_ERROR_RESP: {
RLOGD("processResponse: calling sapCallback->errorResponse %d", rsp->token);
retStatus = sapImpl->sapCallback->errorResponse(rsp->token);
break;
}
case MsgId_RIL_SIM_SAP_SET_TRANSFER_PROTOCOL: {
SapResultCode setTransferProtocolResponse;
if (((RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_RSP *)messagePtr)->response ==
RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_RSP_Response_RIL_E_SUCCESS) {
setTransferProtocolResponse = SapResultCode::SUCCESS;
} else {
setTransferProtocolResponse = SapResultCode::NOT_SUPPORTED;
}
RLOGD("processResponse: calling sapCallback->transferProtocolResponse %d %d",
rsp->token, setTransferProtocolResponse);
retStatus = sapImpl->sapCallback->transferProtocolResponse(rsp->token,
setTransferProtocolResponse);
break;
}
default:
return;
}
sapImpl->checkReturnStatus(retStatus);
}
void sap::processResponse(MsgHeader *rsp, RilSapSocket *sapSocket) {
processResponse(rsp, sapSocket, MsgType_RESPONSE);
}
void sap::processUnsolResponse(MsgHeader *rsp, RilSapSocket *sapSocket) {
processResponse(rsp, sapSocket, MsgType_UNSOL_RESPONSE);
}
void sap::registerService(RIL_RadioFunctions *callbacks) {
using namespace android::hardware;
int simCount = 1;
const char *serviceNames[] = {
android::RIL_getServiceName()
#if (SIM_COUNT >= 2)
, RIL2_SERVICE_NAME
#if (SIM_COUNT >= 3)
, RIL3_SERVICE_NAME
#if (SIM_COUNT >= 4)
, RIL4_SERVICE_NAME
#endif
#endif
#endif
};
RIL_SOCKET_ID socketIds[] = {
RIL_SOCKET_1
#if (SIM_COUNT >= 2)
, RIL_SOCKET_2
#if (SIM_COUNT >= 3)
, RIL_SOCKET_3
#if (SIM_COUNT >= 4)
, RIL_SOCKET_4
#endif
#endif
#endif
};
#if (SIM_COUNT >= 2)
simCount = SIM_COUNT;
#endif
for (int i = 0; i < simCount; i++) {
sapService[i] = new SapImpl;
sapService[i]->slotId = i;
sapService[i]->rilSocketId = socketIds[i];
RLOGD("registerService: starting ISap %s for slotId %d", serviceNames[i], i);
android::status_t status = sapService[i]->registerAsService(serviceNames[i]);
RLOGD("registerService: started ISap %s status %d", serviceNames[i], status);
}
}

@ -0,0 +1,33 @@
/*
* 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 SAP_SERVICE_H
#define SAP_SERVICE_H
#include <telephony/ril.h>
#include <ril_internal.h>
#include <RilSapSocket.h>
#include <hardware/ril/librilutils/proto/sap-api.pb.h>
namespace sap {
void registerService(RIL_RadioFunctions *callbacks);
void processResponse(MsgHeader *rsp, RilSapSocket *sapSocket);
void processUnsolResponse(MsgHeader *rsp, RilSapSocket *sapSocket);
} // namespace android
#endif // RIL_SERVICE_H
Loading…
Cancel
Save