Bug 733990 - Handle errors for ICC IO. r=philikon
authorYoshi Huang <yhuang@mozilla.com>
Wed, 28 Mar 2012 20:46:06 -0700
changeset 90591 2aaa5dbfcca538f177771a7916080b3dd436e88a
parent 90590 fcfebfd76082cad98004276bce8e9da72f0aa203
child 90592 5c63b21280c25d4460fbf206f839ea2b5c7bb688
push id22366
push usermak77@bonardo.net
push dateThu, 29 Mar 2012 15:38:30 +0000
treeherdermozilla-central@ff3521bc6559 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilikon
bugs733990
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 733990 - Handle errors for ICC IO. r=philikon
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
@@ -432,22 +432,25 @@ const READ_RECORD_ABSOLUTE_MODE = 4;
 // GET_RESPONSE mandatory response size for EF, see TS 51.011 clause 9, 
 // 'Response data in case of an EF.'
 const GET_RESPONSE_EF_SIZE_BYTES = 15;
 
 // EF path
 const EF_PATH_MF_SIM = "3f00";
 const EF_PATH_DF_TELECOM = "7f10";
 
-// Status code for ICC I/O, 
-// see GSM11.11 and TS 51.011 clause 9.4.
-const STATUS_NORMAL_ENDING = 0x90;
-const STATUS_NORMAL_ENDING_WITH_EXTRA = 0x91;
-const STATUS_WITH_SIM_DATA = 0x9e;
-const STATUS_WITH_RESPONSE_DATA = 0x9f;
+// Status code of sw1 for ICC I/O,
+// see GSM11.11 and TS 51.011 clause 9.4, and ISO 7816-4
+const ICC_STATUS_NORMAL_ENDING = 0x90;
+const ICC_STATUS_NORMAL_ENDING_WITH_EXTRA = 0x91;
+const ICC_STATUS_WITH_SIM_DATA = 0x9e;
+const ICC_STATUS_WITH_RESPONSE_DATA = 0x9f;
+const ICC_STATUS_ERROR_WRONG_LENGTH = 0x67;
+const ICC_STATUS_ERROR_COMMAND_NOT_ALLOWED = 0x69;
+const ICC_STATUS_ERROR_WRONG_PARAMETERS = 0x6a;
 
 /**
  * GSM PDU constants
  */
 
 // PDU TYPE-OF-ADDRESS
 const PDU_TOA_UNKNOWN       = 0x80; // Unknown. This is used when the user or
                                     // network has no a priori information
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -1239,26 +1239,16 @@ let RIL = {
     this.sendDOMMessage({type: "cardstatechange",
                          cardState: this.cardState});
   },
 
   /**
    * Process the MSISDN ICC I/O response.
    */
   _processMSISDNResponse: function _processMSISDNResponse(options) {
-    let sw1 = Buf.readUint32();
-    let sw2 = Buf.readUint32();
-    // See GSM11.11 section 9.4 for sw1 and sw2
-    if (sw1 != STATUS_NORMAL_ENDING) {
-      // TODO: error 
-      // Wait for fix for Bug 733990 to report error.
-      debug("Error in iccIO");
-    }
-    if (DEBUG) debug("ICC I/O (" + sw1 + "/" + sw2 + ")");
-
     switch (options.command) {
       case ICC_COMMAND_GET_RESPONSE:
         let response = Buf.readString();
         let recordSize = parseInt(
             response.substr(RESPONSE_DATA_RECORD_LENGTH * 2, 2), 16) & 0xff;
         let options = {
           command: ICC_COMMAND_READ_RECORD,
           fileid:  ICC_EF_MSISDN,
@@ -1818,16 +1808,27 @@ RIL[REQUEST_SETUP_DATA_CALL] = function 
     // 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) {
+  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) + ")");
+    return;
+  }
+
   switch (options.fileid) {
     case ICC_EF_MSISDN:
       this._processMSISDNResponse(options);
       break;
   }
 };
 RIL[REQUEST_SEND_USSD] = null;
 RIL[REQUEST_CANCEL_USSD] = null;