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

Commit 0df585fb authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Apply PictureInPictureSurfaceTransaction upon reparent

When autoEnterPip from Task with multiple activities, besides passing
the mLastRecentsAnimationBounds we should also try to pass the last
PictureInPictureSurfaceTransaction to the new Task and apply both.

Changed also
- deprecate the last recents animation bounds and use the transaction only
- reset the transform once applied to the original task

Known issue: original task appears transparent in overview once.

Video: http://recall/-/aaaaaabFQoRHlzixHdtY/hNZ0H62PqgVDEUGh1TVMiT
Bug: 184789412
Bug: 185509920
Test: manual with ApiDemos, see Video
Change-Id: I7fb77e41e1963e14ecaf53bd135d6b4cb24493c9
parent 469e1b49
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package android.view;
import android.app.ActivityManager;
import android.view.IRemoteAnimationFinishedCallback;
import android.graphics.GraphicBuffer;
import android.graphics.Rect;
import android.window.PictureInPictureSurfaceTransaction;
import android.window.TaskSnapshot;

@@ -39,14 +38,13 @@ interface IRecentsAnimationController {
    TaskSnapshot screenshotTask(int taskId);

    /**
     * Sets the final bounds on a Task. This is used by Launcher to notify the system that
     * animating Activity to PiP has completed and the associated task surface should be updated
     * accordingly. This should be called before `finish`
     * Sets the final surface transaction on a Task. This is used by Launcher to notify the system
     * that animating Activity to PiP has completed and the associated task surface should be
     * updated accordingly. This should be called before `finish`
     * @param taskId for which the leash should be updated
     * @param destinationBounds bounds of the final PiP window
     * @param finishTransaction leash operations for the final transform.
     */
     void setFinishTaskBounds(int taskId, in Rect destinationBounds,
     void setFinishTaskTransaction(int taskId,
             in PictureInPictureSurfaceTransaction finishTransaction);

    /**
+19 −0
Original line number Diff line number Diff line
@@ -16,10 +16,13 @@

package android.window;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.Parcel;
import android.os.Parcelable;
import android.view.SurfaceControl;

import java.util.Objects;

@@ -127,6 +130,22 @@ public final class PictureInPictureSurfaceTransaction implements Parcelable {
                + ")";
    }

    /** Applies {@link PictureInPictureSurfaceTransaction} to a given leash. */
    public static void apply(@NonNull PictureInPictureSurfaceTransaction surfaceTransaction,
            @NonNull SurfaceControl surfaceControl,
            @NonNull SurfaceControl.Transaction tx) {
        final Matrix matrix = new Matrix();
        matrix.setScale(surfaceTransaction.mScaleX, surfaceTransaction.mScaleY);
        if (surfaceTransaction.mRotation != 0) {
            matrix.postRotate(surfaceTransaction.mRotation);
        }
        tx.setMatrix(surfaceControl, matrix, new float[9])
                .setPosition(surfaceControl,
                        surfaceTransaction.mPositionX, surfaceTransaction.mPositionY)
                .setWindowCrop(surfaceControl, surfaceTransaction.getWindowCrop())
                .setCornerRadius(surfaceControl, surfaceTransaction.mCornerRadius);
    }

    public static final @android.annotation.NonNull Creator<PictureInPictureSurfaceTransaction>
            CREATOR =
            new Creator<PictureInPictureSurfaceTransaction>() {
+6 −12
Original line number Diff line number Diff line
@@ -367,12 +367,6 @@
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/DisplayRotation.java"
    },
    "-1729340764": {
      "message": "setFinishTaskBounds(%d): bounds=%s",
      "level": "DEBUG",
      "group": "WM_DEBUG_RECENTS_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RecentsAnimationController.java"
    },
    "-1715268616": {
      "message": "Last window, removing starting window %s",
      "level": "VERBOSE",
@@ -1705,6 +1699,12 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-163974242": {
      "message": "setFinishTaskTransaction(%d): transaction=%s",
      "level": "DEBUG",
      "group": "WM_DEBUG_RECENTS_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RecentsAnimationController.java"
    },
    "-143556958": {
      "message": "resumeNextFocusableActivityWhenRootTaskIsEmpty: %s, go home",
      "level": "DEBUG",
@@ -1891,12 +1891,6 @@
      "group": "WM_DEBUG_RECENTS_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RecentsAnimationController.java"
    },
    "86989930": {
      "message": "setTaskWindowingMode: moving task=%d to windowingMode=%d toTop=%b",
      "level": "DEBUG",
      "group": "WM_DEBUG_TASKS",
      "at": "com\/android\/server\/wm\/ActivityTaskManagerService.java"
    },
    "90764070": {
      "message": "Could not report token removal to the window token client.",
      "level": "WARN",
+5 −7
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.shared.system;

import android.graphics.Rect;
import android.os.RemoteException;
import android.util.Log;
import android.view.IRecentsAnimationController;
@@ -72,17 +71,16 @@ public class RecentsAnimationControllerCompat {
    }

    /**
     * Sets the final bounds on a Task. This is used by Launcher to notify the system that
     * animating Activity to PiP has completed and the associated task surface should be updated
     * accordingly. This should be called before `finish`
     * Sets the final surface transaction on a Task. This is used by Launcher to notify the system
     * that animating Activity to PiP has completed and the associated task surface should be
     * updated accordingly. This should be called before `finish`
     * @param taskId Task id of the Activity in PiP mode.
     * @param destinationBounds Bounds of the PiP window on home.
     * @param finishTransaction leash operations for the final transform.
     */
    public void setFinishTaskBounds(int taskId, Rect destinationBounds,
    public void setFinishTaskTransaction(int taskId,
            PictureInPictureSurfaceTransaction finishTransaction) {
        try {
            mAnimationController.setFinishTaskBounds(taskId, destinationBounds, finishTransaction);
            mAnimationController.setFinishTaskTransaction(taskId, finishTransaction);
        } catch (RemoteException e) {
            Log.d(TAG, "Failed to set finish task bounds", e);
        }
+2 −2
Original line number Diff line number Diff line
@@ -160,10 +160,10 @@ public class RemoteTransitionCompat implements Parcelable {
            mWrapped.hideCurrentInputMethod();
        }

        @Override public void setFinishTaskBounds(int taskId, Rect destinationBounds,
        @Override public void setFinishTaskTransaction(int taskId,
                PictureInPictureSurfaceTransaction finishTransaction) {
            if (mWrapped != null) {
                mWrapped.setFinishTaskBounds(taskId, destinationBounds, finishTransaction);
                mWrapped.setFinishTaskTransaction(taskId, finishTransaction);
            }
        }

Loading