浏览代码

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
 import com.facebook.react.bridge.ReactContext;
24
 import com.facebook.react.bridge.ReactContext;
25
 import com.facebook.react.modules.core.PermissionListener;
25
 import com.facebook.react.modules.core.PermissionListener;
26
 
26
 
27
+import org.jitsi.meet.sdk.log.JitsiMeetLogger;
28
+
27
 /**
29
 /**
28
  * Helper class to encapsulate the work which needs to be done on
30
  * Helper class to encapsulate the work which needs to be done on
29
  * {@link Activity} lifecycle methods in order for the React side to be aware of
31
  * {@link Activity} lifecycle methods in order for the React side to be aware of
177
 
179
 
178
     public static void requestPermissions(Activity activity, String[] permissions, int requestCode, PermissionListener listener) {
180
     public static void requestPermissions(Activity activity, String[] permissions, int requestCode, PermissionListener listener) {
179
         permissionListener = listener;
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
 }

正在加载...
取消
保存