Bug 958773 - Don't use js-ctypes in the ril worker r=vicamo
☠☠ backed out by 654854b387dd ☠ ☠
authorFabrice Desré <fabrice@mozilla.com>
Mon, 13 Jan 2014 10:16:05 -0800
changeset 163147 5c6a41cf65df8d97f0180df90c6628168a8955ec
parent 163146 25dac3c4809c0a59aa13134704fdc3c70992a1e2
child 163148 e04013283c0a635977de1e49c3ba0b6d3ffa1e82
child 163154 d524c4b2cbb8c504588921be2dd9b3ed4445f40a
push id3769
push userfdesre@mozilla.com
push dateMon, 13 Jan 2014 19:57:48 +0000
treeherderb2g-inbound@5c6a41cf65df [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvicamo
bugs958773
milestone29.0a1
Bug 958773 - Don't use js-ctypes in the ril worker r=vicamo
dom/system/gonk/RadioInterfaceLayer.js
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -689,17 +689,37 @@ CdmaIccInfo.prototype = {
 
 function RadioInterfaceLayer() {
   gMessageManager.init(this);
   gRadioEnabledController.init(this);
 
   let options = {
     debug: debugPref,
     cellBroadcastDisabled: false,
-    clirMode: RIL.CLIR_DEFAULT
+    clirMode: RIL.CLIR_DEFAULT,
+    quirks: {
+      callstateExtraUint32:
+        libcutils.property_get("ro.moz.ril.callstate_extra_int", "false") === "true",
+      v5Legacy:
+        libcutils.property_get("ro.moz.ril.v5_legacy", "true") === "true",
+      requestUseDialEmergencyCall:
+        libcutils.property_get("ro.moz.ril.dial_emergency_call", "false") === "true",
+      simAppStateExtraFields:
+        libcutils.property_get("ro.moz.ril.simstate_extra_field", "false") === "true",
+      extraUint2ndCall:
+        libcutils.property_get("ro.moz.ril.extra_int_2nd_call", "false") == "true",
+      haveQueryIccLockRetryCount:
+        libcutils.property_get("ro.moz.ril.query_icc_count", "false") == "true",
+      sendStkProfileDownload:
+        libcutils.property_get("ro.moz.ril.send_stk_profile_dl", "false") == "true",
+      dataRegistrationOnDemand:
+        libcutils.property_get("ro.moz.ril.data_reg_on_demand", "false") == "true"
+    },
+    rilEmergencyNumbers: libcutils.property_get("ril.ecclist") ||
+                         libcutils.property_get("ro.ril.ecclist")
   };
 
   try {
     options.cellBroadcastDisabled =
       Services.prefs.getBoolPref(kPrefCellBroadcastDisabled);
   } catch(e) {}
 
   try {
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -33,31 +33,32 @@
  *
  * Note: The code below is purposely lean on abstractions to be as lean in
  * terms of object allocations. As a result, it may look more like C than
  * JavaScript, and that's intended.
  */
 
 "use strict";
 
-importScripts("ril_consts.js", "systemlibs.js");
+importScripts("ril_consts.js");
 importScripts("resource://gre/modules/workers/require.js");
 
 // set to true in ril_consts.js to see debug messages
 let DEBUG = DEBUG_WORKER;
 let CLIENT_ID = -1;
 let GLOBAL = this;
 
 if (!this.debug) {
   // Debugging stub that goes nowhere.
   this.debug = function debug(message) {
     dump("RIL Worker[" + CLIENT_ID + "]: " + message + "\n");
   };
 }
 
+let RIL_EMERGENCY_NUMBERS;
 const DEFAULT_EMERGENCY_NUMBERS = ["112", "911"];
 
 // Timeout value for emergency callback mode.
 const EMERGENCY_CB_MODE_TIMEOUT_MS = 300000;  // 5 mins = 300000 ms.
 
 const ICC_MAX_LINEAR_FIXED_RECORDS = 0xfe;
 
 // MMI match groups
@@ -69,33 +70,32 @@ const MMI_MATCH_GROUP_SIB = 7;
 const MMI_MATCH_GROUP_SIC = 9;
 const MMI_MATCH_GROUP_PWD_CONFIRM = 11;
 const MMI_MATCH_GROUP_DIALING_NUMBER = 12;
 
 const MMI_MAX_LENGTH_SHORT_CODE = 2;
 
 const MMI_END_OF_USSD = "#";
 
-let RILQUIRKS_CALLSTATE_EXTRA_UINT32 = libcutils.property_get("ro.moz.ril.callstate_extra_int", "false") === "true";
+let RILQUIRKS_CALLSTATE_EXTRA_UINT32;
 // This may change at runtime since in RIL v6 and later, we get the version
 // number via the UNSOLICITED_RIL_CONNECTED parcel.
-let RILQUIRKS_V5_LEGACY = libcutils.property_get("ro.moz.ril.v5_legacy", "true") === "true";
-let RILQUIRKS_REQUEST_USE_DIAL_EMERGENCY_CALL = libcutils.property_get("ro.moz.ril.dial_emergency_call", "false") === "true";
-let RILQUIRKS_SIM_APP_STATE_EXTRA_FIELDS = libcutils.property_get("ro.moz.ril.simstate_extra_field", "false") === "true";
+let RILQUIRKS_V5_LEGACY;
+let RILQUIRKS_REQUEST_USE_DIAL_EMERGENCY_CALL;
+let RILQUIRKS_SIM_APP_STATE_EXTRA_FIELDS;
 // Needed for call-waiting on Peak device
-let RILQUIRKS_EXTRA_UINT32_2ND_CALL = libcutils.property_get("ro.moz.ril.extra_int_2nd_call", "false") == "true";
+let RILQUIRKS_EXTRA_UINT32_2ND_CALL;
 // On the emulator we support querying the number of lock retries
-let RILQUIRKS_HAVE_QUERY_ICC_LOCK_RETRY_COUNT = libcutils.property_get("ro.moz.ril.query_icc_count", "false") == "true";
+let RILQUIRKS_HAVE_QUERY_ICC_LOCK_RETRY_COUNT;
 
 // Ril quirk to Send STK Profile Download
-let RILQUIRKS_SEND_STK_PROFILE_DOWNLOAD = libcutils.property_get("ro.moz.ril.send_stk_profile_dl", "false") == "true";
+let RILQUIRKS_SEND_STK_PROFILE_DOWNLOAD;
 
 // Ril quirk to attach data registration on demand.
-let RILQUIRKS_DATA_REGISTRATION_ON_DEMAND =
-  libcutils.property_get("ro.moz.ril.data_reg_on_demand", "false") == "true";
+let RILQUIRKS_DATA_REGISTRATION_ON_DEMAND;
 
 // Marker object.
 let PENDING_NETWORK_TYPE = {};
 
 let Buf = {
   __proto__: (function(){
     return require("resource://gre/modules/workers/worker_buf.js").Buf;
   })(),
@@ -106,39 +106,39 @@ let Buf = {
   init: function() {
     this._init();
 
     // This gets incremented each time we send out a parcel.
     this.mToken = 1;
 
     // Maps tokens we send out with requests to the request type, so that
     // when we get a response parcel back, we know what request it was for.
-    this.mTokenRequestMap = {};
+    this.mTokenRequestMap = new Map();
   },
 
   /**
    * Process one parcel.
    */
   processParcel: function() {
     let response_type = this.readInt32();
 
     let request_type, options;
     if (response_type == RESPONSE_TYPE_SOLICITED) {
       let token = this.readInt32();
       let error = this.readInt32();
 
-      options = this.mTokenRequestMap[token];
+      options = this.mTokenRequestMap.get(token);
       if (!options) {
         if (DEBUG) {
           debug("Suspicious uninvited request found: " + token + ". Ignored!");
         }
         return;
       }
 
-      delete this.mTokenRequestMap[token];
+      this.mTokenRequestMap.delete(token);
       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) {
@@ -169,17 +169,17 @@ let Buf = {
     this.writeInt32(type);
     this.writeInt32(this.mToken);
 
     if (!options) {
       options = {};
     }
     options.rilRequestType = type;
     options.rilRequestError = null;
-    this.mTokenRequestMap[this.mToken] = options;
+    this.mTokenRequestMap.set(this.mToken, options);
     this.mToken++;
     return this.mToken;
   },
 
   simpleRequest: function(type, options) {
     this.newParcel(type, options);
     this.sendParcel();
   },
@@ -2907,22 +2907,18 @@ let RIL = {
 
   /**
    * Check a given number against the list of emergency numbers provided by the RIL.
    *
    * @param number
    *        The number to look up.
    */
    _isEmergencyNumber: function(number) {
-     // Check read-write ecclist property first.
-     let numbers = libcutils.property_get("ril.ecclist");
-     if (!numbers) {
-       // Then read-only ecclist property since others RIL only uses this.
-       numbers = libcutils.property_get("ro.ril.ecclist");
-     }
+     // Check ril provided numbers first.
+     let numbers = RIL_EMERGENCY_NUMBERS;
 
      if (numbers) {
        numbers = numbers.split(",");
      } else {
        // No ecclist system property, so use our own list.
        numbers = DEFAULT_EMERGENCY_NUMBERS;
      }
 
@@ -3580,21 +3576,18 @@ let RIL = {
 
         if (newCall.state == CALL_STATE_INCOMING) {
           newCall.isOutgoing = false;
         } else if (newCall.state == CALL_STATE_DIALING) {
           newCall.isOutgoing = true;
         }
 
         // Set flag for outgoing emergency call.
-        if (newCall.isOutgoing && this._isEmergencyNumber(newCall.number)) {
-          newCall.isEmergency = true;
-        } else {
-          newCall.isEmergency = false;
-        }
+        newCall.isEmergency = newCall.isOutgoing &&
+                              this._isEmergencyNumber(newCall.number);
 
         // Add to our map.
         if (newCall.isMpty) {
           conferenceChanged = true;
           newCall.isConference = true;
           this.currentConference.participants[newCall.callIndex] = newCall;
         } else {
           newCall.isConference = false;
@@ -4957,16 +4950,26 @@ let RIL = {
     }
   },
 
   setInitialOptions: function(options) {
     DEBUG = DEBUG_WORKER || options.debug;
     CLIENT_ID = options.clientId;
     this.cellBroadcastDisabled = options.cellBroadcastDisabled;
     this.clirMode = options.clirMode;
+    RIL_EMERGENCY_NUMBERS = options.rilEmergencyNumbers;
+    let quirks = options.quirks;
+    RILQUIRKS_CALLSTATE_EXTRA_UINT32 = quirks.callstateExtraUint32;
+    RILQUIRKS_V5_LEGACY = quirks.v5Legacy;
+    RILQUIRKS_REQUEST_USE_DIAL_EMERGENCY_CALL = quirks.requestUseDialEmergencyCall;
+    RILQUIRKS_SIM_APP_STATE_EXTRA_FIELDS = quirks.simAppStateExtraFields;
+    RILQUIRKS_EXTRA_UINT32_2ND_CALL = quirks.extraUint2ndCall;
+    RILQUIRKS_HAVE_QUERY_ICC_LOCK_RETRY_COUNT = quirks.haveQueryIccLockRetryCount;
+    RILQUIRKS_SEND_STK_PROFILE_DOWNLOAD = quirks.sendStkProfileDownload;
+    RILQUIRKS_DATA_REGISTRATION_ON_DEMAND = quirks.dataRegistrationOnDemand;
   }
 };
 
 RIL.initRILState();
 
 RIL[REQUEST_GET_SIM_STATUS] = function(length, options) {
   if (options.rilRequestError) {
     return;