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

Commit e6308047 authored by Winson Chung's avatar Winson Chung
Browse files

Only allowed visible, non-stopped activities to enter PIP.

Test: android.server.cts.ActivityManagerPinnedStackTests
Test: #testDisallowPipLaunchFromStoppedActivity

Change-Id: Ieb11345f09019bc83d6aaf92acbc3fb986d9ec43
parent 803abe73
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -7517,9 +7517,10 @@ public class ActivityManagerService extends IActivityManager.Stub
                            + "Can't find activity for token=" + token);
                }
                if (!r.supportsPictureInPicture()) {
                if (!r.canEnterPictureInPicture()) {
                    throw new IllegalArgumentException("enterPictureInPictureMode: "
                            + "Picture-In-Picture not supported for r=" + r);
                            + "Current activity does not support picture-in-picture or is not "
                            + "visible r=" + r);
                }
                if (aspectRatio != null && !isValidPictureInPictureAspectRatio(aspectRatio)) {
+18 −0
Original line number Diff line number Diff line
@@ -922,10 +922,28 @@ final class ActivityRecord {
                && info.resizeMode != RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION;
    }

    /**
     * @return whether this activity's resize mode supports PIP.
     */
    boolean supportsPictureInPicture() {
        return !isHomeActivity() && info.resizeMode == RESIZE_MODE_RESIZEABLE_AND_PIPABLE;
    }

    /**
     * @return whether this activity is currently allowed to enter PIP.
     */
    boolean canEnterPictureInPicture() {
        if (supportsPictureInPicture() && visible) {
            switch (state) {
                case RESUMED:
                case PAUSING:
                case PAUSED:
                    return true;
            }
        }
        return false;
    }

    boolean canGoInDockedStack() {
        return !isHomeActivity() && isResizeableOrForced();
    }