From 345ceb6a2c0edda4ae690e60b2830fe01f598391 Mon Sep 17 00:00:00 2001 From: "Kevin F. Haggerty" Date: Tue, 24 Oct 2017 22:05:11 -0600 Subject: [PATCH] klte-common: libril: Fix SMS on certain variants * Samsung added an int to the end of the RIL_SMS_Response struct in some of the variants (like vzw) but not all * The presence of this field was discovered by examining the stock RIL.java, which conditionally read an extra int from the parcel, based on the device specific CscFeature_RIL_SmsErrorClassRetry feature * This causes SMS messages to show as "failed to send" in the app, when they actually suceeded in sending * Allow Samsung's custom struct and AOSP's to fix it * Forward port to ril-caf on lineage-15.1 Change-Id: I6b3e545c2c42ab2de2ac11e93dfdf9546248080a --- include/telephony/ril.h | 5 +++++ libril/ril_service.cpp | 15 ++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/telephony/ril.h b/include/telephony/ril.h index bb04a2b..357603c 100644 --- a/include/telephony/ril.h +++ b/include/telephony/ril.h @@ -590,6 +590,11 @@ typedef struct { -1 if unknown or not applicable*/ } RIL_SMS_Response; +typedef struct { + RIL_SMS_Response response; + int retryCount; /* Samsung */ +} RIL_SMS_Response_Ext; + /** Used by RIL_REQUEST_WRITE_SMS_TO_SIM */ typedef struct { int status; /* Status of message. See TS 27.005 3.1, "": */ diff --git a/libril/ril_service.cpp b/libril/ril_service.cpp index 6ada423..413da5f 100644 --- a/libril/ril_service.cpp +++ b/libril/ril_service.cpp @@ -3991,15 +3991,20 @@ SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int populateResponseInfo(responseInfo, serial, responseType, e); SendSmsResult result = {}; - if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) { - RLOGE("Invalid response: NULL"); - if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; - result.ackPDU = hidl_string(); - } else { + if (response != NULL && responseLen == sizeof(RIL_SMS_Response)) { RIL_SMS_Response *resp = (RIL_SMS_Response *) response; result.messageRef = resp->messageRef; result.ackPDU = convertCharPtrToHidlString(resp->ackPDU); result.errorCode = resp->errorCode; + } else if (response != NULL && responseLen == sizeof(RIL_SMS_Response_Ext)) { + RIL_SMS_Response *resp = &(((RIL_SMS_Response_Ext *) response)->response); + result.messageRef = resp->messageRef; + result.ackPDU = convertCharPtrToHidlString(resp->ackPDU); + result.errorCode = resp->errorCode; + } else { + RLOGE("Invalid response: NULL"); + if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; + result.ackPDU = hidl_string(); } return result; }