Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b974c06b authored by Jacqueline Bronger's avatar Jacqueline Bronger Committed by Android (Google) Code Review
Browse files

Merge "TV PiP: don't throw exception if entry restricted" into main

parents 3c7fe2cc 7c47fa28
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -3174,6 +3174,15 @@ public class Activity extends ContextThemeWrapper
            throw new IllegalArgumentException("Expected non-null picture-in-picture params");
        }
        if (!mCanEnterPictureInPicture) {
            if (isTvImplicitEnterPipProhibited()) {
                // Don't throw exception on TV so that apps don't crash when not adapted to new
                // restrictions.
                Log.e(TAG,
                        "Activity must be resumed to enter picture-in-picture and not about to be"
                                + " paused. Implicit app entry is only permitted on TV if android"
                                + ".permission.TV_IMPLICIT_ENTER_PIP is held by the app.");
                return false;
            }
            throw new IllegalStateException("Activity must be resumed to enter"
                    + " picture-in-picture");
        }
@@ -3212,7 +3221,7 @@ public class Activity extends ContextThemeWrapper
        return ActivityTaskManager.getMaxNumPictureInPictureActions(this);
    }

    private boolean isImplicitEnterPipProhibited() {
    private boolean isTvImplicitEnterPipProhibited() {
        PackageManager pm = getPackageManager();
        if (android.app.Flags.enableTvImplicitEnterPipRestriction()) {
            return pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK)
@@ -9346,7 +9355,7 @@ public class Activity extends ContextThemeWrapper
                    + mComponent.getClassName());
        }

        if (isImplicitEnterPipProhibited()) {
        if (isTvImplicitEnterPipProhibited()) {
            mCanEnterPictureInPicture = false;
        }

@@ -9376,7 +9385,7 @@ public class Activity extends ContextThemeWrapper
    final void performUserLeaving() {
        onUserInteraction();

        if (isImplicitEnterPipProhibited()) {
        if (isTvImplicitEnterPipProhibited()) {
            mCanEnterPictureInPicture = false;
        }
        onUserLeaveHint();