зеркало из https://github.com/mozilla/gecko-dev.git
Bug 891242 - [MMI] Short Code MMI (length<3) does not work as expected - Gecko part, r=HsinYi
This commit is contained in:
Родитель
f7548efd1c
Коммит
d54991e50e
|
@ -2177,13 +2177,52 @@ let RIL = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Helper to parse and process a MMI string.
|
||||
* Helper to parse MMI/USSD string. TS.22.030 Figure 3.5.3.2.
|
||||
*/
|
||||
_parseMMI: function _parseMMI(mmiString) {
|
||||
if (!mmiString || !mmiString.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let matches = this._matchMMIRegexp(mmiString);
|
||||
if (matches) {
|
||||
// After successfully executing the regular expresion over the MMI string,
|
||||
// the following match groups should contain:
|
||||
// 1 = full MMI string that might be used as a USSD request.
|
||||
// 2 = MMI procedure.
|
||||
// 3 = Service code.
|
||||
// 5 = SIA.
|
||||
// 7 = SIB.
|
||||
// 9 = SIC.
|
||||
// 11 = Password registration.
|
||||
// 12 = Dialing number.
|
||||
return {
|
||||
fullMMI: matches[MMI_MATCH_GROUP_FULL_MMI],
|
||||
procedure: matches[MMI_MATCH_GROUP_MMI_PROCEDURE],
|
||||
serviceCode: matches[MMI_MATCH_GROUP_SERVICE_CODE],
|
||||
sia: matches[MMI_MATCH_GROUP_SIA],
|
||||
sib: matches[MMI_MATCH_GROUP_SIB],
|
||||
sic: matches[MMI_MATCH_GROUP_SIC],
|
||||
pwd: matches[MMI_MATCH_GROUP_PWD_CONFIRM],
|
||||
dialNumber: matches[MMI_MATCH_GROUP_DIALING_NUMBER]
|
||||
};
|
||||
}
|
||||
|
||||
if (this._isPoundString(mmiString) ||
|
||||
this._isMMIShortString(mmiString)) {
|
||||
return {
|
||||
fullMMI: mmiString
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper to parse MMI string via regular expression. TS.22.030 Figure
|
||||
* 3.5.3.2.
|
||||
*/
|
||||
_matchMMIRegexp: function _matchMMIRegexp(mmiString) {
|
||||
// Regexp to parse and process the MMI code.
|
||||
if (this._mmiRegExp == null) {
|
||||
// The first group of the regexp takes the whole MMI string.
|
||||
|
@ -2226,41 +2265,41 @@ let RIL = {
|
|||
|
||||
this._mmiRegExp = new RegExp(pattern);
|
||||
}
|
||||
let matches = this._mmiRegExp.exec(mmiString);
|
||||
|
||||
// If the regex does not apply over the MMI string, it can still be an MMI
|
||||
// code. If the MMI String is a #-string (entry of any characters defined
|
||||
// in the TS.23.038 Default Alphabet followed by #SEND) it shall be treated
|
||||
// as a USSD code.
|
||||
if (matches == null) {
|
||||
if (mmiString.charAt(mmiString.length - 1) == MMI_END_OF_USSD) {
|
||||
return {
|
||||
fullMMI: mmiString
|
||||
};
|
||||
}
|
||||
return null;
|
||||
// Regex only applys for those well-defined MMI strings (refer to TS.22.030
|
||||
// Annex B), otherwise, null should be the expected return value.
|
||||
return this._mmiRegExp.exec(mmiString);
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper to parse # string. TS.22.030 Figure 3.5.3.2.
|
||||
*/
|
||||
_isPoundString: function _isPoundString(mmiString) {
|
||||
return (mmiString.charAt(mmiString.length - 1) === MMI_END_OF_USSD);
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper to parse short string. TS.22.030 Figure 3.5.3.2.
|
||||
*/
|
||||
_isMMIShortString: function _isMMIShortString(mmiString) {
|
||||
if (mmiString.length > 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// After successfully executing the regular expresion over the MMI string,
|
||||
// the following match groups should contain:
|
||||
// 1 = full MMI string that might be used as a USSD request.
|
||||
// 2 = MMI procedure.
|
||||
// 3 = Service code.
|
||||
// 5 = SIA.
|
||||
// 7 = SIB.
|
||||
// 9 = SIC.
|
||||
// 11 = Password registration.
|
||||
// 12 = Dialing number.
|
||||
return {
|
||||
fullMMI: matches[MMI_MATCH_GROUP_FULL_MMI],
|
||||
procedure: matches[MMI_MATCH_GROUP_MMI_PROCEDURE],
|
||||
serviceCode: matches[MMI_MATCH_GROUP_SERVICE_CODE],
|
||||
sia: matches[MMI_MATCH_GROUP_SIA],
|
||||
sib: matches[MMI_MATCH_GROUP_SIB],
|
||||
sic: matches[MMI_MATCH_GROUP_SIC],
|
||||
pwd: matches[MMI_MATCH_GROUP_PWD_CONFIRM],
|
||||
dialNumber: matches[MMI_MATCH_GROUP_DIALING_NUMBER]
|
||||
};
|
||||
if (this._isEmergencyNumber(mmiString)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// In a call case.
|
||||
if (Object.getOwnPropertyNames(this.currentCalls).length > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((mmiString.length != 2) || (mmiString.charAt(0) !== '1')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
sendMMI: function sendMMI(options) {
|
||||
|
@ -2501,10 +2540,9 @@ let RIL = {
|
|||
return;
|
||||
}
|
||||
|
||||
// If the MMI code is not a known code and is a recognized USSD request or
|
||||
// a #-string, it shall still be sent as a USSD request.
|
||||
if (mmi.fullMMI &&
|
||||
(mmiString.charAt(mmiString.length - 1) == MMI_END_OF_USSD)) {
|
||||
// If the MMI code is not a known code and is a recognized USSD request,
|
||||
// it shall still be sent as a USSD request.
|
||||
if (mmi.fullMMI) {
|
||||
if (!_isRadioAvailable(MMI_KS_SC_USSD)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -70,14 +70,44 @@ add_test(function test_parseMMI_undefined() {
|
|||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_parseMMI_invalid() {
|
||||
let mmi = parseMMI("**");
|
||||
add_test(function test_parseMMI_one_digit_short_code() {
|
||||
let mmi = parseMMI("1");
|
||||
|
||||
do_check_eq(mmi.fullMMI, "1");
|
||||
do_check_eq(mmi.procedure, undefined);
|
||||
do_check_eq(mmi.serviceCode, undefined);
|
||||
do_check_eq(mmi.sia, undefined);
|
||||
do_check_eq(mmi.sib, undefined);
|
||||
do_check_eq(mmi.sic, undefined);
|
||||
do_check_eq(mmi.pwd, undefined);
|
||||
do_check_eq(mmi.dialNumber, undefined);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_parseMMI_invalid_short_code() {
|
||||
let mmi = parseMMI("11");
|
||||
|
||||
do_check_null(mmi);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_parseMMI_short_code() {
|
||||
let mmi = parseMMI("21");
|
||||
|
||||
do_check_eq(mmi.fullMMI, "21");
|
||||
do_check_eq(mmi.procedure, undefined);
|
||||
do_check_eq(mmi.serviceCode, undefined);
|
||||
do_check_eq(mmi.sia, undefined);
|
||||
do_check_eq(mmi.sib, undefined);
|
||||
do_check_eq(mmi.sic, undefined);
|
||||
do_check_eq(mmi.pwd, undefined);
|
||||
do_check_eq(mmi.dialNumber, undefined);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_parseMMI_dial_string() {
|
||||
let mmi = parseMMI("12345");
|
||||
|
||||
|
@ -86,6 +116,21 @@ add_test(function test_parseMMI_dial_string() {
|
|||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_parseMMI_USSD_without_asterisk_prefix() {
|
||||
let mmi = parseMMI("123#");
|
||||
|
||||
do_check_eq(mmi.fullMMI, "123#");
|
||||
do_check_eq(mmi.procedure, undefined);
|
||||
do_check_eq(mmi.serviceCode, undefined);
|
||||
do_check_eq(mmi.sia, undefined);
|
||||
do_check_eq(mmi.sib, undefined);
|
||||
do_check_eq(mmi.sic, undefined);
|
||||
do_check_eq(mmi.pwd, undefined);
|
||||
do_check_eq(mmi.dialNumber, undefined);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_parseMMI_USSD() {
|
||||
let mmi = parseMMI("*123#");
|
||||
|
||||
|
@ -318,7 +363,33 @@ add_test(function test_sendMMI_undefined() {
|
|||
});
|
||||
|
||||
add_test(function test_sendMMI_invalid() {
|
||||
testSendMMI("**", MMI_ERROR_KS_ERROR);
|
||||
testSendMMI("11", MMI_ERROR_KS_ERROR);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_sendMMI_short_code() {
|
||||
let workerhelper = getWorker();
|
||||
let worker = workerhelper.worker;
|
||||
|
||||
let ussdOptions;
|
||||
|
||||
worker.RIL.sendUSSD = function fakeSendUSSD(options){
|
||||
ussdOptions = options;
|
||||
worker.RIL[REQUEST_SEND_USSD](0, {
|
||||
rilRequestError: ERROR_SUCCESS
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
|
||||
worker.RIL.sendMMI({mmi: "**"});
|
||||
|
||||
let postedMessage = workerhelper.postedMessage;
|
||||
do_check_eq(ussdOptions.ussd, "**");
|
||||
do_check_eq (postedMessage.errorMsg, GECKO_ERROR_SUCCESS);
|
||||
do_check_true(postedMessage.success);
|
||||
do_check_true(worker.RIL._ussdSession);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче