aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsheesh Saraswat <asheesh.saraswat@stericsson.com>2011-05-31 15:54:33 +0200
committerSverre Vegge <sverre.vegge@stericsson.com>2011-08-03 10:43:39 +0200
commitd05df026508bb1709ca1b02215546d39cd5607c5 (patch)
tree0a18520e33cd6fab36908862d139b1f7b30717e2
parentc9aec37643b77176368537cd3f56ba9571b897cc (diff)
downloadu300-d05df026508bb1709ca1b02215546d39cd5607c5.tar.gz
OEM-RIL: Changes for Sim Access command
Added new command U300_RIL_OEM_MSG_SIM_ACCESS also changed the old U300_RIL_OEM_MSG_SIM_COMMAND to U300_RIL_OEM_MSG_UICC_LOGICAL_CHANNEL_ACCESS Signed-off-by: Sverre Vegge <sverre.vegge@stericsson.com>
-rw-r--r--u300-ril-oem-msg.h15
-rw-r--r--u300-ril-oem-parser.cpp42
-rw-r--r--u300-ril-oem-parser.h37
-rw-r--r--u300-ril-oem.cpp81
4 files changed, 148 insertions, 27 deletions
diff --git a/u300-ril-oem-msg.h b/u300-ril-oem-msg.h
index b8be726..53313b1 100644
--- a/u300-ril-oem-msg.h
+++ b/u300-ril-oem-msg.h
@@ -43,7 +43,8 @@ enum u300_ril_oem_msg_id {
U300_RIL_OEM_MSG_UPDATE_FREQUENCY_SUBSCRIPTION = 4,
U300_RIL_OEM_MSG_OPEN_LOGICAL_CHANNEL = 5,
U300_RIL_OEM_MSG_CLOSE_LOGICAL_CHANNEL = 6,
- U300_RIL_OEM_MSG_SIM_COMMAND = 7,
+ U300_RIL_OEM_MSG_UICC_LOGICAL_CHANNEL_ACCESS = 7,
+ U300_RIL_OEM_MSG_SIM_ACCESS = 8,
U300_RIL_OEM_MSG_LAST, /* Should be last */
};
@@ -84,12 +85,20 @@ struct u300_ril_oem_close_logical_channel_request {
uint32_t channel_session_id;
};
-struct u300_ril_oem_sim_command_request {
+struct u300_ril_oem_uicc_logical_channel_access_request {
uint32_t channel_session_id_val_i32;
android::String8 command_val_string;
};
-struct u300_ril_oem_sim_command_response {
+struct u300_ril_oem_uicc_logical_channel_access_response {
+ android::String8 response_val_string;
+};
+
+struct u300_ril_oem_sim_access_request {
+ android::String8 command_val_string;
+};
+
+struct u300_ril_oem_sim_access_response {
android::String8 response_val_string;
};
#endif
diff --git a/u300-ril-oem-parser.cpp b/u300-ril-oem-parser.cpp
index f59354d..ce3762a 100644
--- a/u300-ril-oem-parser.cpp
+++ b/u300-ril-oem-parser.cpp
@@ -134,8 +134,8 @@ OemRilParser::parseCloseLogicalChannelRequest( struct
}
android::status_t
-OemRilParser::parseSimCommandRequest( struct
- u300_ril_oem_sim_command_request *request)
+OemRilParser::parseUiccLogicalChannelAccessRequest( struct
+ u300_ril_oem_uicc_logical_channel_access_request *request)
{
status_t status;
if (!request)
@@ -150,6 +150,20 @@ OemRilParser::parseSimCommandRequest( struct
return readString(&request->command_val_string);
}
+
+android::status_t
+OemRilParser::parseSimAccessRequest( struct
+ u300_ril_oem_sim_access_request *request)
+{
+ status_t status;
+ if (!request)
+ return BAD_VALUE;
+
+ if (mParcel.dataPosition() != sizeof(struct u300_ril_oem_hdr))
+ return BAD_VALUE;
+
+ return readString(&request->command_val_string);
+}
/* TODO: Implement new parseXXX methods here */
#ifdef U300_RIL_OEM_MSG_SELFTEST
@@ -291,15 +305,33 @@ OemRilParser::writeCloseLogicalChannelResponse()
}
android::status_t
-OemRilParser::writeSimCommandResponse(const struct
- u300_ril_oem_sim_command_response *response)
+OemRilParser::writeUiccLogicalChannelAccessResponse(const struct
+ u300_ril_oem_uicc_logical_channel_access_response *response)
+{
+ status_t status;
+ status = mParcel.setDataSize(0);
+ if (status != NO_ERROR)
+ return status;
+
+ status = writeHeader(U300_RIL_OEM_MSG_UICC_LOGICAL_CHANNEL_ACCESS);
+ if (status != NO_ERROR)
+ return status;
+
+ if (response != NULL)
+ status = writeString(response->response_val_string);
+ return status;
+}
+
+android::status_t
+OemRilParser::writeSimAccessResponse(const struct
+ u300_ril_oem_sim_access_response *response)
{
status_t status;
status = mParcel.setDataSize(0);
if (status != NO_ERROR)
return status;
- status = writeHeader(U300_RIL_OEM_MSG_SIM_COMMAND);
+ status = writeHeader(U300_RIL_OEM_MSG_SIM_ACCESS);
if (status != NO_ERROR)
return status;
diff --git a/u300-ril-oem-parser.h b/u300-ril-oem-parser.h
index 4f106ed..64e9aad 100644
--- a/u300-ril-oem-parser.h
+++ b/u300-ril-oem-parser.h
@@ -138,7 +138,7 @@ public:
status_t parseCloseLogicalChannelRequest(/*out*/ struct
u300_ril_oem_close_logical_channel_request *request);
- /** Parse OEM SIM_COMMAND request
+ /** Parse OEM UICC_LOGICAL_CHANNEL_ACCESS request
*
* \param request: [out] structure to be filled by the request.
* \retval NO_ERROR indicates success.
@@ -146,10 +146,22 @@ public:
* \retval NOT_ENOUGH_DATA indicates buffer underrun.
* \retval NO_MEMORY indicates memory allocation error.
*/
- status_t parseSimCommandRequest(/*out*/ struct
- u300_ril_oem_sim_command_request *request);
- /* TODO: Define new parseXXX methods here */
+ status_t parseUiccLogicalChannelAccessRequest(/*out*/ struct
+ u300_ril_oem_uicc_logical_channel_access_request
+ *request);
+ /** Parse OEM SIM_ACCESS request
+ *
+ * \param request: [out] structure to be filled by the request.
+ * \retval NO_ERROR indicates success.
+ * \retval BAD_VALUE indicates invalid argument.
+ * \retval NOT_ENOUGH_DATA indicates buffer underrun.
+ * \retval NO_MEMORY indicates memory allocation error.
+ */
+ status_t parseSimAccessRequest(/*out*/ struct
+ u300_ril_oem_sim_access_request *request);
+
+ /* TODO: Define new parseXXX methods here */
/** Explicitly reset the parser.
@@ -224,14 +236,25 @@ public:
*/
status_t writeCloseLogicalChannelResponse();
- /** Build OEM SIM_COMMAND response.
+ /** Build OEM UICC_LOGICAL_CHANNEL_ACCESS response.
+ *
+ * \retval NO_ERROR indicates success.
+ * \retval BAD_VALUE indicates invalid argument.
+ * \retval NO_MEMORY indicates memory allocation error.
+ */
+ status_t writeUiccLogicalChannelAccessResponse(const struct
+ u300_ril_oem_uicc_logical_channel_access_response
+ *response);
+
+ /** Build OEM SIM_ACCESS response.
*
* \retval NO_ERROR indicates success.
* \retval BAD_VALUE indicates invalid argument.
* \retval NO_MEMORY indicates memory allocation error.
*/
- status_t writeSimCommandResponse(const struct
- u300_ril_oem_sim_command_response *response);
+ status_t writeSimAccessResponse(const struct
+ u300_ril_oem_sim_access_response *response);
+
/* TODO: Define new writeXXX methods here */
private:
diff --git a/u300-ril-oem.cpp b/u300-ril-oem.cpp
index 7893821..7761e57 100644
--- a/u300-ril-oem.cpp
+++ b/u300-ril-oem.cpp
@@ -62,7 +62,9 @@ static android::status_t handleOemRequestOpenLogicalChannel(
u300_ril::OemRilParser &parser, RIL_Errno *ril_errno);
static android::status_t handleOemRequestCloseLogicalChannel (
u300_ril::OemRilParser &parser, RIL_Errno *ril_errno);
-static android::status_t handleOemRequestSimCommand (
+static android::status_t handleOemRequestUiccLogicalChannelAccess (
+ u300_ril::OemRilParser &parser, RIL_Errno *ril_errno);
+static android::status_t handleOemRequestSimAccess(
u300_ril::OemRilParser &parser, RIL_Errno *ril_errno);
static void onFrequencyNotification(const char *str);
@@ -119,8 +121,12 @@ void requestOEMHookRaw(void *data, size_t datalen, RIL_Token t)
case U300_RIL_OEM_MSG_CLOSE_LOGICAL_CHANNEL:
status = handleOemRequestCloseLogicalChannel(parser, &ril_errno);
break;
- case U300_RIL_OEM_MSG_SIM_COMMAND:
- status = handleOemRequestSimCommand(parser, &ril_errno);
+ case U300_RIL_OEM_MSG_UICC_LOGICAL_CHANNEL_ACCESS:
+ status = handleOemRequestUiccLogicalChannelAccess(parser,
+ &ril_errno);
+ break;
+ case U300_RIL_OEM_MSG_SIM_ACCESS:
+ status = handleOemRequestSimAccess(parser, &ril_errno);
break;
default:
status = NAME_NOT_FOUND;
@@ -416,9 +422,9 @@ static android::status_t handleOemRequestCloseLogicalChannel(
}
/**
- * OEM SIM_COMMAND handler
+ * OEM UICC_LOGICAL_CHANNEL_ACCESS handler
*/
-static android::status_t handleOemRequestSimCommand(
+static android::status_t handleOemRequestUiccLogicalChannelAccess(
u300_ril::OemRilParser &parser, RIL_Errno *ril_errno)
{
int status = 0;
@@ -429,10 +435,10 @@ static android::status_t handleOemRequestSimCommand(
unsigned char sw1, sw2;
ATResponse *atresponse = NULL;
ATCmeError cmeError;
- u300_ril_oem_sim_command_request req;
- u300_ril_oem_sim_command_response *response = NULL;
+ u300_ril_oem_uicc_logical_channel_access_request req;
+ u300_ril_oem_uicc_logical_channel_access_response *response = NULL;
- status = parser.parseSimCommandRequest(&req);
+ status = parser.parseUiccLogicalChannelAccessRequest(&req);
if (status != NO_ERROR)
return status;
@@ -477,15 +483,66 @@ static android::status_t handleOemRequestSimCommand(
status = -1;
goto error;
}
-
- resp[resplen - 4] = 0;
- response->response_val_string = resp;
goto exit;
+error:
+ *ril_errno = RIL_E_GENERIC_FAILURE;
+exit:
+ at_response_free(atresponse);
+ free(cmd);
+ return parser.writeUiccLogicalChannelAccessResponse(response);
+}
+/**
+ * OEM SIM_ACCESS handler
+ */
+static android::status_t handleOemRequestSimAccess(
+ u300_ril::OemRilParser &parser, RIL_Errno *ril_errno)
+{
+ int status = 0;
+ int resplen = 0;
+ char *resp = NULL;
+ char *cmd = NULL;
+ char *line = NULL;
+ unsigned char sw1, sw2;
+ ATResponse *atresponse = NULL;
+ ATCmeError cmeError;
+ u300_ril_oem_sim_access_request req;
+ u300_ril_oem_sim_access_response *response = NULL;
+
+ status = parser.parseSimAccessRequest(&req);
+ if (status != NO_ERROR)
+ return status;
+ asprintf(&cmd, "AT+CSIM=%d, \"%s\"",
+ req.command_val_string.length(),
+ req.command_val_string.string());
+ status = at_send_command_singleline(cmd, "+CSIM:", &atresponse);
+
+ if (status < 0 || atresponse->success == 0)
+ goto error;
+
+ line = atresponse->p_intermediates->line;
+
+ status = at_tok_start(&line);
+ if (status < 0)
+ goto error;
+
+ status = at_tok_nextint(&line, &resplen);
+ if (status < 0)
+ goto error;
+
+ status = at_tok_nextstr(&line, &resp);
+ if (status < 0)
+ goto error;
+
+ if ((resplen < 4) || ((size_t)resplen != strlen(resp))) {
+ status = -1;
+ goto error;
+ }
+ goto exit;
error:
*ril_errno = RIL_E_GENERIC_FAILURE;
exit:
at_response_free(atresponse);
free(cmd);
- return parser.writeSimCommandResponse(response);
+ return parser.writeSimAccessResponse(response);
} \ No newline at end of file