Bug 786831 - Part 3: Update RIL implementations. r=philikon
authorYoshi Huang <allstars.chh@mozilla.com>
Wed, 29 Aug 2012 19:09:12 -0300
changeset 103931 604c5f59c5e0ccea33efd20b8bd7836eda81b3c7
parent 103930 7ea41d5679c4293b7e7056703f2b89ff86e440c3
child 103932 28c0040c73a36c8875b0dcd989d22c4c919580e3
push id14254
push useryhuang@mozilla.com
push dateThu, 30 Aug 2012 21:27:22 +0000
treeherdermozilla-inbound@604c5f59c5e0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilikon
bugs786831
milestone18.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 786831 - Part 3: Update RIL implementations. r=philikon
dom/system/gonk/RILContentHelper.js
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/RILContentHelper.js
+++ b/dom/system/gonk/RILContentHelper.js
@@ -376,21 +376,22 @@ RILContentHelper.prototype = {
                                  Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
     cpmm.sendAsyncMessage("RIL:CancelUSSD", {requestId: requestId});
     return request;
   },
 
-  sendStkResponse: function sendStkResponse(window, response) {
+  sendStkResponse: function sendStkResponse(window, command, response) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
+    response.command = command;
     cpmm.sendAsyncMessage("RIL:SendStkResponse", response);
   },
 
   sendStkMenuSelection: function sendStkMenuSelection(window,
                                                       itemIdentifier,
                                                       helpRequested) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -1933,19 +1933,17 @@ let RIL = {
      Buf.writeUint32(1);
      Buf.writeUint32(options.hasConfirmed ? 1 : 0);
      Buf.sendParcel();
   },
 
   /**
    * Send STK terminal response.
    *
-   * @param commandNumber
-   * @param typeOfCommand
-   * @param commandQualifier
+   * @param command
    * @param resultCode
    * @param [optional] itemIdentifier
    * @param [optional] input
    * @param [optional] isYesNo
    * @param [optional] isUCS2
    * @param [optional] isPacked
    * @param [optional] hasConfirmed
    */
@@ -1979,19 +1977,25 @@ let RIL = {
                 (response.itemIdentifier ? 3 : 0) +
                 (textLen ? textLen + 3 : 0)) * 2;
     Buf.writeUint32(size);
 
     // Command Details
     GsmPDUHelper.writeHexOctet(COMPREHENSIONTLV_TAG_COMMAND_DETAILS |
                                COMPREHENSIONTLV_FLAG_CR);
     GsmPDUHelper.writeHexOctet(3);
-    GsmPDUHelper.writeHexOctet(response.commandNumber);
-    GsmPDUHelper.writeHexOctet(response.typeOfCommand);
-    GsmPDUHelper.writeHexOctet(response.commandQualifier);
+    if (response.command) {
+      GsmPDUHelper.writeHexOctet(response.command.commandNumber);
+      GsmPDUHelper.writeHexOctet(response.command.typeOfCommand);
+      GsmPDUHelper.writeHexOctet(response.command.commandQualifier);
+    } else {
+      GsmPDUHelper.writeHexOctet(0x00);
+      GsmPDUHelper.writeHexOctet(0x00);
+      GsmPDUHelper.writeHexOctet(0x00);
+    }
 
     // Device Identifier
     // According to TS102.223/TS31.111 section 6.8 Structure of
     // TERMINAL RESPONSE, "For all SIMPLE-TLV objects with Min=N,
     // the ME should set the CR(comprehension required) flag to
     // comprehension not required.(CR=0)"
     // Since DEVICE_IDENTITIES and DURATION TLVs have Min=N,
     // the CR flag is not set.
