Pārlūkot izejas kodu

[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
j8
Saúl Ibarra Corretgé 8 gadus atpakaļ
vecāks
revīzija
5d50792a56

+ 13
- 2
android/app/src/main/java/org/jitsi/meet/audiomode/AudioModeModule.java Parādīt failu

@@ -188,13 +188,24 @@ public class AudioModeModule extends ReactContextBaseJavaModule {
188 188
         Runnable r = new Runnable() {
189 189
             @Override
190 190
             public void run() {
191
-                if (updateAudioRoute(mode)) {
191
+                boolean success;
192
+
193
+                try {
194
+                    success = updateAudioRoute(mode);
195
+                } catch (Throwable e) {
196
+                    success = false;
197
+                    Log.e(
198
+                            TAG,
199
+                            "Failed to update audio route for mode: " + mode,
200
+                            e);
201
+                }
202
+                if (success) {
192 203
                     AudioModeModule.this.mode = mode;
193 204
                     promise.resolve(null);
194 205
                 } else {
195 206
                     promise.reject(
196 207
                             "setMode",
197
-                            "Failed to set the requested audio mode");
208
+                            "Failed to set audio mode to " + mode);
198 209
                 }
199 210
             }
200 211
         };

Notiek ielāde…
Atcelt
Saglabāt