Handle empty apn string in setInitialAttachApn HIDL API.
Do not convert empty str to null in ril_service.cpp hidl conversion
as apn cannot be passed as null. QC expects empty apn string.
Change-Id: If9810f2d7741491e4ed440d20c95230e09a4b5d3
Fix: 62066962
Test: manual
diff --git a/libril/ril_service.cpp b/libril/ril_service.cpp
index a5fa8b9..e2fb254 100644
--- a/libril/ril_service.cpp
+++ b/libril/ril_service.cpp
@@ -1902,8 +1902,19 @@
if (s_vendorFunctions->version <= 14) {
RIL_InitialAttachApn iaa = {};
- if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
- return Void();
+ if (dataProfileInfo.apn.size() == 0) {
+ iaa.apn = (char *) calloc(1, sizeof(char));
+ if (iaa.apn == NULL) {
+ RLOGE("Memory allocation failed for request %s",
+ requestToString(pRI->pCI->requestNumber));
+ sendErrorResponse(pRI, RIL_E_NO_MEMORY);
+ return Void();
+ }
+ iaa.apn[0] = '\0';
+ } else {
+ if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
+ return Void();
+ }
}
const hidl_string &protocol =
@@ -1929,9 +1940,21 @@
} else {
RIL_InitialAttachApn_v15 iaa = {};
- if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
- return Void();
+ if (dataProfileInfo.apn.size() == 0) {
+ iaa.apn = (char *) calloc(1, sizeof(char));
+ if (iaa.apn == NULL) {
+ RLOGE("Memory allocation failed for request %s",
+ requestToString(pRI->pCI->requestNumber));
+ sendErrorResponse(pRI, RIL_E_NO_MEMORY);
+ return Void();
+ }
+ iaa.apn[0] = '\0';
+ } else {
+ if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
+ return Void();
+ }
}
+
if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
memsetAndFreeStrings(1, iaa.apn);
return Void();