@@ -3065,37 +3069,32 @@ let RIL = {
     let berTlv = BerTlvHelper.decode(length / 2);
     Buf.readStringDelimiter(length);
 
     let ctlvs = berTlv.value;
     let ctlv = StkProactiveCmdHelper.searchForTag(
         COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs);
     if (!ctlv) {
       RIL.sendStkTerminalResponse({
-        commandNumber: 0,
-        typeOfCommand: 0,
-        commandQualifier: 0,
         resultCode: STK_RESULT_CMD_DATA_NOT_UNDERSTOOD});
       throw new Error("Can't find COMMAND_DETAILS ComprehensionTlv");
     }
 
     let cmdDetails = ctlv.value;
     if (DEBUG) {
       debug("commandNumber = " + cmdDetails.commandNumber +
            " typeOfCommand = " + cmdDetails.typeOfCommand.toString(16) +
            " commandQualifier = " + cmdDetails.commandQualifier);
     }
 
     let param = StkCommandParamsFactory.createParam(cmdDetails, ctlvs);
     if (param) {
-      RIL.sendDOMMessage({rilMessageType: "stkcommand",
-                          commandNumber: cmdDetails.commandNumber,
-                          typeOfCommand: cmdDetails.typeOfCommand,
-                          commandQualifier: cmdDetails.commandQualifier,
-                          options: param});
+      cmdDetails.rilMessageType = "stkcommand";
+      cmdDetails.options = param;
+      RIL.sendDOMMessage(cmdDetails);
     }
   },
 
   /**
    * Send messages to the main thread.
    */
   sendDOMMessage: function sendDOMMessage(message) {
     postMessage(message, "*");
@@ -5421,20 +5420,18 @@ let StkCommandParamsFactory = {
       let ctlv = ctlvs[i];
       if (ctlv.tag == COMPREHENSIONTLV_TAG_ITEM) {
         menu.items.push(ctlv.value);
       }
     }
 
     if (menu.items.length == 0) {
       RIL.sendStkTerminalResponse({
-          commandNumber: cmdDetails.commandNumber,
-          typeOfCommand: cmdDetails.typeOfCommand,
-          commandQualifier: cmdDetails.commandQualifier,
-          resultCode: STK_RESULT_REQUIRED_VALUES_MISSING});
+        command: cmdDetails,
+        resultCode: STK_RESULT_REQUIRED_VALUES_MISSING});
       throw new Error("Stk Menu: Required value missing : items");
     }
 
     ctlv = StkProactiveCmdHelper.searchForTag(COMPREHENSIONTLV_TAG_ITEM_ID, ctlvs);
     if (ctlv) {
       menu.defaultItem = ctlv.value.identifier - 1;
     }
 
