Bug 727319 - Part 1: remove handleRequestError(). r=philikon
authorVicamo Yang <vyang@mozilla.com>
Thu, 05 Apr 2012 14:16:56 -0700
changeset 94428 25b1bf1420ab8909e0dbaa146c6b41de01299914
parent 94427 8646a8cfc01aa0a66e1deb0eb8f876259d58e801
child 94429 52643779c4d85e6c96b9b901abde96705ef02064
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilikon
bugs727319
milestone14.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 727319 - Part 1: remove handleRequestError(). r=philikon
dom/system/gonk/RadioInterfaceLayer.js
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -281,19 +281,16 @@ RadioInterfaceLayer.prototype = {
                + " timezone=" + message.networkTimeZoneInMinutes
                + " dst=" + message.dstFlag
                + " timestamp=" + message.localTimeStampInMS);
         }
         break;
       case "siminfo":
         this.radioState.msisdn = message.msisdn;
         break;
-      case "error":
-        debug("Received error message: " + JSON.stringify(message));
-        break;
       default:
         throw new Error("Don't know about this message type: " + message.type);
     }
   },
 
   _isDataEnabled: function _isDataEnabled() {
     try {
       return Services.prefs.getBoolPref("ril.data.enabled");
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -465,27 +465,19 @@ let Buf = {
       let token = this.readUint32();
       let error = this.readUint32();
 
       options = this.tokenRequestMap[token];
       delete this.tokenRequestMap[token];
       request_type = options.rilRequestType;
 
       options.rilRequestError = error;
-      if (error) {   	  
-        if (DEBUG) {
-          debug("Received error " + error + " for solicited parcel type " +
-                request_type);
-        }
-        RIL.handleRequestError(options);
-        return;
-      }
       if (DEBUG) {
         debug("Solicited response for request type " + request_type +
-              ", token " + token);
+              ", token " + token + ", error " + error);
       }
     } else if (response_type == RESPONSE_TYPE_UNSOLICITED) {
       request_type = this.readUint32();
       if (DEBUG) debug("Unsolicited response for request type " + request_type);
     } else {
       if (DEBUG) debug("Unknown response type: " + response_type);
       return;
     }
@@ -1710,39 +1702,35 @@ let RIL = {
   /**
    * Send messages to the main thread.
    */
   sendDOMMessage: function sendDOMMessage(message) {
     postMessage(message, "*");
   },
 
   /**
-   * Handle the RIL request errors
-   */ 
-  handleRequestError: function handleRequestError(options) {	  
-	options.type = "error";
-	this.sendDOMMessage(options);
-  },   
-
-  /**
    * Handle incoming requests from the RIL. We find the method that
    * corresponds to the request type. Incidentally, the request type
    * _is_ the method name, so that's easy.
    */
 
   handleParcel: function handleParcel(request_type, length, options) {
     let method = this[request_type];
     if (typeof method == "function") {
       if (DEBUG) debug("Handling parcel as " + method.name);
       method.call(this, length, options);
     }
   }
 };
 
-RIL[REQUEST_GET_SIM_STATUS] = function REQUEST_GET_SIM_STATUS() {
+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();
   if (!RILQUIRKS_V5_LEGACY) {
     iccStatus.imsSubscriptionAppIndex = Buf.readUint32();
   }
@@ -1764,30 +1752,42 @@ RIL[REQUEST_GET_SIM_STATUS] = function R
       pin1:           Buf.readUint32(),
       pin2:           Buf.readUint32()
     });
   }
 
   if (DEBUG) debug("iccStatus: " + JSON.stringify(iccStatus));
   this._processICCStatus(iccStatus);
 };
