add pin mode get api
Change-Id: I8ebf1e5e9ad5ad8274d4ff657863e0eb7fecff07
diff --git a/mbtk/mbtk_rild/src/mbtk_info_server.c b/mbtk/mbtk_rild/src/mbtk_info_server.c
index 57dc6ac..d582fb4 100755
--- a/mbtk/mbtk_rild/src/mbtk_info_server.c
+++ b/mbtk/mbtk_rild/src/mbtk_info_server.c
@@ -579,24 +579,24 @@
if (err < 0 || p_response->success == 0 || !p_response->p_intermediates)
{
+ switch (at_get_cme_error(p_response))
+ {
+ case CME_SUCCESS:
+ break;
+
+ case CME_SIM_NOT_INSERTED:
+ case 13: //sim fail,as "sim absent"
+ ret = MBTK_SIM_ABSENT;
+ goto done;
+
+ default:
+ ret = MBTK_SIM_NOT_READY;
+ goto done;
+ }
ret = MBTK_SIM_NOT_READY;
goto done;
}
-
- switch (at_get_cme_error(p_response))
- {
- case CME_SUCCESS:
- break;
-
- case CME_SIM_NOT_INSERTED:
- ret = MBTK_SIM_ABSENT;
- goto done;
-
- default:
- ret = MBTK_SIM_NOT_READY;
- goto done;
- }
-
+
/* CPIN? has succeeded, now look at the result */
cpinLine = p_response->p_intermediates->line;
@@ -1798,6 +1798,64 @@
}
/*
+AT+CLCK=SC,2
++CLCK: 1
+
+OK
+*/
+static int req_get_pin_state(mbtk_enable_pin_info *state, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char cmd[64]={0};
+
+ int err = at_send_command_singleline("AT+CLCK=SC,2", "+CLCK:", &response);
+ if (err < 0 || response == NULL || response->success == 0 || !response->p_intermediates)
+ {
+ if(response)
+ {
+ *cme_err = at_get_cme_error(response);
+ }
+ LOGE("[req_get_pin_state] AT+CLCK fail.");
+ goto exit;
+ }
+
+ char *line = response->p_intermediates->line;
+ if(line == NULL)
+ {
+ LOGE("[req_get_pin_state] line is NULL");
+ goto exit;
+ }
+ err = at_tok_start(&line);
+ if (err < 0)
+ {
+ LOGE("[req_get_pin_state] at_tok_start fail.[%d]", err);
+ goto exit;
+ }
+
+ int clck;
+ err = at_tok_nextint(&line, &clck);
+ if (err < 0)
+ {
+ LOGE("[req_get_pin_state] at_tok_nextint fail.[%d]", err);
+ goto exit;
+ }
+
+ if(clck == 1)
+ {
+ state = MBTK_PIN_ENABLE;
+ }
+ else
+ {
+ state = MBTK_PIN_DISABLE;
+ }
+exit:
+ at_response_free(response);
+ response = NULL;
+ return err;
+}
+
+
+/*
AT+CPIN=1234
OK
@@ -4471,8 +4529,20 @@
{
if(pack->data_len == 0 || pack->data == NULL) // Enable PIN
{
- err = MBTK_INFO_ERR_UNSUPPORTED;
- LOG("Unsupport GET PIN.");
+ mbtk_pin_state_enum pin_state = MBTK_PIN_DISABLE;
+ if(req_get_pin_state(&pin_state, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOGE("Get pin state fail.");
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, MBTK_INFO_ID_SIM_ENABLE_PIN_RSP, &pin_state, sizeof(mbtk_pin_state_enum));
+ }
}
else // Enable PIN
{