Bug 824194 - Refactor TLV size handler in sendStkTerminalResponse. r=allstars.chh
authorEdgar Chen <echen@mozilla.com>
Sat, 22 Dec 2012 11:14:40 +0800
changeset 117016 995041ffb42d896645e3c11fdbf2eb4ad88b30d5
parent 117015 914889120beb56d41c5509082d053ea0748fccbd
child 117017 5ec5718e4fa803a891e8b035a2db6619b13af173
push id24079
push userryanvm@gmail.com
push dateWed, 26 Dec 2012 12:59:56 +0000
treeherdermozilla-central@f5ed2691d901 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersallstars.chh
bugs824194
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 824194 - Refactor TLV size handler in sendStkTerminalResponse. r=allstars.chh
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -3382,40 +3382,42 @@ let RIL = {
           let bits = response.input.length * 7;
           textLen = bits * 7 / 8 + (bits % 8 ? 1 : 0);
         } else {
           textLen = response.input.length;
         }
       }
     }
 
-    // 1 octets = 2 chars.
-    let size = (TLV_COMMAND_DETAILS_SIZE +
-                TLV_DEVICE_ID_SIZE +
-                TLV_RESULT_SIZE +
-                (response.itemIdentifier ? TLV_ITEM_ID_SIZE : 0) +
-                (textLen ? textLen + 3 : 0)) * 2;
+    let berLen = TLV_COMMAND_DETAILS_SIZE +
+                 TLV_DEVICE_ID_SIZE +
+                 TLV_RESULT_SIZE +
+                 (response.itemIdentifier ? TLV_ITEM_ID_SIZE : 0) +
+                 (textLen ? textLen + 3 : 0);
+
     if (response.localInfo) {
       let localInfo = response.localInfo;
-      size = size +
-             (((localInfo.locationInfo ?
-               (localInfo.locationInfo.gsmCellId > 0xffff ?
-                 TLV_LOCATION_INFO_UMTS_SIZE :
-                 TLV_LOCATION_INFO_GSM_SIZE) :
-               0) +
-             (localInfo.imei ? TLV_IMEI_SIZE : 0) +
-             (localInfo.date ? TLV_DATE_TIME_ZONE_SIZE : 0) +
-             (localInfo.language ? TLV_LANGUAGE_SIZE : 0)) * 2);
-    }
+      berLen += ((localInfo.locationInfo ?
+                 (localInfo.locationInfo.gsmCellId > 0xffff ?
+                   TLV_LOCATION_INFO_UMTS_SIZE :
+                   TLV_LOCATION_INFO_GSM_SIZE) :
+                  0) +
+                 (localInfo.imei ? TLV_IMEI_SIZE : 0) +
+                 (localInfo.date ? TLV_DATE_TIME_ZONE_SIZE : 0) +
+                 (localInfo.language ? TLV_LANGUAGE_SIZE : 0));
+    }
+
     if (response.timer) {
       let timer = response.timer;
-      size = size +
-             ((timer.timerId ? TLV_TIMER_IDENTIFIER : 0) +
-              (timer.timerValue ? TLV_TIMER_VALUE : 0)) * 2;
-    }
+      berLen += TLV_TIMER_IDENTIFIER +
+                (timer.timerValue ? TLV_TIMER_VALUE : 0);
+    }
+
+    // 1 octets = 2 chars.
+    let size = berLen * 2;
     Buf.writeUint32(size);
 
     // Command Details
     GsmPDUHelper.writeHexOctet(COMPREHENSIONTLV_TAG_COMMAND_DETAILS |
                                COMPREHENSIONTLV_FLAG_CR);
     GsmPDUHelper.writeHexOctet(3);
     if (response.command) {
       GsmPDUHelper.writeHexOctet(command.commandNumber);