From 0889ffdf27a6f84c3ced2a5da720dbfc1d2ddc03 Mon Sep 17 00:00:00 2001 From: paweldomas Date: Tue, 7 May 2019 14:28:53 -0500 Subject: [PATCH] android fix: do not enter PiP mode when the permissions alert is shown Entering PiP mode while the permissions dialog is display will not only fail, but also mess up the Activity lifecycle on some OS versions. We may end up with two activity/fragment instances and a situation where the onStop callback was not called yet on the instance #1 while the onResume has been already called on instance #2. --- .../org/jitsi/meet/sdk/JitsiMeetActivityDelegate.java | 9 +++++++++ .../src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java | 1 + 2 files changed, 10 insertions(+) diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivityDelegate.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivityDelegate.java index 2fec9ac3b..3567a32af 100644 --- a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivityDelegate.java +++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivityDelegate.java @@ -40,6 +40,15 @@ public class JitsiMeetActivityDelegate { private static PermissionListener permissionListener; private static Callback permissionsCallback; + /** + * Tells whether or not the permissions request is currently in progress. + * + * @return {@code true} if the permssions are being requested or {@code false} otherwise. + */ + static boolean arePermissionsBeingRequested() { + return permissionListener != null; + } + /** * {@link Activity} lifecycle method which should be called from * {@code Activity#onActivityResult} so we are notified about results of external intents diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java index d95b98927..c7f5f1ccd 100644 --- a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java +++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java @@ -123,6 +123,7 @@ public class JitsiMeetView extends BaseReactView { PictureInPictureModule.class); if (pipModule != null && PictureInPictureModule.isPictureInPictureSupported() + && !JitsiMeetActivityDelegate.arePermissionsBeingRequested() && this.url != null) { try { pipModule.enterPictureInPicture();