android: disable PiP on Android Go devices
Despite running Android 8.1, they don't support Picture-in-Picture.
This commit is contained in:
parent
0751c6ab48
commit
ddaaeccafa
|
@ -1,6 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright @ 2018-present 8x8, Inc.
|
* Copyright @ 2017-present 8x8, Inc.
|
||||||
* Copyright @ 2017-2018 Atlassian Pty Ltd
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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(
|
= ReactInstanceManagerHolder.getNativeModule(
|
||||||
PictureInPictureModule.class);
|
PictureInPictureModule.class);
|
||||||
if (pipModule != null
|
if (pipModule != null
|
||||||
&& PictureInPictureModule.isPictureInPictureSupported()
|
&& pipModule.isPictureInPictureSupported()
|
||||||
&& !JitsiMeetActivityDelegate.arePermissionsBeingRequested()
|
&& !JitsiMeetActivityDelegate.arePermissionsBeingRequested()
|
||||||
&& this.url != null) {
|
&& this.url != null) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.app.PictureInPictureParams;
|
import android.app.PictureInPictureParams;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Rational;
|
import android.util.Rational;
|
||||||
|
@ -30,20 +31,41 @@ import com.facebook.react.module.annotations.ReactModule;
|
||||||
|
|
||||||
import org.jitsi.meet.sdk.log.JitsiMeetLogger;
|
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)
|
@ReactModule(name = PictureInPictureModule.NAME)
|
||||||
class PictureInPictureModule
|
class PictureInPictureModule extends ReactContextBaseJavaModule {
|
||||||
extends ReactContextBaseJavaModule {
|
|
||||||
|
|
||||||
public static final String NAME = "PictureInPicture";
|
public static final String NAME = "PictureInPicture";
|
||||||
|
|
||||||
private static final String TAG = NAME;
|
private static final String TAG = NAME;
|
||||||
|
|
||||||
static boolean isPictureInPictureSupported() {
|
private static boolean isSupported;
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PictureInPictureModule(ReactApplicationContext reactContext) {
|
public PictureInPictureModule(ReactApplicationContext reactContext) {
|
||||||
super(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)
|
@TargetApi(Build.VERSION_CODES.O)
|
||||||
public void enterPictureInPicture() {
|
public void enterPictureInPicture() {
|
||||||
if (!isPictureInPictureSupported()) {
|
if (!isSupported) {
|
||||||
throw new IllegalStateException("Picture-in-Picture not supported");
|
throw new IllegalStateException("Picture-in-Picture not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +126,10 @@ class PictureInPictureModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPictureInPictureSupported() {
|
||||||
|
return isSupported;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return NAME;
|
return NAME;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import { Platform } from 'react-native';
|
import { NativeModules, Platform } from 'react-native';
|
||||||
|
|
||||||
import { PIP_ENABLED, getFeatureFlag } from '../../../base/flags';
|
import { PIP_ENABLED, getFeatureFlag } from '../../../base/flags';
|
||||||
import { translate } from '../../../base/i18n';
|
import { translate } from '../../../base/i18n';
|
||||||
|
@ -66,9 +66,8 @@ function _mapStateToProps(state): Object {
|
||||||
const flag = Boolean(getFeatureFlag(state, PIP_ENABLED));
|
const flag = Boolean(getFeatureFlag(state, PIP_ENABLED));
|
||||||
let enabled = flag;
|
let enabled = flag;
|
||||||
|
|
||||||
// Override flag for Android < 26, PiP was introduced in Oreo.
|
// Override flag for Android, since it might be unsupported.
|
||||||
// https://developer.android.com/guide/topics/ui/picture-in-picture
|
if (Platform.OS === 'android' && !NativeModules.PictureInPicture.SUPPORTED) {
|
||||||
if (Platform.OS === 'android' && Platform.Version < 26) {
|
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue