OSDN Git Service

Fix responseCarrierRestrictions string wrting to parcel
authorMeng Wang <mewan@google.com>
Thu, 9 Jun 2016 16:21:26 +0000 (09:21 -0700)
committerMeng Wang <mewan@google.com>
Thu, 9 Jun 2016 19:25:20 +0000 (12:25 -0700)
In Java land, string are read from parcel by readString16.
Hence writeString16 should be invoked in C land,
instead of writeCString

Bug: 28564314
Change-Id: I0ede376541b54d72867f07b96ae52c4a8ed3695f

libril/ril.cpp [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index 294fd4f..ef4204b
@@ -4069,32 +4069,41 @@ static int responseCarrierRestrictions(Parcel &p, void *response, size_t respons
     return RIL_ERRNO_INVALID_RESPONSE;
   }
   if (responselen != sizeof(RIL_CarrierRestrictions)) {
-    RLOGE("responseCarrierRestrictions: invalid response length %d expecting len: %d",
+    RLOGE("responseCarrierRestrictions: invalid response length %lu expecting len: %lu",
           responselen, sizeof(RIL_CarrierRestrictions));
     return RIL_ERRNO_INVALID_RESPONSE;
   }
 
   RIL_CarrierRestrictions *p_cr = (RIL_CarrierRestrictions *)response;
-  p.writeUint32(p_cr->len_allowed_carriers);
-  p.writeUint32(p_cr->len_excluded_carriers);
-  for(uint_t i = 0; i < p_cr->len_allowed_carriers; i++) {
+  startResponse;
+
+  p.writeInt32(p_cr->len_allowed_carriers);
+  p.writeInt32(p_cr->len_excluded_carriers);
+  appendPrintBuf(" %s len_allowed_carriers: %d, len_excluded_carriers: %d,", printBuf,
+                 p_cr->len_allowed_carriers,p_cr->len_excluded_carriers);
+
+  appendPrintBuf(" %s allowed_carriers:", printBuf);
+  for(int32_t i = 0; i < p_cr->len_allowed_carriers; i++) {
     RIL_Carrier *carrier = p_cr->allowed_carriers + i;
-    p.writeCString(carrier->mcc);
-    p.writeCString(carrier->mnc);
+    writeStringToParcel(p, carrier->mcc);
+    writeStringToParcel(p, carrier->mnc);
     p.writeInt32(carrier->match_type);
-    p.writeCString(carrier->match_data);
+    writeStringToParcel(p, carrier->match_data);
+    appendPrintBuf(" %s [%d mcc: %s, mnc: %s, match_type: %d, match_data: %s],", printBuf,
+                   i, carrier->mcc, carrier->mnc, carrier->match_type, carrier->match_data);
   }
-  for(uint_t i = 0; i < p_cr->len_excluded_carriers; i++) {
+
+  appendPrintBuf(" %s excluded_carriers:", printBuf);
+  for(int32_t i = 0; i < p_cr->len_excluded_carriers; i++) {
     RIL_Carrier *carrier = p_cr->excluded_carriers + i;
-    p.writeCString(carrier->mcc);
-    p.writeCString(carrier->mnc);
+    writeStringToParcel(p, carrier->mcc);
+    writeStringToParcel(p, carrier->mnc);
     p.writeInt32(carrier->match_type);
-    p.writeCString(carrier->match_data);
+    writeStringToParcel(p, carrier->match_data);
+    appendPrintBuf(" %s [%d mcc: %s, mnc: %s, match_type: %d, match_data: %s],", printBuf,
+                   i, carrier->mcc, carrier->mnc, carrier->match_type, carrier->match_data);
   }
 
-  startResponse;
-  appendPrintBuf("CarrierRestrictions received: len_allowed_carriers %d len_excluded_carriers %d",
-                  p_cr->len_allowed_carriers,p_cr->len_excluded_carriers);
   closeResponse;
 
   return 0;