diff options
Diffstat (limited to 'java/com/android/dialer/oem')
8 files changed, 89 insertions, 5 deletions
diff --git a/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java b/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java index 18f621e01..9cf145b7a 100644 --- a/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java +++ b/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java @@ -68,7 +68,8 @@ public class MotorolaHiddenMenuKeySequence { private MotorolaHiddenMenuKeySequence(Context context) { featureHiddenMenuEnabled = - context.getResources().getBoolean(R.bool.motorola_feature_hidden_menu); + MotorolaUtils.isSpnMatched(context) + && 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) { diff --git a/java/com/android/dialer/oem/MotorolaUtils.java b/java/com/android/dialer/oem/MotorolaUtils.java index e31ec98b8..d0589103d 100644 --- a/java/com/android/dialer/oem/MotorolaUtils.java +++ b/java/com/android/dialer/oem/MotorolaUtils.java @@ -16,23 +16,53 @@ package com.android.dialer.oem; import android.content.Context; +import android.content.res.Resources; +import android.telephony.TelephonyManager; import com.android.dialer.common.ConfigProviderBindings; +import com.android.dialer.common.PackageUtils; /** 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_NOTIFICATION_ENABLED = + "hd_codec_show_icon_in_notification_enabled"; private static final String CONFIG_HD_CODEC_SHOW_ICON_IN_CALL_LOG_ENABLED = "hd_codec_show_icon_in_call_log_enabled"; + private static final String CONFIG_WIFI_CALL_SHOW_ICON_IN_CALL_LOG_ENABLED = + "wifi_call_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"; + // This is used to check if a Motorola device supports WiFi call feature, by checking if a certain + // package is enabled. + private static final String WIFI_CALL_PACKAGE_NAME = "com.motorola.sprintwfc"; // 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; + // Feature flag indicates it's a WiFi call, currently this is only used by Motorola system build. + private static final int FEATURES_WIFI = 0x80000000; + + private static boolean hasCheckedSprintWifiCall; + private static boolean supportSprintWifiCall; + + /** + * Returns true if SPN is specified and matched the current sim operator name. This is necessary + * since mcc310-mnc000 is not sufficient to identify Sprint network. + */ + static boolean isSpnMatched(Context context) { + try { + String spnResource = context.getResources().getString(R.string.motorola_enabled_spn); + return spnResource.equalsIgnoreCase( + context.getSystemService(TelephonyManager.class).getSimOperatorName()); + } catch (Resources.NotFoundException exception) { + // If SPN is not specified we consider as not necessary to enable/disable the feature. + return true; + } + } public static boolean shouldBlinkHdIconWhenConnectingCall(Context context) { return ConfigProviderBindings.get(context) @@ -40,11 +70,24 @@ public class MotorolaUtils { && isSupportingSprintHdCodec(context); } + public static boolean shouldShowHdIconInNotification(Context context) { + return ConfigProviderBindings.get(context) + .getBoolean(CONFIG_HD_CODEC_SHOW_ICON_IN_NOTIFICATION_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; + && (features & FEATURES_HD_CALL) == FEATURES_HD_CALL + && isSupportingSprintHdCodec(context); + } + + public static boolean shouldShowWifiIconInCallLog(Context context, int features) { + return ConfigProviderBindings.get(context) + .getBoolean(CONFIG_WIFI_CALL_SHOW_ICON_IN_CALL_LOG_ENABLED, true) + && (features & FEATURES_WIFI) == FEATURES_WIFI + && isSupportingSprintWifiCall(context); } /** @@ -60,7 +103,16 @@ public class MotorolaUtils { } private static boolean isSupportingSprintHdCodec(Context context) { - return context.getPackageManager().hasSystemFeature(HD_CALL_FEATRURE) - && context.getResources().getBoolean(R.bool.motorola_sprint_hd_codec); + return isSpnMatched(context) + && context.getResources().getBoolean(R.bool.motorola_sprint_hd_codec) + && context.getPackageManager().hasSystemFeature(HD_CALL_FEATRURE); + } + + private static boolean isSupportingSprintWifiCall(Context context) { + if (!hasCheckedSprintWifiCall) { + supportSprintWifiCall = PackageUtils.isPackageEnabled(WIFI_CALL_PACKAGE_NAME, context); + hasCheckedSprintWifiCall = true; + } + return supportSprintWifiCall; } } diff --git a/java/com/android/dialer/oem/res/values-mcc310-mnc000/motorola_config.xml b/java/com/android/dialer/oem/res/values-mcc310-mnc000/motorola_config.xml new file mode 100644 index 000000000..7f63bee75 --- /dev/null +++ b/java/com/android/dialer/oem/res/values-mcc310-mnc000/motorola_config.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <bool name="motorola_sprint_hd_codec">true</bool> + <bool name="motorola_feature_hidden_menu">true</bool> + <string name="motorola_enabled_spn">Sprint</string> +</resources>
\ No newline at end of file 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 new file mode 100644 index 000000000..39b72cdd1 --- /dev/null +++ b/java/com/android/dialer/oem/res/values-mcc310-mnc120/motorola_config.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <bool name="motorola_sprint_hd_codec">true</bool> + <bool name="motorola_feature_hidden_menu">true</bool> +</resources>
\ No newline at end of file diff --git a/java/com/android/dialer/oem/res/values-mcc311-mnc490/motorola_config.xml b/java/com/android/dialer/oem/res/values-mcc311-mnc490/motorola_config.xml new file mode 100644 index 000000000..39b72cdd1 --- /dev/null +++ b/java/com/android/dialer/oem/res/values-mcc311-mnc490/motorola_config.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <bool name="motorola_sprint_hd_codec">true</bool> + <bool name="motorola_feature_hidden_menu">true</bool> +</resources>
\ No newline at end of file diff --git a/java/com/android/dialer/oem/res/values-mcc311-mnc870/motorola_config.xml b/java/com/android/dialer/oem/res/values-mcc311-mnc870/motorola_config.xml new file mode 100644 index 000000000..39b72cdd1 --- /dev/null +++ b/java/com/android/dialer/oem/res/values-mcc311-mnc870/motorola_config.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <bool name="motorola_sprint_hd_codec">true</bool> + <bool name="motorola_feature_hidden_menu">true</bool> +</resources>
\ No newline at end of file diff --git a/java/com/android/dialer/oem/res/values-mcc312-mnc530/motorola_config.xml b/java/com/android/dialer/oem/res/values-mcc312-mnc530/motorola_config.xml new file mode 100644 index 000000000..39b72cdd1 --- /dev/null +++ b/java/com/android/dialer/oem/res/values-mcc312-mnc530/motorola_config.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <bool name="motorola_sprint_hd_codec">true</bool> + <bool name="motorola_feature_hidden_menu">true</bool> +</resources>
\ No newline at end of file diff --git a/java/com/android/dialer/oem/res/values-mcc316-mnc010/motorola_config.xml b/java/com/android/dialer/oem/res/values-mcc316-mnc010/motorola_config.xml new file mode 100644 index 000000000..39b72cdd1 --- /dev/null +++ b/java/com/android/dialer/oem/res/values-mcc316-mnc010/motorola_config.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <bool name="motorola_sprint_hd_codec">true</bool> + <bool name="motorola_feature_hidden_menu">true</bool> +</resources>
\ No newline at end of file |