sendDialerCode API review
address the feeback from API review:
throw exception rather than a boolean return.
handle exception from callers instead of check return boolean
move secret code detection logic from API to API callers.
Bug: 35767402
Test: Manual
Test: run cts -m CtsTelephonyTestCases -t android.telephony.cts.TelephonyManagerTest
Change-Id: Ie31f399799d4cd2413bf65a227fb000bbbe3c8aa
diff --git a/src/com/android/phone/SpecialCharSequenceMgr.java b/src/com/android/phone/SpecialCharSequenceMgr.java
index 2aa1043..3c02a30 100644
--- a/src/com/android/phone/SpecialCharSequenceMgr.java
+++ b/src/com/android/phone/SpecialCharSequenceMgr.java
@@ -151,8 +151,14 @@
* @return true if a secret code was encountered and intent is sent out
*/
static private boolean handleSecretCode(String input) {
- Phone phone = PhoneGlobals.getPhone();
- return phone.sendDialerCode(input);
+ // Secret codes are in the form *#*#<code>#*#*
+ int len = input.length();
+ if (len > 8 && input.startsWith("*#*#") && input.endsWith("#*#*")) {
+ final Phone phone = PhoneGlobals.getPhone();
+ phone.sendDialerSpecialCode(input.substring(4, len - 4));
+ return true;
+ }
+ return false;
}
static private boolean handleAdnEntry(Context context, String input) {