Bug 1052865 - Mapping the request to different ID based on RIL version. r=hsinyi
authorEdgar Chen <echen@mozilla.com>
Sun, 24 Aug 2014 23:52:00 +0800
changeset 223445 f34d90b1fa1ace3f9b2ef22849b4da5b6465b14a
parent 223444 f6b6edc6f9ed1a94e5177380484d3bbf03f59960
child 223446 442b4849df8607cbbe71a874e15314144106edf3
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs1052865
milestone34.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 1052865 - Mapping the request to different ID based on RIL version. r=hsinyi
dom/system/gonk/ril_consts.js
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/ril_consts.js
+++ b/dom/system/gonk/ril_consts.js
@@ -126,21 +126,20 @@ this.REQUEST_REPORT_SMS_MEMORY_STATUS = 
 this.REQUEST_REPORT_STK_SERVICE_IS_RUNNING = 103;
 this.REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE = 104;
 this.REQUEST_ISIM_AUTHENTICATION = 105;
 this.REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU = 106;
 this.REQUEST_STK_SEND_ENVELOPE_WITH_STATUS = 107;
 this.REQUEST_VOICE_RADIO_TECH = 108;
 this.REQUEST_GET_CELL_INFO_LIST = 109;
 
-// Flame specific parcel types.
-this.REQUEST_SET_UICC_SUBSCRIPTION = 114;
-this.REQUEST_SET_DATA_SUBSCRIPTION = 115;
-this.REQUEST_GET_UICC_SUBSCRIPTION = 116;
-this.REQUEST_GET_DATA_SUBSCRIPTION = 117;
+// CAF specific parcel type. Synced with latest version.
+// Please see https://www.codeaurora.org/cgit/quic/la/platform/hardware/ril/tree/include/telephony/ril.h?h=b2g_kk_3.5
+this.REQUEST_SET_UICC_SUBSCRIPTION = 115;
+this.REQUEST_SET_DATA_SUBSCRIPTION = 116;
 
 // UICC Secure Access.
 this.REQUEST_SIM_OPEN_CHANNEL = 121;
 this.REQUEST_SIM_CLOSE_CHANNEL = 122;
 this.REQUEST_SIM_ACCESS_CHANNEL = 123;
 
 // Mozilla specific parcel type.
 this.REQUEST_GET_UNLOCK_RETRY_COUNT = 150;
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -165,17 +165,17 @@ BufObject.prototype = {
    *        Object containing information about the request, e.g. the
    *        original main thread message object that led to the RIL request.
    */
   newParcel: function(type, options) {
     if (DEBUG) this.context.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.writeInt32(type);
+    this.writeInt32(this._reMapRequestType(type));
     this.writeInt32(this.mToken);
 
     if (!options) {
       options = {};
     }
     options.rilRequestType = type;
     options.rilRequestError = null;
     this.mTokenRequestMap.set(this.mToken, options);
@@ -185,16 +185,38 @@ BufObject.prototype = {
 
   simpleRequest: function(type, options) {
     this.newParcel(type, options);
     this.sendParcel();
   },
 
   onSendParcel: function(parcel) {
     postRILMessage(this.context.clientId, parcel);
+  },
+
+  /**
+   * Remapping the request type to different values based on RIL version.
+   * We only have to do this for SUBSCRIPTION right now, so I just make it
+   * simple. A generic logic or structure could be discussed if we have more
+   * use cases, especially the cases from different partners.
+   */
+  _reMapRequestType: function(type) {
+    let newType = type;
+    switch (type) {
+      case REQUEST_SET_UICC_SUBSCRIPTION:
+      case REQUEST_SET_DATA_SUBSCRIPTION:
+        if (this.context.RIL.version < 9) {
+          // Shift the CAF's proprietary parcels. Please see
+          // https://www.codeaurora.org/cgit/quic/la/platform/hardware/ril/tree/include/telephony/ril.h?h=b2g_jb_3.2
+          newType = type - 1;
+        }
+        break;
+    }
+
+    return newType;
   }
 };
 
 (function() {
   let base = require("resource://gre/modules/workers/worker_buf.js").Buf;
   for (let p in base) {
     BufObject.prototype[p] = base[p];
   }
@@ -350,16 +372,20 @@ function RilObject(aContext) {
   // Init properties that are only initialized once.
   this.v5Legacy = RILQUIRKS_V5_LEGACY;
 
   this.pendingMO = null;
 }
 RilObject.prototype = {
   context: null,
 
+  /**
+   * RIL version.
+   */
+  version: null,
   v5Legacy: null,
 
   /**
    * Valid calls.
    */
   currentCalls: null,
 
   /**
@@ -6741,18 +6767,16 @@ RilObject.prototype[REQUEST_SET_DATA_SUB
     return;
   }
   options.success = (options.rilRequestError === 0);
   if (!options.success) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
   }
   this.sendChromeMessage(options);
 };
-RilObject.prototype[REQUEST_GET_UICC_SUBSCRIPTION] = null;
-RilObject.prototype[REQUEST_GET_DATA_SUBSCRIPTION] = null;
 RilObject.prototype[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 ? this.context.Buf.readInt32List()[0] : -1;
   this.sendChromeMessage(options);
 };
@@ -7089,20 +7113,20 @@ RilObject.prototype[UNSOLICITED_EXIT_EME
 };
 RilObject.prototype[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 = this.context.Buf.readInt32List()[0];
-  this.v5Legacy = (version < 5);
+  this.version = this.context.Buf.readInt32List()[0];
+  this.v5Legacy = (this.version < 5);
   if (DEBUG) {
-    this.context.debug("Detected RIL version " + version);
+    this.context.debug("Detected RIL version " + this.version);
     this.context.debug("this.v5Legacy is " + this.v5Legacy);
   }
 
   this.initRILState();
   // Always ensure that we are not in emergency callback mode when init.
   this.exitEmergencyCbMode();
   // Reset radio in the case that b2g restart (or crash).
   this.setRadioEnabled({enabled: false});