Bug 920391 - B2G RIL: Buf.read/writeUint32 should be of signed int32 operation. r=vicamo
authorYoshi Huang <allstars.chh@mozilla.com>
Thu, 26 Sep 2013 14:53:50 +0800
changeset 148875 d364406e42ee0bdb039c60c44dc7b415ec89af37
parent 148874 2d27102d7b9ed9318e6945f4d83bb88ec1dff183
child 148876 f45566cc47f34496dd81f148416660f0f6bb3547
push id34380
push userryanvm@gmail.com
push dateFri, 27 Sep 2013 01:41:00 +0000
treeherdermozilla-inbound@fdc6054e33e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvicamo
bugs920391
milestone27.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 920391 - B2G RIL: Buf.read/writeUint32 should be of signed int32 operation. r=vicamo
dom/system/gonk/ril_worker.js
dom/system/gonk/tests/header_helpers.js
dom/system/gonk/tests/test_ril_worker_barring_password.js
dom/system/gonk/tests/test_ril_worker_buf.js
dom/system/gonk/tests/test_ril_worker_cdma_info_rec.js
dom/system/gonk/tests/test_ril_worker_cf.js
dom/system/gonk/tests/test_ril_worker_clip.js
dom/system/gonk/tests/test_ril_worker_clir.js
dom/system/gonk/tests/test_ril_worker_cw.js
dom/system/gonk/tests/test_ril_worker_icc.js
dom/system/gonk/tests/test_ril_worker_mmi.js
dom/system/gonk/tests/test_ril_worker_ruim.js
dom/system/gonk/tests/test_ril_worker_stk.js
dom/system/gonk/tests/test_ril_worker_voiceprivacy.js
dom/system/gonk/worker_buf.js
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -107,22 +107,22 @@ let Buf = {
     // when we get a response parcel back, we know what request it was for.
     this.mTokenRequestMap = {};
   },
 
   /**
    * Process one parcel.
    */
   processParcel: function processParcel() {
-    let response_type = this.readUint32();
+    let response_type = this.readInt32();
 
     let request_type, options;
     if (response_type == RESPONSE_TYPE_SOLICITED) {
-      let token = this.readUint32();
-      let error = this.readUint32();
+      let token = this.readInt32();
+      let error = this.readInt32();
 
       options = this.mTokenRequestMap[token];
       if (!options) {
         if (DEBUG) {
           debug("Suspicious uninvited request found: " + token + ". Ignored!");
         }
         return;
       }
@@ -131,17 +131,17 @@ let Buf = {
       request_type = options.rilRequestType;
 
       options.rilRequestError = error;
       if (DEBUG) {
         debug("Solicited response for request type " + request_type +
               ", token " + token + ", error " + error);
       }
     } else if (response_type == RESPONSE_TYPE_UNSOLICITED) {
-      request_type = this.readUint32();
+      request_type = this.readInt32();
       if (DEBUG) debug("Unsolicited response for request type " + request_type);
     } else {
       if (DEBUG) debug("Unknown response type: " + response_type);
       return;
     }
 
     RIL.handleParcel(request_type, this.readAvailable, options);
   },
@@ -155,18 +155,18 @@ let Buf = {
    *        Object containing information about the request, e.g. the
    *        original main thread message object that led to the RIL request.
    */
   newParcel: function newParcel(type, options) {
     if (DEBUG) debug("New outgoing parcel of type " + type);
 
     // We're going to leave room for the parcel size at the beginning.
     this.outgoingIndex = this.PARCEL_SIZE_SIZE;
-    this.writeUint32(type);
-    this.writeUint32(this.mToken);
+    this.writeInt32(type);
+    this.writeInt32(this.mToken);
 
     if (!options) {
       options = {};
     }
     options.rilRequestType = type;
     options.rilRequestError = null;
     this.mTokenRequestMap[this.mToken] = options;
     this.mToken++;
@@ -487,17 +487,17 @@ let RIL = {
    *
    * @param pin
    *        String containing the PIN.
    * @param [optional] aid
    *        AID value.
    */
   enterICCPIN: function enterICCPIN(options) {
     Buf.newParcel(REQUEST_ENTER_SIM_PIN, options);
-    Buf.writeUint32(RILQUIRKS_V5_LEGACY ? 1 : 2);
+    Buf.writeInt32(RILQUIRKS_V5_LEGACY ? 1 : 2);
     Buf.writeString(options.pin);
     if (!RILQUIRKS_V5_LEGACY) {
       Buf.writeString(options.aid || this.aid);
     }
     Buf.sendParcel();
   },
 
   /**
@@ -505,17 +505,17 @@ let RIL = {
    *
    * @param pin
    *        String containing the PIN2.
    * @param [optional] aid
    *        AID value.
    */
   enterICCPIN2: function enterICCPIN2(options) {
     Buf.newParcel(REQUEST_ENTER_SIM_PIN2, options);
-    Buf.writeUint32(RILQUIRKS_V5_LEGACY ? 1 : 2);
+    Buf.writeInt32(RILQUIRKS_V5_LEGACY ? 1 : 2);
     Buf.writeString(options.pin);
     if (!RILQUIRKS_V5_LEGACY) {
       Buf.writeString(options.aid || this.aid);
     }
     Buf.sendParcel();
   },
 
   /**
@@ -523,17 +523,17 @@ let RIL = {
    *
    * @param type
    *        Integer indicating the network personalization be deactivated.
    * @param password
    *        String containing the password.
    */
   enterDepersonalization: function enterDepersonalization(type, password, options) {
     Buf.newParcel(REQUEST_ENTER_NETWORK_DEPERSONALIZATION_CODE, options);
-    Buf.writeUint32(type);
+    Buf.writeInt32(type);
     Buf.writeString(password);
     Buf.sendParcel();
   },
 
   /**
    * Helper function for changing ICC locks.
    */
   iccSetCardLock: function iccSetCardLock(options) {
@@ -581,17 +581,17 @@ let RIL = {
    *        String containing the old PIN value
    * @param newPin
    *        String containing the new PIN value
    * @param [optional] aid
    *        AID value.
    */
   changeICCPIN: function changeICCPIN(options) {
     Buf.newParcel(REQUEST_CHANGE_SIM_PIN, options);
-    Buf.writeUint32(RILQUIRKS_V5_LEGACY ? 2 : 3);
+    Buf.writeInt32(RILQUIRKS_V5_LEGACY ? 2 : 3);
     Buf.writeString(options.pin);
     Buf.writeString(options.newPin);
     if (!RILQUIRKS_V5_LEGACY) {
       Buf.writeString(options.aid || this.aid);
     }
     Buf.sendParcel();
   },
 
@@ -602,17 +602,17 @@ let RIL = {
    *        String containing the old PIN2 value
    * @param newPin
    *        String containing the new PIN2 value
    * @param [optional] aid
    *        AID value.
    */
   changeICCPIN2: function changeICCPIN2(options) {
     Buf.newParcel(REQUEST_CHANGE_SIM_PIN2, options);
-    Buf.writeUint32(RILQUIRKS_V5_LEGACY ? 2 : 3);
+    Buf.writeInt32(RILQUIRKS_V5_LEGACY ? 2 : 3);
     Buf.writeString(options.pin);
     Buf.writeString(options.newPin);
     if (!RILQUIRKS_V5_LEGACY) {
       Buf.writeString(options.aid || this.aid);
     }
     Buf.sendParcel();
   },
   /**
@@ -622,17 +622,17 @@ let RIL = {
    *        String containing the PUK value.
    * @param newPin
    *        String containing the new PIN value.
    * @param [optional] aid
    *        AID value.
    */
    enterICCPUK: function enterICCPUK(options) {
      Buf.newParcel(REQUEST_ENTER_SIM_PUK, options);
-     Buf.writeUint32(RILQUIRKS_V5_LEGACY ? 2 : 3);
+     Buf.writeInt32(RILQUIRKS_V5_LEGACY ? 2 : 3);
      Buf.writeString(options.puk);
      Buf.writeString(options.newPin);
      if (!RILQUIRKS_V5_LEGACY) {
        Buf.writeString(options.aid || this.aid);
      }
      Buf.sendParcel();
    },
 
@@ -643,17 +643,17 @@ let RIL = {
    *        String containing the PUK2 value.
    * @param newPin
    *        String containing the new PIN2 value.
    * @param [optional] aid
    *        AID value.
    */
    enterICCPUK2: function enterICCPUK2(options) {
      Buf.newParcel(REQUEST_ENTER_SIM_PUK2, options);
-     Buf.writeUint32(RILQUIRKS_V5_LEGACY ? 2 : 3);
+     Buf.writeInt32(RILQUIRKS_V5_LEGACY ? 2 : 3);
      Buf.writeString(options.puk);
      Buf.writeString(options.newPin);
      if (!RILQUIRKS_V5_LEGACY) {
        Buf.writeString(options.aid || this.aid);
      }
      Buf.sendParcel();
    },
 
@@ -724,17 +724,17 @@ let RIL = {
    *
    * @param selCode
    *        One of ICC_SEL_CODE_*.
    * @param serviceClass
    *        One of ICC_SERVICE_CLASS_*.
    */
   queryICCLockRetryCount: function queryICCLockRetryCount(options) {
     Buf.newParcel(REQUEST_GET_UNLOCK_RETRY_COUNT, options);
-    Buf.writeUint32(1);
+    Buf.writeInt32(1);
     Buf.writeString(options.selCode);
     Buf.sendParcel();
   },
 
   /**
    * Query ICC facility lock.
    *
    * @param facility
@@ -743,17 +743,17 @@ let RIL = {
    *        Password for the facility, or "" if not required.
    * @param serviceClass
    *        One of ICC_SERVICE_CLASS_*.
    * @param [optional] aid
    *        AID value.
    */
   queryICCFacilityLock: function queryICCFacilityLock(options) {
     Buf.newParcel(REQUEST_QUERY_FACILITY_LOCK, options);
-    Buf.writeUint32(RILQUIRKS_V5_LEGACY ? 3 : 4);
+    Buf.writeInt32(RILQUIRKS_V5_LEGACY ? 3 : 4);
     Buf.writeString(options.facility);
     Buf.writeString(options.password);
     Buf.writeString(options.serviceClass.toString());
     if (!RILQUIRKS_V5_LEGACY) {
       Buf.writeString(options.aid || this.aid);
     }
     Buf.sendParcel();
   },
@@ -769,17 +769,17 @@ let RIL = {
    *        Password for the facility, or "" if not required.
    * @param serviceClass
    *        One of ICC_SERVICE_CLASS_*.
    * @param [optional] aid
    *        AID value.
    */
   setICCFacilityLock: function setICCFacilityLock(options) {
     Buf.newParcel(REQUEST_SET_FACILITY_LOCK, options);
-    Buf.writeUint32(RILQUIRKS_V5_LEGACY ? 4 : 5);
+    Buf.writeInt32(RILQUIRKS_V5_LEGACY ? 4 : 5);
     Buf.writeString(options.facility);
     Buf.writeString(options.enabled ? "1" : "0");
     Buf.writeString(options.password);
     Buf.writeString(options.serviceClass.toString());
     if (!RILQUIRKS_V5_LEGACY) {
       Buf.writeString(options.aid || this.aid);
     }
     Buf.sendParcel();
@@ -804,22 +804,22 @@ let RIL = {
    *         The function for writing string parameter for the ICC_COMMAND_UPDATE_RECORD.
    *  @param [optional] pin2
    *         String containing the PIN2.
    *  @param [optional] aid
    *         AID value.
    */
   iccIO: function iccIO(options) {
     Buf.newParcel(REQUEST_SIM_IO, options);
-    Buf.writeUint32(options.command);
-    Buf.writeUint32(options.fileId);
+    Buf.writeInt32(options.command);
+    Buf.writeInt32(options.fileId);
     Buf.writeString(options.pathId);
-    Buf.writeUint32(options.p1);
-    Buf.writeUint32(options.p2);
-    Buf.writeUint32(options.p3);
+    Buf.writeInt32(options.p1);
+    Buf.writeInt32(options.p2);
+    Buf.writeInt32(options.p3);
 
     // Write data.
     if (options.command == ICC_COMMAND_UPDATE_RECORD &&
         options.dataWriter) {
       options.dataWriter(options.p3);
     } else {
       Buf.writeString(null);
     }
@@ -845,17 +845,17 @@ let RIL = {
    *        AID value.
    */
   getIMSI: function getIMSI(aid) {
     if (RILQUIRKS_V5_LEGACY) {
       Buf.simpleRequest(REQUEST_GET_IMSI);
       return;
     }
     Buf.newParcel(REQUEST_GET_IMSI);
-    Buf.writeUint32(1);
+    Buf.writeInt32(1);
     Buf.writeString(aid || this.aid);
     Buf.sendParcel();
   },
 
   /**
    * Read UICC Phonebook contacts.
    *
    * @param contactType
@@ -933,29 +933,29 @@ let RIL = {
   /**
    * Request the phone's radio power to be switched on or off.
    *
    * @param on
    *        Boolean indicating the desired power state.
    */
   setRadioPower: function setRadioPower(options) {
     Buf.newParcel(REQUEST_RADIO_POWER, options);
-    Buf.writeUint32(1);
-    Buf.writeUint32(options.on ? 1 : 0);
+    Buf.writeInt32(1);
+    Buf.writeInt32(options.on ? 1 : 0);
     Buf.sendParcel();
   },
 
   /**
    * Query call waiting status via MMI.
    */
   _handleQueryMMICallWaiting: function _handleQueryMMICallWaiting(options) {
     function callback(options) {
-      options.length = Buf.readUint32();
-      options.enabled = (Buf.readUint32() === 1);
-      let services = Buf.readUint32();
+      options.length = Buf.readInt32();
+      options.enabled = (Buf.readInt32() === 1);
+      let services = Buf.readInt32();
       if (options.enabled) {
         options.statusMessage = MMI_SM_KS_SERVICE_ENABLED_FOR;
         let serviceClass = [];
         for (let serviceClassMask = 1;
              serviceClassMask <= ICC_SERVICE_CLASS_MAX;
              serviceClassMask <<= 1) {
           if ((serviceClassMask & services) !== 0) {
             serviceClass.push(MMI_KS_SERVICE_CLASS_MAPPING[serviceClassMask]);
@@ -996,34 +996,34 @@ let RIL = {
   },
 
   /**
    * Query call waiting status.
    *
    */
   queryCallWaiting: function queryCallWaiting(options) {
     Buf.newParcel(REQUEST_QUERY_CALL_WAITING, options);
-    Buf.writeUint32(1);
+    Buf.writeInt32(1);
     // As per 3GPP TS 24.083, section 1.6 UE doesn't need to send service
     // class parameter in call waiting interrogation  to network
-    Buf.writeUint32(ICC_SERVICE_CLASS_NONE);
+    Buf.writeInt32(ICC_SERVICE_CLASS_NONE);
     Buf.sendParcel();
   },
 
   /**
    * Set call waiting status.
    *
    * @param on
    *        Boolean indicating the desired waiting status.
    */
   setCallWaiting: function setCallWaiting(options) {
     Buf.newParcel(REQUEST_SET_CALL_WAITING, options);
-    Buf.writeUint32(2);
-    Buf.writeUint32(options.enabled ? 1 : 0);
-    Buf.writeUint32(options.serviceClass !== undefined ?
+    Buf.writeInt32(2);
+    Buf.writeInt32(options.enabled ? 1 : 0);
+    Buf.writeInt32(options.serviceClass !== undefined ?
                     options.serviceClass : ICC_SERVICE_CLASS_VOICE);
     Buf.sendParcel();
   },
 
   /**
    * Queries current CLIP status.
    *
    * (MMI request for code "*#30#")
@@ -1068,31 +1068,31 @@ let RIL = {
    *        Is one of the CLIR_* constants in
    *        nsIDOMMozMobileConnection interface.
    */
   setCLIR: function setCLIR(options) {
     if (options) {
       this.clirMode = options.clirMode;
     }
     Buf.newParcel(REQUEST_SET_CLIR, options);
-    Buf.writeUint32(1);
-    Buf.writeUint32(this.clirMode);
+    Buf.writeInt32(1);
+    Buf.writeInt32(this.clirMode);
     Buf.sendParcel();
   },
 
   /**
    * Set screen state.
    *
    * @param on
    *        Boolean indicating whether the screen should be on or off.
    */
   setScreenState: function setScreenState(on) {
     Buf.newParcel(REQUEST_SCREEN_STATE);
-    Buf.writeUint32(1);
-    Buf.writeUint32(on ? 1 : 0);
+    Buf.writeInt32(1);
+    Buf.writeInt32(on ? 1 : 0);
     Buf.sendParcel();
   },
 
   getVoiceRegistrationState: function getVoiceRegistrationState() {
     Buf.simpleRequest(REQUEST_VOICE_REGISTRATION_STATE);
   },
 
   getVoiceRadioTechnology: function getVoiceRadioTechnology() {
@@ -1119,18 +1119,18 @@ let RIL = {
     if (options) {
       this.preferredNetworkType = options.networkType;
     }
     if (this.preferredNetworkType == null) {
       return;
     }
 
     Buf.newParcel(REQUEST_SET_PREFERRED_NETWORK_TYPE, options);
-    Buf.writeUint32(1);
-    Buf.writeUint32(this.preferredNetworkType);
+    Buf.writeInt32(1);
+    Buf.writeInt32(this.preferredNetworkType);
     Buf.sendParcel();
   },
 
   /**
    * Get the preferred network type.
    */
   getPreferredNetworkType: function getPreferredNetworkType() {
     Buf.simpleRequest(REQUEST_GET_PREFERRED_NETWORK_TYPE);
@@ -1189,35 +1189,35 @@ let RIL = {
 
     if (roamingMode === -1) {
       options.errorMsg = GECKO_ERROR_INVALID_PARAMETER;
       this.sendChromeMessage(options);
       return;
     }
 
     Buf.newParcel(REQUEST_CDMA_SET_ROAMING_PREFERENCE, options);
-    Buf.writeUint32(1);
-    Buf.writeUint32(roamingMode);
+    Buf.writeInt32(1);
+    Buf.writeInt32(roamingMode);
     Buf.sendParcel();
   },
 
   /**
    * Get the roaming preference mode
    */
   queryRoamingPreference: function getRoamingPreference(options) {
     Buf.simpleRequest(REQUEST_CDMA_QUERY_ROAMING_PREFERENCE, options);
   },
 
   /**
    * Set the voice privacy mode
    */
   setVoicePrivacyMode: function setVoicePrivacyMode(options) {
     Buf.newParcel(REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE, options);
-    Buf.writeUint32(1);
-    Buf.writeUint32(options.enabled ? 1 : 0);
+    Buf.writeInt32(1);
+    Buf.writeInt32(options.enabled ? 1 : 0);
     Buf.sendParcel();
   },
 
   /**
    * Get the voice privacy mode
    */
   queryVoicePrivacyMode: function getVoicePrivacyMode(options) {
     Buf.simpleRequest(REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE, options);
@@ -1249,38 +1249,38 @@ let RIL = {
     let data = options.apdu.data || "";
     let data2 = options.apdu.data2 || "";
 
     let p1 = options.apdu.p1;
     let p2 = options.apdu.p2;
     let p3 = options.apdu.p3; // Extra
 
     Buf.newParcel(REQUEST_SIM_ACCESS_CHANNEL, options);
-    Buf.writeUint32(cla);
-    Buf.writeUint32(command);
-    Buf.writeUint32(channel);
+    Buf.writeInt32(cla);
+    Buf.writeInt32(command);
+    Buf.writeInt32(channel);
     Buf.writeString(path); // path
-    Buf.writeUint32(p1);
-    Buf.writeUint32(p2);
-    Buf.writeUint32(p3);
+    Buf.writeInt32(p1);
+    Buf.writeInt32(p2);
+    Buf.writeInt32(p3);
     Buf.writeString(data); // generic data field.
     Buf.writeString(data2);
 
     Buf.sendParcel();
   },
 
   /**
    * Close Logical UICC channel
    */
   iccCloseChannel: function iccCloseChannel(options) {
     if (DEBUG) debug("iccCloseChannel: " + JSON.stringify(options));
 
     Buf.newParcel(REQUEST_SIM_CLOSE_CHANNEL, options);
-    Buf.writeUint32(1);
-    Buf.writeUint32(options.channel);
+    Buf.writeInt32(1);
+    Buf.writeInt32(options.channel);
     Buf.sendParcel();
   },
 
   /**
    * Tell the radio to choose a specific voice/data network
    */
   selectNetwork: function selectNetwork(options) {
     if (DEBUG) {
@@ -1423,21 +1423,21 @@ let RIL = {
     }
 
     this.sendDialRequest(options);
   },
 
   sendDialRequest: function sendDialRequest(options) {
     Buf.newParcel(options.request);
     Buf.writeString(options.number);
-    Buf.writeUint32(options.clirMode || 0);
-    Buf.writeUint32(options.uusInfo || 0);
+    Buf.writeInt32(options.clirMode || 0);
+    Buf.writeInt32(options.uusInfo || 0);
     // TODO Why do we need this extra 0? It was put it in to make this
     // match the format of the binary message.
-    Buf.writeUint32(0);
+    Buf.writeInt32(0);
     Buf.sendParcel();
   },
 
   /**
    * Hang up the phone.
    *
    * @param callIndex
    *        Call index (1-based) as reported by REQUEST_GET_CURRENT_CALLS.
@@ -1448,36 +1448,36 @@ let RIL = {
       return;
     }
 
     switch (call.state) {
       case CALL_STATE_ACTIVE:
       case CALL_STATE_DIALING:
       case CALL_STATE_ALERTING:
         Buf.newParcel(REQUEST_HANGUP);
-        Buf.writeUint32(1);
-        Buf.writeUint32(options.callIndex);
+        Buf.writeInt32(1);
+        Buf.writeInt32(options.callIndex);
         Buf.sendParcel();
         break;
       case CALL_STATE_HOLDING:
         Buf.simpleRequest(REQUEST_HANGUP_WAITING_OR_BACKGROUND);
         break;
     }
   },
 
   /**
    * Mute or unmute the radio.
    *
    * @param mute
    *        Boolean to indicate whether to mute or unmute the radio.
    */
   setMute: function setMute(mute) {
     Buf.newParcel(REQUEST_SET_MUTE);
-    Buf.writeUint32(1);
-    Buf.writeUint32(mute ? 1 : 0);
+    Buf.writeInt32(1);
+    Buf.writeInt32(mute ? 1 : 0);
     Buf.sendParcel();
   },
 
   /**
    * Answer an incoming/waiting call.
    *
    * @param callIndex
    *        Call index of the call to answer.
@@ -1561,18 +1561,18 @@ let RIL = {
 
   conferenceCall: function conferenceCall(options) {
     this._hasConferenceRequest = true;
     Buf.simpleRequest(REQUEST_CONFERENCE, options);
   },
 
   separateCall: function separateCall(options) {
     Buf.newParcel(REQUEST_SEPARATE_CONNECTION, options);
-    Buf.writeUint32(1);
-    Buf.writeUint32(options.callIndex);
+    Buf.writeInt32(1);
+    Buf.writeInt32(options.callIndex);
     Buf.sendParcel();
   },
 
   holdConference: function holdConference() {
     Buf.simpleRequest(REQUEST_SWITCH_HOLDING_AND_ACTIVE);
   },
 
   resumeConference: function resumeConference() {
@@ -1606,36 +1606,36 @@ let RIL = {
       options.encodedBodyLength = options.segments[0].encodedBodyLength;
     }
 
     if (this._isCdma) {
       Buf.newParcel(REQUEST_CDMA_SEND_SMS, options);
       CdmaPDUHelper.writeMessage(options);
     } else {
       Buf.newParcel(REQUEST_SEND_SMS, options);
-      Buf.writeUint32(2);
+      Buf.writeInt32(2);
       Buf.writeString(options.SMSC);
       GsmPDUHelper.writeMessage(options);
     }
     Buf.sendParcel();
   },
 
   /**
    * Acknowledge the receipt and handling of an SMS.
    *
    * @param success
    *        Boolean indicating whether the message was successfuly handled.
    * @param cause
    *        SMS_* constant indicating the reason for unsuccessful handling.
    */
   acknowledgeGsmSms: function acknowledgeGsmSms(success, cause) {
     Buf.newParcel(REQUEST_SMS_ACKNOWLEDGE);
-    Buf.writeUint32(2);
-    Buf.writeUint32(success ? 1 : 0);
-    Buf.writeUint32(cause);
+    Buf.writeInt32(2);
+    Buf.writeInt32(success ? 1 : 0);
+    Buf.writeInt32(cause);
     Buf.sendParcel();
   },
 
   /**
    * Acknowledge the receipt and handling of an SMS.
    *
    * @param success
    *        Boolean indicating whether the message was successfuly handled.
@@ -1656,18 +1656,18 @@ let RIL = {
    *
    * @param success
    *        Boolean indicating whether the message was successfuly handled.
    * @param cause
    *        SMS_* constant indicating the reason for unsuccessful handling.
    */
   acknowledgeCdmaSms: function acknowledgeCdmaSms(success, cause) {
     Buf.newParcel(REQUEST_CDMA_SMS_ACKNOWLEDGE);
-    Buf.writeUint32(success ? 0 : 1);
-    Buf.writeUint32(cause);
+    Buf.writeInt32(success ? 0 : 1);
+    Buf.writeInt32(cause);
     Buf.sendParcel();
   },
 
   setCellBroadcastDisabled: function setCellBroadcastDisabled(options) {
     this.cellBroadcastDisabled = options.disabled;
 
     // If |this.mergedCellBroadcastConfig| is null, either we haven't finished
     // reading required SIM files, or no any channel is ever configured.  In
@@ -1710,23 +1710,23 @@ let RIL = {
       this.setSmsBroadcastActivation(false);
     }
   },
 
   setGsmSmsBroadcastConfig: function setGsmSmsBroadcastConfig(config) {
     Buf.newParcel(REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
 
     let numConfigs = config ? config.length / 2 : 0;
-    Buf.writeUint32(numConfigs);
+    Buf.writeInt32(numConfigs);
     for (let i = 0; i < config.length;) {
-      Buf.writeUint32(config[i++]);
-      Buf.writeUint32(config[i++]);
-      Buf.writeUint32(0x00);
-      Buf.writeUint32(0xFF);
-      Buf.writeUint32(1);
+      Buf.writeInt32(config[i++]);
+      Buf.writeInt32(config[i++]);
+      Buf.writeInt32(0x00);
+      Buf.writeInt32(0xFF);
+      Buf.writeInt32(1);
     }
 
     Buf.sendParcel();
   },
 
   /**
    * Send CDMA SMS broadcast config.
    *
@@ -1737,25 +1737,25 @@ let RIL = {
     // It will be further decomposed, ex: [1, 4) => 1, 2, 3.
     Buf.newParcel(REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
 
     let numConfigs = 0;
     for (let i = 0; i < config.length; i += 2) {
       numConfigs += (config[i+1] - config[i]);
     }
 
-    Buf.writeUint32(numConfigs);
+    Buf.writeInt32(numConfigs);
     for (let i = 0; i < config.length;) {
       let begin = config[i++];
       let end = config[i++];
 
       for (let j = begin; j < end; ++j) {
-        Buf.writeUint32(j);
-        Buf.writeUint32(0);  // Language Indicator: Unknown or unspecified.
-        Buf.writeUint32(1);
+        Buf.writeInt32(j);
+        Buf.writeInt32(0);  // Language Indicator: Unknown or unspecified.
+        Buf.writeInt32(1);
       }
     }
 
     Buf.sendParcel();
   },
 
   setSmsBroadcastConfig: function setSmsBroadcastConfig(config) {
     if (this._isCdma) {
@@ -1764,19 +1764,19 @@ let RIL = {
       this.setGsmSmsBroadcastConfig(config);
     }
   },
 
   setSmsBroadcastActivation: function setSmsBroadcastActivation(activate) {
     let parcelType = this._isCdma ? REQUEST_CDMA_SMS_BROADCAST_ACTIVATION :
                                     REQUEST_GSM_SMS_BROADCAST_ACTIVATION;
     Buf.newParcel(parcelType);
-    Buf.writeUint32(1);
+    Buf.writeInt32(1);
     // See hardware/ril/include/telephony/ril.h, 0 - Activate, 1 - Turn off.
-    Buf.writeUint32(activate ? 0 : 1);
+    Buf.writeInt32(activate ? 0 : 1);
     Buf.sendParcel();
   },
 
   /**
    * Start a DTMF Tone.
    *
    * @param dtmfChar
    *        DTMF signal to send, 0-9, *, +
@@ -1857,17 +1857,17 @@ let RIL = {
     let radioTech;
     if (RILQUIRKS_V5_LEGACY) {
       radioTech = this._isCdma ? DATACALL_RADIOTECHNOLOGY_CDMA
                                : DATACALL_RADIOTECHNOLOGY_GSM;
     } else {
       radioTech = options.radioTech + 2;
     }
     let token = Buf.newParcel(REQUEST_SETUP_DATA_CALL, options);
-    Buf.writeUint32(7);
+    Buf.writeInt32(7);
     Buf.writeString(radioTech.toString());
     Buf.writeString(DATACALL_PROFILE_DEFAULT.toString());
     Buf.writeString(options.apn);
     Buf.writeString(options.user);
     Buf.writeString(options.passwd);
     Buf.writeString(options.chappap.toString());
     Buf.writeString(options.pdptype);
     Buf.sendParcel();
@@ -1884,17 +1884,17 @@ let RIL = {
    */
   deactivateDataCall: function deactivateDataCall(options) {
     let datacall = this.currentDataCalls[options.cid];
     if (!datacall) {
       return;
     }
 
     Buf.newParcel(REQUEST_DEACTIVATE_DATA_CALL, options);
-    Buf.writeUint32(2);
+    Buf.writeInt32(2);
     Buf.writeString(options.cid);
     Buf.writeString(options.reason || DATACALL_DEACTIVATE_NO_REASON);
     Buf.sendParcel();
 
     datacall.state = GECKO_NETWORK_STATE_DISCONNECTING;
     this.sendChromeMessage(datacall);
   },
 
@@ -2363,22 +2363,22 @@ let RIL = {
    *        One of nsIDOMMozMobileCFInfo.CALL_FORWARD_REASON_* constants.
    * @param serviceClass
    *        One of ICC_SERVICE_CLASS_* constants.
    * @param number
    *        Phone number of forwarding address.
    */
   queryCallForwardStatus: function queryCallForwardStatus(options) {
     Buf.newParcel(REQUEST_QUERY_CALL_FORWARD_STATUS, options);
-    Buf.writeUint32(CALL_FORWARD_ACTION_QUERY_STATUS);
-    Buf.writeUint32(options.reason);
-    Buf.writeUint32(options.serviceClass || ICC_SERVICE_CLASS_NONE);
-    Buf.writeUint32(this._toaFromString(options.number));
+    Buf.writeInt32(CALL_FORWARD_ACTION_QUERY_STATUS);
+    Buf.writeInt32(options.reason);
+    Buf.writeInt32(options.serviceClass || ICC_SERVICE_CLASS_NONE);
+    Buf.writeInt32(this._toaFromString(options.number));
     Buf.writeString(options.number);
-    Buf.writeUint32(0);
+    Buf.writeInt32(0);
     Buf.sendParcel();
   },
 
   /**
    * Configures call forward rule.
    *
    * @param action
    *        One of nsIDOMMozMobileCFInfo.CALL_FORWARD_ACTION_* constants.
@@ -2388,22 +2388,22 @@ let RIL = {
    *        One of ICC_SERVICE_CLASS_* constants.
    * @param number
    *        Phone number of forwarding address.
    * @param timeSeconds
    *        Time in seconds to wait beforec all is forwarded.
    */
   setCallForward: function setCallForward(options) {
     Buf.newParcel(REQUEST_SET_CALL_FORWARD, options);
-    Buf.writeUint32(options.action);
-    Buf.writeUint32(options.reason);
-    Buf.writeUint32(options.serviceClass);
-    Buf.writeUint32(this._toaFromString(options.number));
+    Buf.writeInt32(options.action);
+    Buf.writeInt32(options.reason);
+    Buf.writeInt32(options.serviceClass);
+    Buf.writeInt32(this._toaFromString(options.number));
     Buf.writeString(options.number);
-    Buf.writeUint32(options.timeSeconds);
+    Buf.writeInt32(options.timeSeconds);
     Buf.sendParcel();
   },
 
   /**
    * Queries current call barring rules.
    *
    * @param program
    *        One of nsIDOMMozMobileConnection.CALL_BARRING_PROGRAM_* constants.
@@ -2438,50 +2438,50 @@ let RIL = {
    *
    * @param pin
    *        Old password.
    * @param newPin
    *        New password.
    */
   changeCallBarringPassword: function changeCallBarringPassword(options) {
     Buf.newParcel(REQUEST_CHANGE_BARRING_PASSWORD, options);
-    Buf.writeUint32(3);
+    Buf.writeInt32(3);
     // Set facility to ICC_CB_FACILITY_BA_ALL by following TS.22.030 clause
     // 6.5.4 and Table B.1.
     Buf.writeString(ICC_CB_FACILITY_BA_ALL);
     Buf.writeString(options.pin);
     Buf.writeString(options.newPin);
     Buf.sendParcel();
   },
 
   /**
    * Handle STK CALL_SET_UP request.
    *
    * @param hasConfirmed
    *        Does use have confirmed the call requested from ICC?
    */
   stkHandleCallSetup: function stkHandleCallSetup(options) {
      Buf.newParcel(REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM);
-     Buf.writeUint32(1);
-     Buf.writeUint32(options.hasConfirmed ? 1 : 0);
+     Buf.writeInt32(1);
+     Buf.writeInt32(options.hasConfirmed ? 1 : 0);
      Buf.sendParcel();
   },
 
   /**
    * Send STK Profile Download.
    *
    * @param profile Profile supported by ME.
    */
   sendStkTerminalProfile: function sendStkTerminalProfile(profile) {
     Buf.newParcel(REQUEST_STK_SET_PROFILE);
-    Buf.writeUint32(profile.length * 2);
+    Buf.writeInt32(profile.length * 2);
     for (let i = 0; i < profile.length; i++) {
       GsmPDUHelper.writeHexOctet(profile[i]);
     }
-    Buf.writeUint32(0);
+    Buf.writeInt32(0);
     Buf.sendParcel();
   },
 
   /**
    * Send STK terminal response.
    *
    * @param command
    * @param deviceIdentities
@@ -2500,17 +2500,17 @@ let RIL = {
     }
 
     let command = response.command;
     Buf.newParcel(REQUEST_STK_SEND_TERMINAL_RESPONSE);
 
     // 1st mark for Parcel size
     Buf.startCalOutgoingSize(function(size) {
       // Parcel size is in string length, which costs 2 uint8 per char.
-      Buf.writeUint32(size / 2);
+      Buf.writeInt32(size / 2);
     });
 
     // Command Details
     GsmPDUHelper.writeHexOctet(COMPREHENSIONTLV_TAG_COMMAND_DETAILS |
                                COMPREHENSIONTLV_FLAG_CR);
     GsmPDUHelper.writeHexOctet(3);
     if (response.command) {
       GsmPDUHelper.writeHexOctet(command.commandNumber);
@@ -2646,17 +2646,17 @@ let RIL = {
       if (timer.timerValue) {
         ComprehensionTlvHelper.writeTimerValueTlv(timer.timerValue, false);
       }
     }
 
     // Calculate and write Parcel size to 1st mark
     Buf.stopCalOutgoingSize();
 
-    Buf.writeUint32(0);
+    Buf.writeInt32(0);
     Buf.sendParcel();
   },
 
   /**
    * Send STK Envelope(Menu Selection) command.
    *
    * @param itemIdentifier
    * @param helpRequested
@@ -2767,17 +2767,17 @@ let RIL = {
     if (DEBUG) {
       debug("Stk Envelope " + JSON.stringify(options));
     }
     Buf.newParcel(REQUEST_STK_SEND_ENVELOPE_COMMAND);
 
     // 1st mark for Parcel size
     Buf.startCalOutgoingSize(function(size) {
       // Parcel size is in string length, which costs 2 uint8 per char.
-      Buf.writeUint32(size / 2);
+      Buf.writeInt32(size / 2);
     });
 
     // Write a BER-TLV
     GsmPDUHelper.writeHexOctet(options.tag);
     // 2nd mark for BER length
     Buf.startCalOutgoingSize(function(size) {
       // BER length is in number of hexOctets, which costs 4 uint8 per hexOctet.
       GsmPDUHelper.writeHexOctet(size / 4);
@@ -2870,17 +2870,17 @@ let RIL = {
     }
 
     // Calculate and write BER length to 2nd mark
     Buf.stopCalOutgoingSize();
 
     // Calculate and write Parcel size to 1st mark
     Buf.stopCalOutgoingSize();
 
-    Buf.writeUint32(0);
+    Buf.writeInt32(0);
     Buf.sendParcel();
   },
 
   /**
    * Check a given number against the list of emergency numbers provided by the RIL.
    *
    * @param number
    *        The number to look up.
@@ -3032,17 +3032,17 @@ let RIL = {
    * Helper for processing responses of functions such as enterICC* and changeICC*.
    */
   _processEnterAndChangeICCResponses:
     function _processEnterAndChangeICCResponses(length, options) {
     options.success = (options.rilRequestError === 0);
     if (!options.success) {
       options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
     }
-    options.retryCount = length ? Buf.readUint32List()[0] : -1;
+    options.retryCount = length ? Buf.readInt32List()[0] : -1;
     if (options.rilMessageType != "sendMMI") {
       this.sendChromeMessage(options);
       return;
     }
 
     let mmiServiceCode = options.mmiServiceCode;
 
     if (options.success) {
@@ -4036,29 +4036,29 @@ let RIL = {
       pid: message.pid,
       dcs: message.dcs,
       encoding: message.encoding,
     };
     Buf.newParcel(REQUEST_STK_SEND_ENVELOPE_WITH_STATUS, options);
 
     Buf.seekIncoming(-1 * (Buf.getCurrentParcelSize() - Buf.getReadAvailable()
                            - 2 * Buf.UINT32_SIZE)); // Skip response_type & request_type.
-    let messageStringLength = Buf.readUint32(); // In semi-octets
+    let messageStringLength = Buf.readInt32(); // In semi-octets
     let smscLength = GsmPDUHelper.readHexOctet(); // In octets, inclusive of TOA
     let tpduLength = (messageStringLength / 2) - (smscLength + 1); // In octets
 
     // Device identities: 4 bytes
     // Address: 0 or (2 + smscLength)
     // SMS TPDU: (2 or 3) + tpduLength
     let berLen = 4 +
                  (smscLength ? (2 + smscLength) : 0) +
                  (tpduLength <= 127 ? 2 : 3) + tpduLength; // In octets
 
     let parcelLength = (berLen <= 127 ? 2 : 3) + berLen; // In octets
-    Buf.writeUint32(parcelLength * 2); // In semi-octets
+    Buf.writeInt32(parcelLength * 2); // In semi-octets
 
     // Write a BER-TLV
     GsmPDUHelper.writeHexOctet(BER_SMS_PP_DOWNLOAD_TAG);
     if (berLen > 127) {
       GsmPDUHelper.writeHexOctet(0x81);
     }
     GsmPDUHelper.writeHexOctet(berLen);
 
@@ -4099,23 +4099,23 @@ let RIL = {
    *                `encoding` and `responsePduLen`.
    *
    * @see 3GPP TS 23.040 section 9.2.2.1a
    */
   acknowledgeIncomingGsmSmsWithPDU: function acknowledgeIncomingGsmSmsWithPDU(success, responsePduLen, options) {
     Buf.newParcel(REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU);
 
     // Two strings.
-    Buf.writeUint32(2);
+    Buf.writeInt32(2);
 
     // String 1: Success
     Buf.writeString(success ? "1" : "0");
 
     // String 2: RP-ACK/RP-ERROR PDU
-    Buf.writeUint32(2 * (responsePduLen + (success ? 5 : 6))); // In semi-octet
+    Buf.writeInt32(2 * (responsePduLen + (success ? 5 : 6))); // In semi-octet
     // 1. TP-MTI & TP-UDHI
     GsmPDUHelper.writeHexOctet(PDU_MTI_SMS_DELIVER);
     if (!success) {
       // 2. TP-FCS
       GsmPDUHelper.writeHexOctet(PDU_FCS_USIM_DATA_DOWNLOAD_ERROR);
     }
     // 3. TP-PI
     GsmPDUHelper.writeHexOctet(PDU_PI_USER_DATA_LENGTH |
@@ -4141,39 +4141,39 @@ let RIL = {
 
   /**
    * @param message A decoded SMS-DELIVER message.
    */
   writeSmsToSIM: function writeSmsToSIM(message) {
     Buf.newParcel(REQUEST_WRITE_SMS_TO_SIM);
 
     // Write EFsms Status
-    Buf.writeUint32(EFSMS_STATUS_FREE);
+    Buf.writeInt32(EFSMS_STATUS_FREE);
 
     Buf.seekIncoming(-1 * (Buf.getCurrentParcelSize() - Buf.getReadAvailable()
                            - 2 * Buf.UINT32_SIZE)); // Skip response_type & request_type.
-    let messageStringLength = Buf.readUint32(); // In semi-octets
+    let messageStringLength = Buf.readInt32(); // In semi-octets
     let smscLength = GsmPDUHelper.readHexOctet(); // In octets, inclusive of TOA
     let pduLength = (messageStringLength / 2) - (smscLength + 1); // In octets
 
     // 1. Write PDU first.
     if (smscLength > 0) {
       Buf.seekIncoming(smscLength * Buf.PDU_HEX_OCTET_SIZE);
     }
     // Write EFsms PDU string length
-    Buf.writeUint32(2 * pduLength); // In semi-octets
+    Buf.writeInt32(2 * pduLength); // In semi-octets
     if (pduLength) {
       Buf.copyIncomingToOutgoing(Buf.PDU_HEX_OCTET_SIZE * pduLength);
     }
     // Write 2 string delimitors for the total string length must be even.
     Buf.writeStringDelimiter(0);
 
     // 2. Write SMSC
     // Write EFsms SMSC string length
-    Buf.writeUint32(2 * (smscLength + 1)); // Plus smscLength itself, in semi-octets
+    Buf.writeInt32(2 * (smscLength + 1)); // Plus smscLength itself, in semi-octets
     // Write smscLength
     GsmPDUHelper.writeHexOctet(smscLength);
     // Write TOA & SMSC Address
     if (smscLength) {
       Buf.seekIncoming(-1 * (Buf.getCurrentParcelSize() - Buf.getReadAvailable()
                              - 2 * Buf.UINT32_SIZE // Skip response_type, request_type.
                              - 2 * Buf.PDU_HEX_OCTET_SIZE)); // Skip messageStringLength & smscLength.
       Buf.copyIncomingToOutgoing(Buf.PDU_HEX_OCTET_SIZE * smscLength);
@@ -4395,19 +4395,19 @@ let RIL = {
             rilMessageToken: options.rilMessageToken,
             errorMsg: options.rilRequestError,
           });
           break;
       }
       return;
     }
 
-    options.messageRef = Buf.readUint32();
+    options.messageRef = Buf.readInt32();
     options.ackPDU = Buf.readString();
-    options.errorCode = Buf.readUint32();
+    options.errorCode = Buf.readInt32();
 
     if ((options.segmentMaxSeq > 1)
         && (options.segmentSeq < options.segmentMaxSeq)) {
       // Not last segment
       this._processSentSmsSegment(options);
     } else {
       // Last segment sent with success.
       if (options.requestStatusReport) {
@@ -4766,17 +4766,17 @@ let RIL = {
     this.sendChromeMessage({rilMessageType: "datacalllist",
                             datacalls: datacall_list});
   },
 
   /**
    * Process STK Proactive Command.
    */
   processStkProactiveCommand: function processStkProactiveCommand() {
-    let length = Buf.readUint32();
+    let length = Buf.readInt32();
     let berTlv = BerTlvHelper.decode(length / 2);
     Buf.readStringDelimiter(length);
 
     let ctlvs = berTlv.value;
     let ctlv = StkProactiveCmdHelper.searchForTag(
         COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs);
     if (!ctlv) {
       RIL.sendStkTerminalResponse({
@@ -4836,46 +4836,46 @@ let RIL = {
 RIL.initRILState();
 
 RIL[REQUEST_GET_SIM_STATUS] = function REQUEST_GET_SIM_STATUS(length, options) {
   if (options.rilRequestError) {
     return;
   }
 
   let iccStatus = {};
-  iccStatus.cardState = Buf.readUint32(); // CARD_STATE_*
-  iccStatus.universalPINState = Buf.readUint32(); // CARD_PINSTATE_*
-  iccStatus.gsmUmtsSubscriptionAppIndex = Buf.readUint32();
-  iccStatus.cdmaSubscriptionAppIndex = Buf.readUint32();
+  iccStatus.cardState = Buf.readInt32(); // CARD_STATE_*
+  iccStatus.universalPINState = Buf.readInt32(); // CARD_PINSTATE_*
+  iccStatus.gsmUmtsSubscriptionAppIndex = Buf.readInt32();
+  iccStatus.cdmaSubscriptionAppIndex = Buf.readInt32();
   if (!RILQUIRKS_V5_LEGACY) {
-    iccStatus.imsSubscriptionAppIndex = Buf.readUint32();
-  }
-
-  let apps_length = Buf.readUint32();
+    iccStatus.imsSubscriptionAppIndex = Buf.readInt32();
+  }
+
+  let apps_length = Buf.readInt32();
   if (apps_length > CARD_MAX_APPS) {
     apps_length = CARD_MAX_APPS;
   }
 
   iccStatus.apps = [];
   for (let i = 0 ; i < apps_length ; i++) {
     iccStatus.apps.push({
-      app_type:       Buf.readUint32(), // CARD_APPTYPE_*
-      app_state:      Buf.readUint32(), // CARD_APPSTATE_*
-      perso_substate: Buf.readUint32(), // CARD_PERSOSUBSTATE_*
+      app_type:       Buf.readInt32(), // CARD_APPTYPE_*
+      app_state:      Buf.readInt32(), // CARD_APPSTATE_*
+      perso_substate: Buf.readInt32(), // CARD_PERSOSUBSTATE_*
       aid:            Buf.readString(),
       app_label:      Buf.readString(),
-      pin1_replaced:  Buf.readUint32(),
-      pin1:           Buf.readUint32(),
-      pin2:           Buf.readUint32()
+      pin1_replaced:  Buf.readInt32(),
+      pin1:           Buf.readInt32(),
+      pin2:           Buf.readInt32()
     });
     if (RILQUIRKS_SIM_APP_STATE_EXTRA_FIELDS) {
-      Buf.readUint32();
-      Buf.readUint32();
-      Buf.readUint32();
-      Buf.readUint32();
+      Buf.readInt32();
+      Buf.readInt32();
+      Buf.readInt32();
+      Buf.readInt32();
     }
   }
 
   if (DEBUG) debug("iccStatus: " + JSON.stringify(iccStatus));
   this._processICCStatus(iccStatus);
 };
 RIL[REQUEST_ENTER_SIM_PIN] = function REQUEST_ENTER_SIM_PIN(length, options) {
   this._processEnterAndChangeICCResponses(length, options);
@@ -4903,55 +4903,55 @@ RIL[REQUEST_GET_CURRENT_CALLS] = functio
   if (options.rilRequestError) {
     return;
   }
 
   let calls_length = 0;
   // The RIL won't even send us the length integer if there are no active calls.
   // So only read this integer if the parcel actually has it.
   if (length) {
-    calls_length = Buf.readUint32();
+    calls_length = Buf.readInt32();
   }
   if (!calls_length) {
     this._processCalls(null);
     return;
   }
 
   let calls = {};
   for (let i = 0; i < calls_length; i++) {
     let call = {};
 
     // Extra uint32 field to get correct callIndex and rest of call data for
     // call waiting feature.
     if (RILQUIRKS_EXTRA_UINT32_2ND_CALL && i > 0) {
-      Buf.readUint32();
-    }
-
-    call.state          = Buf.readUint32(); // CALL_STATE_*
-    call.callIndex      = Buf.readUint32(); // GSM index (1-based)
-    call.toa            = Buf.readUint32();
-    call.isMpty         = Boolean(Buf.readUint32());
-    call.isMT           = Boolean(Buf.readUint32());
-    call.als            = Buf.readUint32();
-    call.isVoice        = Boolean(Buf.readUint32());
-    call.isVoicePrivacy = Boolean(Buf.readUint32());
+      Buf.readInt32();
+    }
+
+    call.state          = Buf.readInt32(); // CALL_STATE_*
+    call.callIndex      = Buf.readInt32(); // GSM index (1-based)
+    call.toa            = Buf.readInt32();
+    call.isMpty         = Boolean(Buf.readInt32());
+    call.isMT           = Boolean(Buf.readInt32());
+    call.als            = Buf.readInt32();
+    call.isVoice        = Boolean(Buf.readInt32());
+    call.isVoicePrivacy = Boolean(Buf.readInt32());
     if (RILQUIRKS_CALLSTATE_EXTRA_UINT32) {
-      Buf.readUint32();
+      Buf.readInt32();
     }
     call.number             = Buf.readString(); //TODO munge with TOA
-    call.numberPresentation = Buf.readUint32(); // CALL_PRESENTATION_*
+    call.numberPresentation = Buf.readInt32(); // CALL_PRESENTATION_*
     call.name               = Buf.readString();
-    call.namePresentation   = Buf.readUint32();
+    call.namePresentation   = Buf.readInt32();
 
     call.uusInfo = null;
-    let uusInfoPresent = Buf.readUint32();
+    let uusInfoPresent = Buf.readInt32();
     if (uusInfoPresent == 1) {
       call.uusInfo = {
-        type:     Buf.readUint32(),
-        dcs:      Buf.readUint32(),
+        type:     Buf.readInt32(),
+        dcs:      Buf.readInt32(),
         userData: null //XXX TODO byte array?!?
       };
     }
 
     calls[call.callIndex] = call;
   }
   this._processCalls(calls);
 };
@@ -5029,26 +5029,26 @@ RIL[REQUEST_CONFERENCE] = function REQUE
     this._hasConferenceRequest = false;
     return;
   }
 };
 RIL[REQUEST_UDUB] = null;
 RIL[REQUEST_LAST_CALL_FAIL_CAUSE] = function REQUEST_LAST_CALL_FAIL_CAUSE(length, options) {
   let num = 0;
   if (length) {
-    num = Buf.readUint32();
+    num = Buf.readInt32();
   }
   if (!num) {
     // No response of REQUEST_LAST_CALL_FAIL_CAUSE. Change the call state into
     // 'disconnected' directly.
     this._handleDisconnectedCall(options);
     return;
   }
 
-  let failCause = Buf.readUint32();
+  let failCause = Buf.readInt32();
   switch (failCause) {
     case CALL_FAIL_NORMAL:
       this._handleDisconnectedCall(options);
       break;
     default:
       this._sendCallError(options.callIndex,
                           RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[failCause]);
       break;
@@ -5057,31 +5057,31 @@ RIL[REQUEST_LAST_CALL_FAIL_CAUSE] = func
 RIL[REQUEST_SIGNAL_STRENGTH] = function REQUEST_SIGNAL_STRENGTH(length, options) {
   this._receivedNetworkInfo(NETWORK_INFO_SIGNAL);
 
   if (options.rilRequestError) {
     return;
   }
 
   let signal = {
-    gsmSignalStrength: Buf.readUint32(),
-    gsmBitErrorRate:   Buf.readUint32(),
-    cdmaDBM:           Buf.readUint32(),
-    cdmaECIO:          Buf.readUint32(),
-    evdoDBM:           Buf.readUint32(),
-    evdoECIO:          Buf.readUint32(),
-    evdoSNR:           Buf.readUint32()
+    gsmSignalStrength: Buf.readInt32(),
+    gsmBitErrorRate:   Buf.readInt32(),
+    cdmaDBM:           Buf.readInt32(),
+    cdmaECIO:          Buf.readInt32(),
+    evdoDBM:           Buf.readInt32(),
+    evdoECIO:          Buf.readInt32(),
+    evdoSNR:           Buf.readInt32()
   };
 
   if (!RILQUIRKS_V5_LEGACY) {
-    signal.lteSignalStrength = Buf.readUint32();
-    signal.lteRSRP =           Buf.readUint32();
-    signal.lteRSRQ =           Buf.readUint32();
-    signal.lteRSSNR =          Buf.readUint32();
-    signal.lteCQI =            Buf.readUint32();
+    signal.lteSignalStrength = Buf.readInt32();
+    signal.lteRSRP =           Buf.readInt32();
+    signal.lteRSRQ =           Buf.readInt32();
+    signal.lteRSSNR =          Buf.readInt32();
+    signal.lteCQI =            Buf.readInt32();
   }
 
   if (DEBUG) debug("signal strength: " + JSON.stringify(signal));
 
   this._processSignalStrength(signal);
 };
 RIL[REQUEST_VOICE_REGISTRATION_STATE] = function REQUEST_VOICE_REGISTRATION_STATE(length, options) {
   this._receivedNetworkInfo(NETWORK_INFO_VOICE_REGISTRATION_STATE);
@@ -5186,18 +5186,18 @@ RIL[REQUEST_SETUP_DATA_CALL] = function 
 RIL[REQUEST_SIM_IO] = function REQUEST_SIM_IO(length, options) {
   if (!length) {
     ICCIOHelper.processICCIOError(options);
     return;
   }
 
   // Don't need to read rilRequestError since we can know error status from
   // sw1 and sw2.
-  options.sw1 = Buf.readUint32();
-  options.sw2 = Buf.readUint32();
+  options.sw1 = Buf.readInt32();
+  options.sw2 = Buf.readInt32();
   if (options.sw1 != ICC_STATUS_NORMAL_ENDING) {
     ICCIOHelper.processICCIOError(options);
     return;
   }
   ICCIOHelper.processICCIO(options);
 };
 RIL[REQUEST_SEND_USSD] = function REQUEST_SEND_USSD(length, options) {
   if (DEBUG) {
@@ -5219,26 +5219,26 @@ RIL[REQUEST_CANCEL_USSD] = function REQU
 RIL[REQUEST_GET_CLIR] = function REQUEST_GET_CLIR(length, options) {
   options.success = (options.rilRequestError === 0);
   if (!options.success) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
     this.sendChromeMessage(options);
     return;
   }
 
-  let bufLength = Buf.readUint32();
+  let bufLength = Buf.readInt32();
   if (!bufLength || bufLength < 2) {
     options.success = false;
     options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
     this.sendChromeMessage(options);
     return;
   }
 
-  options.n = Buf.readUint32(); // Will be TS 27.007 +CLIR parameter 'n'.
-  options.m = Buf.readUint32(); // Will be TS 27.007 +CLIR parameter 'm'.
+  options.n = Buf.readInt32(); // Will be TS 27.007 +CLIR parameter 'n'.
+  options.m = Buf.readInt32(); // Will be TS 27.007 +CLIR parameter 'm'.
 
   if (options.rilMessageType === "sendMMI") {
     // TS 27.007 +CLIR parameter 'm'.
     switch (options.m) {
       // CLIR not provisioned.
       case 0:
         options.statusMessage = MMI_SM_KS_SERVICE_NOT_PROVISIONED;
         break;
@@ -5327,33 +5327,33 @@ RIL[REQUEST_QUERY_CALL_FORWARD_STATUS] =
     if (!options.success) {
       options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
       this.sendChromeMessage(options);
       return;
     }
 
     let rulesLength = 0;
     if (length) {
-      rulesLength = Buf.readUint32();
+      rulesLength = Buf.readInt32();
     }
     if (!rulesLength) {
       options.success = false;
       options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
       this.sendChromeMessage(options);
       return;
     }
     let rules = new Array(rulesLength);
     for (let i = 0; i < rulesLength; i++) {
       let rule = {};
-      rule.active       = Buf.readUint32() == 1; // CALL_FORWARD_STATUS_*
-      rule.reason       = Buf.readUint32(); // CALL_FORWARD_REASON_*
-      rule.serviceClass = Buf.readUint32();
-      rule.toa          = Buf.readUint32();
+      rule.active       = Buf.readInt32() == 1; // CALL_FORWARD_STATUS_*
+      rule.reason       = Buf.readInt32(); // CALL_FORWARD_REASON_*
+      rule.serviceClass = Buf.readInt32();
+      rule.toa          = Buf.readInt32();
       rule.number       = Buf.readString();
-      rule.timeSeconds  = Buf.readUint32();
+      rule.timeSeconds  = Buf.readInt32();
       rules[i] = rule;
     }
     options.rules = rules;
     if (options.rilMessageType === "sendMMI") {
       options.statusMessage = MMI_SM_KS_SERVICE_INTERROGATED;
       // MMI query call forwarding options request returns a set of rules that
       // will be exposed in the form of an array of nsIDOMMozMobileCFInfo
       // instances.
@@ -5393,19 +5393,19 @@ RIL[REQUEST_QUERY_CALL_WAITING] =
     return;
   }
 
   if (options.callback) {
     options.callback.call(this, options);
     return;
   }
 
-  options.length = Buf.readUint32();
-  options.enabled = ((Buf.readUint32() == 1) &&
-                     ((Buf.readUint32() & ICC_SERVICE_CLASS_VOICE) == 0x01));
+  options.length = Buf.readInt32();
+  options.enabled = ((Buf.readInt32() == 1) &&
+                     ((Buf.readInt32() & ICC_SERVICE_CLASS_VOICE) == 0x01));
   this.sendChromeMessage(options);
 };
 
 RIL[REQUEST_SET_CALL_WAITING] = function REQUEST_SET_CALL_WAITING(length, options) {
   options.success = (options.rilRequestError === 0);
   if (!options.success) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
     this.sendChromeMessage(options);
@@ -5458,18 +5458,18 @@ RIL[REQUEST_DEACTIVATE_DATA_CALL] = func
 RIL[REQUEST_QUERY_FACILITY_LOCK] = function REQUEST_QUERY_FACILITY_LOCK(length, options) {
   options.success = (options.rilRequestError === 0);
   if (!options.success) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
   }
 
   let services;
   if (length) {
-    // Buf.readUint32List()[0] for Call Barring is a bit vector of services.
-    services = Buf.readUint32List()[0];
+    // Buf.readInt32List()[0] for Call Barring is a bit vector of services.
+    services = Buf.readInt32List()[0];
   } else {
     options.success = false;
     options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
     this.sendChromeMessage(options);
     return;
   }
 
   options.enabled = services === 0 ? false : true;
@@ -5494,17 +5494,17 @@ RIL[REQUEST_QUERY_FACILITY_LOCK] = funct
   this.sendChromeMessage(options);
 };
 RIL[REQUEST_SET_FACILITY_LOCK] = function REQUEST_SET_FACILITY_LOCK(length, options) {
   options.success = (options.rilRequestError === 0);
   if (!options.success) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
   }
 
-  options.retryCount = length ? Buf.readUint32List()[0] : -1;
+  options.retryCount = length ? Buf.readInt32List()[0] : -1;
 
   if (options.success && (options.rilMessageType === "sendMMI")) {
     switch (options.procedure) {
       case MMI_PROCEDURE_ACTIVATION:
         options.statusMessage = MMI_SM_KS_SERVICE_ENABLED;
         break;
       case MMI_PROCEDURE_DEACTIVATION:
         options.statusMessage = MMI_SM_KS_SERVICE_DISABLED;
@@ -5522,17 +5522,17 @@ RIL[REQUEST_CHANGE_BARRING_PASSWORD] =
 };
 RIL[REQUEST_SIM_OPEN_CHANNEL] = function REQUEST_SIM_OPEN_CHANNEL(length, options) {
   if (options.rilRequestError) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
     this.sendChromeMessage(options);
     return;
   }
 
-  options.channel = Buf.readUint32();
+  options.channel = Buf.readInt32();
   if (DEBUG) debug("Setting channel number in options: " + options.channel);
   this.sendChromeMessage(options);
 };
 RIL[REQUEST_SIM_CLOSE_CHANNEL] = function REQUEST_SIM_CLOSE_CHANNEL(length, options) {
   if (options.rilRequestError) {
     options.error = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
     this.sendChromeMessage(options);
     return;
@@ -5542,33 +5542,33 @@ RIL[REQUEST_SIM_CLOSE_CHANNEL] = functio
   this.sendChromeMessage(options);
 };
 RIL[REQUEST_SIM_ACCESS_CHANNEL] = function REQUEST_SIM_ACCESS_CHANNEL(length, options) {
   if (options.rilRequestError) {
     options.error = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
     this.sendChromeMessage(options);
   }
 
-  options.sw1 = Buf.readUint32();
-  options.sw2 = Buf.readUint32();
+  options.sw1 = Buf.readInt32();
+  options.sw2 = Buf.readInt32();
   options.simResponse = Buf.readString();
   if (DEBUG) {
     debug("Setting return values for RIL[REQUEST_SIM_ACCESS_CHANNEL]: ["
           + options.sw1 + "," + options.sw2 + ", " + options.simResponse + "]");
   }
   this.sendChromeMessage(options);
 };
 RIL[REQUEST_QUERY_NETWORK_SELECTION_MODE] = function REQUEST_QUERY_NETWORK_SELECTION_MODE(length, options) {
   this._receivedNetworkInfo(NETWORK_INFO_NETWORK_SELECTION_MODE);
 
   if (options.rilRequestError) {
     return;
   }
 
-  let mode = Buf.readUint32List();
+  let mode = Buf.readInt32List();
   let selectionMode;
 
   switch (mode[0]) {
     case NETWORK_SELECTION_MODE_AUTOMATIC:
       selectionMode = GECKO_NETWORK_SELECTION_AUTOMATIC;
       break;
     case NETWORK_SELECTION_MODE_MANUAL:
       selectionMode = GECKO_NETWORK_SELECTION_MANUAL;
@@ -5622,30 +5622,30 @@ RIL[REQUEST_GET_MUTE] = null;
 RIL[REQUEST_QUERY_CLIP] = function REQUEST_QUERY_CLIP(length, options) {
   options.success = (options.rilRequestError === 0);
   if (!options.success) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
     this.sendChromeMessage(options);
     return;
   }
 
-  let bufLength = Buf.readUint32();
+  let bufLength = Buf.readInt32();
   if (!bufLength) {
     options.success = false;
     options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
     this.sendChromeMessage(options);
     return;
   }
 
   // options.provisioned informs about the called party receives the calling
   // party's address information:
   // 0 for CLIP not provisioned
   // 1 for CLIP provisioned
   // 2 for unknown
-  options.provisioned = Buf.readUint32();
+  options.provisioned = Buf.readInt32();
   if (options.rilMessageType === "sendMMI") {
     switch (options.provisioned) {
       case 0:
         options.statusMessage = MMI_SM_KS_SERVICE_DISABLED;
         break;
       case 1:
         options.statusMessage = MMI_SM_KS_SERVICE_ENABLED;
         break;
@@ -5658,32 +5658,32 @@ RIL[REQUEST_QUERY_CLIP] = function REQUE
   this.sendChromeMessage(options);
 };
 RIL[REQUEST_LAST_DATA_CALL_FAIL_CAUSE] = null;
 
 RIL.readDataCall_v5 = function readDataCall_v5(options) {
   if (!options) {
     options = {};
   }
-  options.cid = Buf.readUint32().toString();
-  options.active = Buf.readUint32(); // DATACALL_ACTIVE_*
+  options.cid = Buf.readInt32().toString();
+  options.active = Buf.readInt32(); // DATACALL_ACTIVE_*
   options.type = Buf.readString();
   options.apn = Buf.readString();
   options.address = Buf.readString();
   return options;
 };
 
 RIL.readDataCall_v6 = function readDataCall_v6(options) {
   if (!options) {
     options = {};
   }
-  options.status = Buf.readUint32();  // DATACALL_FAIL_*
-  options.suggestedRetryTime = Buf.readUint32();
-  options.cid = Buf.readUint32().toString();
-  options.active = Buf.readUint32();  // DATACALL_ACTIVE_*
+  options.status = Buf.readInt32();  // DATACALL_FAIL_*
+  options.suggestedRetryTime = Buf.readInt32();
+  options.cid = Buf.readInt32().toString();
+  options.active = Buf.readInt32();  // DATACALL_ACTIVE_*
   options.type = Buf.readString();
   options.ifname = Buf.readString();
   options.ipaddr = Buf.readString();
   options.dns = Buf.readString();
   options.gw = Buf.readString();
   if (options.dns) {
     options.dns = options.dns.split(" ");
   }
@@ -5715,19 +5715,19 @@ RIL[REQUEST_DATA_CALL_LIST] = function R
 
   if (!length) {
     this._processDataCallList(null);
     return;
   }
 
   let version = 0;
   if (!RILQUIRKS_V5_LEGACY) {
-    version = Buf.readUint32();
-  }
-  let num = Buf.readUint32();
+    version = Buf.readInt32();
+  }
+  let num = Buf.readInt32();
   let datacalls = {};
   for (let i = 0; i < num; i++) {
     let datacall;
     if (version < 6) {
       datacall = this.readDataCall_v5();
     } else {
       datacall = this.readDataCall_v6();
     }
@@ -5773,19 +5773,19 @@ RIL[REQUEST_SET_PREFERRED_NETWORK_TYPE] 
 
   options.success = (options.rilRequestError == ERROR_SUCCESS);
   this.sendChromeMessage(options);
 };
 RIL[REQUEST_GET_PREFERRED_NETWORK_TYPE] = function REQUEST_GET_PREFERRED_NETWORK_TYPE(length, options) {
   let networkType;
   if (!options.rilRequestError) {
     networkType = RIL_PREFERRED_NETWORK_TYPE_TO_GECKO.indexOf(GECKO_PREFERRED_NETWORK_TYPE_DEFAULT);
-    let responseLen = Buf.readUint32(); // Number of INT32 responsed.
+    let responseLen = Buf.readInt32(); // Number of INT32 responsed.
     if (responseLen) {
-      this.preferredNetworkType = networkType = Buf.readUint32();
+      this.preferredNetworkType = networkType = Buf.readInt32();
     }
   }
 
   this.sendChromeMessage({
     rilMessageType: "getPreferredNetworkType",
     networkType: networkType,
     success: options.rilRequestError == ERROR_SUCCESS
   });
@@ -5798,17 +5798,17 @@ RIL[REQUEST_CDMA_SET_ROAMING_PREFERENCE]
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
   }
   this.sendChromeMessage(options);
 };
 RIL[REQUEST_CDMA_QUERY_ROAMING_PREFERENCE] = function REQUEST_CDMA_QUERY_ROAMING_PREFERENCE(length, options) {
   if (options.rilRequestError) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
   } else {
-    let mode = Buf.readUint32List();
+    let mode = Buf.readInt32List();
     options.mode = CDMA_ROAMING_PREFERENCE_TO_GECKO[mode[0]];
   }
   this.sendChromeMessage(options);
 };
 RIL[REQUEST_SET_TTY_MODE] = null;
 RIL[REQUEST_QUERY_TTY_MODE] = null;
 RIL[REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE] = function REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE(length, options) {
   if (options.rilRequestError) {
@@ -5821,17 +5821,17 @@ RIL[REQUEST_CDMA_SET_PREFERRED_VOICE_PRI
 };
 RIL[REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE] = function REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE(length, options) {
   if (options.rilRequestError) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
     this.sendChromeMessage(options);
     return;
   }
 
-  let enabled = Buf.readUint32List();
+  let enabled = Buf.readInt32List();
   options.enabled = enabled[0] ? true : false;
   this.sendChromeMessage(options);
 };
 RIL[REQUEST_CDMA_FLASH] = null;
 RIL[REQUEST_CDMA_BURST_DTMF] = null;
 RIL[REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY] = null;
 RIL[REQUEST_CDMA_SEND_SMS] = function REQUEST_CDMA_SEND_SMS(length, options) {
   this._processSmsSendResult(length, options);
@@ -5900,56 +5900,56 @@ RIL[REQUEST_REPORT_SMS_MEMORY_STATUS] = 
 RIL[REQUEST_REPORT_STK_SERVICE_IS_RUNNING] = null;
 RIL[REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU] = null;
 RIL[REQUEST_STK_SEND_ENVELOPE_WITH_STATUS] = function REQUEST_STK_SEND_ENVELOPE_WITH_STATUS(length, options) {
   if (options.rilRequestError) {
     this.acknowledgeGsmSms(false, PDU_FCS_UNSPECIFIED);
     return;
   }
 
-  let sw1 = Buf.readUint32();
-  let sw2 = Buf.readUint32();
+  let sw1 = Buf.readInt32();
+  let sw2 = Buf.readInt32();
   if ((sw1 == ICC_STATUS_SAT_BUSY) && (sw2 === 0x00)) {
     this.acknowledgeGsmSms(false, PDU_FCS_USAT_BUSY);
     return;
   }
 
   let success = ((sw1 == ICC_STATUS_NORMAL_ENDING) && (sw2 === 0x00))
                 || (sw1 == ICC_STATUS_NORMAL_ENDING_WITH_EXTRA);
 
-  let messageStringLength = Buf.readUint32(); // In semi-octets
+  let messageStringLength = Buf.readInt32(); // In semi-octets
   let responsePduLen = messageStringLength / 2; // In octets
   if (!responsePduLen) {
     this.acknowledgeGsmSms(success, success ? PDU_FCS_OK
                                          : PDU_FCS_USIM_DATA_DOWNLOAD_ERROR);
     return;
   }
 
   this.acknowledgeIncomingGsmSmsWithPDU(success, responsePduLen, options);
 };
 RIL[REQUEST_VOICE_RADIO_TECH] = function REQUEST_VOICE_RADIO_TECH(length, options) {
   if (options.rilRequestError) {
     if (DEBUG) {
       debug("Error when getting voice radio tech: " + options.rilRequestError);
     }
     return;
   }
-  let radioTech = Buf.readUint32List();
+  let radioTech = Buf.readInt32List();
   this._processRadioTech(radioTech[0]);
 };
 RIL[REQUEST_GET_UNLOCK_RETRY_COUNT] = function REQUEST_GET_UNLOCK_RETRY_COUNT(length, options) {
   options.success = (options.rilRequestError === 0);
   if (!options.success) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
   }
-  options.retryCount = length ? Buf.readUint32List()[0] : -1;
+  options.retryCount = length ? Buf.readInt32List()[0] : -1;
   this.sendChromeMessage(options);
 };
 RIL[UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED] = function UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED() {
-  let radioState = Buf.readUint32();
+  let radioState = Buf.readInt32();
 
   // Ensure radio state at boot time.
   if (this._isInitialRadioState) {
     // Even radioState is RADIO_STATE_OFF, we still have to maually turn radio off,
     // otherwise REQUEST_GET_SIM_STATUS will still report CARD_STATE_PRESENT.
     this.setRadioPower({on: false});
   }
 
@@ -6050,17 +6050,17 @@ RIL[UNSOLICITED_RESPONSE_NEW_SMS] = func
   // Not reserved FCS values, send ACK now.
   this.acknowledgeGsmSms(result == PDU_FCS_OK, result);
 };
 RIL[UNSOLICITED_RESPONSE_NEW_SMS_STATUS_REPORT] = function UNSOLICITED_RESPONSE_NEW_SMS_STATUS_REPORT(length) {
   let result = this._processSmsStatusReport(length);
   this.acknowledgeGsmSms(result == PDU_FCS_OK, result);
 };
 RIL[UNSOLICITED_RESPONSE_NEW_SMS_ON_SIM] = function UNSOLICITED_RESPONSE_NEW_SMS_ON_SIM(length) {
-  // let info = Buf.readUint32List();
+  // let info = Buf.readInt32List();
   //TODO
 };
 RIL[UNSOLICITED_ON_USSD] = function UNSOLICITED_ON_USSD() {
   let [typeCode, message] = Buf.readStringList();
   if (DEBUG) {
     debug("On USSD. Type Code: " + typeCode + " Message: " + message);
   }
 
@@ -6118,20 +6118,20 @@ RIL[UNSOLICITED_DATA_CALL_LIST_CHANGED] 
   if (RILQUIRKS_V5_LEGACY) {
     this.getDataCallList();
     return;
   }
   this[REQUEST_DATA_CALL_LIST](length, {rilRequestError: ERROR_SUCCESS});
 };
 RIL[UNSOLICITED_SUPP_SVC_NOTIFICATION] = function UNSOLICITED_SUPP_SVC_NOTIFICATION(length) {
   let info = {};
-  info.notificationType = Buf.readUint32();
-  info.code = Buf.readUint32();
-  info.index = Buf.readUint32();
-  info.type = Buf.readUint32();
+  info.notificationType = Buf.readInt32();
+  info.code = Buf.readInt32();
+  info.index = Buf.readInt32();
+  info.type = Buf.readInt32();
   info.number = Buf.readString();
 
   this._processSuppSvcNotification(info);
 };
 
 RIL[UNSOLICITED_STK_SESSION_END] = function UNSOLICITED_STK_SESSION_END() {
   this.sendChromeMessage({rilMessageType: "stksessionend"});
 };
@@ -6143,20 +6143,20 @@ RIL[UNSOLICITED_STK_EVENT_NOTIFY] = func
 };
 RIL[UNSOLICITED_STK_CALL_SETUP] = null;
 RIL[UNSOLICITED_SIM_SMS_STORAGE_FULL] = null;
 RIL[UNSOLICITED_SIM_REFRESH] = null;
 RIL[UNSOLICITED_CALL_RING] = function UNSOLICITED_CALL_RING() {
   let info = {rilMessageType: "callRing"};
   let isCDMA = false; //XXX TODO hard-code this for now
   if (isCDMA) {
-    info.isPresent = Buf.readUint32();
-    info.signalType = Buf.readUint32();
-    info.alertPitch = Buf.readUint32();
-    info.signal = Buf.readUint32();
+    info.isPresent = Buf.readInt32();
+    info.signalType = Buf.readInt32();
+    info.alertPitch = Buf.readInt32();
+    info.signal = Buf.readInt32();
   }
   // At this point we don't know much other than the fact there's an incoming
   // call, but that's enough to bring up the Phone app already. We'll know
   // details once we get a call state changed notification and can then
   // dispatch DOM events etc.
   this.sendChromeMessage(info);
 };
 RIL[UNSOLICITED_RESPONSE_SIM_STATUS_CHANGED] = function UNSOLICITED_RESPONSE_SIM_STATUS_CHANGED() {
@@ -6174,17 +6174,17 @@ RIL[UNSOLICITED_RESPONSE_CDMA_NEW_SMS] =
   }
 
   // Not reserved FCS values, send ACK now.
   this.acknowledgeCdmaSms(result == PDU_FCS_OK, result);
 };
 RIL[UNSOLICITED_RESPONSE_NEW_BROADCAST_SMS] = function UNSOLICITED_RESPONSE_NEW_BROADCAST_SMS(length) {
   let message;
   try {
-    message = GsmPDUHelper.readCbMessage(Buf.readUint32());
+    message = GsmPDUHelper.readCbMessage(Buf.readInt32());
   } catch (e) {
     if (DEBUG) {
       debug("Failed to parse Cell Broadcast message: " + JSON.stringify(e));
     }
     return;
   }
 
   message = this._processReceivedSmsCbPage(message);
@@ -6198,28 +6198,28 @@ RIL[UNSOLICITED_RESPONSE_NEW_BROADCAST_S
 RIL[UNSOLICITED_CDMA_RUIM_SMS_STORAGE_FULL] = null;
 RIL[UNSOLICITED_RESTRICTED_STATE_CHANGED] = null;
 RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE] = function UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE() {
   this._handleChangedEmergencyCbMode(true);
 };
 RIL[UNSOLICITED_CDMA_CALL_WAITING] = function UNSOLICITED_CDMA_CALL_WAITING(length) {
   let call = {};
   call.number              = Buf.readString();
-  call.numberPresentation  = Buf.readUint32();
+  call.numberPresentation  = Buf.readInt32();
   call.name                = Buf.readString();
-  call.namePresentation    = Buf.readUint32();
-  call.isPresent           = Buf.readUint32();
-  call.signalType          = Buf.readUint32();
-  call.alertPitch          = Buf.readUint32();
-  call.signal              = Buf.readUint32();
+  call.namePresentation    = Buf.readInt32();
+  call.isPresent           = Buf.readInt32();
+  call.signalType          = Buf.readInt32();
+  call.alertPitch          = Buf.readInt32();
+  call.signal              = Buf.readInt32();
   this.sendChromeMessage({rilMessageType: "cdmaCallWaiting",
                           number: call.number});
 };
 RIL[UNSOLICITED_CDMA_OTA_PROVISION_STATUS] = function UNSOLICITED_CDMA_OTA_PROVISION_STATUS() {
-  let status = Buf.readUint32List()[0];
+  let status = Buf.readInt32List()[0];
   this.sendChromeMessage({rilMessageType: "otastatuschange",
                           status: status});
 };
 RIL[UNSOLICITED_CDMA_INFO_REC] = function UNSOLICITED_CDMA_INFO_REC(length) {
   let record = CdmaPDUHelper.decodeInformationRecord();
   record.rilMessageType = "cdma-info-rec-received";
   this.sendChromeMessage(record);
 };
@@ -6231,17 +6231,17 @@ RIL[UNSOLICITED_EXIT_EMERGENCY_CALLBACK_
 };
 RIL[UNSOLICITED_RIL_CONNECTED] = function UNSOLICITED_RIL_CONNECTED(length) {
   // Prevent response id collision between UNSOLICITED_RIL_CONNECTED and
   // UNSOLICITED_VOICE_RADIO_TECH_CHANGED for Akami on gingerbread branch.
   if (!length) {
     return;
   }
 
-  let version = Buf.readUint32List()[0];
+  let version = Buf.readInt32List()[0];
   RILQUIRKS_V5_LEGACY = (version < 5);
   if (DEBUG) {
     debug("Detected RIL version " + version);
     debug("RILQUIRKS_V5_LEGACY is " + RILQUIRKS_V5_LEGACY);
   }
 
   this.initRILState();
   // Always ensure that we are not in emergency callback mode when init.
@@ -7078,17 +7078,17 @@ let GsmPDUHelper = {
   },
 
   /**
    * Read Alpha Id and Dialling number from TS TS 151.011 clause 10.5.1
    *
    * @param recordSize  The size of linear fixed record.
    */
   readAlphaIdDiallingNumber: function readAlphaIdDiallingNumber(recordSize) {
-    let length = Buf.readUint32();
+    let length = Buf.readInt32();
 
     let alphaLen = recordSize - ADN_FOOTER_SIZE_BYTES;
     let alphaId = this.readAlphaIdentifier(alphaLen);
 
     let number = this.readNumberWithLength();
 
     // Skip 2 unused octets, CCP and EXT1.
     Buf.seekIncoming(2 * Buf.PDU_HEX_OCTET_SIZE);
@@ -7109,17 +7109,17 @@ let GsmPDUHelper = {
    * @param alphaId     Alpha Identifier to be written.
    * @param number      Dialling Number to be written.
    */
   writeAlphaIdDiallingNumber: function writeAlphaIdDiallingNumber(recordSize,
                                                                   alphaId,
                                                                   number) {
     // Write String length
     let strLen = recordSize * 2;
-    Buf.writeUint32(strLen);
+    Buf.writeInt32(strLen);
 
     let alphaLen = recordSize - ADN_FOOTER_SIZE_BYTES;
     this.writeAlphaIdentifier(alphaLen, alphaId);
     this.writeNumberWithLength(number);
 
     // Write unused octets 0xff, CCP and EXT1.
     this.writeHexOctet(0xff);
     this.writeHexOctet(0xff);
@@ -7666,17 +7666,17 @@ let GsmPDUHelper = {
   processReceivedSms: function processReceivedSms(length) {
     if (!length) {
       if (DEBUG) debug("Received empty SMS!");
       return [null, PDU_FCS_UNSPECIFIED];
     }
 
     // An SMS is a string, but we won't read it as such, so let's read the
     // string length and then defer to PDU parsing helper.
-    let messageStringLength = Buf.readUint32();
+    let messageStringLength = Buf.readInt32();
     if (DEBUG) debug("Got new SMS, length " + messageStringLength);
     let message = this.readMessage();
     if (DEBUG) debug("Got new SMS: " + JSON.stringify(message));
 
     // Read string delimiters. See Buf.readString().
     Buf.readStringDelimiter(length);
 
     // Determine result
@@ -7865,17 +7865,17 @@ let GsmPDUHelper = {
                          3 + // PID, DCS, UDL
                          userDataLengthInOctets;
     if (validity) {
       //TODO: add more to pduOctetLength
     }
 
     // Start the string. Since octets are represented in hex, we will need
     // twice as many characters as octets.
-    Buf.writeUint32(pduOctetLength * 2);
+    Buf.writeInt32(pduOctetLength * 2);
 
     // - PDU-TYPE-
 
     // +--------+----------+---------+---------+--------+---------+
     // | RP (1) | UDHI (1) | SRR (1) | VPF (2) | RD (1) | MTI (2) |
     // +--------+----------+---------+---------+--------+---------+
     // RP:    0   Reply path parameter is not set
     //        1   Reply path parameter is set
@@ -8517,21 +8517,21 @@ let CdmaPDUHelper = {
 
     encodeResult = null;
   },
 
   /**
    * Data writters
    */
   writeInt: function writeInt(value) {
-    Buf.writeUint32(value);
+    Buf.writeInt32(value);
   },
 
   writeByte: function writeByte(value) {
-    Buf.writeUint32(value & 0xFF);
+    Buf.writeInt32(value & 0xFF);
   },
 
   /**
    * Transform GSM DCS to CDMA encoding.
    */
   gsmDcsToCdmaEncoding: function gsmDcsToCdmaEncoding(encoding) {
     switch (encoding) {
       case PDU_DCS_MSG_CODING_7BITS_ALPHABET:
@@ -8852,21 +8852,21 @@ let CdmaPDUHelper = {
 
     return [message, PDU_FCS_OK];
   },
 
   /**
    * Data readers
    */
   readInt: function readInt() {
-    return Buf.readUint32();
+    return Buf.readInt32();
   },
 
   readByte: function readByte() {
-    return (Buf.readUint32() & 0xFF);
+    return (Buf.readInt32() & 0xFF);
   },
 
   /**
    * Decode CDMA address data into address string
    *
    * @see 3GGP2 C.S0015-B 2.0, 3.4.3.3 Address Parameters
    *
    * Required key in addrInfo
@@ -9329,112 +9329,112 @@ let CdmaPDUHelper = {
     return result;
   },
 
   /**
    * Decode information record parcel.
    */
   decodeInformationRecord: function cdma_decodeInformationRecord() {
     let record = {};
-    let numOfRecords = Buf.readUint32();
+    let numOfRecords = Buf.readInt32();
 
     let type;
     for (let i = 0; i < numOfRecords; i++) {
-      type = Buf.readUint32();
+      type = Buf.readInt32();
 
       switch (type) {
         /*
          * Every type is encaped by ril, except extended display
          */
         case PDU_CDMA_INFO_REC_TYPE_DISPLAY:
           record.display = Buf.readString();
           break;
         case PDU_CDMA_INFO_REC_TYPE_CALLED_PARTY_NUMBER:
           record.calledNumber = {};
           record.calledNumber.number = Buf.readString();
-          record.calledNumber.type = Buf.readUint32();
-          record.calledNumber.plan = Buf.readUint32();
-          record.calledNumber.pi = Buf.readUint32();
-          record.calledNumber.si = Buf.readUint32();
+          record.calledNumber.type = Buf.readInt32();
+          record.calledNumber.plan = Buf.readInt32();
+          record.calledNumber.pi = Buf.readInt32();
+          record.calledNumber.si = Buf.readInt32();
           break;
         case PDU_CDMA_INFO_REC_TYPE_CALLING_PARTY_NUMBER:
           record.callingNumber = {};
           record.callingNumber.number = Buf.readString();
-          record.callingNumber.type = Buf.readUint32();
-          record.callingNumber.plan = Buf.readUint32();
-          record.callingNumber.pi = Buf.readUint32();
-          record.callingNumber.si = Buf.readUint32();
+          record.callingNumber.type = Buf.readInt32();
+          record.callingNumber.plan = Buf.readInt32();
+          record.callingNumber.pi = Buf.readInt32();
+          record.callingNumber.si = Buf.readInt32();
           break;
         case PDU_CDMA_INFO_REC_TYPE_CONNECTED_NUMBER:
           record.connectedNumber = {};
           record.connectedNumber.number = Buf.readString();
-          record.connectedNumber.type = Buf.readUint32();
-          record.connectedNumber.plan = Buf.readUint32();
-          record.connectedNumber.pi = Buf.readUint32();
-          record.connectedNumber.si = Buf.readUint32();
+          record.connectedNumber.type = Buf.readInt32();
+          record.connectedNumber.plan = Buf.readInt32();
+          record.connectedNumber.pi = Buf.readInt32();
+          record.connectedNumber.si = Buf.readInt32();
           break;
         case PDU_CDMA_INFO_REC_TYPE_SIGNAL:
           record.signal = {};
-          record.signal.present = Buf.readUint32();
-          record.signal.type = Buf.readUint32();
-          record.signal.alertPitch = Buf.readUint32();
-          record.signal.signal = Buf.readUint32();
+          record.signal.present = Buf.readInt32();
+          record.signal.type = Buf.readInt32();
+          record.signal.alertPitch = Buf.readInt32();
+          record.signal.signal = Buf.readInt32();
           break;
         case PDU_CDMA_INFO_REC_TYPE_REDIRECTING_NUMBER:
           record.redirect = {};
           record.redirect.number = Buf.readString();
-          record.redirect.type = Buf.readUint32();
-          record.redirect.plan = Buf.readUint32();
-          record.redirect.pi = Buf.readUint32();
-          record.redirect.si = Buf.readUint32();
-          record.redirect.reason = Buf.readUint32();
+          record.redirect.type = Buf.readInt32();
+          record.redirect.plan = Buf.readInt32();
+          record.redirect.pi = Buf.readInt32();
+          record.redirect.si = Buf.readInt32();
+          record.redirect.reason = Buf.readInt32();
           break;
         case PDU_CDMA_INFO_REC_TYPE_LINE_CONTROL:
           record.lineControl = {};
-          record.lineControl.polarityIncluded = Buf.readUint32();
-          record.lineControl.toggle = Buf.readUint32();
-          record.lineControl.recerse = Buf.readUint32();
-          record.lineControl.powerDenial = Buf.readUint32();
+          record.lineControl.polarityIncluded = Buf.readInt32();
+          record.lineControl.toggle = Buf.readInt32();
+          record.lineControl.recerse = Buf.readInt32();
+          record.lineControl.powerDenial = Buf.readInt32();
           break;
         case PDU_CDMA_INFO_REC_TYPE_EXTENDED_DISPLAY:
-          let length = Buf.readUint32();
+          let length = Buf.readInt32();
           /*
            * Extended display is still in format defined in
            * C.S0005-F v1.0, 3.7.5.16
            */
           record.extendedDisplay = {};
 
-          let headerByte = Buf.readUint32();
+          let headerByte = Buf.readInt32();
           length--;
           // Based on spec, headerByte must be 0x80 now
           record.extendedDisplay.indicator = (headerByte >> 7);
           record.extendedDisplay.type = (headerByte & 0x7F);
           record.extendedDisplay.records = [];
 
           while (length > 0) {
             let display = {};
 
-            display.tag = Buf.readUint32();
+            display.tag = Buf.readInt32();
             length--;
             if (display.tag !== INFO_REC_EXTENDED_DISPLAY_BLANK &&
                 display.tag !== INFO_REC_EXTENDED_DISPLAY_SKIP) {
               display.content = Buf.readString();
               length -= (display.content.length + 1);
             }
 
             record.extendedDisplay.records.push(display);
           }
           break;
         case PDU_CDMA_INFO_REC_TYPE_T53_CLIR:
-          record.cause = Buf.readUint32();
+          record.cause = Buf.readInt32();
           break;
         case PDU_CDMA_INFO_REC_TYPE_T53_AUDIO_CONTROL:
           record.audioControl = {};
-          record.audioControl.upLink = Buf.readUint32();
-          record.audioControl.downLink = Buf.readUint32();
+          record.audioControl.upLink = Buf.readInt32();
+          record.audioControl.downLink = Buf.readInt32();
           break;
         case PDU_CDMA_INFO_REC_TYPE_T53_RELEASE:
           // Fall through
         default:
           throw new Error("UNSOLICITED_CDMA_INFO_REC(), Unsupported information record type " + record.type + "\n");
       }
     }
 
@@ -10881,17 +10881,17 @@ let ICCIOHelper = {
     let func = this[options.command];
     func.call(this, options);
   },
 
   /**
    * Process a ICC_COMMAND_GET_RESPONSE type command for REQUEST_SIM_IO.
    */
   processICCIOGetResponse: function processICCIOGetResponse(options) {
-    let strLen = Buf.readUint32();
+    let strLen = Buf.readInt32();
 
     // The format is from TS 51.011, clause 9.2.1
 
     // Skip RFU, data[0] data[1]
     Buf.seekIncoming(2 * Buf.PDU_HEX_OCTET_SIZE);
 
     // File size, data[2], data[3]
     options.fileSize = (GsmPDUHelper.readHexOctet() << 8) |
@@ -11018,17 +11018,17 @@ let ICCRecordHelper = {
   },
 
   /**
    * Read EF_phase.
    * This EF is only available in SIM.
    */
   readICCPhase: function readICCPhase() {
     function callback() {
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
 
       let phase = GsmPDUHelper.readHexOctet();
       // If EF_phase is coded '03' or greater, an ME supporting STK shall
       // perform the PROFILE DOWNLOAD procedure.
       if (phase >= ICC_PHASE_2_PROFILE_DOWNLOAD_REQUIRED) {
         RIL.sendStkTerminalProfile(STK_SUPPORTED_TERMINAL_PROFILE);
       }
 
@@ -11039,17 +11039,17 @@ let ICCRecordHelper = {
                                    callback: callback.bind(this)});
   },
 
   /**
    * Read the ICCID.
    */
   readICCID: function readICCID() {
     function callback() {
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
       let octetLen = strLen / 2;
       RIL.iccInfo.iccid = GsmPDUHelper.readSwappedNibbleBcdString(octetLen);
       Buf.readStringDelimiter(strLen);
 
       if (DEBUG) debug("ICCID: " + RIL.iccInfo.iccid);
       if (RIL.iccInfo.iccid) {
         ICCUtilsHelper.handleICCInfoChange();
       }
@@ -11079,17 +11079,17 @@ let ICCRecordHelper = {
                                    callback: callback.bind(this)});
   },
 
   /**
    * Read the AD (Administrative Data) from the ICC.
    */
   readAD: function readAD() {
     function callback() {
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
       // Each octet is encoded into two chars.
       let octetLen = strLen / 2;
       let ad = GsmPDUHelper.readHexOctetArray(octetLen);
       Buf.readStringDelimiter(strLen);
 
       if (DEBUG) {
         let str = "";
         for (let i = 0; i < ad.length; i++) {
@@ -11112,17 +11112,17 @@ let ICCRecordHelper = {
                                    callback: callback.bind(this)});
   },
 
   /**
    * Read the SPN (Service Provider Name) from the ICC.
    */
   readSPN: function readSPN() {
     function callback() {
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
       // Each octet is encoded into two chars.
       let octetLen = strLen / 2;
       let spnDisplayCondition = GsmPDUHelper.readHexOctet();
       // Minus 1 because the first octet is used to store display condition.
       let spn = GsmPDUHelper.readAlphaIdentifier(octetLen - 1);
       Buf.readStringDelimiter(strLen);
 
       if (DEBUG) {
@@ -11140,17 +11140,17 @@ let ICCRecordHelper = {
                                    callback: callback.bind(this)});
   },
 
   /**
    * Read the (U)SIM Service Table from the ICC.
    */
   readSST: function readSST() {
     function callback() {
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
       // Each octet is encoded into two chars.
       let octetLen = strLen / 2;
       let sst = GsmPDUHelper.readHexOctetArray(octetLen);
       Buf.readStringDelimiter(strLen);
       RIL.iccInfoPrivate.sst = sst;
       if (DEBUG) {
         let str = "";
         for (let i = 0; i < sst.length; i++) {
@@ -11310,17 +11310,17 @@ let ICCRecordHelper = {
   /**
    * Read USIM Phonebook.
    *
    * @param onsuccess   Callback to be called when success.
    * @param onerror     Callback to be called when error.
    */
   readPBR: function readPBR(onsuccess, onerror) {
     function callback(options) {
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
       let octetLen = strLen / 2, readLen = 0;
 
       let pbrTlvs = [];
       while (readLen < octetLen) {
         let tag = GsmPDUHelper.readHexOctet();
         if (tag == 0xff) {
           readLen++;
           Buf.seekIncoming((octetLen - readLen) * Buf.PDU_HEX_OCTET_SIZE);
@@ -11375,17 +11375,17 @@ let ICCRecordHelper = {
    *
    * @param fileId       EF id of the IAP.
    * @param recordNumber The number of the record shall be loaded.
    * @param onsuccess    Callback to be called when success.
    * @param onerror      Callback to be called when error.
    */
   readIAP: function readIAP(fileId, recordNumber, onsuccess, onerror) {
     function callback(options) {
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
       let octetLen = strLen / 2;
       this._iapRecordSize = options.recordSize;
 
       let iap = GsmPDUHelper.readHexOctetArray(octetLen);
       Buf.readStringDelimiter(strLen);
 
       if (onsuccess) {
         onsuccess(iap);
@@ -11409,17 +11409,17 @@ let ICCRecordHelper = {
    * @param iap          The IAP value to be written.
    * @param onsuccess    Callback to be called when success.
    * @param onerror      Callback to be called when error.
    */
   updateIAP: function updateIAP(fileId, recordNumber, iap, onsuccess, onerror) {
     let dataWriter = function dataWriter(recordSize) {
       // Write String length
       let strLen = recordSize * 2;
-      Buf.writeUint32(strLen);
+      Buf.writeInt32(strLen);
 
       for (let i = 0; i < iap.length; i++) {
         GsmPDUHelper.writeHexOctet(iap[i]);
       }
 
       Buf.writeStringDelimiter(strLen);
     }.bind(this);
 
@@ -11443,17 +11443,17 @@ let ICCRecordHelper = {
    * @param fileId       EF id of the EMAIL.
    * @param fileType     The type of the EMAIL, one of the ICC_USIM_TYPE* constants.
    * @param recordNumber The number of the record shall be loaded.
    * @param onsuccess    Callback to be called when success.
    * @param onerror      Callback to be called when error.
    */
   readEmail: function readEmail(fileId, fileType, recordNumber, onsuccess, onerror) {
     function callback(options) {
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
       let octetLen = strLen / 2;
       let email = null;
       this._emailRecordSize = options.recordSize;
 
       // Read contact's email
       //
       // | Byte     | Description                 | Length | M/O
       // | 1 ~ X    | E-mail Address              |   X    |  M
@@ -11497,17 +11497,17 @@ let ICCRecordHelper = {
    * @param onerror      Callback to be called when error.
    */
   updateEmail: function updateEmail(pbr, recordNumber, email, adnRecordId, onsuccess, onerror) {
     let fileId = pbr[USIM_PBR_EMAIL].fileId;
     let fileType = pbr[USIM_PBR_EMAIL].fileType;
     let dataWriter = function dataWriter(recordSize) {
       // Write String length
       let strLen = recordSize * 2;
-      Buf.writeUint32(strLen);
+      Buf.writeInt32(strLen);
 
       if (fileType == ICC_USIM_TYPE1_TAG) {
         GsmPDUHelper.writeStringTo8BitUnpacked(recordSize, email);
       } else {
         GsmPDUHelper.writeStringTo8BitUnpacked(recordSize - 2, email);
         GsmPDUHelper.writeHexOctet(pbr.adn.sfi || 0xff);
         GsmPDUHelper.writeHexOctet(adnRecordId);
       }
@@ -11535,17 +11535,17 @@ let ICCRecordHelper = {
    * @param fileId       EF id of the ANR.
    * @param fileType     One of the ICC_USIM_TYPE* constants.
    * @param recordNumber The number of the record shall be loaded.
    * @param onsuccess    Callback to be called when success.
    * @param onerror      Callback to be called when error.
    */
   readANR: function readANR(fileId, fileType, recordNumber, onsuccess, onerror) {
     function callback(options) {
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
       let number = null;
       this._anrRecordSize = options.recordSize;
 
       // Skip EF_AAS Record ID.
       Buf.seekIncoming(1 * Buf.PDU_HEX_OCTET_SIZE);
 
       number = GsmPDUHelper.readNumberWithLength();
 
@@ -11584,17 +11584,17 @@ let ICCRecordHelper = {
    * @param onerror      Callback to be called when error.
    */
   updateANR: function updateANR(pbr, recordNumber, number, adnRecordId, onsuccess, onerror) {
     let fileId = pbr[USIM_PBR_ANR0].fileId;
     let fileType = pbr[USIM_PBR_ANR0].fileType;
     let dataWriter = function dataWriter(recordSize) {
       // Write String length
       let strLen = recordSize * 2;
-      Buf.writeUint32(strLen);
+      Buf.writeInt32(strLen);
 
       // EF_AAS record Id. Unused for now.
       GsmPDUHelper.writeHexOctet(0xff);
 
       GsmPDUHelper.writeNumberWithLength(number);
 
       // Write unused octets 0xff, CCP and EXT1.
       GsmPDUHelper.writeHexOctet(0xff);
@@ -11619,17 +11619,17 @@ let ICCRecordHelper = {
   /**
    * Read the SPDI (Service Provider Display Information) from the ICC.
    *
    * See TS 131.102 section 4.2.66 for USIM and TS 51.011 section 10.3.50
    * for SIM.
    */
   readSPDI: function readSPDI() {
     function callback() {
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
       let octetLen = strLen / 2;
       let readLen = 0;
       let endLoop = false;
       RIL.iccInfoPrivate.SPDI = null;
       while ((readLen < octetLen) && !endLoop) {
         let tlvTag = GsmPDUHelper.readHexOctet();
         let tlvLen = GsmPDUHelper.readHexOctet();
         readLen += 2; // For tag and length fields.
@@ -11663,17 +11663,17 @@ let ICCRecordHelper = {
 
     // PLMN List is Servive 51 in USIM, EF_SPDI
     ICCIOHelper.loadTransparentEF({fileId: ICC_EF_SPDI,
                                    callback: callback.bind(this)});
   },
 
   _readCbmiHelper: function _readCbmiHelper(which) {
     function callback() {
-      let strLength = Buf.readUint32();
+      let strLength = Buf.readInt32();
 
       // Each Message Identifier takes two octets and each octet is encoded
       // into two chars.
       let numIds = strLength / 4, list = null;
       if (numIds) {
         list = [];
         for (let i = 0, id; i < numIds; i++) {
           id = GsmPDUHelper.readHexOctet() << 8 | GsmPDUHelper.readHexOctet();
@@ -11728,17 +11728,17 @@ let ICCRecordHelper = {
   /**
    * Read EFcbmir (Cell Broadcast Message Identifier Range selection)
    *
    * @see 3GPP TS 31.102 v110.02.0 section 4.2.22 EFcbmir
    * @see 3GPP TS 51.011 v5.0.0 section 10.3.28 EFcbmir
    */
   readCBMIR: function readCBMIR() {
     function callback() {
-      let strLength = Buf.readUint32();
+      let strLength = Buf.readInt32();
 
       // Each Message Identifier range takes four octets and each octet is
       // encoded into two chars.
       let numIds = strLength / 8, list = null;
       if (numIds) {
         list = [];
         for (let i = 0, from, to; i < numIds; i++) {
           // `Bytes one and two of each range identifier equal the lower value
@@ -11777,17 +11777,17 @@ let ICCRecordHelper = {
    * Read OPL (Operator PLMN List) from USIM.
    *
    * See 3GPP TS 31.102 Sec. 4.2.59 for USIM
    *     3GPP TS 51.011 Sec. 10.3.42 for SIM.
    */
   readOPL: function readOPL() {
     let opl = [];
     function callback(options) {
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
       // The first 7 bytes are LAI (for UMTS) and the format of LAI is defined
       // in 3GPP TS 23.003, Sec 4.1
       //    +-------------+---------+
       //    | Octet 1 - 3 | MCC/MNC |
       //    +-------------+---------+
       //    | Octet 4 - 7 |   LAC   |
       //    +-------------+---------+
       let mccMnc = [GsmPDUHelper.readHexOctet(),
@@ -11847,17 +11847,17 @@ let ICCRecordHelper = {
    * Read PNN (PLMN Network Name) from USIM.
    *
    * See 3GPP TS 31.102 Sec. 4.2.58 for USIM
    *     3GPP TS 51.011 Sec. 10.3.41 for SIM.
    */
   readPNN: function readPNN() {
     function callback(options) {
       let pnnElement;
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
       let octetLen = strLen / 2;
       let readLen = 0;
 
       while (readLen < octetLen) {
         let tlvTag = GsmPDUHelper.readHexOctet();
 
         if (tlvTag == 0xFF) {
           // Unused byte
@@ -11913,17 +11913,17 @@ let ICCRecordHelper = {
    * Find free record id.
    *
    * @param fileId      EF id.
    * @param onsuccess   Callback to be called when success.
    * @param onerror     Callback to be called when error.
    */
   findFreeRecordId: function findFreeRecordId(fileId, onsuccess, onerror) {
     function callback(options) {
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
       let octetLen = strLen / 2;
       let readLen = 0;
 
       while (readLen < octetLen) {
         let octet = GsmPDUHelper.readHexOctet();
         readLen++;
         if (octet != 0xff) {
           break;
@@ -12983,17 +12983,17 @@ let RuimRecordHelper = {
   },
 
   /**
    * Read CDMAHOME for CSIM.
    * See 3GPP2 C.S0023 Sec. 3.4.8.
    */
   readCDMAHome: function readCDMAHome() {
     function callback(options) {
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
       let tempOctet = GsmPDUHelper.readHexOctet();
       cdmaHomeSystemId.push(((GsmPDUHelper.readHexOctet() & 0x7f) << 8) | tempOctet);
       tempOctet = GsmPDUHelper.readHexOctet();
       cdmaHomeNetworkId.push(((GsmPDUHelper.readHexOctet() & 0xff) << 8) | tempOctet);
 
       // Consuming the last octet: band class.
       Buf.seekIncoming(Buf.PDU_HEX_OCTET_SIZE);
 
@@ -13018,17 +13018,17 @@ let RuimRecordHelper = {
   },
 
   /**
    * Read CDMA Service Table.
    * See 3GPP2 C.S0023 Sec. 3.4.18
    */
   readCST: function readCST() {
     function callback() {
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
       // Each octet is encoded into two chars.
       RIL.iccInfoPrivate.cst = GsmPDUHelper.readHexOctetArray(strLen / 2);
       Buf.readStringDelimiter(strLen);
 
       if (DEBUG) {
         let str = "";
         for (let i = 0; i < RIL.iccInfoPrivate.cst.length; i++) {
           str += RIL.iccInfoPrivate.cst[i] + ", ";
@@ -13042,17 +13042,17 @@ let RuimRecordHelper = {
       }
     }
     ICCIOHelper.loadTransparentEF({fileId: ICC_EF_CSIM_CST,
                                    callback: callback.bind(this)});
   },
 
   readSPN: function readSPN() {
     function callback() {
-      let strLen = Buf.readUint32();
+      let strLen = Buf.readInt32();
       let octetLen = strLen / 2;
       let displayCondition = GsmPDUHelper.readHexOctet();
       let codingScheme = GsmPDUHelper.readHexOctet();
       // Skip one octet: language indicator.
       Buf.seekIncoming(Buf.PDU_HEX_OCTET_SIZE);
       let readLen = 3;
 
       // SPN String ends up with 0xff.
--- a/dom/system/gonk/tests/header_helpers.js
+++ b/dom/system/gonk/tests/header_helpers.js
@@ -104,17 +104,17 @@ function newIncomingParcel(fakeParcelSiz
   let bytes = new Uint8Array(buffer);
 
   let writeIndex = 0;
   function writeUint8(value) {
     bytes[writeIndex] = value;
     ++writeIndex;
   }
 
-  function writeUint32(value) {
+  function writeInt32(value) {
     writeUint8(value & 0xff);
     writeUint8((value >> 8) & 0xff);
     writeUint8((value >> 16) & 0xff);
     writeUint8((value >> 24) & 0xff);
   }
 
   function writeParcelSize(value) {
     writeUint8((value >> 24) & 0xff);
@@ -123,18 +123,18 @@ function newIncomingParcel(fakeParcelSiz
     writeUint8(value & 0xff);
   }
 
   if (fakeParcelSize < 0) {
     fakeParcelSize = realParcelSize;
   }
   writeParcelSize(fakeParcelSize);
 
-  writeUint32(response);
-  writeUint32(request);
+  writeInt32(response);
+  writeInt32(request);
 
   // write parcel data
   for (let ii = 0; ii < data.length; ++ii) {
     writeUint8(data[ii]);
   }
 
   return bytes;
 }
--- a/dom/system/gonk/tests/test_ril_worker_barring_password.js
+++ b/dom/system/gonk/tests/test_ril_worker_barring_password.js
@@ -37,20 +37,20 @@ function newUint8Worker() {
 
 add_test(function test_change_call_barring_password() {
   let worker = newUint8Worker();
   let buf = worker.Buf;
 
   function do_test(facility, pin, newPin) {
     buf.sendParcel = function fakeSendParcel () {
       // Request Type.
-      do_check_eq(this.readUint32(), REQUEST_CHANGE_BARRING_PASSWORD);
+      do_check_eq(this.readInt32(), REQUEST_CHANGE_BARRING_PASSWORD);
 
       // Token : we don't care.
-      this.readUint32();
+      this.readInt32();
 
       let parcel = this.readStringList();
       do_check_eq(parcel.length, 3);
       do_check_eq(parcel[0], facility);
       do_check_eq(parcel[1], pin);
       do_check_eq(parcel[2], newPin);
     };
 
--- a/dom/system/gonk/tests/test_ril_worker_buf.js
+++ b/dom/system/gonk/tests/test_ril_worker_buf.js
@@ -46,17 +46,17 @@ function add_test_incoming_parcel(parcel
   });
 }
 
 // Test normal parcel handling.
 add_test_incoming_parcel(null,
   function test_normal_parcel_handling(worker) {
     do_check_throws(function normal_handler() {
       // reads exactly the same size, should not throw anything.
-      worker.Buf.readUint32();
+      worker.Buf.readInt32();
     });
   }
 );
 
 // Test parcel under read.
 add_test_incoming_parcel(null,
   function test_parcel_under_read(worker) {
     do_check_throws(function under_read_handler() {
--- a/dom/system/gonk/tests/test_ril_worker_cdma_info_rec.js
+++ b/dom/system/gonk/tests/test_ril_worker_cdma_info_rec.js
@@ -26,17 +26,17 @@ function newWorkerWithParcel(parcelBuf) 
   worker.Buf.readUint8 = function () {
     return buf[index++];
   };
 
   worker.Buf.readUint16 = function () {
     return buf[index++];
   };
 
-  worker.Buf.readUint32 = function () {
+  worker.Buf.readInt32 = function () {
     return buf[index++];
   };
 
   return worker;
 }
 
 // Test CDMA information record decoder.
 
--- a/dom/system/gonk/tests/test_ril_worker_cf.js
+++ b/dom/system/gonk/tests/test_ril_worker_cf.js
@@ -101,17 +101,17 @@ add_test(function test_queryCallForwardS
   let worker = workerHelper.worker;
 
   worker.RIL.setCallForward = function fakeSetCallForward(options) {
     worker.RIL[REQUEST_SET_CALL_FORWARD](0, {
       rilRequestError: ERROR_SUCCESS
     });
   };
 
-  worker.Buf.readUint32 = function fakeReadUint32() {
+  worker.Buf.readInt32 = function fakeReadUint32() {
     return worker.Buf.int32Array.pop();
   };
 
   worker.Buf.readString = function fakeReadString() {
     return "+34666222333";
   };
 
   worker.RIL.queryCallForwardStatus = function fakeQueryCallForward(options) {
--- a/dom/system/gonk/tests/test_ril_worker_clip.js
+++ b/dom/system/gonk/tests/test_ril_worker_clip.js
@@ -25,17 +25,17 @@ function _getWorker() {
     }
   };
 }
 
 add_test(function test_queryCLIP_provisioned() {
   let workerHelper = _getWorker();
   let worker = workerHelper.worker;
 
-  worker.Buf.readUint32 = function fakeReadUint32() {
+  worker.Buf.readInt32 = function fakeReadUint32() {
     return worker.Buf.int32Array.pop();
   };
 
   worker.RIL.queryCLIP = function fakeQueryCLIP(options) {
     worker.Buf.int32Array = [
       1,  // CLIP provisioned.
       1   // Length.
     ];
@@ -53,17 +53,17 @@ add_test(function test_queryCLIP_provisi
   do_check_eq(postedMessage.provisioned, 1);
   run_next_test();
 });
 
 add_test(function test_getCLIP_error_generic_failure_invalid_length() {
   let workerHelper = _getWorker();
   let worker = workerHelper.worker;
 
-  worker.Buf.readUint32 = function fakeReadUint32() {
+  worker.Buf.readInt32 = function fakeReadUint32() {
     return worker.Buf.int32Array.pop();
   };
 
   worker.RIL.queryCLIP = function fakeQueryCLIP(options) {
     worker.Buf.int32Array = [
       1,  // CLIP provisioned.
       0   // Length.
     ];
--- a/dom/system/gonk/tests/test_ril_worker_clir.js
+++ b/dom/system/gonk/tests/test_ril_worker_clir.js
@@ -80,17 +80,17 @@ add_test(function test_setCLIR_generic_f
 
   run_next_test();
 });
 
 add_test(function test_getCLIR_n0_m1() {
   let workerHelper = _getWorker();
   let worker = workerHelper.worker;
 
-  worker.Buf.readUint32 = function fakeReadUint32() {
+  worker.Buf.readInt32 = function fakeReadUint32() {
     return worker.Buf.int32Array.pop();
   };
 
   worker.RIL.getCLIR = function fakeGetCLIR(options) {
     worker.Buf.int32Array = [
       1,  // Presentation indicator is used according to the subscription
           // of the CLIR service.
       0,  // CLIR provisioned in permanent mode.
@@ -112,17 +112,17 @@ add_test(function test_getCLIR_n0_m1() {
   do_check_eq(postedMessage.m, 1);
   run_next_test();
 });
 
 add_test(function test_getCLIR_error_generic_failure_invalid_length() {
   let workerHelper = _getWorker();
   let worker = workerHelper.worker;
 
-  worker.Buf.readUint32 = function fakeReadUint32() {
+  worker.Buf.readInt32 = function fakeReadUint32() {
     return worker.Buf.int32Array.pop();
   };
 
   worker.RIL.getCLIR = function fakeGetCLIR(options) {
     worker.Buf.int32Array = [
       1,  // Presentation indicator is used according to the subscription
           // of the CLIR service.
       0,  // CLIR provisioned in permanent mode.
--- a/dom/system/gonk/tests/test_ril_worker_cw.js
+++ b/dom/system/gonk/tests/test_ril_worker_cw.js
@@ -69,17 +69,17 @@ add_test(function test_setCallWaiting_ge
 
   run_next_test();
 });
 
 add_test(function test_queryCallWaiting_success_enabled_true() {
   let workerHelper = _getWorker();
   let worker = workerHelper.worker;
 
-  worker.Buf.readUint32 = function fakeReadUint32() {
+  worker.Buf.readInt32 = function fakeReadUint32() {
     return worker.Buf.int32Array.pop();
   };
 
   worker.RIL.queryCallWaiting = function fakeQueryCallWaiting(options) {
     worker.Buf.int32Array = [
       1,  // serviceClass
       1,  // enabled
       1   // length
@@ -99,17 +99,17 @@ add_test(function test_queryCallWaiting_
   do_check_true(postedMessage.enabled);
   run_next_test();
 });
 
 add_test(function test_queryCallWaiting_success_enabled_false() {
   let workerHelper = _getWorker();
   let worker = workerHelper.worker;
 
-  worker.Buf.readUint32 = function fakeReadUint32() {
+  worker.Buf.readInt32 = function fakeReadUint32() {
     return worker.Buf.int32Array.pop();
   };
 
   worker.RIL.queryCallWaiting = function fakeQueryCallWaiting(options) {
     worker.Buf.int32Array = [
       1,  // serviceClass
       0,  // enabled
       1   // length
--- a/dom/system/gonk/tests/test_ril_worker_icc.js
+++ b/dom/system/gonk/tests/test_ril_worker_icc.js
@@ -487,38 +487,38 @@ add_test(function test_is_gsm_8bit_alpha
  */
 add_test(function test_icc_get_card_lock_state_fdn() {
   let worker = newUint8Worker();
   let ril = worker.RIL;
   let buf = worker.Buf;
 
   buf.sendParcel = function () {
     // Request Type.
-    do_check_eq(this.readUint32(), REQUEST_QUERY_FACILITY_LOCK)
+    do_check_eq(this.readInt32(), REQUEST_QUERY_FACILITY_LOCK)
 
     // Token : we don't care.
-    this.readUint32();
+    this.readInt32();
 
     // String Array Length.
-    do_check_eq(this.readUint32(), worker.RILQUIRKS_V5_LEGACY ? 3 : 4);
+    do_check_eq(this.readInt32(), worker.RILQUIRKS_V5_LEGACY ? 3 : 4);
 
     // Facility.
     do_check_eq(this.readString(), ICC_CB_FACILITY_FDN);
 
     // Password.
     do_check_eq(this.readString(), "");
 
     // Service class.
     do_check_eq(this.readString(), (ICC_SERVICE_CLASS_VOICE |
                                     ICC_SERVICE_CLASS_DATA  |
                                     ICC_SERVICE_CLASS_FAX).toString());
 
     if (!worker.RILQUIRKS_V5_LEGACY) {
       // AID. Ignore because it's from modem.
-      this.readUint32();
+      this.readInt32();
     }
 
     run_next_test();
   };
 
   ril.iccGetCardLockState({lockType: "fdn"});
 });
 
@@ -754,17 +754,17 @@ add_test(function test_read_pbr() {
   let io     = worker.ICCIOHelper;
 
   io.loadLinearFixedEF = function fakeLoadLinearFixedEF(options)  {
     let pbr_1 = [
       0xa8, 0x05, 0xc0, 0x03, 0x4f, 0x3a, 0x01
     ];
 
     // Write data size
-    buf.writeUint32(pbr_1.length * 2);
+    buf.writeInt32(pbr_1.length * 2);
 
     // Write pbr
     for (let i = 0; i < pbr_1.length; i++) {
       helper.writeHexOctet(pbr_1[i]);
     }
 
     // Write string delimiter
     buf.writeStringDelimiter(pbr_1.length * 2);
@@ -815,17 +815,17 @@ add_test(function test_read_email() {
   io.loadLinearFixedEF = function fakeLoadLinearFixedEF(options)  {
     let email_1 = [
       0x65, 0x6D, 0x61, 0x69, 0x6C,
       0x00, 0x6D, 0x6F, 0x7A, 0x69,
       0x6C, 0x6C, 0x61, 0x2E, 0x63,
       0x6F, 0x6D, 0x02, 0x23];
 
     // Write data size
-    buf.writeUint32(email_1.length * 2);
+    buf.writeInt32(email_1.length * 2);
 
     // Write email
     for (let i = 0; i < email_1.length; i++) {
       helper.writeHexOctet(email_1[i]);
     }
 
     // Write string delimiter
     buf.writeStringDelimiter(email_1.length * 2);
@@ -883,59 +883,59 @@ add_test(function test_update_email() {
     ril.iccIO(options);
   };
 
   function do_test(pbr, expectedEmail, expectedAdnRecordId) {
     buf.sendParcel = function () {
       count++;
 
       // Request Type.
-      do_check_eq(this.readUint32(), REQUEST_SIM_IO);
+      do_check_eq(this.readInt32(), REQUEST_SIM_IO);
 
       // Token : we don't care
-      this.readUint32();
+      this.readInt32();
 
       // command.
-      do_check_eq(this.readUint32(), ICC_COMMAND_UPDATE_RECORD);
+      do_check_eq(this.readInt32(), ICC_COMMAND_UPDATE_RECORD);
 
       // fileId.
-      do_check_eq(this.readUint32(), fileId);
+      do_check_eq(this.readInt32(), fileId);
 
       // pathId.
       do_check_eq(this.readString(),
                   EF_PATH_MF_SIM + EF_PATH_DF_TELECOM + EF_PATH_DF_PHONEBOOK);
 
       // p1.
-      do_check_eq(this.readUint32(), recordNumber);
+      do_check_eq(this.readInt32(), recordNumber);
 
       // p2.
-      do_check_eq(this.readUint32(), READ_RECORD_ABSOLUTE_MODE);
+      do_check_eq(this.readInt32(), READ_RECORD_ABSOLUTE_MODE);
 
       // p3.
-      do_check_eq(this.readUint32(), recordSize);
+      do_check_eq(this.readInt32(), recordSize);
 
       // data.
-      let strLen = this.readUint32();
+      let strLen = this.readInt32();
       let email;
       if (pbr.email.fileType === ICC_USIM_TYPE1_TAG) {
         email = pduHelper.read8BitUnpackedToString(recordSize);
       } else {
         email = pduHelper.read8BitUnpackedToString(recordSize - 2);
         do_check_eq(pduHelper.readHexOctet(), pbr.adn.sfi);
         do_check_eq(pduHelper.readHexOctet(), expectedAdnRecordId);
       }
       this.readStringDelimiter(strLen);
       do_check_eq(email, expectedEmail);
 
       // pin2.
       do_check_eq(this.readString(), null);
 
       if (!worker.RILQUIRKS_V5_LEGACY) {
         // AID. Ignore because it's from modem.
-        this.readUint32();
+        this.readInt32();
       }
 
       if (count == NUM_TESTS) {
         run_next_test();
       }
     };
     recordHelper.updateEmail(pbr, recordNumber, expectedEmail, expectedAdnRecordId);
   }
@@ -957,17 +957,17 @@ add_test(function test_read_anr() {
   let recordSize;
 
   io.loadLinearFixedEF = function fakeLoadLinearFixedEF(options)  {
     let anr_1 = [
       0x01, 0x05, 0x81, 0x10, 0x32,
       0x54, 0xF6, 0xFF, 0xFF];
 
     // Write data size
-    buf.writeUint32(anr_1.length * 2);
+    buf.writeInt32(anr_1.length * 2);
 
     // Write anr
     for (let i = 0; i < anr_1.length; i++) {
       helper.writeHexOctet(anr_1[i]);
     }
 
     // Write string delimiter
     buf.writeStringDelimiter(anr_1.length * 2);
@@ -1024,42 +1024,42 @@ add_test(function test_update_anr() {
     ril.iccIO(options);
   };
 
   function do_test(pbr, expectedANR, expectedAdnRecordId) {
     buf.sendParcel = function () {
       count++;
 
       // Request Type.
-      do_check_eq(this.readUint32(), REQUEST_SIM_IO);
+      do_check_eq(this.readInt32(), REQUEST_SIM_IO);
 
       // Token : we don't care
-      this.readUint32();
+      this.readInt32();
 
       // command.
-      do_check_eq(this.readUint32(), ICC_COMMAND_UPDATE_RECORD);
+      do_check_eq(this.readInt32(), ICC_COMMAND_UPDATE_RECORD);
 
       // fileId.
-      do_check_eq(this.readUint32(), fileId);
+      do_check_eq(this.readInt32(), fileId);
 
       // pathId.
       do_check_eq(this.readString(),
                   EF_PATH_MF_SIM + EF_PATH_DF_TELECOM + EF_PATH_DF_PHONEBOOK);
 
       // p1.
-      do_check_eq(this.readUint32(), recordNumber);
+      do_check_eq(this.readInt32(), recordNumber);
 
       // p2.
-      do_check_eq(this.readUint32(), READ_RECORD_ABSOLUTE_MODE);
+      do_check_eq(this.readInt32(), READ_RECORD_ABSOLUTE_MODE);
 
       // p3.
-      do_check_eq(this.readUint32(), recordSize);
+      do_check_eq(this.readInt32(), recordSize);
 
       // data.
-      let strLen = this.readUint32();
+      let strLen = this.readInt32();
       // EF_AAS, ignore.
       pduHelper.readHexOctet();
       do_check_eq(pduHelper.readNumberWithLength(), expectedANR);
       // EF_CCP, ignore.
       pduHelper.readHexOctet();
       // EF_EXT1, ignore.
       pduHelper.readHexOctet();
       if (pbr.anr0.fileType === ICC_USIM_TYPE2_TAG) {
@@ -1068,17 +1068,17 @@ add_test(function test_update_anr() {
       }
       this.readStringDelimiter(strLen);
 
       // pin2.
       do_check_eq(this.readString(), null);
 
       if (!worker.RILQUIRKS_V5_LEGACY) {
         // AID. Ignore because it's from modem.
-        this.readUint32();
+        this.readInt32();
       }
 
       if (count == NUM_TESTS) {
         run_next_test();
       }
     };
     recordHelper.updateANR(pbr, recordNumber, expectedANR, expectedAdnRecordId);
   }
@@ -1098,17 +1098,17 @@ add_test(function test_read_iap() {
   let buf    = worker.Buf;
   let io     = worker.ICCIOHelper;
   let recordSize;
 
   io.loadLinearFixedEF = function fakeLoadLinearFixedEF(options)  {
     let iap_1 = [0x01, 0x02];
 
     // Write data size/
-    buf.writeUint32(iap_1.length * 2);
+    buf.writeInt32(iap_1.length * 2);
 
     // Write iap.
     for (let i = 0; i < iap_1.length; i++) {
       helper.writeHexOctet(iap_1[i]);
     }
 
     // Write string delimiter.
     buf.writeStringDelimiter(iap_1.length * 2);
@@ -1167,53 +1167,53 @@ add_test(function test_update_iap() {
     options.p2 = READ_RECORD_ABSOLUTE_MODE;
     options.p3 = recordSize;
     ril.iccIO(options);
   };
 
   function do_test(expectedIAP) {
     buf.sendParcel = function () {
       // Request Type.
-      do_check_eq(this.readUint32(), REQUEST_SIM_IO);
+      do_check_eq(this.readInt32(), REQUEST_SIM_IO);
 
       // Token : we don't care
-      this.readUint32();
+      this.readInt32();
 
       // command.
-      do_check_eq(this.readUint32(), ICC_COMMAND_UPDATE_RECORD);
+      do_check_eq(this.readInt32(), ICC_COMMAND_UPDATE_RECORD);
 
       // fileId.
-      do_check_eq(this.readUint32(), fileId);
+      do_check_eq(this.readInt32(), fileId);
 
       // pathId.
       do_check_eq(this.readString(),
                   EF_PATH_MF_SIM + EF_PATH_DF_TELECOM + EF_PATH_DF_PHONEBOOK);
 
       // p1.
-      do_check_eq(this.readUint32(), recordNumber);
+      do_check_eq(this.readInt32(), recordNumber);
 
       // p2.
-      do_check_eq(this.readUint32(), READ_RECORD_ABSOLUTE_MODE);
+      do_check_eq(this.readInt32(), READ_RECORD_ABSOLUTE_MODE);
 
       // p3.
-      do_check_eq(this.readUint32(), recordSize);
+      do_check_eq(this.readInt32(), recordSize);
 
       // data.
-      let strLen = this.readUint32();
+      let strLen = this.readInt32();
       for (let i = 0; i < recordSize; i++) {
         do_check_eq(expectedIAP[i], pduHelper.readHexOctet());
       }
       this.readStringDelimiter(strLen);
 
       // pin2.
       do_check_eq(this.readString(), null);
 
       if (!worker.RILQUIRKS_V5_LEGACY) {
         // AID. Ignore because it's from modem.
-        this.readUint32();
+        this.readInt32();
       }
 
       run_next_test();
     };
     recordHelper.updateIAP(fileId, recordNumber, expectedIAP);
   }
 
   do_test([1, 2]);
@@ -1241,54 +1241,54 @@ add_test(function test_update_adn_like()
     options.p1 = options.recordNumber;
     options.p2 = READ_RECORD_ABSOLUTE_MODE;
     options.p3 = recordSize;
     ril.iccIO(options);
   };
 
   buf.sendParcel = function () {
     // Request Type.
-    do_check_eq(this.readUint32(), REQUEST_SIM_IO);
+    do_check_eq(this.readInt32(), REQUEST_SIM_IO);
 
     // Token : we don't care
-    this.readUint32();
+    this.readInt32();
 
     // command.
-    do_check_eq(this.readUint32(), ICC_COMMAND_UPDATE_RECORD);
+    do_check_eq(this.readInt32(), ICC_COMMAND_UPDATE_RECORD);
 
     // fileId.
-    do_check_eq(this.readUint32(), fileId);
+    do_check_eq(this.readInt32(), fileId);
 
     // pathId.
     do_check_eq(this.readString(), EF_PATH_MF_SIM + EF_PATH_DF_TELECOM);
 
     // p1.
-    do_check_eq(this.readUint32(), 1);
+    do_check_eq(this.readInt32(), 1);
 
     // p2.
-    do_check_eq(this.readUint32(), READ_RECORD_ABSOLUTE_MODE);
+    do_check_eq(this.readInt32(), READ_RECORD_ABSOLUTE_MODE);
 
     // p3.
-    do_check_eq(this.readUint32(), 0x20);
+    do_check_eq(this.readInt32(), 0x20);
 
     // data.
     let contact = pdu.readAlphaIdDiallingNumber(0x20);
     do_check_eq(contact.alphaId, "test");
     do_check_eq(contact.number, "123456");
 
     // pin2.
     if (fileId == ICC_EF_ADN) {
       do_check_eq(this.readString(), null);
     } else {
       do_check_eq(this.readString(), "1111");
     }
 
     if (!worker.RILQUIRKS_V5_LEGACY) {
       // AID. Ignore because it's from modem.
-      this.readUint32();
+      this.readInt32();
     }
 
     if (fileId == ICC_EF_FDN) {
       run_next_test();
     }
   };
 
   fileId = ICC_EF_ADN;
@@ -1308,17 +1308,17 @@ add_test(function test_find_free_record_
   let worker = newUint8Worker();
   let pduHelper = worker.GsmPDUHelper;
   let recordHelper = worker.ICCRecordHelper;
   let buf = worker.Buf;
   let io  = worker.ICCIOHelper;
 
   function writeRecord (record) {
     // Write data size
-    buf.writeUint32(record.length * 2);
+    buf.writeInt32(record.length * 2);
 
     for (let i = 0; i < record.length; i++) {
       pduHelper.writeHexOctet(record[i]);
     }
 
     // Write string delimiter
     buf.writeStringDelimiter(record.length * 2);
   }
@@ -1728,20 +1728,20 @@ add_test(function test_set_icc_card_lock
 
   const serviceClass = ICC_SERVICE_CLASS_VOICE |
                        ICC_SERVICE_CLASS_DATA  |
                        ICC_SERVICE_CLASS_FAX;
 
   function do_test(aLock, aPassword, aEnabled) {
     buf.sendParcel = function fakeSendParcel () {
       // Request Type.
-      do_check_eq(this.readUint32(), REQUEST_SET_FACILITY_LOCK);
+      do_check_eq(this.readInt32(), REQUEST_SET_FACILITY_LOCK);
 
       // Token : we don't care
-      this.readUint32();
+      this.readInt32();
 
       let parcel = this.readStringList();
       do_check_eq(parcel.length, 5);
       do_check_eq(parcel[0], GECKO_CARDLOCK_TO_FACILITIY_LOCK[aLock]);
       do_check_eq(parcel[1], aEnabled ? "1" : "0");
       do_check_eq(parcel[2], GECKO_CARDLOCK_TO_PASSWORD[aLock]);
       do_check_eq(parcel[3], serviceClass.toString());
       do_check_eq(parcel[4], aid);
@@ -1778,24 +1778,24 @@ add_test(function test_unlock_card_lock_
   GECKO_CARDLOCK_TO_PASSWORD_TYPE[GECKO_CARDLOCK_SPCK] = "pin";
   GECKO_CARDLOCK_TO_PASSWORD_TYPE[GECKO_CARDLOCK_NCK_PUK] = "puk";
   GECKO_CARDLOCK_TO_PASSWORD_TYPE[GECKO_CARDLOCK_CCK_PUK] = "puk";
   GECKO_CARDLOCK_TO_PASSWORD_TYPE[GECKO_CARDLOCK_SPCK_PUK] = "puk";
 
   function do_test(aLock, aPassword) {
     buf.sendParcel = function fakeSendParcel () {
       // Request Type.
-      do_check_eq(this.readUint32(), REQUEST_ENTER_NETWORK_DEPERSONALIZATION_CODE);
+      do_check_eq(this.readInt32(), REQUEST_ENTER_NETWORK_DEPERSONALIZATION_CODE);
 
       // Token : we don't care
-      this.readUint32();
+      this.readInt32();
 
       let lockType = GECKO_PERSO_LOCK_TO_CARD_PERSO_LOCK[aLock];
       // Lock Type
-      do_check_eq(this.readUint32(), lockType);
+      do_check_eq(this.readInt32(), lockType);
 
       // Pin/Puk.
       do_check_eq(this.readString(), aPassword);
     };
 
     let lock = {lockType: aLock};
     lock[GECKO_CARDLOCK_TO_PASSWORD_TYPE[aLock]] = aPassword;
     ril.iccUnlockCardLock(lock);
@@ -1862,17 +1862,17 @@ add_test(function test_reading_ad_and_pa
 
     io.loadTransparentEF = function fakeLoadTransparentEF(options) {
       let ad = [0x00, 0x00, 0x00];
       if (mncLengthInEf) {
         ad.push(mncLengthInEf);
       }
 
       // Write data size
-      buf.writeUint32(ad.length * 2);
+      buf.writeInt32(ad.length * 2);
 
       // Write data
       for (let i = 0; i < ad.length; i++) {
         helper.writeHexOctet(ad[i]);
       }
 
       // Write string delimiter
       buf.writeStringDelimiter(ad.length * 2);
--- a/dom/system/gonk/tests/test_ril_worker_mmi.js
+++ b/dom/system/gonk/tests/test_ril_worker_mmi.js
@@ -430,17 +430,17 @@ add_test(function test_sendMMI_call_forw
 
   run_next_test();
 });
 
 add_test(function test_sendMMI_call_forwarding_interrogation() {
   let workerhelper = getWorker();
   let worker = workerhelper.worker;
 
-  worker.Buf.readUint32 = function fakeReadUint32() {
+  worker.Buf.readInt32 = function fakeReadUint32() {
     return worker.Buf.int32Array.pop();
   };
 
   worker.Buf.readString = function fakeReadString() {
     return "+34666222333";
   };
 
   worker.RIL.queryCallForwardStatus = function fakeQueryCallForward(options) {
@@ -472,17 +472,17 @@ add_test(function test_sendMMI_call_forw
   do_check_eq(postedMessage.rules[0].number, "+34666222333");
   run_next_test();
 });
 
 add_test(function test_sendMMI_call_forwarding_interrogation_no_rules() {
   let workerhelper = getWorker();
   let worker = workerhelper.worker;
 
-  worker.Buf.readUint32 = function fakeReadUint32() {
+  worker.Buf.readInt32 = function fakeReadUint32() {
     return 0;
   };
 
   worker.RIL.queryCallForwardStatus = function fakeQueryCallForward(options) {
     worker.RIL[REQUEST_QUERY_CALL_FORWARD_STATUS](1, {
       rilRequestError: ERROR_SUCCESS
     });
   };
@@ -766,17 +766,17 @@ add_test(function test_sendMMI_get_IMEI_
 
   run_next_test();
 });
 
 add_test(function test_sendMMI_call_barring_BAIC_interrogation_voice() {
   let workerhelper = getWorker();
   let worker = workerhelper.worker;
 
-  worker.Buf.readUint32List = function fakeReadUint32List() {
+  worker.Buf.readInt32List = function fakeReadUint32List() {
     return [1];
   };
 
   worker.RIL.queryICCFacilityLock =
     function fakeQueryICCFacilityLock(options){
       worker.RIL[REQUEST_QUERY_FACILITY_LOCK](1, {
         rilMessageType: "sendMMI",
         rilRequestError: ERROR_SUCCESS
@@ -949,17 +949,17 @@ add_test(function test_sendMMI_call_wait
 
   run_next_test();
 });
 
 add_test(function test_sendMMI_call_waiting_interrogation() {
   let workerhelper = getWorker();
   let worker = workerhelper.worker;
 
-  worker.Buf.readUint32 = function fakeReadUint32() {
+  worker.Buf.readInt32 = function fakeReadUint32() {
     return worker.Buf.int32Array.pop();
   };
 
   worker.RIL.queryCallWaiting = function fakeQueryCallWaiting(options) {
     worker.Buf.int32Array = [
       7,   // serviceClass
       1,   // enabled
       2    // length
--- a/dom/system/gonk/tests/test_ril_worker_ruim.js
+++ b/dom/system/gonk/tests/test_ril_worker_ruim.js
@@ -77,17 +77,17 @@ add_test(function test_read_cdmahome() {
   let helper = worker.GsmPDUHelper;
   let buf    = worker.Buf;
   let io     = worker.ICCIOHelper;
 
   io.loadLinearFixedEF = function fakeLoadLinearFixedEF(options)  {
     let cdmaHome = [0xc1, 0x34, 0xff, 0xff, 0x00];
 
     // Write data size
-    buf.writeUint32(cdmaHome.length * 2);
+    buf.writeInt32(cdmaHome.length * 2);
 
     // Write cdma home file.
     for (let i = 0; i < cdmaHome.length; i++) {
       helper.writeHexOctet(cdmaHome[i]);
     }
 
     // Write string delimiter
     buf.writeStringDelimiter(cdmaHome.length * 2);
@@ -123,17 +123,17 @@ add_test(function test_read_cdmaspn() {
   let worker = newUint8Worker();
   let helper = worker.GsmPDUHelper;
   let buf    = worker.Buf;
   let io     = worker.ICCIOHelper;
 
   function testReadSpn(file, expectedSpn, expectedDisplayCondition) {
     io.loadTransparentEF = function fakeLoadTransparentEF(options)  {
       // Write data size
-      buf.writeUint32(file.length * 2);
+      buf.writeInt32(file.length * 2);
 
       // Write file.
       for (let i = 0; i < file.length; i++) {
         helper.writeHexOctet(file[i]);
       }
 
       // Write string delimiter
       buf.writeStringDelimiter(file.length * 2);
--- a/dom/system/gonk/tests/test_ril_worker_stk.js
+++ b/dom/system/gonk/tests/test_ril_worker_stk.js
@@ -87,26 +87,26 @@ add_test(function test_send_stk_terminal
  */
 add_test(function test_stk_terminal_response() {
   let worker = newUint8SupportOutgoingIndexWorker();
   let buf = worker.Buf;
   let pduHelper = worker.GsmPDUHelper;
 
   buf.sendParcel = function () {
     // Type
-    do_check_eq(this.readUint32(), REQUEST_STK_SEND_TERMINAL_RESPONSE);
+    do_check_eq(this.readInt32(), REQUEST_STK_SEND_TERMINAL_RESPONSE);
 
     // Token : we don't care
-    this.readUint32();
+    this.readInt32();
 
     // Data Size, 44 = 2 * (TLV_COMMAND_DETAILS_SIZE(5) +
     //                      TLV_DEVICE_ID_SIZE(4) +
     //                      TLV_RESULT_SIZE(3) +
     //                      TEXT LENGTH(10))
-    do_check_eq(this.readUint32(), 44);
+    do_check_eq(this.readInt32(), 44);
 
     // Command Details, Type-Length-Value
     do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_COMMAND_DETAILS |
                                           COMPREHENSIONTLV_FLAG_CR);
     do_check_eq(pduHelper.readHexOctet(), 3);
     do_check_eq(pduHelper.readHexOctet(), 0x01);
     do_check_eq(pduHelper.readHexOctet(), STK_CMD_PROVIDE_LOCAL_INFO);
     do_check_eq(pduHelper.readHexOctet(), STK_LOCAL_INFO_NNA);
@@ -743,26 +743,26 @@ add_test(function test_stk_proactive_com
  */
 add_test(function test_stk_event_download_location_status() {
   let worker = newUint8SupportOutgoingIndexWorker();
   let buf = worker.Buf;
   let pduHelper = worker.GsmPDUHelper;
 
   buf.sendParcel = function () {
     // Type
-    do_check_eq(this.readUint32(), REQUEST_STK_SEND_ENVELOPE_COMMAND);
+    do_check_eq(this.readInt32(), REQUEST_STK_SEND_ENVELOPE_COMMAND);
 
     // Token : we don't care
-    this.readUint32();
+    this.readInt32();
 
     // Data Size, 42 = 2 * (2 + TLV_DEVICE_ID_SIZE(4) +
     //                      TLV_EVENT_LIST_SIZE(3) +
     //                      TLV_LOCATION_STATUS_SIZE(3) +
     //                      TLV_LOCATION_INFO_GSM_SIZE(9))
-    do_check_eq(this.readUint32(), 42);
+    do_check_eq(this.readInt32(), 42);
 
     // BER tag
     do_check_eq(pduHelper.readHexOctet(), BER_EVENT_DOWNLOAD_TAG);
 
     // BER length, 19 = TLV_DEVICE_ID_SIZE(4) +
     //                  TLV_EVENT_LIST_SIZE(3) +
     //                  TLV_LOCATION_STATUS_SIZE(3) +
     //                  TLV_LOCATION_INFO_GSM_SIZE(9)
@@ -825,25 +825,25 @@ add_test(function test_stk_event_downloa
  */
 add_test(function test_stk_event_download_language_selection() {
   let worker = newUint8SupportOutgoingIndexWorker();
   let buf = worker.Buf;
   let pduHelper = worker.GsmPDUHelper;
 
   buf.sendParcel = function () {
     // Type
-    do_check_eq(this.readUint32(), REQUEST_STK_SEND_ENVELOPE_COMMAND);
+    do_check_eq(this.readInt32(), REQUEST_STK_SEND_ENVELOPE_COMMAND);
 
     // Token : we don't care
-    this.readUint32();
+    this.readInt32();
 
     // Data Size, 26 = 2 * (2 + TLV_DEVICE_ID_SIZE(4) +
     //                      TLV_EVENT_LIST_SIZE(3) +
     //                      TLV_LANGUAGE(4))
-    do_check_eq(this.readUint32(), 26);
+    do_check_eq(this.readInt32(), 26);
 
     // BER tag
     do_check_eq(pduHelper.readHexOctet(), BER_EVENT_DOWNLOAD_TAG);
 
     // BER length, 19 = TLV_DEVICE_ID_SIZE(4) +
     //                  TLV_EVENT_LIST_SIZE(3) +
     //                  TLV_LANGUAGE(4)
     do_check_eq(pduHelper.readHexOctet(), 11);
@@ -883,23 +883,23 @@ add_test(function test_stk_event_downloa
  */
 add_test(function test_stk_event_download_user_activity() {
   let worker = newUint8SupportOutgoingIndexWorker();
   let buf = worker.Buf;
   let pduHelper = worker.GsmPDUHelper;
 
   buf.sendParcel = function () {
     // Type
-    do_check_eq(this.readUint32(), REQUEST_STK_SEND_ENVELOPE_COMMAND);
+    do_check_eq(this.readInt32(), REQUEST_STK_SEND_ENVELOPE_COMMAND);
 
     // Token : we don't care
-    this.readUint32();
+    this.readInt32();
 
     // Data Size, 18 = 2 * (2 + TLV_DEVICE_ID_SIZE(4) + TLV_EVENT_LIST_SIZE(3))
-    do_check_eq(this.readUint32(), 18);
+    do_check_eq(this.readInt32(), 18);
 
     // BER tag
     do_check_eq(pduHelper.readHexOctet(), BER_EVENT_DOWNLOAD_TAG);
 
     // BER length, 7 = TLV_DEVICE_ID_SIZE(4) + TLV_EVENT_LIST_SIZE(3)
     do_check_eq(pduHelper.readHexOctet(), 7);
 
     // Device Identities, Type-Length-Value(Source ID-Destination ID)
@@ -931,23 +931,23 @@ add_test(function test_stk_event_downloa
  */
 add_test(function test_stk_event_download_idle_screen_available() {
   let worker = newUint8SupportOutgoingIndexWorker();
   let buf = worker.Buf;
   let pduHelper = worker.GsmPDUHelper;
 
   buf.sendParcel = function () {
     // Type
-    do_check_eq(this.readUint32(), REQUEST_STK_SEND_ENVELOPE_COMMAND);
+    do_check_eq(this.readInt32(), REQUEST_STK_SEND_ENVELOPE_COMMAND);
 
     // Token : we don't care
-    this.readUint32();
+    this.readInt32();
 
     // Data Size, 18 = 2 * (2 + TLV_DEVICE_ID_SIZE(4) + TLV_EVENT_LIST_SIZE(3))
-    do_check_eq(this.readUint32(), 18);
+    do_check_eq(this.readInt32(), 18);
 
     // BER tag
     do_check_eq(pduHelper.readHexOctet(), BER_EVENT_DOWNLOAD_TAG);
 
     // BER length, 7 = TLV_DEVICE_ID_SIZE(4) + TLV_EVENT_LIST_SIZE(3)
     do_check_eq(pduHelper.readHexOctet(), 7);
 
     // Device Identities, Type-Length-Value(Source ID-Destination ID)
--- a/dom/system/gonk/tests/test_ril_worker_voiceprivacy.js
+++ b/dom/system/gonk/tests/test_ril_worker_voiceprivacy.js
@@ -67,17 +67,17 @@ add_test(function test_setVoicePrivacyMo
 
   run_next_test();
 });
 
 add_test(function test_queryVoicePrivacyMode_success_enabled_true() {
   let workerHelper = _getWorker();
   let worker = workerHelper.worker;
 
-  worker.Buf.readUint32List = function fakeReadUint32List() {
+  worker.Buf.readInt32List = function fakeReadUint32List() {
     return [1];
   };
 
   worker.RIL.queryVoicePrivacyMode = function fakeQueryVoicePrivacyMode(options) {
     worker.RIL[REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE](1, {
       rilRequestError: ERROR_SUCCESS
     });
   };
@@ -90,17 +90,17 @@ add_test(function test_queryVoicePrivacy
   do_check_true(postedMessage.enabled);
   run_next_test();
 });
 
 add_test(function test_queryVoicePrivacyMode_success_enabled_false() {
   let workerHelper = _getWorker();
   let worker = workerHelper.worker;
 
-  worker.Buf.readUint32List = function fakeReadUint32List() {
+  worker.Buf.readInt32List = function fakeReadUint32List() {
     return [0];
   };
 
   worker.RIL.queryVoicePrivacyMode = function fakeQueryVoicePrivacyMode(options) {
     worker.RIL[REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE](1, {
       rilRequestError: ERROR_SUCCESS
     });
   };
--- a/dom/system/gonk/worker_buf.js
+++ b/dom/system/gonk/worker_buf.js
@@ -257,48 +257,48 @@ let Buf = {
     this.readAvailable -= length;
     return array;
   },
 
   readUint16: function readUint16() {
     return this.readUint8() | this.readUint8() << 8;
   },
 
-  readUint32: function readUint32() {
+  readInt32: function readInt32() {
     return this.readUint8()       | this.readUint8() <<  8 |
            this.readUint8() << 16 | this.readUint8() << 24;
   },
 
-  readUint32List: function readUint32List() {
-    let length = this.readUint32();
+  readInt32List: function readInt32List() {
+    let length = this.readInt32();
     let ints = [];
     for (let i = 0; i < length; i++) {
-      ints.push(this.readUint32());
+      ints.push(this.readInt32());
     }
     return ints;
   },
 
   readString: function readString() {
-    let string_len = this.readUint32();
+    let string_len = this.readInt32();
     if (string_len < 0 || string_len >= this.INT32_MAX) {
       return null;
     }
     let s = "";
     for (let i = 0; i < string_len; i++) {
       s += String.fromCharCode(this.readUint16());
     }
     // Strings are \0\0 delimited, but that isn't part of the length. And
     // if the string length is even, the delimiter is two characters wide.
     // It's insane, I know.
     this.readStringDelimiter(string_len);
     return s;
   },
 
   readStringList: function readStringList() {
-    let num_strings = this.readUint32();
+    let num_strings = this.readInt32();
     let strings = [];
     for (let i = 0; i < num_strings; i++) {
       strings.push(this.readString());
     }
     return strings;
   },
 
   readStringDelimiter: function readStringDelimiter(length) {
@@ -344,40 +344,40 @@ let Buf = {
     this.outgoingIndex++;
   },
 
   writeUint16: function writeUint16(value) {
     this.writeUint8(value & 0xff);
     this.writeUint8((value >> 8) & 0xff);
   },
 
-  writeUint32: function writeUint32(value) {
+  writeInt32: function writeInt32(value) {
     this.writeUint8(value & 0xff);
     this.writeUint8((value >> 8) & 0xff);
     this.writeUint8((value >> 16) & 0xff);
     this.writeUint8((value >> 24) & 0xff);
   },
 
   writeString: function writeString(value) {
     if (value == null) {
-      this.writeUint32(-1);
+      this.writeInt32(-1);
       return;
     }
-    this.writeUint32(value.length);
+    this.writeInt32(value.length);
     for (let i = 0; i < value.length; i++) {
       this.writeUint16(value.charCodeAt(i));
     }
     // Strings are \0\0 delimited, but that isn't part of the length. And
     // if the string length is even, the delimiter is two characters wide.
     // It's insane, I know.
     this.writeStringDelimiter(value.length);
   },
 
   writeStringList: function writeStringList(strings) {
-    this.writeUint32(strings.length);
+    this.writeInt32(strings.length);
     for (let i = 0; i < strings.length; i++) {
       this.writeString(strings[i]);
     }
   },
 
   writeStringDelimiter: function writeStringDelimiter(length) {
     this.writeUint16(0);
     if (!(length & 1)) {
@@ -582,17 +582,17 @@ let Buf = {
   /**
    * Process one parcel.
    *
    * |processParcel| is an implementation provided incoming parcel processing
    * function invoked when we have received a complete parcel.  Implementation
    * may call multiple read functions to extract data from the incoming buffer.
    */
   //processParcel: function processParcel() {
-  //  let something = this.readUint32();
+  //  let something = this.readInt32();
   //  ...
   //},
 
   /**
    * Write raw data out to underlying channel.
    *
    * |onSendParcel| is an implementation provided stream output function
    * invoked when we're really going to write something out.  We assume the