From e070e083681ca540cde2a57459fe1f4a44e8cb7c Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 14 Jun 2022 08:11:54 +0200 Subject: [PATCH] Added failsafe --- .../eu/faircode/email/MediaPlayerHelper.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MediaPlayerHelper.java b/app/src/main/java/eu/faircode/email/MediaPlayerHelper.java index ebfe98a824..b41d44859b 100644 --- a/app/src/main/java/eu/faircode/email/MediaPlayerHelper.java +++ b/app/src/main/java/eu/faircode/email/MediaPlayerHelper.java @@ -85,11 +85,16 @@ public class MediaPlayerHelper { if (am == null) return false; - // This doesn't require READ_PHONE_STATE permission - int mode = am.getMode(); - EntityLog.log(context, "Audio mode=" + mode); - return (mode == AudioManager.MODE_RINGTONE || - mode == AudioManager.MODE_IN_CALL || - mode == AudioManager.MODE_IN_COMMUNICATION); + try { + // This doesn't require READ_PHONE_STATE permission + int mode = am.getMode(); + Log.i("Audio mode=" + mode); + return (mode == AudioManager.MODE_RINGTONE || + mode == AudioManager.MODE_IN_CALL || + mode == AudioManager.MODE_IN_COMMUNICATION); + } catch (Throwable ex) { + Log.e(ex); + return false; + } } }