summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/android/dialer/compat/telecom/TelecomManagerCompat.java14
-rw-r--r--src/com/android/dialer/util/TelecomUtil.java2
2 files changed, 15 insertions, 1 deletions
diff --git a/src/com/android/dialer/compat/telecom/TelecomManagerCompat.java b/src/com/android/dialer/compat/telecom/TelecomManagerCompat.java
index 05055a45e..845f378e3 100644
--- a/src/com/android/dialer/compat/telecom/TelecomManagerCompat.java
+++ b/src/com/android/dialer/compat/telecom/TelecomManagerCompat.java
@@ -82,4 +82,18 @@ public class TelecomManagerCompat {
}
return PhoneNumberUtils.isVoiceMailNumber(number);
}
+
+ /**
+ * Silences the ringer if a ringing call exists. Noop if {@link TelecomManager#silenceRinger()}
+ * is unavailable.
+ *
+ * @param telecomManager the {@link TelecomManager} to use to silence the ringer
+ * @throws NullPointerException if telecomManager is null
+ */
+ public static void silenceRinger(TelecomManager telecomManager) {
+ if (CompatUtils.isMarshmallowCompatible() || CompatUtils
+ .isMethodAvailable("android.telecom.TelecomManager", "silenceRinger")) {
+ telecomManager.silenceRinger();
+ }
+ }
}
diff --git a/src/com/android/dialer/util/TelecomUtil.java b/src/com/android/dialer/util/TelecomUtil.java
index bc6b32d6e..01a379438 100644
--- a/src/com/android/dialer/util/TelecomUtil.java
+++ b/src/com/android/dialer/util/TelecomUtil.java
@@ -62,7 +62,7 @@ public class TelecomUtil {
public static void silenceRinger(Context context) {
if (hasModifyPhoneStatePermission(context)) {
try {
- getTelecomManager(context).silenceRinger();
+ TelecomManagerCompat.silenceRinger(getTelecomManager(context));
} catch (SecurityException e) {
// Just in case
Log.w(TAG, "TelecomManager.silenceRinger called without permission.");