ril: service: Fix RIL_UNSOL_NITZ_TIME_RECEIVED Parcel
authorPaul Keith <javelinanddart@gmail.com>
Sun, 22 Oct 2017 03:25:25 +0000 (05:25 +0200)
committerChristopher H. <raymanfx@gmail.com>
Sat, 23 Jun 2018 09:55:58 +0000 (11:55 +0200)
* Sometimes, the modem is sending 1-2 extra fields with
  the country mcc, which confuses ServiceStateTracker
* Drop the extra data here, instead of in our RIL class

[haggertk]: Forward port to ril-caf on lineage-15.

Change-Id: Ifbec67bb0dac271226bd8b5471deaf6a2ef33f2b

ril/libril/ril_service.cpp

index 016a215d41e3f6f12255f55c3a79df09e16830f8..37bd2a6fc30d48d623ffb8b75d420edb315abd40 100644 (file)
@@ -6692,8 +6692,25 @@ int radio::nitzTimeReceivedInd(int slotId,
             RLOGE("nitzTimeReceivedInd: invalid response");
             return 0;
         }
-        hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
+        hidl_string nitzTime;
         int64_t timeReceived = android::elapsedRealtime();
+        char *resp = strndup((char *) response, responseLen);
+        char *tmp = resp;
+
+        /* Find the 3rd comma */
+        for (int i = 0; i < 3; i++) {
+            if (tmp != NULL) {
+                tmp = strchr(tmp + 1, ',');
+            }
+        }
+
+        /* Make the 3rd comma the end of the string */
+        if (tmp != NULL) {
+            *tmp = '\0';
+        }
+
+        nitzTime = convertCharPtrToHidlString(resp);
+        free(resp);
 #if VDBG
         RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
                 timeReceived);