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

Commit db423654 authored by Hongwei Wang's avatar Hongwei Wang Committed by Android (Google) Code Review
Browse files

Merge "GRANT TRUSTED_OVERLAY after PiP is entered" into main

parents 58668a9a 3b93cc4b
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -521,8 +521,18 @@ public class PipTransition extends PipTransitionController {
            @NonNull Point leashOffset, @PipAnimationController.TransitionDirection int direction,
            @NonNull Point leashOffset, @PipAnimationController.TransitionDirection int direction,
            @NonNull SurfaceControl.Transaction tx) {
            @NonNull SurfaceControl.Transaction tx) {
        final boolean enteringPip = isInPipDirection(direction);
        final boolean enteringPip = isInPipDirection(direction);
        final SurfaceControl leash = mPipOrganizer.getSurfaceControl();
        final boolean hasValidLeash = leash != null && leash.isValid();
        if (enteringPip) {
        if (enteringPip) {
            mPipTransitionState.setTransitionState(ENTERED_PIP);
            mPipTransitionState.setTransitionState(ENTERED_PIP);
            // TRUSTED_OVERLAY is granted iff Shell successfully receives the transition.
            // It's revoked once the task exits pinned mode in
            // RootWindowContainer#notifyActivityPipModeChanged
            if (hasValidLeash) {
                ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                        "Set TRUSTED_OVERLAY for Task#%d", taskInfo.taskId);
                tx.setTrustedOverlay(leash, true);
            }
        }
        }
        // If we have an exit transition, but aren't playing a transition locally, it
        // If we have an exit transition, but aren't playing a transition locally, it
        // means we're expecting the exit transition will be "merged" into another transition
        // means we're expecting the exit transition will be "merged" into another transition
@@ -530,8 +540,6 @@ public class PipTransition extends PipTransitionController {
        // the exit transition is merged.
        // the exit transition is merged.
        if ((mExitTransition == null || mMoveToBackTransition == null || isAnimatingLocally())
        if ((mExitTransition == null || mMoveToBackTransition == null || isAnimatingLocally())
                && mFinishCallback != null) {
                && mFinishCallback != null) {
            final SurfaceControl leash = mPipOrganizer.getSurfaceControl();
            final boolean hasValidLeash = leash != null && leash.isValid();
            WindowContainerTransaction wct = null;
            WindowContainerTransaction wct = null;
            if (isOutPipDirection(direction)) {
            if (isOutPipDirection(direction)) {
                // Only need to reset surface properties. The server-side operations were already
                // Only need to reset surface properties. The server-side operations were already
+6 −5
Original line number Original line Diff line number Diff line
@@ -2400,14 +2400,15 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            mService.getTaskChangeNotificationController().notifyActivityPinned(r);
            mService.getTaskChangeNotificationController().notifyActivityPinned(r);
        } else {
        } else {
            mService.getTaskChangeNotificationController().notifyActivityUnpinned();
            mService.getTaskChangeNotificationController().notifyActivityUnpinned();
        }
            // Revoke the TRUSTED_OVERLAY here as a blanket policy.
        mWindowManager.mPolicy.setPipVisibilityLw(inPip);
            if (task.getSurfaceControl() != null) {
            if (task.getSurfaceControl() != null) {
                mWmService.mTransactionFactory.get()
                mWmService.mTransactionFactory.get()
                    .setTrustedOverlay(task.getSurfaceControl(), inPip)
                        .setTrustedOverlay(task.getSurfaceControl(), false)
                        .apply();
                        .apply();
            }
            }
        }
        }
        mWindowManager.mPolicy.setPipVisibilityLw(inPip);
    }


    void executeAppTransitionForAllDisplay() {
    void executeAppTransitionForAllDisplay() {
        for (int displayNdx = getChildCount() - 1; displayNdx >= 0; --displayNdx) {
        for (int displayNdx = getChildCount() - 1; displayNdx >= 0; --displayNdx) {