From 5d50792a56c341cf19053e316660b88a9af8d71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 19 Apr 2017 12:29:52 +0200 Subject: [PATCH] [RN] Make AudioMode more resilient on Android Some devices may give an error stating that INTERACT_ACROSS_USERS_FULL permission is neeced. This permission can only be achieved by signing the application with the same key as the system, which is never going to happen so deal with it by catching any exceptions setting the mode may cause and failing as gracefully as we can. Ref: http://stackoverflow.com/questions/34172575/audiomanager-setmode-securityexception-on-huawei-android-4 --- .../org/jitsi/meet/audiomode/AudioModeModule.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/java/org/jitsi/meet/audiomode/AudioModeModule.java b/android/app/src/main/java/org/jitsi/meet/audiomode/AudioModeModule.java index e28f6e085..66292cc80 100644 --- a/android/app/src/main/java/org/jitsi/meet/audiomode/AudioModeModule.java +++ b/android/app/src/main/java/org/jitsi/meet/audiomode/AudioModeModule.java @@ -188,13 +188,24 @@ public class AudioModeModule extends ReactContextBaseJavaModule { Runnable r = new Runnable() { @Override public void run() { - if (updateAudioRoute(mode)) { + boolean success; + + try { + success = updateAudioRoute(mode); + } catch (Throwable e) { + success = false; + Log.e( + TAG, + "Failed to update audio route for mode: " + mode, + e); + } + if (success) { AudioModeModule.this.mode = mode; promise.resolve(null); } else { promise.reject( "setMode", - "Failed to set the requested audio mode"); + "Failed to set audio mode to " + mode); } } };