libril: fix network operator search

The number of mQANElements should be defined in the system
prop ro.ril.telephony.mqanelements

Change-Id: Ie5bb8ba80c5ac93b7502da3b1bb3d2b4404ecd5e
tirimbino
Martin Bouchet 7 years ago committed by Christopher N. Hesse
parent d912396454
commit f7c75aa4e0
  1. 21
      ril/libril/ril_service.cpp

@ -25,6 +25,7 @@
#include <hidl/HidlTransportSupport.h> #include <hidl/HidlTransportSupport.h>
#include <utils/SystemClock.h> #include <utils/SystemClock.h>
#include <inttypes.h> #include <inttypes.h>
#include <cutils/properties.h>
#define INVALID_HEX_CHAR 16 #define INVALID_HEX_CHAR 16
@ -3700,6 +3701,10 @@ int radio::getOperatorResponse(int slotId,
#if VDBG #if VDBG
RLOGD("getOperatorResponse: serial %d", serial); RLOGD("getOperatorResponse: serial %d", serial);
#endif #endif
int mqanelements;
char value[PROPERTY_VALUE_MAX];
property_get("ro.ril.telephony.mqanelements", value, "4");
mqanelements = atoi(value);
if (radioService[slotId]->mRadioResponse != NULL) { if (radioService[slotId]->mRadioResponse != NULL) {
RadioResponseInfo responseInfo = {}; RadioResponseInfo responseInfo = {};
@ -3708,14 +3713,14 @@ int radio::getOperatorResponse(int slotId,
hidl_string shortName; hidl_string shortName;
hidl_string numeric; hidl_string numeric;
int numStrings = responseLen / sizeof(char *); int numStrings = responseLen / sizeof(char *);
if (response == NULL || numStrings != 3) { if (response == NULL || numStrings != mqanelements - 2) {
RLOGE("getOperatorResponse Invalid response: NULL"); RLOGE("getOperatorResponse Invalid response: NULL");
if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
} else { } else {
char **resp = (char **) response; char **resp = (char **) response;
longName = convertCharPtrToHidlString(resp[0]); longName = convertCharPtrToHidlString(resp[0]);
shortName = convertCharPtrToHidlString(resp[1]); shortName = convertCharPtrToHidlString(resp[0]);
numeric = convertCharPtrToHidlString(resp[2]); numeric = convertCharPtrToHidlString(resp[2]);
} }
Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse( Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
@ -4344,22 +4349,26 @@ int radio::getAvailableNetworksResponse(int slotId,
#if VDBG #if VDBG
RLOGD("getAvailableNetworksResponse: serial %d", serial); RLOGD("getAvailableNetworksResponse: serial %d", serial);
#endif #endif
int mqanelements;
char value[PROPERTY_VALUE_MAX];
property_get("ro.ril.telephony.mqanelements", value, "4");
mqanelements = atoi(value);
if (radioService[slotId]->mRadioResponse != NULL) { if (radioService[slotId]->mRadioResponse != NULL) {
RadioResponseInfo responseInfo = {}; RadioResponseInfo responseInfo = {};
populateResponseInfo(responseInfo, serial, responseType, e); populateResponseInfo(responseInfo, serial, responseType, e);
hidl_vec<OperatorInfo> networks; hidl_vec<OperatorInfo> networks;
if ((response == NULL && responseLen != 0) if ((response == NULL && responseLen != 0)
|| responseLen % (4 * sizeof(char *))!= 0) { || responseLen % (mqanelements * sizeof(char *))!= 0) {
RLOGE("getAvailableNetworksResponse Invalid response: NULL"); RLOGE("getAvailableNetworksResponse Invalid response: NULL");
if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
} else { } else {
char **resp = (char **) response; char **resp = (char **) response;
int numStrings = responseLen / sizeof(char *); int numStrings = responseLen / sizeof(char *);
networks.resize(numStrings/4); networks.resize(numStrings/mqanelements);
for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) { for (int i = 0, j = 0; i < numStrings; i = i + mqanelements, j++) {
networks[j].alphaLong = convertCharPtrToHidlString(resp[i]); networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]); networks[j].alphaShort = convertCharPtrToHidlString(resp[i]);
networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]); networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
int status = convertOperatorStatusToInt(resp[i + 3]); int status = convertOperatorStatusToInt(resp[i + 3]);
if (status == -1) { if (status == -1) {

Loading…
Cancel
Save