Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
android: disable PiP on Android Go devices
Saúl Ibarra Corretgéddaaeccafa81
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.javaindex 9c1bb2bd05..e690046118 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@@ -1,6 +1,5 @@/*- * Copyright @ 2018-present 8x8, Inc.- * Copyright @ 2017-2018 Atlassian Pty Ltd+ * Copyright @ 2017-present 8x8, Inc.** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.@@ -126,7 +125,7 @@ public class JitsiMeetView extends BaseReactView<JitsiMeetViewListener>= ReactInstanceManagerHolder.getNativeModule(PictureInPictureModule.class);if (pipModule != null- && PictureInPictureModule.isPictureInPictureSupported()+ && pipModule.isPictureInPictureSupported()&& !JitsiMeetActivityDelegate.arePermissionsBeingRequested()&& this.url != null) {try {diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/PictureInPictureModule.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/PictureInPictureModule.javaindex 2123334d54..a8edcd9573 100644--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/PictureInPictureModule.java+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/PictureInPictureModule.java@@ -1,5 +1,5 @@/*- * Copyright @ 2017-present Atlassian Pty Ltd+ * Copyright @ 2017-present 8x8, Inc.** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.@@ -18,6 +18,7 @@ package org.jitsi.meet.sdk;import android.annotation.TargetApi;import android.app.Activity;+import android.app.ActivityManager;import android.app.PictureInPictureParams;import android.os.Build;import android.util.Rational;@@ -30,20 +31,41 @@ import com.facebook.react.module.annotations.ReactModule;import org.jitsi.meet.sdk.log.JitsiMeetLogger;+import java.util.HashMap;+import java.util.Map;++import static android.content.Context.ACTIVITY_SERVICE;+@ReactModule(name = PictureInPictureModule.NAME)-class PictureInPictureModule- extends ReactContextBaseJavaModule {+class PictureInPictureModule extends ReactContextBaseJavaModule {public static final String NAME = "PictureInPicture";-private static final String TAG = NAME;- static boolean isPictureInPictureSupported() {- return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;- }+ private static boolean isSupported;public PictureInPictureModule(ReactApplicationContext reactContext) {super(reactContext);++ ActivityManager am = (ActivityManager) reactContext.getSystemService(ACTIVITY_SERVICE);++ // Android Go devices don't support PiP. There doesn't seem to be a better way to detect it than+ // to use ActivityManager.isLowRamDevice().+ // https://stackoverflow.com/questions/58340558/how-to-detect-android-go+ isSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !am.isLowRamDevice();+ }++ /**+ * Gets a {@code Map} of constants this module exports to JS. Supports JSON+ * types.+ *+ * @return a {@link Map} of constants this module exports to JS+ */+ @Override+ public Map<String, Object> getConstants() {+ Map<String, Object> constants = new HashMap<>();+ constants.put("SUPPORTED", isSupported);+ return constants;}/**@@ -61,7 +83,7 @@ class PictureInPictureModule*/@TargetApi(Build.VERSION_CODES.O)public void enterPictureInPicture() {- if (!isPictureInPictureSupported()) {+ if (!isSupported) {throw new IllegalStateException("Picture-in-Picture not supported");}@@ -104,6 +126,10 @@ class PictureInPictureModule}}+ public boolean isPictureInPictureSupported() {+ return isSupported;+ }+@Overridepublic String getName() {return NAME;diff --git a/react/features/mobile/picture-in-picture/components/PictureInPictureButton.js b/react/features/mobile/picture-in-picture/components/PictureInPictureButton.jsindex 2212b7d1b8..63220a56eb 100644--- a/react/features/mobile/picture-in-picture/components/PictureInPictureButton.js+++ b/react/features/mobile/picture-in-picture/components/PictureInPictureButton.js@@ -1,6 +1,6 @@// @flow-import { Platform } from 'react-native';+import { NativeModules, Platform } from 'react-native';import { PIP_ENABLED, getFeatureFlag } from '../../../base/flags';import { translate } from '../../../base/i18n';@@ -66,9 +66,8 @@ function _mapStateToProps(state): Object {const flag = Boolean(getFeatureFlag(state, PIP_ENABLED));let enabled = flag;- // Override flag for Android < 26, PiP was introduced in Oreo.- // https://developer.android.com/guide/topics/ui/picture-in-picture- if (Platform.OS === 'android' && Platform.Version < 26) {+ // Override flag for Android, since it might be unsupported.+ if (Platform.OS === 'android' && !NativeModules.PictureInPicture.SUPPORTED) {enabled = false;}