summaryrefslogtreecommitdiffstats
path: root/java/com/android/dialer/oem
diff options
context:
space:
mode:
authorroldenburg <roldenburg@google.com>2018-02-20 17:14:12 -0800
committerEric Erfanian <erfanian@google.com>2018-02-22 21:10:07 +0000
commitf5326db368ba35faf861f690b09d0ea9c8d5080f (patch)
treecc91fa71714011ad64986ed853af1f06b7eb9e4d /java/com/android/dialer/oem
parent6bc46129b93069868d2425fb9d9c50e1dabe6502 (diff)
downloadandroid_packages_apps_Dialer-f5326db368ba35faf861f690b09d0ea9c8d5080f.tar.gz
android_packages_apps_Dialer-f5326db368ba35faf861f690b09d0ea9c8d5080f.tar.bz2
android_packages_apps_Dialer-f5326db368ba35faf861f690b09d0ea9c8d5080f.zip
Add Tracfone to Motorola menu, move existing menu to Sprint only
Bug: 71707082 Test: MotorolaHiddenMenuKeySequenceTest PiperOrigin-RevId: 186387666 Change-Id: I3971604d717dcea8bfd1159b281a2dc5a0f3b0f7
Diffstat (limited to 'java/com/android/dialer/oem')
-rw-r--r--java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java111
-rw-r--r--java/com/android/dialer/oem/MotorolaUtils.java3
-rw-r--r--java/com/android/dialer/oem/res/values-mcc310-mnc120/motorola_config.xml56
-rw-r--r--java/com/android/dialer/oem/res/values/motorola_config.xml45
4 files changed, 132 insertions, 83 deletions
diff --git a/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java b/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java
index 79abff08e..81f6b607c 100644
--- a/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java
+++ b/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java
@@ -22,7 +22,11 @@ import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
+import android.support.annotation.VisibleForTesting;
import com.android.dialer.common.LogUtil;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import java.util.regex.Pattern;
/**
@@ -30,13 +34,14 @@ import java.util.regex.Pattern;
*/
public class MotorolaHiddenMenuKeySequence {
private static final String EXTRA_HIDDEN_MENU_CODE = "HiddenMenuCode";
+
private static MotorolaHiddenMenuKeySequence instance = null;
- private static String[] hiddenKeySequenceArray = null;
- private static String[] hiddenKeySequenceIntentArray = null;
- private static String[] hiddenKeyPatternArray = null;
- private static String[] hiddenKeyPatternIntentArray = null;
- private static boolean featureHiddenMenuEnabled = false;
+ @VisibleForTesting final List<String> hiddenKeySequences = new ArrayList<>();
+ @VisibleForTesting final List<String> hiddenKeySequenceIntents = new ArrayList<>();
+ @VisibleForTesting final List<String> hiddenKeyPatterns = new ArrayList<>();
+ @VisibleForTesting final List<String> hiddenKeyPatternIntents = new ArrayList<>();
+ @VisibleForTesting boolean featureHiddenMenuEnabled = false;
/**
* Handle input char sequence.
@@ -46,8 +51,7 @@ public class MotorolaHiddenMenuKeySequence {
* @return true if the input matches any pattern
*/
static boolean handleCharSequence(Context context, String input) {
- getInstance(context);
- if (!featureHiddenMenuEnabled) {
+ if (!getInstance(context).featureHiddenMenuEnabled) {
return false;
}
return handleKeySequence(context, input) || handleKeyPattern(context, input);
@@ -66,60 +70,81 @@ public class MotorolaHiddenMenuKeySequence {
return instance;
}
- private MotorolaHiddenMenuKeySequence(Context context) {
- featureHiddenMenuEnabled = MotorolaUtils.isSupportingHiddenMenu(context);
- // In case we do have a SPN from resource we need to match from service; otherwise we are
- // free to go
- if (featureHiddenMenuEnabled) {
-
- hiddenKeySequenceArray =
- context.getResources().getStringArray(R.array.motorola_hidden_menu_key_sequence);
- hiddenKeySequenceIntentArray =
- context.getResources().getStringArray(R.array.motorola_hidden_menu_key_sequence_intents);
- hiddenKeyPatternArray =
- context.getResources().getStringArray(R.array.motorola_hidden_menu_key_pattern);
- hiddenKeyPatternIntentArray =
- context.getResources().getStringArray(R.array.motorola_hidden_menu_key_pattern_intents);
-
- if (hiddenKeySequenceArray.length != hiddenKeySequenceIntentArray.length
- || hiddenKeyPatternArray.length != hiddenKeyPatternIntentArray.length
- || (hiddenKeySequenceArray.length == 0 && hiddenKeyPatternArray.length == 0)) {
- LogUtil.e(
- "MotorolaHiddenMenuKeySequence",
- "the key sequence array is not matching, turn off feature."
- + "key sequence: %d != %d, key pattern %d != %d",
- hiddenKeySequenceArray.length,
- hiddenKeySequenceIntentArray.length,
- hiddenKeyPatternArray.length,
- hiddenKeyPatternIntentArray.length);
- featureHiddenMenuEnabled = false;
- }
+ @VisibleForTesting
+ MotorolaHiddenMenuKeySequence(Context context) {
+ if (MotorolaUtils.isSupportingHiddenMenu(context)) {
+ Collections.addAll(
+ hiddenKeySequences,
+ context.getResources().getStringArray(R.array.motorola_hidden_menu_key_sequence));
+ Collections.addAll(
+ hiddenKeySequenceIntents,
+ context.getResources().getStringArray(R.array.motorola_hidden_menu_key_sequence_intents));
+ Collections.addAll(
+ hiddenKeyPatterns,
+ context.getResources().getStringArray(R.array.motorola_hidden_menu_key_pattern));
+ Collections.addAll(
+ hiddenKeyPatternIntents,
+ context.getResources().getStringArray(R.array.motorola_hidden_menu_key_pattern_intents));
+ featureHiddenMenuEnabled = true;
+ }
+
+ if ("tracfone".equals(System.getProperty("ro.carrier"))) {
+ addHiddenKeySequence("#83865625#", "com.motorola.extensions.TFUnlock");
+ addHiddenKeySequence("#83782887#", "com.motorola.extensions.TFStatus");
+ featureHiddenMenuEnabled = true;
}
+
+ if (hiddenKeySequences.size() != hiddenKeySequenceIntents.size()
+ || hiddenKeyPatterns.size() != hiddenKeyPatternIntents.size()
+ || (hiddenKeySequences.isEmpty() && hiddenKeyPatterns.isEmpty())) {
+ LogUtil.e(
+ "MotorolaHiddenMenuKeySequence",
+ "the key sequence array is not matching, turn off feature."
+ + "key sequence: %d != %d, key pattern %d != %d",
+ hiddenKeySequences.size(),
+ hiddenKeySequenceIntents.size(),
+ hiddenKeyPatterns.size(),
+ hiddenKeyPatternIntents.size());
+ featureHiddenMenuEnabled = false;
+ }
+ }
+
+ private void addHiddenKeySequence(String keySequence, String intentAction) {
+ hiddenKeySequences.add(keySequence);
+ hiddenKeySequenceIntents.add(intentAction);
}
private static boolean handleKeyPattern(Context context, String input) {
+ MotorolaHiddenMenuKeySequence instance = getInstance(context);
+
int len = input.length();
- if (len <= 3 || hiddenKeyPatternArray == null || hiddenKeyPatternIntentArray == null) {
+ if (len <= 3
+ || instance.hiddenKeyPatterns == null
+ || instance.hiddenKeyPatternIntents == null) {
return false;
}
- for (int i = 0; i < hiddenKeyPatternArray.length; i++) {
- if ((Pattern.compile(hiddenKeyPatternArray[i])).matcher(input).matches()) {
- return sendIntent(context, input, hiddenKeyPatternIntentArray[i]);
+ for (int i = 0; i < instance.hiddenKeyPatterns.size(); i++) {
+ if (Pattern.matches(instance.hiddenKeyPatterns.get(i), input)) {
+ return sendIntent(context, input, instance.hiddenKeyPatternIntents.get(i));
}
}
return false;
}
private static boolean handleKeySequence(Context context, String input) {
+ MotorolaHiddenMenuKeySequence instance = getInstance(context);
+
int len = input.length();
- if (len <= 3 || hiddenKeySequenceArray == null || hiddenKeySequenceIntentArray == null) {
+ if (len <= 3
+ || instance.hiddenKeySequences == null
+ || instance.hiddenKeySequenceIntents == null) {
return false;
}
- for (int i = 0; i < hiddenKeySequenceArray.length; i++) {
- if (hiddenKeySequenceArray[i].equals(input)) {
- return sendIntent(context, input, hiddenKeySequenceIntentArray[i]);
+ for (int i = 0; i < instance.hiddenKeySequences.size(); i++) {
+ if (instance.hiddenKeySequences.get(i).equals(input)) {
+ return sendIntent(context, input, instance.hiddenKeySequenceIntents.get(i));
}
}
return false;
diff --git a/java/com/android/dialer/oem/MotorolaUtils.java b/java/com/android/dialer/oem/MotorolaUtils.java
index c1e2da256..1446a0219 100644
--- a/java/com/android/dialer/oem/MotorolaUtils.java
+++ b/java/com/android/dialer/oem/MotorolaUtils.java
@@ -43,7 +43,8 @@ public class MotorolaUtils {
// package is enabled.
@VisibleForTesting public static final String WIFI_CALL_PACKAGE_NAME = "com.motorola.sprintwfc";
// Thi is used to check if a Motorola device supports hidden menu feature.
- private static final String HIDDEN_MENU_FEATURE = "com.motorola.software.sprint.hidden_menu";
+ @VisibleForTesting
+ static final String HIDDEN_MENU_FEATURE = "com.motorola.software.sprint.hidden_menu";
private static boolean hasCheckedSprintWifiCall;
private static boolean supportSprintWifiCall;
diff --git a/java/com/android/dialer/oem/res/values-mcc310-mnc120/motorola_config.xml b/java/com/android/dialer/oem/res/values-mcc310-mnc120/motorola_config.xml
index c5cb0d1f7..417a4b845 100644
--- a/java/com/android/dialer/oem/res/values-mcc310-mnc120/motorola_config.xml
+++ b/java/com/android/dialer/oem/res/values-mcc310-mnc120/motorola_config.xml
@@ -17,4 +17,60 @@
<resources>
<bool name="motorola_sprint_hd_codec">true</bool>
+
+ <!-- Hidden menu configuration for Motorola. -->
+ <!-- This defines the specific key sequence that will be caught in the SpecialCharSequenceMgr
+ such as, ##OMADM# -->
+ <string-array name="motorola_hidden_menu_key_sequence">
+ <item>##66236#</item> <!--##OMADM#-->
+ <item>##2539#</item> <!--##AKEY#-->
+ <item>##786#</item> <!--##RTN#-->
+ <item>##72786#</item> <!--##SCRTN#-->
+ <item>##3282#</item> <!--##DATA#-->
+ <item>##33284#</item> <!--##DEBUG#-->
+ <item>##3424#</item> <!--##DIAG#-->
+ <item>##564#</item> <!--##LOG#-->
+ <item>##4567257#</item> <!--##GLMSCLR#-->
+ <item>##873283#</item> <!--##UPDATE#-->
+ <item>##6343#</item> <!--##MEID#-->
+ <item>##27263#</item> <!--##BRAND#-->
+ <item>##258#</item> <!--##BLV#-->
+ <item>##8422#</item> <!--##UICC#-->
+ <item>##4382#</item> <!--CMAS/WEA-->
+ </string-array>
+
+ <string name="motorola_hidden_menu_intent">com.motorola.intent.action.LAUNCH_HIDDEN_MENU</string>
+
+ <!-- This defines the intents that will be send out when the key sequence is matched, this must be
+ in the same order with he KeySequence array. -->
+ <string-array name="motorola_hidden_menu_key_sequence_intents">
+ <item>@string/motorola_hidden_menu_intent</item>
+ <item>@string/motorola_hidden_menu_intent</item>
+ <item>@string/motorola_hidden_menu_intent</item>
+ <item>@string/motorola_hidden_menu_intent</item>
+ <item>@string/motorola_hidden_menu_intent</item>
+ <item>@string/motorola_hidden_menu_intent</item>
+ <item>@string/motorola_hidden_menu_intent</item>
+ <item>@string/motorola_hidden_menu_intent</item>
+ <item>@string/motorola_hidden_menu_intent</item>
+ <item>com.motorola.android.intent.action.omadm.sprint.hfa</item>
+ <item>@string/motorola_hidden_menu_intent</item>
+ <item>@string/motorola_hidden_menu_intent</item>
+ <item>@string/motorola_hidden_menu_intent</item>
+ <item>@string/motorola_hidden_menu_intent</item>
+ <item>@string/motorola_hidden_menu_intent</item>
+ </string-array>
+
+ <!-- This defines the specific key patterns that will be caught in the SpecialCharSequenceMgr
+ such as, ##[0-9]{3,7}# -->
+ <string-array name="motorola_hidden_menu_key_pattern">
+ <!--##MSL#, here MSL is 6 digits SPC code, ##OTKSL#, OTKSL is also digits code -->
+ <item>##[0-9]{6}#</item>
+ </string-array>
+
+ <!-- This defines the intents that will be send out when the key sequence is matched, this must be
+ in the same order with he KeyPattern array. -->
+ <string-array name="motorola_hidden_menu_key_pattern_intents">
+ <item>@string/motorola_hidden_menu_intent</item>
+ </string-array>
</resources> \ No newline at end of file
diff --git a/java/com/android/dialer/oem/res/values/motorola_config.xml b/java/com/android/dialer/oem/res/values/motorola_config.xml
index ba451e715..fd9cee0a9 100644
--- a/java/com/android/dialer/oem/res/values/motorola_config.xml
+++ b/java/com/android/dialer/oem/res/values/motorola_config.xml
@@ -20,59 +20,26 @@
<bool name="motorola_sprint_hd_codec">false</bool>
<!-- Hidden menu configuration for Motorola. -->
- <!-- This defines the specific key seuquence that will be catched in the SpecialCharSequenceMgr
+ <!-- This defines the specific key sequence that will be caught in the SpecialCharSequenceMgr
such as, ##OMADM# -->
<string-array name="motorola_hidden_menu_key_sequence">
- <item>##66236#</item> <!--##OMADM#-->
- <item>##2539#</item> <!--##AKEY#-->
- <item>##786#</item> <!--##RTN#-->
- <item>##72786#</item> <!--##SCRTN#-->
- <item>##3282#</item> <!--##DATA#-->
- <item>##33284#</item> <!--##DEBUG#-->
- <item>##3424#</item> <!--##DIAG#-->
- <item>##564#</item> <!--##LOG#-->
- <item>##4567257#</item> <!--##GLMSCLR#-->
- <item>##873283#</item> <!--##UPDATE#-->
- <item>##6343#</item> <!--##MEID#-->
- <item>##27263#</item> <!--##BRAND#-->
- <item>##258#</item> <!--##BLV#-->
- <item>##8422#</item> <!--##UICC#-->
- <item>##4382#</item> <!--CMAS/WEA-->
</string-array>
- <string name="motorola_hidden_menu_intent">com.motorola.intent.action.LAUNCH_HIDDEN_MENU</string>
+ <string name="motorola_hidden_menu_intent"></string>
- <!-- This defines the intents that will be send out when the key quence is matched, this must be
+ <!-- This defines the intents that will be send out when the key sequence is matched, this must be
in the same order with he KeySequence array. -->
<string-array name="motorola_hidden_menu_key_sequence_intents">
- <item>@string/motorola_hidden_menu_intent</item>
- <item>@string/motorola_hidden_menu_intent</item>
- <item>@string/motorola_hidden_menu_intent</item>
- <item>@string/motorola_hidden_menu_intent</item>
- <item>@string/motorola_hidden_menu_intent</item>
- <item>@string/motorola_hidden_menu_intent</item>
- <item>@string/motorola_hidden_menu_intent</item>
- <item>@string/motorola_hidden_menu_intent</item>
- <item>@string/motorola_hidden_menu_intent</item>
- <item>com.motorola.android.intent.action.omadm.sprint.hfa</item>
- <item>@string/motorola_hidden_menu_intent</item>
- <item>@string/motorola_hidden_menu_intent</item>
- <item>@string/motorola_hidden_menu_intent</item>
- <item>@string/motorola_hidden_menu_intent</item>
- <item>@string/motorola_hidden_menu_intent</item>
</string-array>
- <!-- This defines the specific key patterns that will be catched in the SpecialCharSequenceMgr
+ <!-- This defines the specific key patterns that will be caught in the SpecialCharSequenceMgr
such as, ##[0-9]{3,7}# -->
<string-array name="motorola_hidden_menu_key_pattern">
- <!--##MSL#, here MSL is 6 digits SPC code, ##OTKSL#, OTKSL is also digits code -->
- <item>##[0-9]{6}#</item>
</string-array>
- <!-- This defines the intents that will be send out when the key quence is matched, this must be
+ <!-- This defines the intents that will be send out when the key sequence is matched, this must be
in the same order with he KeyPattern array. -->
<string-array name="motorola_hidden_menu_key_pattern_intents">
- <item>@string/motorola_hidden_menu_intent</item>
</string-array>
<!-- This defines the provider names for cequint callerid applications
@@ -80,4 +47,4 @@
<string-array name="cequint_providers">
<item>com.cequint.ecid</item>
</string-array>
-</resources> \ No newline at end of file
+</resources>