summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNancy Chen <nancychen@google.com>2015-11-26 00:51:09 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-11-26 00:51:09 +0000
commit1b5158652ecf29602ce62b4c766fc971619d2726 (patch)
tree1db8318889a77cb64a2bfc84ba6215cc7eb94e5b
parenta31f24c1ace1ed10b87daa8d23af58e6598fa075 (diff)
parent15d1f41fb48ef119ec02b3d50bede25281ae8f50 (diff)
Merge "Guard against crashes in <M devices for getDefaultDialerPackage call." into ub-contactsdialer-b-dev
-rw-r--r--src/com/android/dialer/compat/DialerCompatUtils.java11
-rw-r--r--src/com/android/dialer/util/TelecomUtil.java6
2 files changed, 17 insertions, 0 deletions
diff --git a/src/com/android/dialer/compat/DialerCompatUtils.java b/src/com/android/dialer/compat/DialerCompatUtils.java
index 678ffb09d..cda51c691 100644
--- a/src/com/android/dialer/compat/DialerCompatUtils.java
+++ b/src/com/android/dialer/compat/DialerCompatUtils.java
@@ -30,4 +30,15 @@ public final class DialerCompatUtils {
return SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.LOLLIPOP)
>= Build.VERSION_CODES.M;
}
+
+ /**
+ * Determines if this version is compatible with a default dialer. Can also force the version to
+ * be lower through SdkVersionOverride.
+ *
+ * @return {@code true} if default dialer is a feature on this device, {@code false} otherwise.
+ */
+ public static boolean isDefaultDialerCompatible() {
+ return SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.LOLLIPOP)
+ >= Build.VERSION_CODES.M;
+ }
} \ No newline at end of file
diff --git a/src/com/android/dialer/util/TelecomUtil.java b/src/com/android/dialer/util/TelecomUtil.java
index 123057787..a0c833462 100644
--- a/src/com/android/dialer/util/TelecomUtil.java
+++ b/src/com/android/dialer/util/TelecomUtil.java
@@ -28,6 +28,8 @@ import android.telecom.TelecomManager;
import android.text.TextUtils;
import android.util.Log;
+import com.android.dialer.compat.DialerCompatUtils;
+
import java.util.ArrayList;
import java.util.List;
@@ -187,6 +189,10 @@ public class TelecomUtil {
}
public static boolean isDefaultDialer(Context context) {
+ if (!DialerCompatUtils.isDefaultDialerCompatible()) {
+ return false;
+ }
+
final boolean result = TextUtils.equals(context.getPackageName(),
getTelecomManager(context).getDefaultDialerPackage());
if (result) {