Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1092161 - Properly handle MMI short-string codes r=drs
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielesvelto authored and Kai-Zhen Li committed Nov 1, 2014
1 parent 71dcf10 commit 65bb12d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions apps/communications/dialer/js/mmi.js
Expand Up @@ -373,8 +373,10 @@ var MmiManager = {
// If we're on a CDMA network USSD/MMI numbers are not available
return false;
} else {
// A valid USSD/MMI code is any 'number' ending in '#'.
return (number.charAt(number.length - 1) === '#');
/* A valid USSD/MMI code is any 'number' ending in '#' or made of only
* one or two characters (see 3GPP TS 20.030 6.3.5.2). */
return (number.charAt(number.length - 1) === '#') ||
(number.length <= 2);
}
},

Expand Down
8 changes: 8 additions & 0 deletions apps/communications/dialer/test/unit/mmi_test.js
Expand Up @@ -241,6 +241,14 @@ suite('dialer/mmi', function() {
assert.isTrue(MmiManager.isMMI('*123#', 0));
});

test('Check an MMI single-digit short-string code', function() {
assert.isTrue(MmiManager.isMMI('1', 0));
});

test('Check an MMI double-digit short-string code', function() {
assert.isTrue(MmiManager.isMMI('11', 0));
});

test('Check a non-MMI code', function() {
assert.isFalse(MmiManager.isMMI('123', 0));
});
Expand Down

0 comments on commit 65bb12d

Please sign in to comment.