Bug 1062720 - Response 0x01 or 0x00 for the "Yes"/"No" request of GET_INKEY. r=hsinyi, a=bajaj
authorEdgar Chen <echen@mozilla.com>
Tue, 09 Sep 2014 12:29:05 +0800
changeset 225004 33c183bacd646dc774a71b93daf50186aac097c3
parent 225003 c61d4add4ba562a96c1563535d0fab051d62459a
child 225005 2e7c9193980f94ea4f1b7028af19da552966aa1d
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, bajaj
bugs1062720
milestone34.0a2
Bug 1062720 - Response 0x01 or 0x00 for the "Yes"/"No" request of GET_INKEY. r=hsinyi, a=bajaj
dom/system/gonk/ril_worker.js
dom/system/gonk/tests/test_ril_worker_stk.js
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -3086,17 +3086,18 @@ RilObject.prototype = {
     if (response.resultCode != STK_RESULT_HELP_INFO_REQUIRED) {
       let text;
       if (response.isYesNo !== undefined) {
         // GET_INKEY
         // When the ME issues a successful TERMINAL RESPONSE for a GET INKEY
         // ("Yes/No") command with command qualifier set to "Yes/No", it shall
         // supply the value '01' when the answer is "positive" and the value
         // '00' when the answer is "negative" in the Text string data object.
-        text = response.isYesNo ? 0x01 : 0x00;
+        text = response.isYesNo ? String.fromCharCode(0x01)
+                                : String.fromCharCode(0x00);
       } else {
         text = response.input;
       }
 
       if (text) {
         GsmPDUHelper.writeHexOctet(COMPREHENSIONTLV_TAG_TEXT_STRING |
                                    COMPREHENSIONTLV_FLAG_CR);
 
--- a/dom/system/gonk/tests/test_ril_worker_stk.js
+++ b/dom/system/gonk/tests/test_ril_worker_stk.js
@@ -151,16 +151,91 @@ add_test(function test_stk_terminal_resp
       }
     },
     input: "Mozilla",
     resultCode: STK_RESULT_OK
   };
   context.RIL.sendStkTerminalResponse(response);
 });
 
+/**
+ * Verify STK terminal response : GET_INKEY - YES/NO request
+ */
+add_test(function test_stk_terminal_response_get_inkey() {
+  function do_test(isYesNo) {
+    let worker = newUint8SupportOutgoingIndexWorker();
+    let context = worker.ContextPool._contexts[0];
+    let buf = context.Buf;
+    let pduHelper = context.GsmPDUHelper;
+
+    buf.sendParcel = function() {
+      // Type
+      do_check_eq(this.readInt32(), REQUEST_STK_SEND_TERMINAL_RESPONSE);
+
+      // Token : we don't care
+      this.readInt32();
+
+      // Data Size, 32 = 2 * (TLV_COMMAND_DETAILS_SIZE(5) +
+      //                      TLV_DEVICE_ID_SIZE(4) +
+      //                      TLV_RESULT_SIZE(3) +
+      //                      TEXT LENGTH(4))
+      do_check_eq(this.readInt32(), 32);
+
+      // Command Details, Type-Length-Value
+      do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_COMMAND_DETAILS |
+                                            COMPREHENSIONTLV_FLAG_CR);
+      do_check_eq(pduHelper.readHexOctet(), 3);
+      do_check_eq(pduHelper.readHexOctet(), 0x01);
+      do_check_eq(pduHelper.readHexOctet(), STK_CMD_GET_INKEY);
+      do_check_eq(pduHelper.readHexOctet(), 0x04);
+
+      // Device Identifies, Type-Length-Value(Source ID-Destination ID)
+      do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_DEVICE_ID);
+      do_check_eq(pduHelper.readHexOctet(), 2);
+      do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_ME);
+      do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_SIM);
+
+      // Result
+      do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_RESULT |
+                                            COMPREHENSIONTLV_FLAG_CR);
+      do_check_eq(pduHelper.readHexOctet(), 1);
+      do_check_eq(pduHelper.readHexOctet(), STK_RESULT_OK);
+
+      // Yes/No response
+      do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_TEXT_STRING |
+                                            COMPREHENSIONTLV_FLAG_CR);
+      do_check_eq(pduHelper.readHexOctet(), 2);
+      do_check_eq(pduHelper.readHexOctet(), STK_TEXT_CODING_GSM_8BIT);
+      do_check_eq(pduHelper.readHexOctet(), isYesNo ? 0x01 : 0x00);
+
+      run_next_test();
+    };
+
+    let response = {
+      command: {
+        commandNumber: 0x01,
+        typeOfCommand: STK_CMD_GET_INKEY,
+        commandQualifier: 0x04,
+        options: {
+          isYesNoRequested: true
+        }
+      },
+      isYesNo: isYesNo,
+      resultCode: STK_RESULT_OK
+    };
+
+    context.RIL.sendStkTerminalResponse(response);
+  };
+
+  // Test "Yes" response
+  do_test(true);
+  // Test "No" response
+  do_test(false);
+});
+
 // Test ComprehensionTlvHelper
 
 /**
  * Verify ComprehensionTlvHelper.writeLocationInfoTlv
  */
 add_test(function test_write_location_info_tlv() {
   let worker = newUint8Worker();
   let context = worker.ContextPool._contexts[0];