diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2018-06-19 17:23:12 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-06-19 17:23:12 +0000 |
commit | dfaf0c7a27f6a31406e899985f5b3f0ac758237b (patch) | |
tree | d7df9e311f0b4983b0e715185392d715af4d1adf /ril | |
parent | 67cb71a2a3d84e8b7ac350b0e8f011c966508494 (diff) | |
parent | 5168292543096b59117f3a923a2c0e2a17485722 (diff) | |
download | android_device_generic_goldfish-dfaf0c7a27f6a31406e899985f5b3f0ac758237b.tar.gz android_device_generic_goldfish-dfaf0c7a27f6a31406e899985f5b3f0ac758237b.tar.bz2 android_device_generic_goldfish-dfaf0c7a27f6a31406e899985f5b3f0ac758237b.zip |
Merge "Emulator: add CSIM authentication support" into pi-dev
Diffstat (limited to 'ril')
-rw-r--r-- | ril/reference-ril.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/ril/reference-ril.c b/ril/reference-ril.c index 03c9897..4503e1b 100644 --- a/ril/reference-ril.c +++ b/ril/reference-ril.c @@ -410,6 +410,21 @@ static RIL_Errno setInterfaceState(const char* interfaceName, return RIL_E_SUCCESS; } +static void parseAuthResponse(char* line, RIL_SIM_IO_Response* response) { + // example string +CSIM=number, "<base64string>9000" + // get the status first + int len = strlen(line); + char* first_double_quote = strchr(line, '"'); + if (first_double_quote == NULL) { + RLOGE("%s bad response %s", __func__, line); + return; + } + char* data_ptr = first_double_quote + 1; + sscanf(line + (len -5), "%2x%2x", &(response->sw1), &(response->sw2)); + line[len-5] = '\0'; + response->simResponse = strdup(data_ptr); +} + /** do post-AT+CFUN=1 initialization */ static void onRadioPowerOn() { @@ -2353,6 +2368,52 @@ static void requestGetMute(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, &muteResponse, sizeof(muteResponse)); } +static void requestGetSimAuthentication(void *data, size_t datalen __unused, RIL_Token t) +{ + // TODO - hook this up with real query/info from radio. + RIL_SimAuthentication* auth = (RIL_SimAuthentication*)data; + + RIL_SIM_IO_Response auth_response = { + 0x90, + 0x00, + "" + }; + + // special case: empty authData, should return empty response + if (auth->authData == NULL || strlen(auth->authData) == 0) { + char reply[] = ""; + RIL_onRequestComplete(t, RIL_E_SUCCESS, &auth_response, sizeof(auth_response)); + RLOGD("%s empty data in", __func__); + return; + } + + //talk to modem + ATResponse *p_response = NULL; + memset(&auth_response, 0, sizeof(auth_response)); + int err; + char *cmd = NULL; + int auth_len = strlen(auth->authData); + int total_len = auth_len + 12; + asprintf(&cmd, "AT+CSIM=%d, \"008800%02x%02x%s00\"", total_len, auth->authContext, + auth_len, auth->authData); + + err = at_send_command_singleline(cmd, "+CSIM:", &p_response); + if (err < 0 || p_response == NULL || p_response->success == 0) { + ALOGE("%s Error %d transmitting CSIM: %d", __func__, + err, p_response ? p_response->success : 0); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + at_response_free(p_response); + return; + } + + char* line = p_response->p_intermediates->line; + + parseAuthResponse(line, &auth_response); + RIL_onRequestComplete(t, RIL_E_SUCCESS, &auth_response, sizeof(auth_response)); + free(auth_response.simResponse); + free(p_response); +} + /*** Callback methods from the RIL library to us ***/ /** @@ -2748,6 +2809,10 @@ onRequest (int request, void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); break; + case RIL_REQUEST_SIM_AUTHENTICATION: + requestGetSimAuthentication(data, datalen, t); + break; + case RIL_REQUEST_BASEBAND_VERSION: requestCdmaBaseBandVersion(request, data, datalen, t); break; |