From 201aca3682af60fbb4185926df4b18ab3d5d951c Mon Sep 17 00:00:00 2001 From: Sanket Padawe Date: Thu, 21 Jan 2016 15:49:33 -0800 Subject: [PATCH] Use SimRefreshResponse struct in RIL Versions greater than 7 Modify condition to use SimRefreshResponse struct in all RIL Versions greater than 7. BUG=21075857 Change-Id: Ifde00434bfcaecf3b4c32392fc4964fe3b43f6b5 --- ril/libril/RilSapSocket.cpp | 31 ++++++++++++++++--------------- ril/libril/ril.cpp | 2 +- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/ril/libril/RilSapSocket.cpp b/ril/libril/RilSapSocket.cpp index e422f344..19457f43 100644 --- a/ril/libril/RilSapSocket.cpp +++ b/ril/libril/RilSapSocket.cpp @@ -300,25 +300,26 @@ void RilSapSocket::onRequestComplete(RIL_Token t, RIL_Errno e, void *response, SapSocketRequest* request= (SapSocketRequest*)t; MsgHeader *hdr = request->curr; - if (response && response_len > 0) { - MsgHeader rsp; - rsp.token = request->curr->token; - rsp.type = MsgType_RESPONSE; - rsp.id = request->curr->id; - rsp.error = (Error)e; - rsp.payload = (pb_bytes_array_t *)calloc(1, - sizeof(pb_bytes_array_t) + response_len); - if (!rsp.payload) { - RLOGE("onRequestComplete: OOM"); - } else { + MsgHeader rsp; + rsp.token = request->curr->token; + rsp.type = MsgType_RESPONSE; + rsp.id = request->curr->id; + rsp.error = (Error)e; + rsp.payload = (pb_bytes_array_t *)calloc(1, sizeof(pb_bytes_array_t) + response_len); + if (!rsp.payload) { + RLOGE("onRequestComplete: OOM"); + } else { + if (response && response_len > 0) { memcpy(rsp.payload->bytes, response, response_len); rsp.payload->size = response_len; + } else { + rsp.payload->size = 0; + } - RLOGE("Token:%d, MessageId:%d", hdr->token, hdr->id); + RLOGE("Token:%d, MessageId:%d", hdr->token, hdr->id); - sendResponse(&rsp); - free(rsp.payload); - } + sendResponse(&rsp); + free(rsp.payload); } // Deallocate SapSocketRequest diff --git a/ril/libril/ril.cpp b/ril/libril/ril.cpp index 2bb7684c..fac94123 100755 --- a/ril/libril/ril.cpp +++ b/ril/libril/ril.cpp @@ -3267,7 +3267,7 @@ static int responseSimRefresh(Parcel &p, void *response, size_t responselen) { startResponse; if (s_callbacks.version <= LAST_IMPRECISE_RIL_VERSION) { - if (s_callbacks.version == 7) { + if (s_callbacks.version >= 7) { responseSimRefreshV7(p, response); } else { int *p_cur = ((int *) response);