@@ -5450,19 +5447,17 @@ let StkCommandParamsFactory = {
   },
 
   processDisplayText: function processDisplayText(cmdDetails, ctlvs) {
     let textMsg = {};
 
     let ctlv = StkProactiveCmdHelper.searchForTag(COMPREHENSIONTLV_TAG_TEXT_STRING, ctlvs);
     if (!ctlv) {
       RIL.sendStkTerminalResponse({
-        commandNumber: cmdDetails.commandNumber,
-        typeOfCommand: cmdDetails.typeOfCommand,
-        commandQualifier: cmdDetails.commandQualifier,
+        command: cmdDetails,
         resultCode: STK_RESULT_REQUIRED_VALUES_MISSING});
       throw new Error("Stk Display Text: Required value missing : Text String");
     }
     textMsg.text = ctlv.value.textString;
 
     ctlv = StkProactiveCmdHelper.searchForTag(COMPREHENSIONTLV_TAG_IMMEDIATE_RESPONSE, ctlvs);
     if (ctlv) {
       textMsg.responseNeeded = true;
@@ -5482,36 +5477,32 @@ let StkCommandParamsFactory = {
   },
 
   processSetUpIdleModeText: function processSetUpIdleModeText(cmdDetails, ctlvs) {
     let textMsg = {};
 
     let ctlv = StkProactiveCmdHelper.searchForTag(COMPREHENSIONTLV_TAG_TEXT_STRING, ctlvs);
     if (!ctlv) {
       RIL.sendStkTerminalResponse({
-        commandNumber: cmdDetails.commandNumber,
-        typeOfCommand: cmdDetails.typeOfCommand,
-        commandQualifier: cmdDetails.commandQualifier,
+        command: cmdDetails,
         resultCode: STK_RESULT_REQUIRED_VALUES_MISSING});
       throw new Error("Stk Set Up Idle Text: Required value missing : Text String");
     }
     textMsg.text = ctlv.value.textString;
 
     return textMsg;
   },
 
   processGetInkey: function processGetInkey(cmdDetails, ctlvs) {
     let input = {};
 
     let ctlv = StkProactiveCmdHelper.searchForTag(COMPREHENSIONTLV_TAG_TEXT_STRING, ctlvs);
     if (!ctlv) {
       RIL.sendStkTerminalResponse({
-        commandNumber: cmdDetails.commandNumber,
-        typeOfCommand: cmdDetails.typeOfCommand,
-        commandQualifier: cmdDetails.commandQualifier,
+        command: cmdDetails,
         resultCode: STK_RESULT_REQUIRED_VALUES_MISSING});
       throw new Error("Stk Get InKey: Required value missing : Text String");
     }
     input.text = ctlv.value.textString;
 
     input.minLength = 1;
     input.maxLength = 1;
 
@@ -5540,19 +5531,17 @@ let StkCommandParamsFactory = {
   },
 
   processGetInput: function processGetInput(cmdDetails, ctlvs) {
     let input = {};
 
     let ctlv = StkProactiveCmdHelper.searchForTag(COMPREHENSIONTLV_TAG_TEXT_STRING, ctlvs);
     if (!ctlv) {
       RIL.sendStkTerminalResponse({
-        commandNumber: cmdDetails.commandNumber,
-        typeOfCommand: cmdDetails.typeOfCommand,
-        commandQualifier: cmdDetails.commandQualifier,
+        command: cmdDetails,
         resultCode: STK_RESULT_REQUIRED_VALUES_MISSING});
       throw new Error("Stk Get Input: Required value missing : Text String");
     }
     input.text = ctlv.value.textString;
 
     ctlv = StkProactiveCmdHelper.searchForTag(COMPREHENSIONTLV_TAG_RESPONSE_LENGTH, ctlvs);
     if (ctlv) {
       input.minLength = ctlv.value.minLength;
@@ -5593,19 +5582,17 @@ let StkCommandParamsFactory = {
   },
 
   processEventNotify: function processEventNotify(cmdDetails, ctlvs) {
     let textMsg = {};
 
     let ctlv = StkProactiveCmdHelper.searchForTag(COMPREHENSIONTLV_TAG_ALPHA_ID, ctlvs);
     if (!ctlv) {
       RIL.sendStkTerminalResponse({
-        commandNumber: cmdDetails.commandNumber,
-        typeOfCommand: cmdDetails.typeOfCommand,
-        commandQualifier: cmdDetails.commandQualifier,
+        command: cmdDetails,
         resultCode: STK_RESULT_REQUIRED_VALUES_MISSING});
       throw new Error("Stk Event Notfiy: Required value missing : Alpha ID");
     }
     textMsg.text = ctlv.value.identifier;
 
     return textMsg;
   },
 
@@ -5622,36 +5609,32 @@ let StkCommandParamsFactory = {
           break;
         }
       }
     }
 
     let ctlv = StkProactiveCmdHelper.searchForTag(COMPREHENSIONTLV_TAG_ADDRESS, ctlvs);
     if (!ctlv) {
       RIL.sendStkTerminalResponse({
-        commandNumber: cmdDetails.commandNumber,
-        typeOfCommand: cmdDetails.typeOfCommand,
-        commandQualifier: cmdDetails.commandQualifier,
+        command: cmdDetails,
         resultCode: STK_RESULT_REQUIRED_VALUES_MISSING});
       throw new Error("Stk Set Up Call: Required value missing : Adress");
     }
     call.address = ctlv.value.number;
 
     return call;
   },
 
   processLaunchBrowser: function processLaunchBrowser(cmdDetails, ctlvs) {
     let browser = {};
 
     let ctlv = StkProactiveCmdHelper.searchForTag(COMPREHENSIONTLV_TAG_URL, ctlvs);
     if (!ctlv) {
       RIL.sendStkTerminalResponse({
-        commandNumber: cmdDetails.commandNumber,
-        typeOfCommand: cmdDetails.typeOfCommand,
-        commandQualifier: cmdDetails.commandQualifier,
+        command: cmdDetails,
         resultCode: STK_RESULT_REQUIRED_VALUES_MISSING});
       throw new Error("Stk Launch Browser: Required value missing : URL");
     }
     browser.url = ctlv.value.url;
 
     ctlv = StkProactiveCmdHelper.searchForTag(COMPREHENSIONTLV_TAG_ALPHA_ID, ctlvs)
     if (ctlv) {
       browser.confirmMessage = ctlv.value.identifier;
@@ -5909,19 +5892,16 @@ let ComprehensionTlvHelper = {
     // TS 101.220, clause 7.1.1
     let tag, tagValue, cr;
     switch (temp) {
       // TS 101.220, clause 7.1.1
       case 0x0: // Not used.
       case 0xff: // Not used.
       case 0x80: // Reserved for future use.
         RIL.sendStkTerminalResponse({
-          commandNumber: 0,
-          typeOfCommand: 0,
-          commandQualifier: 0,
           resultCode: STK_RESULT_CMD_DATA_NOT_UNDERSTOOD});
         throw new Error("Invalid octet when parsing Comprehension TLV :" + temp);
         break;
       case 0x7f: // Tag is three byte format.
         // TS 101.220 clause 7.1.1.2.
         // | Byte 1 | Byte 2                        | Byte 3 |
         // |        | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |        |
         // | 0x7f   |CR | Tag Value                          |
@@ -5954,51 +5934,39 @@ let ComprehensionTlvHelper = {
     hlen++;
     if (temp < 0x80) {
       length = temp;
     } else if (temp == 0x81) {
       length = GsmPDUHelper.readHexOctet();
       hlen++;
       if (length < 0x80) {
         RIL.sendStkTerminalResponse({
-          commandNumber: 0,
-          typeOfCommand: 0,
-          commandQualifier: 0,
           resultCode: STK_RESULT_CMD_DATA_NOT_UNDERSTOOD});
         throw new Error("Invalid length in Comprehension TLV :" + length);
       }
     } else if (temp == 0x82) {
       length = (GsmPDUHelper.readHexOctet() << 8) | GsmPDUHelper.readHexOctet();
       hlen += 2;
       if (lenth < 0x0100) {
          RIL.sendStkTerminalResponse({
-          commandNumber: 0,
-          typeOfCommand: 0,
-          commandQualifier: 0,
           resultCode: STK_RESULT_CMD_DATA_NOT_UNDERSTOOD});
         throw new Error("Invalid length in 3-byte Comprehension TLV :" + length);
       }
     } else if (temp == 0x83) {
       length = (GsmPDUHelper.readHexOctet() << 16) |
                (GsmPDUHelper.readHexOctet() << 8)  |
                 GsmPDUHelper.readHexOctet();
       hlen += 3;
       if (length < 0x010000) {
         RIL.sendStkTerminalResponse({
-          commandNumber: 0,
-          typeOfCommand: 0,
-          commandQualifier: 0,
           resultCode: STK_RESULT_CMD_DATA_NOT_UNDERSTOOD});
         throw new Error("Invalid length in 4-byte Comprehension TLV :" + length);
       }
     } else {
       RIL.sendStkTerminalResponse({
-        commandNumber: 0,
-        typeOfCommand: 0,
-        commandQualifier: 0,
         resultCode: STK_RESULT_CMD_DATA_NOT_UNDERSTOOD});
       throw new Error("Invalid octet in Comprehension TLV :" + length);
     }
 
     let ctlv = {
       tag: tag,
       length: length,
       value: StkProactiveCmdHelper.retrieve(tag, length),
@@ -6042,45 +6010,33 @@ let BerTlvHelper = {
       let temp = GsmPDUHelper.readHexOctet();
       hlen++;
       if (temp < 0x80) {
         length = temp;
       } else if(temp == 0x81) {
         length = GsmPDUHelper.readHexOctet();
         if (length < 0x80) {
           RIL.sendStkTerminalResponse({
-            commandNumber: 0,
-            typeOfCommand: 0,
-            commandQualifier: 0,
             resultCode: STK_RESULT_CMD_DATA_NOT_UNDERSTOOD});
           throw new Error("Invalid length " + length);
         }
       } else {
         RIL.sendStkTerminalResponse({
-          commandNumber: 0,
-          typeOfCommand: 0,
-          commandQualifier: 0,
           resultCode: STK_RESULT_CMD_DATA_NOT_UNDERSTOOD});
         throw new Error("Invalid length octet " + temp);
       }
     } else {
       RIL.sendStkTerminalResponse({
-        commandNumber: 0,
-        typeOfCommand: 0,
-        commandQualifier: 0,
         resultCode: STK_RESULT_CMD_DATA_NOT_UNDERSTOOD});
       throw new Error("Unknown BER tag");
     }
 
     // If the value length of the BerTlv is larger than remaining value on Parcel.
     if (dataLen - hlen < length) {
       RIL.sendStkTerminalResponse({
-        commandNumber: 0,
-        typeOfCommand: 0,
-        commandQualifier: 0,
         resultCode: STK_RESULT_CMD_DATA_NOT_UNDERSTOOD});
       throw new Error("BerTlvHelper value length too long!!");
       return;
     }
 
     let ctlvs = ComprehensionTlvHelper.decodeChunks(length);
     let berTlv = {
       tag: tag,