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

Commit 942a85c6 authored by Winson Chung's avatar Winson Chung
Browse files

Prevent non-fullscreen activities from triggering auto-enter PiP

Bug: 63581685
Test: android.server.cts.ActivityManagerPinnedStackTests
Test: #testAppOpsDenyPipOnPause
Test: Launch screenshot from notification tray above auto-enter PiP
      activity

Change-Id: I0bddfd5c47d6053d079b9bd426003d526e8bb0dd
parent b544b81b
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -2881,10 +2881,13 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
                        transit = TRANSIT_TASK_OPEN_BEHIND;
                        transit = TRANSIT_TASK_OPEN_BEHIND;
                    } else {
                    } else {
                        // If a new task is being launched, then mark the existing top activity as
                        // If a new task is being launched, then mark the existing top activity as
                        // supporting picture-in-picture while pausing
                        // supporting picture-in-picture while pausing only if the starting activity
                        // would not be considered an overlay on top of the current activity
                        // (eg. not fullscreen, or the assistant)
                        if (focusedTopActivity != null
                        if (focusedTopActivity != null
                                && focusedTopActivity.getStackId() != PINNED_STACK_ID
                                && focusedTopActivity.getStackId() != PINNED_STACK_ID
                                && r.getStackId() != ASSISTANT_STACK_ID) {
                                && r.getStackId() != ASSISTANT_STACK_ID
                                && r.fullscreen) {
                            focusedTopActivity.supportsPictureInPictureWhilePausing = true;
                            focusedTopActivity.supportsPictureInPictureWhilePausing = true;
                        }
                        }
                        transit = TRANSIT_TASK_OPEN;
                        transit = TRANSIT_TASK_OPEN;
@@ -4549,9 +4552,10 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
            updateTransitLocked(TRANSIT_TASK_TO_FRONT, options);
            updateTransitLocked(TRANSIT_TASK_TO_FRONT, options);
        }
        }
        // If a new task is moved to the front, then mark the existing top activity as supporting
        // If a new task is moved to the front, then mark the existing top activity as supporting
        // picture-in-picture while paused
        // picture-in-picture while paused only if the task would not be considered an oerlay on top
        // of the current activity (eg. not fullscreen, or the assistant)
        if (topActivity != null && topActivity.getStackId() != PINNED_STACK_ID
        if (topActivity != null && topActivity.getStackId() != PINNED_STACK_ID
                && tr.getStackId() != ASSISTANT_STACK_ID) {
                && tr.getStackId() != ASSISTANT_STACK_ID && tr.containsOnlyFullscreenActivities()) {
            topActivity.supportsPictureInPictureWhilePausing = true;
            topActivity.supportsPictureInPictureWhilePausing = true;
        }
        }


+13 −0
Original line number Original line Diff line number Diff line
@@ -1112,6 +1112,19 @@ final class TaskRecord extends ConfigurationContainer implements TaskWindowConta
        return intent != null ? intent : affinityIntent;
        return intent != null ? intent : affinityIntent;
    }
    }


    /**
     * @return Whether there are only fullscreen activities in this task.
     */
    boolean containsOnlyFullscreenActivities() {
        for (int i = 0; i < mActivities.size(); i++) {
            final ActivityRecord r = mActivities.get(i);
            if (!r.finishing && !r.fullscreen) {
                return false;
            }
        }
        return true;
    }

    /** Returns the first non-finishing activity from the root. */
    /** Returns the first non-finishing activity from the root. */
    ActivityRecord getRootActivity() {
    ActivityRecord getRootActivity() {
        for (int i = 0; i < mActivities.size(); i++) {
        for (int i = 0; i < mActivities.size(); i++) {