Bug 1113054 - [B2G][RIL] Support RIL version 10. r=hsinyi
authorEdgar Chen <echen@mozilla.com>
Thu, 18 Dec 2014 18:27:55 +0800
changeset 229305 e6ed8f17d3233ca4752d823323b755d446a4e8e2
parent 229304 42787b9fb44f43d60e818d8404caaa7ed0c12d70
child 229306 913d11496669596d0b96692a00aefbb5f8dc42fa
push id11352
push userryanvm@gmail.com
push dateTue, 17 Feb 2015 19:29:37 +0000
treeherderfx-team@b6c56fab513d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs1113054
milestone38.0a1
Bug 1113054 - [B2G][RIL] Support RIL version 10. r=hsinyi
dom/system/gonk/ril_consts.js
dom/system/gonk/ril_worker.js
dom/system/gonk/ril_worker_buf_object.js
--- a/dom/system/gonk/ril_consts.js
+++ b/dom/system/gonk/ril_consts.js
@@ -125,26 +125,41 @@ this.REQUEST_SET_SMSC_ADDRESS = 101;
 this.REQUEST_REPORT_SMS_MEMORY_STATUS = 102;
 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;
+this.REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE = 110;
+this.REQUEST_SET_INITIAL_ATTACH_APN = 111;
+this.REQUEST_IMS_REGISTRATION_STATE = 112;
+this.REQUEST_IMS_SEND_SMS = 113;
+this.REQUEST_SIM_TRANSMIT_APDU_BASIC = 114;
+this.REQUEST_SIM_OPEN_CHANNEL = 115;
+this.REQUEST_SIM_CLOSE_CHANNEL = 116;
+this.REQUEST_SIM_TRANSMIT_APDU_CHANNEL = 117;
+this.REQUEST_NV_READ_ITEM = 118;
+this.REQUEST_NV_WRITE_ITEM = 119;
+this.REQUEST_NV_WRITE_CDMA_PRL = 120;
+this.REQUEST_NV_RESET_CONFIG = 121;
+this.REQUEST_SET_UICC_SUBSCRIPTION = 122;
+this.REQUEST_ALLOW_DATA = 123;
+this.REQUEST_GET_HARDWARE_CONFIG = 124;
+this.REQUEST_SIM_AUTHENTICATION = 125;
+this.REQUEST_GET_DC_RT_INFO = 126;
+this.REQUEST_SET_DC_RT_INFO_RATE = 127;
+this.REQUEST_SET_DATA_PROFILE = 128;
+this.REQUEST_SHUTDOWN = 129;
 
-// 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;
+// CAF specific parcel type. It should be synced with latest version. But CAF
+// doesn't have l version for b2g yet, so we set REQUEST_SET_DATA_SUBSCRIPTION
+// to a value that won't get conflict with known AOSP parcel.
+this.REQUEST_SET_DATA_SUBSCRIPTION = 130;
 
 // Mozilla specific parcel type.
 this.REQUEST_GET_UNLOCK_RETRY_COUNT = 150;
 
 // Fugu specific parcel types.
 this.RIL_REQUEST_GPRS_ATTACH = 5018;
 this.RIL_REQUEST_GPRS_DETACH = 5019;
 
@@ -186,16 +201,22 @@ this.UNSOLICITED_CDMA_INFO_REC = 1027;
 this.UNSOLICITED_OEM_HOOK_RAW = 1028;
 this.UNSOLICITED_RINGBACK_TONE = 1029;
 this.UNSOLICITED_RESEND_INCALL_MUTE = 1030;
 this.UNSOLICITED_CDMA_SUBSCRIPTION_SOURCE_CHANGED = 1031;
 this.UNSOLICITED_CDMA_PRL_CHANGED = 1032;
 this.UNSOLICITED_EXIT_EMERGENCY_CALLBACK_MODE = 1033;
 this.UNSOLICITED_RIL_CONNECTED = 1034;
 this.UNSOLICITED_VOICE_RADIO_TECH_CHANGED = 1035;
