From d02e24248f0d38e084336e463da559fedc3ac896 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 2 Aug 2016 10:58:31 +0200 Subject: [PATCH] catch platform bug when getting ringer mode --- .../services/XmppConnectionService.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index ed0b32fb8..cf850b9b2 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -721,10 +721,15 @@ public class XmppConnectionService extends Service { private boolean isPhoneSilenced() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); - if (treatVibrateAsSilent()) { - return audioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL; - } else { - return audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT; + try { + if (treatVibrateAsSilent()) { + return audioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL; + } else { + return audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT; + } + } catch (Throwable throwable) { + Log.d(Config.LOGTAG,"platform bug in isPhoneSilenced ("+ throwable.getMessage()+")"); + return false; } }