Bug 1159134 - Part 1: Fix improper CTLV encoding in STK Event Download. r=echen

This commit is contained in:
Bevis Tseng 2015-05-06 19:25:31 +08:00
Родитель 0fba25d883
Коммит 80a768333b
2 изменённых файлов: 20 добавлений и 8 удалений

Просмотреть файл

@ -2788,8 +2788,10 @@ RilObject.prototype = {
if (options.address) {
GsmPDUHelper.writeHexOctet(COMPREHENSIONTLV_TAG_ADDRESS |
COMPREHENSIONTLV_FLAG_CR);
let addressLength = options.address[0] == '+' ? options.address.length - 1
: options.address.length;
ComprehensionTlvHelper.writeLength(
Math.ceil(options.address.length/2) + 1 // address BCD + TON
Math.ceil(addressLength / 2) + 1 // address BCD + TON
);
this.context.ICCPDUHelper.writeDiallingNumber(options.address);
}
@ -11379,19 +11381,29 @@ ComprehensionTlvHelperObject.prototype = {
let GsmPDUHelper = this.context.GsmPDUHelper;
let cause = -1;
for (let errorNo in RIL_ERROR_TO_GECKO_ERROR) {
if (geckoError == RIL_ERROR_TO_GECKO_ERROR[errorNo]) {
for (let errorNo in RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR) {
if (geckoError == RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[errorNo]) {
cause = errorNo;
break;
}
}
// Causes specified in 10.5.4.11 of TS 04.08 are less than 128.
// we can ignore causes > 127 since Cause TLV is optional in
// STK_EVENT_TYPE_CALL_DISCONNECTED.
if (cause > 127) {
return;
}
cause = (cause == -1) ? ERROR_SUCCESS : cause;
GsmPDUHelper.writeHexOctet(COMPREHENSIONTLV_TAG_CAUSE |
COMPREHENSIONTLV_FLAG_CR);
GsmPDUHelper.writeHexOctet(2); // For single cause value.
// TS 04.08, clause 10.5.4.11: National standard code + user location.
// TS 04.08, clause 10.5.4.11:
// Code Standard : Standard defined for GSM PLMNS
// Location: User
GsmPDUHelper.writeHexOctet(0x60);
// TS 04.08, clause 10.5.4.11: ext bit = 1 + 7 bits for cause.
@ -11438,11 +11450,11 @@ ComprehensionTlvHelperObject.prototype = {
// TS 102.223, clause 8.38
// +----------------+------------------+-------------------+
// | hours (1 byte) | minutes (1 btye) | secounds (1 byte) |
// | hours (1 byte) | minutes (1 btye) | seconds (1 byte) |
// +----------------+------------------+-------------------+
GsmPDUHelper.writeSwappedNibbleBCDNum(Math.floor(seconds / 60 / 60));
GsmPDUHelper.writeSwappedNibbleBCDNum(Math.floor(seconds / 60) % 60);
GsmPDUHelper.writeSwappedNibbleBCDNum(seconds % 60);
GsmPDUHelper.writeSwappedNibbleBCDNum(Math.floor(seconds) % 60);
},
writeTextStringTlv: function(text, coding) {

Просмотреть файл

@ -625,7 +625,7 @@ add_test(function test_write_disconnecting_cause() {
let pduHelper = context.GsmPDUHelper;
let tlvHelper = context.ComprehensionTlvHelper;
tlvHelper.writeCauseTlv(RIL_ERROR_TO_GECKO_ERROR[ERROR_GENERIC_FAILURE]);
tlvHelper.writeCauseTlv(RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_BUSY]);
let tag = pduHelper.readHexOctet();
equal(tag, COMPREHENSIONTLV_TAG_CAUSE | COMPREHENSIONTLV_FLAG_CR);
let len = pduHelper.readHexOctet();
@ -633,7 +633,7 @@ add_test(function test_write_disconnecting_cause() {
let standard = pduHelper.readHexOctet();
equal(standard, 0x60);
let cause = pduHelper.readHexOctet();
equal(cause, 0x80 | ERROR_GENERIC_FAILURE);
equal(cause, 0x80 | CALL_FAIL_BUSY);
run_next_test();
});