diff options
author | Sooraj Sasindran <sasindran@google.com> | 2017-06-07 16:30:18 -0700 |
---|---|---|
committer | Sooraj Sasindran <sasindran@google.com> | 2017-06-08 09:39:31 -0700 |
commit | 758ee46f08d307e4b6750889cf49105a82525bec (patch) | |
tree | 37977c65994984cecf461d366016ced0f0aa49e5 | |
parent | 75e42a55efe9bd706b5c2876e4f91fa251e5bcd5 (diff) | |
download | android_hardware_ril-758ee46f08d307e4b6750889cf49105a82525bec.tar.gz android_hardware_ril-758ee46f08d307e4b6750889cf49105a82525bec.tar.bz2 android_hardware_ril-758ee46f08d307e4b6750889cf49105a82525bec.zip |
Use Hex conversion for cid and lac
Use Hex conversion for cid and lac
Bug=37056478
Test: verified that cid and lacs given to applications
are same as what modem sent
Change-Id: I0ec8544f9c0425e97663cc24079be3d50b8a2aca
-rw-r--r-- | libril/ril_service.cpp | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/libril/ril_service.cpp b/libril/ril_service.cpp index 43c3b1d..143a06f 100644 --- a/libril/ril_service.cpp +++ b/libril/ril_service.cpp @@ -3390,6 +3390,20 @@ int convertResponseStringEntryToInt(char **response, int index, int numStrings) 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 +3414,37 @@ void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity, 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 +3463,13 @@ void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity, } 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 +3481,11 @@ void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity, 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 +3495,33 @@ void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity, 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: { |