From 8c30fb5d129aa94b13e5fdb4305473a96ca4c1e0 Mon Sep 17 00:00:00 2001 From: "Kevin F. Haggerty" Date: Tue, 24 Oct 2017 22:05:11 -0600 Subject: [PATCH] msm8974-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 --- ril/include/telephony/ril.h | 5 +++++ ril/libril/ril_service.cpp | 16 +++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ril/include/telephony/ril.h b/ril/include/telephony/ril.h index 15a88b6..1ccb519 100644 --- a/ril/include/telephony/ril.h +++ b/ril/include/telephony/ril.h @@ -586,6 +586,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/ril/libril/ril_service.cpp b/ril/libril/ril_service.cpp index 5aa3dcd..d619870 100644 --- a/ril/libril/ril_service.cpp +++ b/ril/libril/ril_service.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2016 The Android Open Source Project + * Copyright (c) 2018 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -3971,15 +3972,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; }