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

Commit cfcef3f3 authored by Hongwei Wang's avatar Hongwei Wang Committed by Android Build Coastguard Worker
Browse files

GRANT TRUSTED_OVERLAY after PiP is entered

- Make sure the TRUSTED_OVERLAY is only granted after WMShell
  successfully handled the entering PiP transition
- Revoke TRUSTED_OVERLAY in WM once the task is not pinned any more

Flag: EXEMPT securityfix
Bug: 436270922
Test: atest PinnedStackTests
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:8a84266ada6944eff7e5c73bdee3caefda364bf3
Merged-In: Id849d93bc92209fc296ee91ef70b0ffe2a09550e
Change-Id: Id849d93bc92209fc296ee91ef70b0ffe2a09550e
parent 5e77a2d1
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -459,16 +459,24 @@ public class PipTransition extends PipTransitionController {
            @PipAnimationController.TransitionDirection int direction,
            @NonNull SurfaceControl.Transaction tx) {
        final boolean enteringPip = isInPipDirection(direction);
        final SurfaceControl leash = mPipOrganizer.getSurfaceControl();
        final boolean hasValidLeash = leash != null && leash.isValid();
        if (enteringPip) {
            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
        // means we're expecting the exit transition will be "merged" into another transition
        // (likely a remote like launcher), so don't fire the finish-callback here -- wait until
        // the exit transition is merged.
        if ((mExitTransition == null || isAnimatingLocally()) && mFinishCallback != null) {
            final SurfaceControl leash = mPipOrganizer.getSurfaceControl();
            final boolean hasValidLeash = leash != null && leash.isValid();
            WindowContainerTransaction wct = null;
            if (isOutPipDirection(direction)) {
                // Only need to reset surface properties. The server-side operations were already
+6 −5
Original line number Diff line number Diff line
@@ -2366,14 +2366,15 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            mService.getTaskChangeNotificationController().notifyActivityPinned(r);
        } else {
            mService.getTaskChangeNotificationController().notifyActivityUnpinned();
        }
        mWindowManager.mPolicy.setPipVisibilityLw(inPip);
            // Revoke the TRUSTED_OVERLAY here as a blanket policy.
            if (task.getSurfaceControl() != null) {
                mWmService.mTransactionFactory.get()
                    .setTrustedOverlay(task.getSurfaceControl(), inPip)
                        .setTrustedOverlay(task.getSurfaceControl(), false)
                        .apply();
            }
        }
        mWindowManager.mPolicy.setPipVisibilityLw(inPip);
    }

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