summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorroldenburg <roldenburg@google.com>2018-01-24 14:09:58 -0800
committerCopybara-Service <copybara-piper@google.com>2018-01-24 16:49:47 -0800
commit6b0a018b4e93a72e92cdf085b2d718cd71bc7256 (patch)
treec4cd27dfa084f69a9a985505b587e71c6f039598 /java
parent3bee9a13ea767987623d422457fc4fbe8daa81e5 (diff)
Add support for forwarding more special codes
Bug: 72162360 Test: SpecialCharSequenceMgrTest, manual PiperOrigin-RevId: 183138805 Change-Id: I57903a6b3bc30243e4f225d758d1ace550e8ab99
Diffstat (limited to 'java')
-rw-r--r--java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java25
1 files changed, 16 insertions, 9 deletions
diff --git a/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java b/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java
index e6d405ccf..76892552b 100644
--- a/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java
+++ b/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java
@@ -131,22 +131,29 @@ public class SpecialCharSequenceMgr {
}
/**
- * Handles secret codes to launch arbitrary activities in the form of *#*#<code>#*#*.
+ * Handles secret codes to launch arbitrary activities in the form of
+ * *#*#<code>#*#* or *#<code_starting_with_number>#.
*
* @param context the context to use
* @param input the text to check for a secret code in
* @return true if a secret code was encountered and handled
*/
static boolean handleSecretCode(Context context, String input) {
- // Secret codes are accessed by dialing *#*#<code>#*#*
-
- int len = input.length();
- if (len <= 8 || !input.startsWith("*#*#") || !input.endsWith("#*#*")) {
- return false;
+ // Secret codes are accessed by dialing *#*#<code>#*#* or "*#<code_starting_with_number>#"
+ if (input.length() > 8 && input.startsWith("*#*#") && input.endsWith("#*#*")) {
+ String secretCode = input.substring(4, input.length() - 4);
+ TelephonyManagerCompat.handleSecretCode(context, secretCode);
+ return true;
}
- String secretCode = input.substring(4, len - 4);
- TelephonyManagerCompat.handleSecretCode(context, secretCode);
- return true;
+ if (input.length() >= 4
+ && input.startsWith("*#")
+ && input.endsWith("#")
+ && Character.isDigit(input.charAt(2))) {
+ String secretCode = input.substring(2, input.length() - 1);
+ TelephonyManagerCompat.handleSecretCode(context, secretCode);
+ return true;
+ }
+ return false;
}
/**