소스 검색

android: fix crash when requesting permissions

The RN Permissions module calls this in a non-UI thread. What we observe is a
crash in ViewGroup.dispatchCancelPendingInputEvents, which is called on the
calling (ie, non-UI) thread. This doesn't look very safe, so try to avoid a
crash by pretending the permission was denied.
j8
Saúl Ibarra Corretgé 5 년 전
부모
커밋
57bbe3f75a
1개의 변경된 파일13개의 추가작업 그리고 1개의 파일을 삭제
  1. 13
    1
      android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivityDelegate.java

+ 13
- 1
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivityDelegate.java 파일 보기

@@ -24,6 +24,8 @@ import com.facebook.react.bridge.Callback;
24 24
 import com.facebook.react.bridge.ReactContext;
25 25
 import com.facebook.react.modules.core.PermissionListener;
26 26
 
27
+import org.jitsi.meet.sdk.log.JitsiMeetLogger;
28
+
27 29
 /**
28 30
  * Helper class to encapsulate the work which needs to be done on
29 31
  * {@link Activity} lifecycle methods in order for the React side to be aware of
@@ -177,6 +179,16 @@ public class JitsiMeetActivityDelegate {
177 179
 
178 180
     public static void requestPermissions(Activity activity, String[] permissions, int requestCode, PermissionListener listener) {
179 181
         permissionListener = listener;
180
-        activity.requestPermissions(permissions, requestCode);
182
+
183
+        // The RN Permissions module calls this in a non-UI thread. What we observe is a crash in ViewGroup.dispatchCancelPendingInputEvents,
184
+        // which is called on the calling (ie, non-UI) thread. This doesn't look very safe, so try to avoid a crash by pretending the permission
185
+        // was denied.
186
+
187
+        try {
188
+            activity.requestPermissions(permissions, requestCode);
189
+        } catch (Exception e) {
190
+            JitsiMeetLogger.e(e, "Error requesting permissions");
191
+            onRequestPermissionsResult(requestCode, permissions, new int[0]);
192
+        }
181 193
     }
182 194
 }

Loading…
취소
저장