Merge "Snap for 5925869 from bf7fd5c8280bf69dbd1b14abad9373e4dd04391f to sdk-release" into sdk-release
diff --git a/libril/Android.mk b/libril/Android.mk
index ee0530f..87319bf 100644
--- a/libril/Android.mk
+++ b/libril/Android.mk
@@ -21,14 +21,13 @@
     android.hardware.radio@1.0 \
     android.hardware.radio@1.1 \
     android.hardware.radio.deprecated@1.0 \
-    libhidlbase  \
-    libhidltransport \
-    libhwbinder
+    libhidlbase \
 
 LOCAL_STATIC_LIBRARIES := \
-    libprotobuf-c-nano-enable_malloc \
+    libprotobuf-c-nano-enable_malloc-32bit \
 
 LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter -Werror
+LOCAL_CFLAGS += -DPB_FIELD_32BIT
 
 ifeq ($(SIM_COUNT), 2)
     LOCAL_CFLAGS += -DANDROID_MULTI_SIM -DDSDA_RILD1
diff --git a/libril/ril_service.cpp b/libril/ril_service.cpp
index 0938ffc..6220640 100755
--- a/libril/ril_service.cpp
+++ b/libril/ril_service.cpp
@@ -3564,6 +3564,11 @@
                     std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
             cellIdentity.cellIdentityGsm[0].mnc =
                     ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc);
+
+            if (cellIdentity.cellIdentityGsm[0].mcc == "-1") {
+                cellIdentity.cellIdentityGsm[0].mcc = "";
+            }
+
             cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
             cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
             cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
@@ -3577,6 +3582,11 @@
                     std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
             cellIdentity.cellIdentityWcdma[0].mnc =
                     ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc);
+
+            if (cellIdentity.cellIdentityWcdma[0].mcc == "-1") {
+                cellIdentity.cellIdentityWcdma[0].mcc = "";
+            }
+
             cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
             cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
             cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
@@ -3601,6 +3611,11 @@
                     std::to_string(rilCellIdentity.cellIdentityLte.mcc);
             cellIdentity.cellIdentityLte[0].mnc =
                     ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc);
+
+            if (cellIdentity.cellIdentityLte[0].mcc == "-1") {
+                cellIdentity.cellIdentityLte[0].mcc = "";
+            }
+
             cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
             cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
             cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
@@ -3614,6 +3629,11 @@
                     std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
             cellIdentity.cellIdentityTdscdma[0].mnc =
                     ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc);
+
+            if (cellIdentity.cellIdentityTdscdma[0].mcc == "-1") {
+                cellIdentity.cellIdentityTdscdma[0].mcc = "";
+            }
+
             cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
             cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
             cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
@@ -3747,6 +3767,14 @@
             /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
             rilCellIdentity.cellIdentityGsm.cid =
                     convertResponseHexStringEntryToInt(response, 2, numStrings);
+
+            if (numStrings >= 13) {
+                rilCellIdentity.cellIdentityGsm.mcc =
+                        convertResponseStringEntryToInt(response, 11, numStrings);
+
+                rilCellIdentity.cellIdentityGsm.mnc =
+                        convertResponseStringEntryToInt(response, 12, numStrings);
+            }
             break;
         }
         case RIL_CELL_INFO_TYPE_WCDMA: {
@@ -3757,6 +3785,14 @@
             /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
             rilCellIdentity.cellIdentityWcdma.cid =
                     convertResponseHexStringEntryToInt(response, 2, numStrings);
+
+            if (numStrings >= 13) {
+                rilCellIdentity.cellIdentityWcdma.mcc =
+                        convertResponseStringEntryToInt(response, 11, numStrings);
+
+                rilCellIdentity.cellIdentityWcdma.mnc =
+                        convertResponseStringEntryToInt(response, 12, numStrings);
+            }
             break;
         }
         case RIL_CELL_INFO_TYPE_TD_SCDMA:{
@@ -3767,6 +3803,14 @@
             /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
             rilCellIdentity.cellIdentityTdscdma.cid =
                     convertResponseHexStringEntryToInt(response, 2, numStrings);
+
+            if (numStrings >= 13) {
+                rilCellIdentity.cellIdentityTdscdma.mcc =
+                        convertResponseStringEntryToInt(response, 11, numStrings);
+
+                rilCellIdentity.cellIdentityTdscdma.mnc =
+                        convertResponseStringEntryToInt(response, 12, numStrings);
+            }
             break;
         }
         case RIL_CELL_INFO_TYPE_LTE: {
@@ -3776,6 +3820,14 @@
                     convertResponseStringEntryToInt(response, 7, numStrings);
             rilCellIdentity.cellIdentityLte.ci =
                     convertResponseStringEntryToInt(response, 8, numStrings);
+
+            if (numStrings >= 13) {
+                rilCellIdentity.cellIdentityLte.mcc =
+                        convertResponseStringEntryToInt(response, 11, numStrings);
+
+                rilCellIdentity.cellIdentityLte.mnc =
+                        convertResponseStringEntryToInt(response, 12, numStrings);
+            }
             break;
         }
         default: {
@@ -3866,7 +3918,7 @@
             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
         } else if (s_vendorFunctions->version <= 14) {
             int numStrings = responseLen / sizeof(char *);
-            if ((numStrings != 6) && (numStrings != 11)) {
+            if ((numStrings != 6) && (numStrings != 11) && (numStrings != 13)) {
                 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
                 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
             } else {
diff --git a/libril/ril_unsol_commands.h b/libril/ril_unsol_commands.h
index bd2cf70..831f5fb 100644
--- a/libril/ril_unsol_commands.h
+++ b/libril/ril_unsol_commands.h
@@ -64,3 +64,4 @@
     {RIL_UNSOL_MODEM_RESTART, radio::modemResetInd, WAKE_PARTIAL},
     {RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION, radio::carrierInfoForImsiEncryption, WAKE_PARTIAL},
     {RIL_UNSOL_NETWORK_SCAN_RESULT, radio::networkScanResultInd, WAKE_PARTIAL},
+    {RIL_UNSOL_KEEPALIVE_STATUS, radio::keepaliveStatusInd, WAKE_PARTIAL},
diff --git a/librilutils/Android.bp b/librilutils/Android.bp
index 91ef34e..c5207f8 100644
--- a/librilutils/Android.bp
+++ b/librilutils/Android.bp
@@ -16,10 +16,11 @@
         "-Wall",
         "-Wextra",
         "-Werror",
+        "-DPB_FIELD_32BIT"
     ],
 
     proto: {
-        type: "nanopb-c-enable_malloc",
+        type: "nanopb-c-enable_malloc-32bit",
         export_proto_headers: true,
     },
 
diff --git a/librilutils/proto/sap-api.proto b/librilutils/proto/sap-api.proto
index 7a3d83b..5d125e4 100644
--- a/librilutils/proto/sap-api.proto
+++ b/librilutils/proto/sap-api.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
 option java_package = "org.android.btsap";
 option java_outer_classname = "SapApi";