summaryrefslogtreecommitdiffstats
path: root/java/com/android/dialer/oem
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-03-15 14:41:07 -0700
committerEric Erfanian <erfanian@google.com>2017-03-15 16:24:23 -0700
commitd5e47f6da5b08b13ecdfa7f1edc7e12aeb83fab9 (patch)
treeb54abbb51fb7d66e7755a1fbb5db023ff601090b /java/com/android/dialer/oem
parent30436e7e6d3f2c8755a91b2b6222b74d465a9e87 (diff)
downloadandroid_packages_apps_Dialer-d5e47f6da5b08b13ecdfa7f1edc7e12aeb83fab9.tar.gz
android_packages_apps_Dialer-d5e47f6da5b08b13ecdfa7f1edc7e12aeb83fab9.tar.bz2
android_packages_apps_Dialer-d5e47f6da5b08b13ecdfa7f1edc7e12aeb83fab9.zip
Update Dialer source from latest green build.
* Refactor voicemail component * Add new enriched calling components Test: treehugger, manual aosp testing Change-Id: I521a0f86327d4b42e14d93927c7d613044ed5942
Diffstat (limited to 'java/com/android/dialer/oem')
-rw-r--r--java/com/android/dialer/oem/AndroidManifest.xml3
-rw-r--r--java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java153
-rw-r--r--java/com/android/dialer/oem/MotorolaUtils.java51
-rw-r--r--java/com/android/dialer/oem/res/values/motorola_config.xml64
4 files changed, 271 insertions, 0 deletions
diff --git a/java/com/android/dialer/oem/AndroidManifest.xml b/java/com/android/dialer/oem/AndroidManifest.xml
new file mode 100644
index 000000000..e161a6d14
--- /dev/null
+++ b/java/com/android/dialer/oem/AndroidManifest.xml
@@ -0,0 +1,3 @@
+<manifest
+ package="com.android.dialer.oem">
+</manifest> \ No newline at end of file
diff --git a/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java b/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java
new file mode 100644
index 000000000..18f621e01
--- /dev/null
+++ b/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * This file is derived in part from code issued under the following license.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package com.android.dialer.oem;
+
+import android.content.ActivityNotFoundException;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ResolveInfo;
+import com.android.dialer.common.LogUtil;
+import java.util.regex.Pattern;
+
+/**
+ * Util class to handle special char sequence and launch corresponding intent based the sequence.
+ */
+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;
+
+ /**
+ * Handle input char sequence.
+ *
+ * @param context context
+ * @param input input sequence
+ * @return true if the input matches any pattern
+ */
+ static boolean handleCharSequence(Context context, String input) {
+ getInstance(context);
+ if (!featureHiddenMenuEnabled) {
+ return false;
+ }
+ return handleKeySequence(context, input) || handleKeyPattern(context, input);
+ }
+
+ /**
+ * Public interface to return the Singleton instance
+ *
+ * @param context the Context
+ * @return the MotorolaHiddenMenuKeySequence singleton instance
+ */
+ private static synchronized MotorolaHiddenMenuKeySequence getInstance(Context context) {
+ if (null == instance) {
+ instance = new MotorolaHiddenMenuKeySequence(context);
+ }
+ return instance;
+ }
+
+ private MotorolaHiddenMenuKeySequence(Context context) {
+ featureHiddenMenuEnabled =
+ context.getResources().getBoolean(R.bool.motorola_feature_hidden_menu);
+ // 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;
+ }
+ }
+ }
+
+ private static boolean handleKeyPattern(Context context, String input) {
+ int len = input.length();
+ if (len <= 3 || hiddenKeyPatternArray == null || hiddenKeyPatternIntentArray == 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]);
+ }
+ }
+ return false;
+ }
+
+ private static boolean handleKeySequence(Context context, String input) {
+ int len = input.length();
+ if (len <= 3 || hiddenKeySequenceArray == null || hiddenKeySequenceIntentArray == null) {
+ return false;
+ }
+
+ for (int i = 0; i < hiddenKeySequenceArray.length; i++) {
+ if (hiddenKeySequenceArray[i].equals(input)) {
+ return sendIntent(context, input, hiddenKeySequenceIntentArray[i]);
+ }
+ }
+ return false;
+ }
+
+ private static boolean sendIntent(
+ final Context context, final String input, final String action) {
+ LogUtil.d("MotorolaHiddenMenuKeySequence.sendIntent", "input: %s", input);
+ try {
+ Intent intent = new Intent(action);
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.putExtra(EXTRA_HIDDEN_MENU_CODE, input);
+
+ ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, 0);
+
+ if (resolveInfo != null
+ && resolveInfo.activityInfo != null
+ && resolveInfo.activityInfo.enabled) {
+ context.startActivity(intent);
+ return true;
+ } else {
+ LogUtil.w("MotorolaHiddenMenuKeySequence.sendIntent", "not able to resolve the intent");
+ }
+ } catch (ActivityNotFoundException e) {
+ LogUtil.e(
+ "MotorolaHiddenMenuKeySequence.sendIntent", "handleHiddenMenu Key Pattern Exception", e);
+ }
+ return false;
+ }
+}
diff --git a/java/com/android/dialer/oem/MotorolaUtils.java b/java/com/android/dialer/oem/MotorolaUtils.java
new file mode 100644
index 000000000..29bf0b23d
--- /dev/null
+++ b/java/com/android/dialer/oem/MotorolaUtils.java
@@ -0,0 +1,51 @@
+package com.android.dialer.oem;
+
+import android.content.Context;
+import com.android.dialer.common.ConfigProviderBindings;
+
+/** Util class for Motorola OEM devices. */
+public class MotorolaUtils {
+
+ private static final String CONFIG_HD_CODEC_BLINKING_ICON_WHEN_CONNECTING_CALL_ENABLED =
+ "hd_codec_blinking_icon_when_connecting_enabled";
+ private static final String CONFIG_HD_CODEC_SHOW_ICON_IN_CALL_LOG_ENABLED =
+ "hd_codec_show_icon_in_call_log_enabled";
+
+ // This is used to check if a Motorola device supports HD voice call feature, which comes from
+ // system feature setting.
+ private static final String HD_CALL_FEATRURE = "com.motorola.software.sprint.hd_call";
+
+ // Feature flag indicates it's a HD call, currently this is only used by Motorola system build.
+ // TODO(b/35359461): Upstream and move it to android.provider.CallLog.
+ private static final int FEATURES_HD_CALL = 0x10000000;
+
+ public static boolean shouldBlinkHdIconWhenConnectingCall(Context context) {
+ return ConfigProviderBindings.get(context)
+ .getBoolean(CONFIG_HD_CODEC_BLINKING_ICON_WHEN_CONNECTING_CALL_ENABLED, true)
+ && isSupportingSprintHdCodec(context);
+ }
+
+ public static boolean shouldShowHdIconInCallLog(Context context, int features) {
+ return ConfigProviderBindings.get(context)
+ .getBoolean(CONFIG_HD_CODEC_SHOW_ICON_IN_CALL_LOG_ENABLED, true)
+ && isSupportingSprintHdCodec(context)
+ && (features & FEATURES_HD_CALL) == FEATURES_HD_CALL;
+ }
+
+ /**
+ * Handle special char sequence entered in dialpad. This may launch special intent based on input.
+ *
+ * @param context context
+ * @param input input string
+ * @return true if the input is consumed and the intent is launched
+ */
+ public static boolean handleSpecialCharSequence(Context context, String input) {
+ // TODO(b/35395377): Add check for Motorola devices.
+ return MotorolaHiddenMenuKeySequence.handleCharSequence(context, input);
+ }
+
+ private static boolean isSupportingSprintHdCodec(Context context) {
+ return context.getPackageManager().hasSystemFeature(HD_CALL_FEATRURE)
+ && context.getResources().getBoolean(R.bool.motorola_sprint_hd_codec);
+ }
+}
diff --git a/java/com/android/dialer/oem/res/values/motorola_config.xml b/java/com/android/dialer/oem/res/values/motorola_config.xml
new file mode 100644
index 000000000..f875d573d
--- /dev/null
+++ b/java/com/android/dialer/oem/res/values/motorola_config.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <!-- Flag to control if HD codec is supported by Sprint. -->
+ <bool name="motorola_sprint_hd_codec">false</bool>
+
+ <!-- Hidden menu configuration for Motorola. -->
+ <!-- Flag to control if the Hidden Menu sequence will be supported by Sprint. -->
+ <bool name="motorola_feature_hidden_menu">false</bool>
+
+ <!-- This defines the specific key seuquence that will be catched 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 quence 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
+ 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
+ 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