release-request-276f9f52-87fd-4915-bd79-9a2f0ee77433-for-git_oc-release-4090213 snap-temp-L31600000073091223
Change-Id: Ia9d4a10c599a00b57d58805c433956a0e23922a0
diff --git a/libril/ril_service.cpp b/libril/ril_service.cpp
index 43c3b1d..a5fa8b9 100644
--- a/libril/ril_service.cpp
+++ b/libril/ril_service.cpp
@@ -2974,7 +2974,8 @@
populateResponseInfo(responseInfo, serial, responseType, e);
hidl_vec<Call> calls;
- if (response == NULL || (responseLen % sizeof(RIL_Call *)) != 0) {
+ if ((response == NULL && responseLen != 0)
+ || (responseLen % sizeof(RIL_Call *)) != 0) {
RLOGE("getCurrentCallsResponse: Invalid response");
if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
} else {
@@ -3390,6 +3391,20 @@
return -1;
}
+int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
+ const int hexBase = 16;
+ if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
+ return strtol(response[index], NULL, hexBase);
+ }
+
+ return -1;
+}
+
+/* Fill Cell Identity info from Voice Registration State Response.
+ * This fucntion is applicable only for RIL Version < 15.
+ * Response is a "char **".
+ * First and Second entries are in hex string format
+ * and rest are integers represented in ascii format. */
void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
int numStrings, char** response) {
@@ -3400,28 +3415,37 @@
switch(rilCellIdentity.cellInfoType) {
case RIL_CELL_INFO_TYPE_GSM: {
+ /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
rilCellIdentity.cellIdentityGsm.lac =
- convertResponseStringEntryToInt(response, 1, numStrings);
+ convertResponseHexStringEntryToInt(response, 1, numStrings);
+
+ /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
rilCellIdentity.cellIdentityGsm.cid =
- convertResponseStringEntryToInt(response, 2, numStrings);
+ convertResponseHexStringEntryToInt(response, 2, numStrings);
break;
}
case RIL_CELL_INFO_TYPE_WCDMA: {
+ /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
rilCellIdentity.cellIdentityWcdma.lac =
- convertResponseStringEntryToInt(response, 1, numStrings);
+ convertResponseHexStringEntryToInt(response, 1, numStrings);
+
+ /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
rilCellIdentity.cellIdentityWcdma.cid =
- convertResponseStringEntryToInt(response, 2, numStrings);
+ convertResponseHexStringEntryToInt(response, 2, numStrings);
rilCellIdentity.cellIdentityWcdma.psc =
convertResponseStringEntryToInt(response, 14, numStrings);
break;
}
case RIL_CELL_INFO_TYPE_TD_SCDMA:{
+ /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
rilCellIdentity.cellIdentityTdscdma.lac =
- convertResponseStringEntryToInt(response, 1, numStrings);
+ convertResponseHexStringEntryToInt(response, 1, numStrings);
+
+ /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
rilCellIdentity.cellIdentityTdscdma.cid =
- convertResponseStringEntryToInt(response, 2, numStrings);
+ convertResponseHexStringEntryToInt(response, 2, numStrings);
break;
}
@@ -3440,10 +3464,13 @@
}
case RIL_CELL_INFO_TYPE_LTE:{
+ /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
rilCellIdentity.cellIdentityLte.tac =
- convertResponseStringEntryToInt(response, 1, numStrings);
+ convertResponseHexStringEntryToInt(response, 1, numStrings);
+
+ /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
rilCellIdentity.cellIdentityLte.ci =
- convertResponseStringEntryToInt(response, 2, numStrings);
+ convertResponseHexStringEntryToInt(response, 2, numStrings);
break;
}
@@ -3455,6 +3482,11 @@
fillCellIdentityResponse(cellIdentity, rilCellIdentity);
}
+/* Fill Cell Identity info from Data Registration State Response.
+ * This fucntion is applicable only for RIL Version < 15.
+ * Response is a "char **".
+ * First and Second entries are in hex string format
+ * and rest are integers represented in ascii format. */
void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
int numStrings, char** response) {
@@ -3464,24 +3496,33 @@
rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
switch(rilCellIdentity.cellInfoType) {
case RIL_CELL_INFO_TYPE_GSM: {
+ /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
rilCellIdentity.cellIdentityGsm.lac =
- convertResponseStringEntryToInt(response, 1, numStrings);
+ convertResponseHexStringEntryToInt(response, 1, numStrings);
+
+ /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
rilCellIdentity.cellIdentityGsm.cid =
- convertResponseStringEntryToInt(response, 2, numStrings);
+ convertResponseHexStringEntryToInt(response, 2, numStrings);
break;
}
case RIL_CELL_INFO_TYPE_WCDMA: {
+ /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
rilCellIdentity.cellIdentityWcdma.lac =
- convertResponseStringEntryToInt(response, 1, numStrings);
+ convertResponseHexStringEntryToInt(response, 1, numStrings);
+
+ /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
rilCellIdentity.cellIdentityWcdma.cid =
- convertResponseStringEntryToInt(response, 2, numStrings);
+ convertResponseHexStringEntryToInt(response, 2, numStrings);
break;
}
case RIL_CELL_INFO_TYPE_TD_SCDMA:{
+ /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
rilCellIdentity.cellIdentityTdscdma.lac =
- convertResponseStringEntryToInt(response, 1, numStrings);
+ convertResponseHexStringEntryToInt(response, 1, numStrings);
+
+ /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
rilCellIdentity.cellIdentityTdscdma.cid =
- convertResponseStringEntryToInt(response, 2, numStrings);
+ convertResponseHexStringEntryToInt(response, 2, numStrings);
break;
}
case RIL_CELL_INFO_TYPE_LTE: {
@@ -3770,9 +3811,11 @@
populateResponseInfo(responseInfo, serial, responseType, e);
SetupDataCallResult result = {};
- if (response == NULL || responseLen != sizeof(RIL_Data_Call_Response_v11)) {
- RLOGE("setupDataCallResponse: Invalid response");
- if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
+ if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
+ if (response != NULL) {
+ RLOGE("setupDataCallResponse: Invalid response");
+ if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
+ }
result.status = DataCallFailCause::ERROR_UNSPECIFIED;
result.type = hidl_string();
result.ifname = hidl_string();
@@ -3938,7 +3981,8 @@
populateResponseInfo(responseInfo, serial, responseType, e);
hidl_vec<CallForwardInfo> callForwardInfos;
- if (response == NULL || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
+ if ((response == NULL && responseLen != 0)
+ || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
RLOGE("getCallForwardStatusResponse Invalid response: NULL");
if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
} else {
@@ -4266,7 +4310,8 @@
RadioResponseInfo responseInfo = {};
populateResponseInfo(responseInfo, serial, responseType, e);
hidl_vec<OperatorInfo> networks;
- if (response == NULL || responseLen % (4 * sizeof(char *))!= 0) {
+ if ((response == NULL && responseLen != 0)
+ || responseLen % (4 * sizeof(char *))!= 0) {
RLOGE("getAvailableNetworksResponse Invalid response: NULL");
if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
} else {
@@ -4460,7 +4505,8 @@
populateResponseInfo(responseInfo, serial, responseType, e);
hidl_vec<SetupDataCallResult> ret;
- if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
+ if ((response == NULL && responseLen != 0)
+ || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
RLOGE("getDataCallListResponse: invalid response");
if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
} else {
@@ -4570,7 +4616,7 @@
RadioResponseInfo responseInfo = {};
populateResponseInfo(responseInfo, serial, responseType, e);
hidl_vec<RadioBandMode> modes;
- if (response == NULL || responseLen % sizeof(int) != 0) {
+ if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
RLOGE("getAvailableBandModesResponse Invalid response: NULL");
if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
} else {
@@ -4737,7 +4783,8 @@
populateResponseInfo(responseInfo, serial, responseType, e);
hidl_vec<NeighboringCell> cells;
- if (response == NULL || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
+ if ((response == NULL && responseLen != 0)
+ || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
RLOGE("getNeighboringCidsResponse Invalid response: NULL");
if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
} else {
@@ -5040,7 +5087,8 @@
populateResponseInfo(responseInfo, serial, responseType, e);
hidl_vec<GsmBroadcastSmsConfigInfo> configs;
- if (response == NULL || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
+ if ((response == NULL && responseLen != 0)
+ || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
} else {
@@ -5124,7 +5172,8 @@
populateResponseInfo(responseInfo, serial, responseType, e);
hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
- if (response == NULL || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
+ if ((response == NULL && responseLen != 0)
+ || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
} else {
@@ -5545,7 +5594,8 @@
populateResponseInfo(responseInfo, serial, responseType, e);
hidl_vec<CellInfo> ret;
- if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
+ if ((response == NULL && responseLen != 0)
+ || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
RLOGE("getCellInfoListResponse: Invalid response");
if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
} else {
@@ -5699,7 +5749,9 @@
int numInts = responseLen / sizeof(int);
if (response == NULL || responseLen % sizeof(int) != 0) {
RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
- if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
+ if (response != NULL) {
+ if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
+ }
} else {
int *pInt = (int *) response;
channelId = pInt[0];
@@ -5900,7 +5952,8 @@
populateResponseInfo(responseInfo, serial, responseType, e);
hidl_vec<HardwareConfig> result;
- if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
+ if ((response == NULL && responseLen != 0)
+ || responseLen % sizeof(RIL_HardwareConfig) != 0) {
RLOGE("hardwareConfigChangedInd: invalid response");
if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
} else {
@@ -6350,7 +6403,7 @@
populateResponseInfo(responseInfo, serial, responseType, e);
hidl_vec<hidl_string> data;
- if (response == NULL || responseLen % sizeof(char *) != 0) {
+ if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
RLOGE("sendRequestStringsResponse Invalid response: NULL");
if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
} else {
@@ -6698,7 +6751,8 @@
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
- if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
+ if ((response == NULL && responseLen != 0)
+ || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
RLOGE("dataCallListChangedInd: invalid response");
return 0;
}
@@ -7581,7 +7635,7 @@
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
- if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
+ if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
RLOGE("cellInfoListInd: invalid response");
return 0;
}
@@ -7702,7 +7756,8 @@
int indicationType, int token, RIL_Errno e, void *response,
size_t responseLen) {
if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
- if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
+ if ((response == NULL && responseLen != 0)
+ || responseLen % sizeof(RIL_HardwareConfig) != 0) {
RLOGE("hardwareConfigChangedInd: invalid response");
return 0;
}