From 9e8a087decb639ff9ad62e7ee311a398a69d2bb7 Mon Sep 17 00:00:00 2001 From: kaiyiz Date: Mon, 22 Sep 2014 15:29:56 +0800 Subject: Dialer: Customize features for regional package 1. Add engineering mode secret code "*#7548135*#"; 2. Use secret code to trigger factory test mode; 3. Hide diag port and to open diag port menu need to dial *76278#. Ticket CD-290 Change-Id: Iae26756824f1f2cc9693546eb39a1a45761e4f88 (cherry picked from commit 144951edf8fdc556f81ca7e1bee180a4ba64f9d4) --- res/values/customize.xml | 38 +++++++++++++ src/com/android/dialer/SpecialCharSequenceMgr.java | 65 +++++++++++++++++++--- 2 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 res/values/customize.xml diff --git a/res/values/customize.xml b/res/values/customize.xml new file mode 100644 index 000000000..593bdc1ed --- /dev/null +++ b/res/values/customize.xml @@ -0,0 +1,38 @@ + + + + + + false + + + false + + \ No newline at end of file diff --git a/src/com/android/dialer/SpecialCharSequenceMgr.java b/src/com/android/dialer/SpecialCharSequenceMgr.java index 43672231d..602bf2bd4 100644 --- a/src/com/android/dialer/SpecialCharSequenceMgr.java +++ b/src/com/android/dialer/SpecialCharSequenceMgr.java @@ -74,6 +74,10 @@ public class SpecialCharSequenceMgr { private static final String MMI_IMEI_DISPLAY = "*#06#"; private static final String MMI_REGULATORY_INFO_DISPLAY = "*#07#"; private static final int IMEI_14_DIGIT = 14; + private static final String MMI_OPEN_DIAG_MENU_DISPLAY = "*76278#"; + private static final String MMI_FACTORY_MODE_DISPLAY = "#38378#"; + private static final String MMI_ENGINEER_MODE_DISPLAY = "*#7548135*#"; + /** * Remembers the previous {@link QueryHandler} and cancel the operation when needed, to * prevent possible crash. @@ -136,17 +140,43 @@ public class SpecialCharSequenceMgr { //get rid of the separators so that the string gets parsed correctly String dialString = PhoneNumberUtils.stripSeparators(input); - if (handleDeviceIdDisplay(context, dialString) - || handleRegulatoryInfoDisplay(context, dialString) - || handlePinEntry(context, dialString) - || handleAdnEntry(context, dialString, textField) - || handleSecretCode(context, dialString)) { - return true; + if (context.getResources().getBoolean(R.bool.def_dialer_secretcode_enabled) || + context.getResources().getBoolean(R.bool.def_dialer_settings_diagport_enabled)) { + if (handleDeviceIdDisplay(context, dialString) + || handleRegulatoryInfoDisplay(context, dialString) + || handleEngineerModeDisplay(context, dialString) + || handlePinEntry(context, dialString) + || handleAdnEntry(context, dialString, textField) + || handleSecretCode(context, dialString) + || handleFactorySetCode(context, dialString) + || handleSetDiagPortCode(context, dialString)) { + return true; + } + } else { + if (handleDeviceIdDisplay(context, dialString) + || handleRegulatoryInfoDisplay(context, dialString) + || handleEngineerModeDisplay(context, dialString) + || handlePinEntry(context, dialString) + || handleAdnEntry(context, dialString, textField) + || handleSecretCode(context, dialString)) { + return true; + } } return false; } + private static boolean handleSetDiagPortCode(Context context, String input) { + int len = input.length(); + if (input.equals(MMI_OPEN_DIAG_MENU_DISPLAY)) { + Intent intent = new Intent(SECRET_CODE_ACTION, + Uri.parse("android_secret_code://" + input.substring(1, len - 1))); + context.sendBroadcast(intent); + return true; + } + return false; + } + /** * Cleanup everything around this class. Must be run inside the main thread. * @@ -186,6 +216,17 @@ public class SpecialCharSequenceMgr { return false; } + private static boolean handleFactorySetCode(Context context, String input) { + int len = input.length(); + if (input.equals(MMI_FACTORY_MODE_DISPLAY)) { + Intent intent = new Intent(SECRET_CODE_ACTION, + Uri.parse("android_secret_code://" + input.substring(1, len - 1))); + context.sendBroadcast(intent); + return true; + } + return false; + } + /** * Handle ADN requests by filling in the SIM contact number into the requested * EditText. @@ -383,6 +424,16 @@ public class SpecialCharSequenceMgr { return false; } + private static boolean handleEngineerModeDisplay(Context context, String input) { + if (input.equals(MMI_ENGINEER_MODE_DISPLAY)) { + Intent intent = new Intent(SECRET_CODE_ACTION, + Uri.parse("android_secret_code://3878")); + context.sendBroadcast(intent); + return true; + } + return false; + } + /******* * This code is used to handle SIM Contact queries *******/ @@ -496,7 +547,7 @@ public class SpecialCharSequenceMgr { Context context = sc.progressDialog.getContext(); name = context.getString(R.string.menu_callNumber, name); Toast.makeText(context, name, Toast.LENGTH_SHORT) - .show(); + .show(); } } finally { MoreCloseables.closeQuietly(c); -- cgit v1.2.3