-RIL[REQUEST_ENTER_SIM_PIN] = function REQUEST_ENTER_SIM_PIN() {
+RIL[REQUEST_ENTER_SIM_PIN] = function REQUEST_ENTER_SIM_PIN(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   let response = Buf.readUint32List();
   if (DEBUG) debug("REQUEST_ENTER_SIM_PIN returned " + response);
 };
-RIL[REQUEST_ENTER_SIM_PUK] = function REQUEST_ENTER_SIM_PUK() {
+RIL[REQUEST_ENTER_SIM_PUK] = function REQUEST_ENTER_SIM_PUK(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   let response = Buf.readUint32List();
   if (DEBUG) debug("REQUEST_ENTER_SIM_PUK returned " + response);
 };
 RIL[REQUEST_ENTER_SIM_PIN2] = null;
 RIL[REQUEST_ENTER_SIM_PUK2] = null;
 RIL[REQUEST_CHANGE_SIM_PIN] = null;
 RIL[REQUEST_CHANGE_SIM_PIN2] = null;
 RIL[REQUEST_ENTER_NETWORK_DEPERSONALIZATION] = null;
-RIL[REQUEST_GET_CURRENT_CALLS] = function REQUEST_GET_CURRENT_CALLS(length) {
+RIL[REQUEST_GET_CURRENT_CALLS] = function REQUEST_GET_CURRENT_CALLS(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   this.initRILQuirks();
 
   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();
   }
@@ -1825,35 +1825,51 @@ RIL[REQUEST_GET_CURRENT_CALLS] = functio
       };
     }
 
     calls[call.callIndex] = call;
   }
   this._processCalls(calls);
 };
 RIL[REQUEST_DIAL] = null;
