From 6b0a018b4e93a72e92cdf085b2d718cd71bc7256 Mon Sep 17 00:00:00 2001 From: roldenburg Date: Wed, 24 Jan 2018 14:09:58 -0800 Subject: Add support for forwarding more special codes Bug: 72162360 Test: SpecialCharSequenceMgrTest, manual PiperOrigin-RevId: 183138805 Change-Id: I57903a6b3bc30243e4f225d758d1ace550e8ab99 --- .../dialer/dialpadview/SpecialCharSequenceMgr.java | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'java') 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 *#*##*#*. + * Handles secret codes to launch arbitrary activities in the form of + * *#*##*#* or *##. * * @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 *#*##*#* - - int len = input.length(); - if (len <= 8 || !input.startsWith("*#*#") || !input.endsWith("#*#*")) { - return false; + // Secret codes are accessed by dialing *#*##*#* or "*##" + 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; } /** -- cgit v1.2.3