From 5b3af25ab6dabf1a54218cca42b816f6eb444a96 Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Tue, 9 Sep 2014 12:29:05 +0800 Subject: [PATCH] Bug 1062720 - Response 0x01 or 0x00 for the "Yes"/"No" request of GET_INKEY. r=hsinyi --- dom/system/gonk/ril_worker.js | 3 +- dom/system/gonk/tests/test_ril_worker_stk.js | 75 ++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index b61771a21a43..0881c9c21ff5 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -3091,7 +3091,8 @@ RilObject.prototype = { // ("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; } diff --git a/dom/system/gonk/tests/test_ril_worker_stk.js b/dom/system/gonk/tests/test_ril_worker_stk.js index 7842402e1da9..35a0e6636d97 100644 --- a/dom/system/gonk/tests/test_ril_worker_stk.js +++ b/dom/system/gonk/tests/test_ril_worker_stk.js @@ -156,6 +156,81 @@ add_test(function test_stk_terminal_response() { 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 /**