+this.UNSOLICITED_CELL_INFO_LIST = 1036;
+this.UNSOLICITED_RESPONSE_IMS_NETWORK_STATE_CHANGED = 1037;
+this.UNSOLICITED_UICC_SUBSCRIPTION_STATUS_CHANGED = 1038;
+this.UNSOLICITED_SRVCC_STATE_NOTIFY = 1039;
+this.UNSOLICITED_HARDWARE_CONFIG_CHANGED = 1040;
+this.UNSOLICITED_DC_RT_INFO_CHANGED = 1041;
 
 this.ERROR_SUCCESS = 0;
 this.ERROR_RADIO_NOT_AVAILABLE = 1;
 this.ERROR_GENERIC_FAILURE = 2;
 this.ERROR_PASSWORD_INCORRECT = 3;
 this.ERROR_SIM_PIN2 = 4;
 this.ERROR_SIM_PUK2 = 5;
 this.ERROR_REQUEST_NOT_SUPPORTED = 6;
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -1317,64 +1317,42 @@ RilObject.prototype = {
   queryVoicePrivacyMode: function(options) {
     this.context.Buf.simpleRequest(REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE, options);
   },
 
   /**
    * Open Logical UICC channel (aid) for Secure Element access
    */
   iccOpenChannel: function(options) {
-    if (DEBUG) {
-      this.context.debug("iccOpenChannel: " + JSON.stringify(options));
-    }
-
     let Buf = this.context.Buf;
     Buf.newParcel(REQUEST_SIM_OPEN_CHANNEL, options);
     Buf.writeString(options.aid);
     Buf.sendParcel();
   },
 
   /**
    * Exchange APDU data on an open Logical UICC channel
    */
   iccExchangeAPDU: function(options) {
-    if (DEBUG) this.context.debug("iccExchangeAPDU: " + JSON.stringify(options));
-
-    let cla = options.apdu.cla;
-    let command = options.apdu.command;
-    let channel = options.channel;
-    let path = options.apdu.path || "";
-    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
-
-    let Buf = this.context.Buf;
-    Buf.newParcel(REQUEST_SIM_ACCESS_CHANNEL, options);
-    Buf.writeInt32(cla);
-    Buf.writeInt32(command);
-    Buf.writeInt32(channel);
-    Buf.writeString(path); // path
-    Buf.writeInt32(p1);
-    Buf.writeInt32(p2);
-    Buf.writeInt32(p3);
-    Buf.writeString(data); // generic data field.
-    Buf.writeString(data2);
-
+    let Buf = this.context.Buf;
+    Buf.newParcel(REQUEST_SIM_TRANSMIT_APDU_CHANNEL, options);
+    Buf.writeInt32(options.channel);
+    Buf.writeInt32(options.apdu.cla);
+    Buf.writeInt32(options.apdu.command);
+    Buf.writeInt32(options.apdu.p1);
+    Buf.writeInt32(options.apdu.p2);
+    Buf.writeInt32(options.apdu.p3);
+    Buf.writeString(options.apdu.data);
     Buf.sendParcel();
   },
 
   /**
    * Close Logical UICC channel
    */
   iccCloseChannel: function(options) {
-    if (DEBUG) this.context.debug("iccCloseChannel: " + JSON.stringify(options));
-
     let Buf = this.context.Buf;
     Buf.newParcel(REQUEST_SIM_CLOSE_CHANNEL, options);
     Buf.writeInt32(1);
     Buf.writeInt32(options.channel);
     Buf.sendParcel();
   },
 
   /**
@@ -5858,57 +5836,16 @@ RilObject.prototype[REQUEST_CHANGE_BARRI
   if (options.rilMessageType != "sendMMI") {
     this.sendChromeMessage(options);
     return;
   }
 
   options.statusMessage = MMI_SM_KS_PASSWORD_CHANGED;
   this.sendChromeMessage(options);
 };
-RilObject.prototype[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 = this.context.Buf.readInt32();
-  if (DEBUG) {
-    this.context.debug("Setting channel number in options: " + options.channel);
-  }
-  this.sendChromeMessage(options);
-};
-RilObject.prototype[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;
-  }
-
-  // No return value
-  this.sendChromeMessage(options);
-};
-RilObject.prototype[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);
-  }
-
-  let Buf = this.context.Buf;
-  options.sw1 = Buf.readInt32();
-  options.sw2 = Buf.readInt32();
-  options.simResponse = Buf.readString();
-  if (DEBUG) {
-    this.context.debug("Setting return values for RIL[REQUEST_SIM_ACCESS_CHANNEL]: [" +
-                       options.sw1 + "," +
-                       options.sw2 + ", " +
-                       options.simResponse + "]");
-  }
-  this.sendChromeMessage(options);
-};
 RilObject.prototype[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 = this.context.Buf.readInt32List();
@@ -6422,22 +6359,74 @@ RilObject.prototype[REQUEST_VOICE_RADIO_
       this.context.debug("Error when getting voice radio tech: " +
                          options.rilRequestError);
     }
     return;
   }
   let radioTech = this.context.Buf.readInt32List();
   this._processRadioTech(radioTech[0]);
 };
+RilObject.prototype[REQUEST_GET_CELL_INFO_LIST] = null;
+RilObject.prototype[REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE] = null;
+RilObject.prototype[REQUEST_SET_INITIAL_ATTACH_APN] = null;
+RilObject.prototype[REQUEST_IMS_REGISTRATION_STATE] = null;
+RilObject.prototype[REQUEST_IMS_SEND_SMS] = null;
+RilObject.prototype[REQUEST_SIM_TRANSMIT_APDU_BASIC] = null;
+RilObject.prototype[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 = this.context.Buf.readInt32();
+  if (DEBUG) {
+    this.context.debug("Setting channel number in options: " + options.channel);
+  }
+  this.sendChromeMessage(options);
+};
+RilObject.prototype[REQUEST_SIM_CLOSE_CHANNEL] = function REQUEST_SIM_CLOSE_CHANNEL(length, options) {
+  this.sendDefaultResponse(options);
+};
+RilObject.prototype[REQUEST_SIM_TRANSMIT_APDU_CHANNEL] = function REQUEST_SIM_TRANSMIT_APDU_CHANNEL(length, options) {
+  if (options.rilRequestError) {
+    options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
+    this.sendChromeMessage(options);
+    return;
+  }
+
+  let Buf = this.context.Buf;
+  options.sw1 = Buf.readInt32();
+  options.sw2 = Buf.readInt32();
+  options.simResponse = Buf.readString();
+  if (DEBUG) {
+    this.context.debug("Setting return values for RIL[REQUEST_SIM_TRANSMIT_APDU_CHANNEL]: [" +
+                       options.sw1 + "," +
+                       options.sw2 + ", " +
+                       options.simResponse + "]");
+  }
+  this.sendChromeMessage(options);
+};
+RilObject.prototype[REQUEST_NV_READ_ITEM] = null;
+RilObject.prototype[REQUEST_NV_WRITE_ITEM] = null;
+RilObject.prototype[REQUEST_NV_WRITE_CDMA_PRL] = null;
+RilObject.prototype[REQUEST_NV_RESET_CONFIG] = null;
 RilObject.prototype[REQUEST_SET_UICC_SUBSCRIPTION] = function REQUEST_SET_UICC_SUBSCRIPTION(length, options) {
   // Resend data subscription after uicc subscription.
   if (this._attachDataRegistration) {
     this.setDataRegistration({attach: true});
   }
 };
+RilObject.prototype[REQUEST_ALLOW_DATA] = null;
+RilObject.prototype[REQUEST_GET_HARDWARE_CONFIG] = null;
+RilObject.prototype[REQUEST_SIM_AUTHENTICATION] = null;
+RilObject.prototype[REQUEST_GET_DC_RT_INFO] = null;
+RilObject.prototype[REQUEST_SET_DC_RT_INFO_RATE] = null;
+RilObject.prototype[REQUEST_SET_DATA_PROFILE] = null;
+RilObject.prototype[REQUEST_SHUTDOWN] = null;
 RilObject.prototype[REQUEST_SET_DATA_SUBSCRIPTION] = function REQUEST_SET_DATA_SUBSCRIPTION(length, options) {
   if (!options.rilMessageType) {
     // The request was made by ril_worker itself. Don't report.
     return;
   }
   options.success = (options.rilRequestError === 0);
   if (!options.success) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
@@ -6822,16 +6811,22 @@ RilObject.prototype[UNSOLICITED_RIL_CONN
 RilObject.prototype[UNSOLICITED_VOICE_RADIO_TECH_CHANGED] = function UNSOLICITED_VOICE_RADIO_TECH_CHANGED(length) {
   // This unsolicited response will be sent when the technology of a multi-tech
   // modem is changed, ex. switch between gsm and cdma.
   // TODO: We may need to do more on updating data when switching between gsm
   //       and cdma mode, e.g. IMEI, ESN, iccInfo, iccType ... etc.
   //       See Bug 866038.
   this._processRadioTech(this.context.Buf.readInt32List()[0]);
 };
+RilObject.prototype[UNSOLICITED_CELL_INFO_LIST] = null;
+RilObject.prototype[UNSOLICITED_RESPONSE_IMS_NETWORK_STATE_CHANGED] = null;
+RilObject.prototype[UNSOLICITED_UICC_SUBSCRIPTION_STATUS_CHANGED] = null;
+RilObject.prototype[UNSOLICITED_SRVCC_STATE_NOTIFY] = null;
+RilObject.prototype[UNSOLICITED_HARDWARE_CONFIG_CHANGED] = null;
+RilObject.prototype[UNSOLICITED_DC_RT_INFO_CHANGED] = null;
 
 /**
  * This object exposes the functionality to parse and serialize PDU strings
  *
  * A PDU is a string containing a series of hexadecimally encoded octets
  * or nibble-swapped binary-coded decimals (BCDs). It contains not only the
  * message text but information about the sender, the SMS service center,
  * timestamp, etc.
--- a/dom/system/gonk/ril_worker_buf_object.js
+++ b/dom/system/gonk/ril_worker_buf_object.js
@@ -24,16 +24,36 @@
     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 = new Map();
     // This is because the underlying 'Buf' is still using the 'init' pattern, so
     // this derived one needs to invoke it.
     // Using 'apply' style to mark it's a parent method calling explicitly.
     Buf._init.apply(this);
+
+    // 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.
+    this._requestMap = {};
+    // RIL version 8.
+    // For 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
+    let map = {};
+    map[REQUEST_SET_UICC_SUBSCRIPTION] = 114;
+    map[REQUEST_SET_DATA_SUBSCRIPTION] = 115;
+    this._requestMap[8] = map;
+    // RIL version 9.
+    // For the CAF's proprietary parcels. Please see
+    // https://www.codeaurora.org/cgit/quic/la/platform/hardware/ril/tree/include/telephony/ril.h?h=b2g_kk_3.5
+    map = {};
+    map[REQUEST_SET_UICC_SUBSCRIPTION] = 115;
+    map[REQUEST_SET_DATA_SUBSCRIPTION] = 116;
+    this._requestMap[9] = map;
   };
 
   /**
    * "inherit" the basic worker buffer.
    */
   BufObject.prototype = Object.create(Buf);
 
   /**
@@ -119,29 +139,28 @@
 
   /**
    * 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.
    */
   BufObject.prototype._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;
+    for (let version in this._requestMap) {
+      if (this.context.RIL.version <= version) {
+        let newType = this._requestMap[version][type];
+        if (newType) {
+          if (DEBUG) {
+            this.context.debug("Remap request type to " + newType);
+          }
+          return newType;
         }
-        break;
+      }
     }
-
-    return newType;
+    return type;
   };
 
   // Before we make sure to form it as a module would not add extra
   // overhead of module loading, we need to define it in this way
   // rather than 'module.exports' it as a module component.
   exports.BufObject = BufObject;
 })(self); // in worker self is the global