summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSooraj Sasindran <sasindran@google.com>2017-06-08 23:42:55 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-06-08 23:42:55 +0000
commitaacc2e78d85f50af8256d16455a21dc2221ce0a2 (patch)
tree1040ee57c779b940ee16d32393c99bab12bd3120
parentf65b2c949ee3da2b502e610aff2b11dce34dad8c (diff)
parent758ee46f08d307e4b6750889cf49105a82525bec (diff)
downloadandroid_hardware_ril-aacc2e78d85f50af8256d16455a21dc2221ce0a2.tar.gz
android_hardware_ril-aacc2e78d85f50af8256d16455a21dc2221ce0a2.tar.bz2
android_hardware_ril-aacc2e78d85f50af8256d16455a21dc2221ce0a2.zip
Use Hex conversion for cid and lac
am: 758ee46f08 Change-Id: I1de11843062178ecf5b5978e7d4292c5d338bba5
-rw-r--r--libril/ril_service.cpp68
1 files changed, 54 insertions, 14 deletions
diff --git a/libril/ril_service.cpp b/libril/ril_service.cpp
index da66ea1..37c96dc 100644
--- a/libril/ril_service.cpp
+++ b/libril/ril_service.cpp
@@ -3489,6 +3489,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) {
@@ -3499,28 +3513,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;
}
@@ -3539,10 +3562,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;
}
@@ -3554,6 +3580,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) {
@@ -3563,24 +3594,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: {