-RIL[REQUEST_GET_IMSI] = function REQUEST_GET_IMSI(length) {
+RIL[REQUEST_GET_IMSI] = function REQUEST_GET_IMSI(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   this.IMSI = Buf.readString();
 };
-RIL[REQUEST_HANGUP] = function REQUEST_HANGUP(length) {
+RIL[REQUEST_HANGUP] = function REQUEST_HANGUP(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   this.getCurrentCalls();
 }; 
 RIL[REQUEST_HANGUP_WAITING_OR_BACKGROUND] = null;
 RIL[REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND] = null;
 RIL[REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE] = null;
-RIL[REQUEST_SWITCH_HOLDING_AND_ACTIVE] = function REQUEST_SWITCH_HOLDING_AND_ACTIVE(length) {
+RIL[REQUEST_SWITCH_HOLDING_AND_ACTIVE] = function REQUEST_SWITCH_HOLDING_AND_ACTIVE(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   // XXX Normally we should get a UNSOLICITED_RESPONSE_CALL_STATE_CHANGED parcel 
   // notifying us of call state changes, but sometimes we don't (have no idea why).
   // this.getCurrentCalls() helps update the call state actively.
   this.getCurrentCalls();
 };
 RIL[REQUEST_CONFERENCE] = null;
 RIL[REQUEST_UDUB] = null;
 RIL[REQUEST_LAST_CALL_FAIL_CAUSE] = null;
-RIL[REQUEST_SIGNAL_STRENGTH] = function REQUEST_SIGNAL_STRENGTH() {
+RIL[REQUEST_SIGNAL_STRENGTH] = function REQUEST_SIGNAL_STRENGTH(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   let obj = {};
 
   // GSM
   // Valid values are (0-31, 99) as defined in TS 27.007 8.5.
   obj.gsmSignalStrength = Buf.readUint32();
   // The SGS2 seems to compute the number of bars for us and expose those
   // instead of the actual signal strength.
   obj.bars = obj.gsmSignalStrength >> 8; //TODO remove this, see bug 729173
@@ -1891,26 +1907,38 @@ RIL[REQUEST_SIGNAL_STRENGTH] = function 
     // Channel Quality Indicator, valid values are 0 to 15.
     obj.lteCQI = Buf.readUint32();
   }
 
   if (DEBUG) debug("Signal strength " + JSON.stringify(obj));
   this.sendDOMMessage({type: "signalstrengthchange",
                        signalStrength: obj});
 };
-RIL[REQUEST_VOICE_REGISTRATION_STATE] = function REQUEST_VOICE_REGISTRATION_STATE(length) {
+RIL[REQUEST_VOICE_REGISTRATION_STATE] = function REQUEST_VOICE_REGISTRATION_STATE(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   let state = Buf.readStringList();
 debug("voice registration state: " + state);
   this._processVoiceRegistrationState(state);
 };
-RIL[REQUEST_DATA_REGISTRATION_STATE] = function REQUEST_DATA_REGISTRATION_STATE(length) {
+RIL[REQUEST_DATA_REGISTRATION_STATE] = function REQUEST_DATA_REGISTRATION_STATE(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   let state = Buf.readStringList();
   this._processDataRegistrationState(state);
 };
-RIL[REQUEST_OPERATOR] = function REQUEST_OPERATOR(length) {
+RIL[REQUEST_OPERATOR] = function REQUEST_OPERATOR(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   let operator = Buf.readStringList();
   if (DEBUG) debug("Operator data: " + operator);
   if (operator.length < 3) {
     if (DEBUG) debug("Expected at least 3 strings for operator.");
   }
   if (!this.operator ||
       this.operator.alphaLong  != operator[0] ||
       this.operator.alphaShort != operator[1] ||
@@ -1920,22 +1948,25 @@ RIL[REQUEST_OPERATOR] = function REQUEST
                      numeric:    operator[2]};
     this.sendDOMMessage({type: "operatorchange",
                          operator: this.operator});
   }
 };
 RIL[REQUEST_RADIO_POWER] = null;
 RIL[REQUEST_DTMF] = null;
 RIL[REQUEST_SEND_SMS] = function REQUEST_SEND_SMS(length, options) {
+  if (options.rilRequestError) {
+    //TODO handle errors (bug 727319)
+    return;
+  }
+
   options.messageRef = Buf.readUint32();
   options.ackPDU = Buf.readString();
   options.errorCode = Buf.readUint32();
 
-  //TODO handle errors (bug 727319)
-
   if (options.requestStatusReport) {
     this._pendingSentSmsMap[options.messageRef] = options;
   }
 
   if ((options.segmentMaxSeq > 1)
       && (options.segmentSeq < options.segmentMaxSeq)) {
     // Not last segment
     if (!options.requestStatusReport) {
@@ -1963,29 +1994,37 @@ RIL.readSetupDataCall_v5 = function read
   options.dns = dns;
   options.gw = gw;
   options.active = DATACALL_ACTIVE_UNKNOWN;
   options.state = GECKO_NETWORK_STATE_CONNECTING;
   return options;
 };
 
 RIL[REQUEST_SETUP_DATA_CALL] = function REQUEST_SETUP_DATA_CALL(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   if (RILQUIRKS_V5_LEGACY) {
     this.readSetupDataCall_v5(options);
     this.currentDataCalls[options.cid] = options;
     this.sendDOMMessage({type: "datacallstatechange",
                          datacall: options});
     // Let's get the list of data calls to ensure we know whether it's active
     // or not.
     this.getDataCallList();
     return;
   }
   this[REQUEST_DATA_CALL_LIST](length, options);
 };
 RIL[REQUEST_SIM_IO] = function REQUEST_SIM_IO(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   let sw1 = Buf.readUint32();
   let sw2 = Buf.readUint32();
   if (sw1 != ICC_STATUS_NORMAL_ENDING) {
     // See GSM11.11, TS 51.011 clause 9.4, and ISO 7816-4 for the error
     // description.
     debug("ICC I/O Error EF id = " + options.fileid.toString(16) +
           " command = " + options.command.toString(16) +
           "(" + sw1.toString(16) + "/" + sw2.toString(16) + ")");
@@ -2002,43 +2041,63 @@ RIL[REQUEST_SEND_USSD] = null;
 RIL[REQUEST_CANCEL_USSD] = null;
 RIL[REQUEST_GET_CLIR] = null;
 RIL[REQUEST_SET_CLIR] = null;
 RIL[REQUEST_QUERY_CALL_FORWARD_STATUS] = null;
 RIL[REQUEST_SET_CALL_FORWARD] = null;
 RIL[REQUEST_QUERY_CALL_WAITING] = null;
 RIL[REQUEST_SET_CALL_WAITING] = null;
 RIL[REQUEST_SMS_ACKNOWLEDGE] = null;
-RIL[REQUEST_GET_IMEI] = function REQUEST_GET_IMEI() {
+RIL[REQUEST_GET_IMEI] = function REQUEST_GET_IMEI(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   this.IMEI = Buf.readString();
 };
-RIL[REQUEST_GET_IMEISV] = function REQUEST_GET_IMEISV() {
+RIL[REQUEST_GET_IMEISV] = function REQUEST_GET_IMEISV(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   this.IMEISV = Buf.readString();
 };
 RIL[REQUEST_ANSWER] = null;
 RIL[REQUEST_DEACTIVATE_DATA_CALL] = function REQUEST_DEACTIVATE_DATA_CALL(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   let datacall = this.currentDataCalls[options.cid];
   delete this.currentDataCalls[options.cid];
   datacall.state = GECKO_NETWORK_STATE_DISCONNECTED;
   this.sendDOMMessage({type: "datacallstatechange",
                        datacall: datacall});
 };
 RIL[REQUEST_QUERY_FACILITY_LOCK] = null;
 RIL[REQUEST_SET_FACILITY_LOCK] = null;
 RIL[REQUEST_CHANGE_BARRING_PASSWORD] = null;
-RIL[REQUEST_QUERY_NETWORK_SELECTION_MODE] = function REQUEST_QUERY_NETWORK_SELECTION_MODE() {
+RIL[REQUEST_QUERY_NETWORK_SELECTION_MODE] = function REQUEST_QUERY_NETWORK_SELECTION_MODE(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   let mode = Buf.readUint32List();
   this.networkSelectionMode = mode[0];
 };
 RIL[REQUEST_SET_NETWORK_SELECTION_AUTOMATIC] = null;
 RIL[REQUEST_SET_NETWORK_SELECTION_MANUAL] = null;
 RIL[REQUEST_QUERY_AVAILABLE_NETWORKS] = null;
 RIL[REQUEST_DTMF_START] = null;
 RIL[REQUEST_DTMF_STOP] = null;
-RIL[REQUEST_BASEBAND_VERSION] = function REQUEST_BASEBAND_VERSION() {
+RIL[REQUEST_BASEBAND_VERSION] = function REQUEST_BASEBAND_VERSION(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   this.basebandVersion = Buf.readString();
   if (DEBUG) debug("Baseband version: " + this.basebandVersion);
 };
 RIL[REQUEST_SEPARATE_CONNECTION] = null;
 RIL[REQUEST_SET_MUTE] = null;
 RIL[REQUEST_GET_MUTE] = null;
 RIL[REQUEST_QUERY_CLIP] = null;
 RIL[REQUEST_LAST_DATA_CALL_FAIL_CAUSE] = null;
@@ -2074,17 +2133,21 @@ RIL.readDataCall_v6 = function readDataC
     obj.ipaddr = obj.ipaddr.split(" ")[0];
   }
   if (obj.gw) {
     obj.gw = obj.gw.split(" ")[0];
   }
   return obj;
 };
 
-RIL[REQUEST_DATA_CALL_LIST] = function REQUEST_DATA_CALL_LIST(length) {
+RIL[REQUEST_DATA_CALL_LIST] = function REQUEST_DATA_CALL_LIST(length, options) {
+  if (options.rilRequestError) {
+    return;
+  }
+
   this.initRILQuirks();
   if (!length) {
     this._processDataCallList(null);
     return;
   }
 
   let version = 0;
   if (!RILQUIRKS_V5_LEGACY) {
@@ -2142,18 +2205,22 @@ RIL[REQUEST_CDMA_GET_BROADCAST_SMS_CONFI
 RIL[REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG] = null;
 RIL[REQUEST_CDMA_SMS_BROADCAST_ACTIVATION] = null;
 RIL[REQUEST_CDMA_SUBSCRIPTION] = null;
 RIL[REQUEST_CDMA_WRITE_SMS_TO_RUIM] = null;
 RIL[REQUEST_CDMA_DELETE_SMS_ON_RUIM] = null;
 RIL[REQUEST_DEVICE_IDENTITY] = null;
 RIL[REQUEST_EXIT_EMERGENCY_CALLBACK_MODE] = null;
 RIL[REQUEST_GET_SMSC_ADDRESS] = function REQUEST_GET_SMSC_ADDRESS(length, options) {
-  //TODO: notify main thread if we fail retrieving the SMSC, especially
-  // if there was a pending SMS (bug 727319).
+  if (options.rilRequestError) {
+    //TODO: notify main thread if we fail retrieving the SMSC, especially
+    // if there was a pending SMS (bug 727319).
+    return;
+  }
+
   this.SMSC = Buf.readString();
   // If the SMSC was not retrieved on RIL initialization, an attempt to
   // get it is triggered from this.sendSMS followed by the 'options'
   // parameter of the SMS, so that we can send it after successfully
   // retrieving the SMSC.
   if (this.SMSC && options.body) {
     this.sendSMS(options);
   }
@@ -2279,25 +2346,25 @@ RIL[UNSOLICITED_NITZ_TIME_RECEIVED] = fu
 
   this.sendDOMMessage({type: "nitzTime",
                        networkTimeInSeconds: timeInSeconds,
                        networkTimeZoneInMinutes: tz * 15,
                        dstFlag: dst,
                        localTimeStampInMS: now});
 };
 
-RIL[UNSOLICITED_SIGNAL_STRENGTH] = function UNSOLICITED_SIGNAL_STRENGTH() {
-  this[REQUEST_SIGNAL_STRENGTH]();
+RIL[UNSOLICITED_SIGNAL_STRENGTH] = function UNSOLICITED_SIGNAL_STRENGTH(length) {
+  this[REQUEST_SIGNAL_STRENGTH](length, {rilRequestError: ERROR_SUCCESS});
 };
-RIL[UNSOLICITED_DATA_CALL_LIST_CHANGED] = function UNSOLICITED_DATA_CALL_LIST_CHANGED(length, options) {
+RIL[UNSOLICITED_DATA_CALL_LIST_CHANGED] = function UNSOLICITED_DATA_CALL_LIST_CHANGED(length) {
   if (RILQUIRKS_V5_LEGACY) {
     this.getDataCallList();
     return;
   }
-  this[REQUEST_GET_DATA_CALL_LIST](length, options);
+  this[REQUEST_GET_DATA_CALL_LIST](length, {rilRequestError: ERROR_SUCCESS});
 };
 RIL[UNSOLICITED_SUPP_SVC_NOTIFICATION] = null;
 RIL[UNSOLICITED_STK_SESSION_END] = null;
 RIL[UNSOLICITED_STK_PROACTIVE_COMMAND] = null;
 RIL[UNSOLICITED_STK_EVENT_NOTIFY] = null;
 RIL[UNSOLICITED_STK_CALL_SETUP] = null;
 RIL[UNSOLICITED_SIM_SMS_STORAGE_FULL] = null;
 RIL[UNSOLICITED_SIM_REFRESH] = null;
@@ -2324,17 +2391,17 @@ RIL[UNSOLICITED_CDMA_RUIM_SMS_STORAGE_FU
 RIL[UNSOLICITED_RESTRICTED_STATE_CHANGED] = null;
 RIL[UNSOLICITED_ENTER_EMERGENCY_CALLBACK_MODE] = null;
 RIL[UNSOLICITED_CDMA_CALL_WAITING] = null;
 RIL[UNSOLICITED_CDMA_OTA_PROVISION_STATUS] = null;
 RIL[UNSOLICITED_CDMA_INFO_REC] = null;
 RIL[UNSOLICITED_OEM_HOOK_RAW] = null;
 RIL[UNSOLICITED_RINGBACK_TONE] = null;
 RIL[UNSOLICITED_RESEND_INCALL_MUTE] = null;
-RIL[UNSOLICITED_RIL_CONNECTED] = function UNSOLICITED_RIL_CONNECTED(length, options) {
+RIL[UNSOLICITED_RIL_CONNECTED] = function UNSOLICITED_RIL_CONNECTED(length) {
   let version = Buf.readUint32List()[0];
   RILQUIRKS_V5_LEGACY = (version < 5);
   if (DEBUG) {
     debug("Detected RIL version " + version);
     debug("RILQUIRKS_V5_LEGACY is " + RILQUIRKS_V5_LEGACY);
   }
 };