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

Commit 79090d69 authored by Jerry Chang's avatar Jerry Chang
Browse files

Snapshot all tasks in pending recents animation when rotating devices

Since both of splitting tasks in split screen go to overview together
now, update to snapshot all pending animations when rotating while
showing overview to ensure both of splitting task snapshots are taken
with proper bounds before rotation.

Bug: 200813008
Test: atest RecentsAnimationControllerTest
Test: enter overview after activated split screen, observed task
      thumbnails showing with correct bounds after roation.
Change-Id: Id1101bf8be67593f85a43c1d4afae769ffc737d3
parent cb5907cc
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import static org.hamcrest.core.Is.is;

import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.window.TaskSnapshot;
import android.app.IActivityTaskManager;
import android.content.ComponentName;
import android.content.Context;
@@ -41,6 +40,7 @@ import android.util.Pair;
import android.view.IRecentsAnimationController;
import android.view.IRecentsAnimationRunner;
import android.view.RemoteAnimationTarget;
import android.window.TaskSnapshot;

import androidx.test.filters.LargeTest;
import androidx.test.runner.lifecycle.Stage;
@@ -210,7 +210,8 @@ public class RecentsAnimationPerfTest extends WindowManagerPerfTestBase
            }

            @Override
            public void onAnimationCanceled(TaskSnapshot taskSnapshot) throws RemoteException {
            public void onAnimationCanceled(int[] taskIds, TaskSnapshot[] taskSnapshots)
                    throws RemoteException {
                Assume.assumeNoException(
                        new AssertionError("onAnimationCanceled should not be called"));
            }
+8 −6
Original line number Diff line number Diff line
@@ -35,15 +35,17 @@ oneway interface IRecentsAnimationRunner {
     * wallpaper not drawing in time, or the handler not finishing the animation within a predefined
     * amount of time.
     *
     * @param taskSnapshot If the snapshot is null, the animation will be cancelled and the leash
     *                     will be inactive immediately. Otherwise, the contents of the task will be
     *                     replaced with {@param taskSnapshot}, such that the runner's leash is
     * @param taskIds Indicates tasks with cancelling snapshot.
     * @param taskSnapshots If the snapshots is null, the animation will be cancelled and the leash
     *                      will be inactive immediately. Otherwise, the contents of the tasks will
     *                      be replaced with {@param taskSnapshots}, such that the runner's leash is
     *                      still active. As soon as the runner doesn't need the leash anymore, it
     *                      must call {@link IRecentsAnimationController#cleanupScreenshot).
     *
     * @see {@link RecentsAnimationController#cleanupScreenshot}
     */
    void onAnimationCanceled(in @nullable TaskSnapshot taskSnapshot) = 1;
    void onAnimationCanceled(in @nullable int[] taskIds,
            in @nullable TaskSnapshot[] taskSnapshots) = 1;

    /**
     * Called when the system is ready for the handler to start animating all the visible tasks.
+15 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static android.graphics.Bitmap.Config.ARGB_8888;

import static com.android.systemui.shared.system.WindowManagerWrapper.WINDOWING_MODE_UNDEFINED;

import android.window.TaskSnapshot;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Point;
@@ -30,6 +29,9 @@ import android.graphics.Rect;
import android.hardware.HardwareBuffer;
import android.util.Log;
import android.view.WindowInsetsController.Appearance;
import android.window.TaskSnapshot;

import java.util.HashMap;

/**
 * Data for a single thumbnail.
@@ -80,6 +82,18 @@ public class ThumbnailData {
        return thumbnail;
    }

    public static HashMap<Integer, ThumbnailData> wrap(int[] taskIds, TaskSnapshot[] snapshots) {
        HashMap<Integer, ThumbnailData> temp = new HashMap<>();
        if (taskIds == null || snapshots == null || taskIds.length != snapshots.length) {
            return temp;
        }

        for (int i = snapshots.length - 1; i >= 0; i--) {
            temp.put(taskIds[i], new ThumbnailData(snapshots[i]));
        }
        return temp;
    }

    public ThumbnailData(TaskSnapshot snapshot) {
        thumbnail = makeThumbnail(snapshot);
        insets = new Rect(snapshot.getContentInsets());
+3 −3
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.app.ActivityClient;
import android.app.ActivityManager;
import android.app.ActivityManager.RecentTaskInfo;
import android.app.ActivityManager.RunningTaskInfo;
import android.window.TaskSnapshot;
import android.app.ActivityOptions;
import android.app.ActivityTaskManager;
import android.app.AppGlobals;
@@ -50,6 +49,7 @@ import android.util.Log;
import android.view.IRecentsAnimationController;
import android.view.IRecentsAnimationRunner;
import android.view.RemoteAnimationTarget;
import android.window.TaskSnapshot;

import com.android.internal.app.IVoiceInteractionManagerService;
import com.android.systemui.shared.recents.model.Task;
@@ -189,9 +189,9 @@ public class ActivityManagerWrapper {
                    }

                    @Override
                    public void onAnimationCanceled(TaskSnapshot taskSnapshot) {
                    public void onAnimationCanceled(int[] taskIds, TaskSnapshot[] taskSnapshots) {
                        animationHandler.onAnimationCanceled(
                                taskSnapshot != null ? new ThumbnailData(taskSnapshot) : null);
                                ThumbnailData.wrap(taskIds, taskSnapshots));
                    }

                    @Override
+5 −3
Original line number Diff line number Diff line
@@ -39,12 +39,14 @@ public class RecentsAnimationControllerCompat {

    public ThumbnailData screenshotTask(int taskId) {
        try {
            TaskSnapshot snapshot = mAnimationController.screenshotTask(taskId);
            return snapshot != null ? new ThumbnailData(snapshot) : new ThumbnailData();
            final TaskSnapshot snapshot = mAnimationController.screenshotTask(taskId);
            if (snapshot != null) {
                return new ThumbnailData(snapshot);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to screenshot task", e);
            return new ThumbnailData();
        }
        return new ThumbnailData();
    }

    public void setInputConsumerEnabled(boolean enabled) {
Loading