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

Commit e2c77f90 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Handle content insets for snapshots

Pass information about content insets of a snapshotted task to
SystemUI and use it there to correctly offset the snapshot
when drawing.

Test: Open app, go to recents, make sure app aligns before
and after the animation.
Bug: 31339431
Change-Id: I2ff9bd44534bd8f66b591385da1e1e3aec40b6c5
parent a50da607
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -27,3 +27,5 @@ parcelable ActivityManager.RunningTaskInfo;
parcelable ActivityManager.StackInfo;
/** @hide */
parcelable ActivityManager.TaskThumbnail;
/** @hide */
parcelable ActivityManager.TaskSnapshot;
 No newline at end of file
+57 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.annotation.TestApi;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.GraphicBuffer;
import android.graphics.Matrix;
import android.graphics.Point;
import android.os.BatteryStats;
@@ -2125,6 +2126,62 @@ public class ActivityManager {
        };
    }

    /**
     * Represents a task snapshot.
     * @hide
     */
    public static class TaskSnapshot implements Parcelable {

        private final GraphicBuffer mSnapshot;
        private final int mOrientation;
        private final Rect mContentInsets;

        public TaskSnapshot(GraphicBuffer snapshot, int orientation, Rect contentInsets) {
            mSnapshot = snapshot;
            mOrientation = orientation;
            mContentInsets = new Rect(contentInsets);
        }

        private TaskSnapshot(Parcel source) {
            mSnapshot = source.readParcelable(null /* classLoader */);
            mOrientation = source.readInt();
            mContentInsets = source.readParcelable(null /* classLoader */);
        }

        public GraphicBuffer getSnapshot() {
            return mSnapshot;
        }

        public int getOrientation() {
            return mOrientation;
        }

        public Rect getContentInsets() {
            return mContentInsets;
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeParcelable(mSnapshot, 0);
            dest.writeInt(mOrientation);
            dest.writeParcelable(mContentInsets, 0);
        }

        public static final Creator<TaskSnapshot> CREATOR = new Creator<TaskSnapshot>() {
            public TaskSnapshot createFromParcel(Parcel source) {
                return new TaskSnapshot(source);
            }
            public TaskSnapshot[] newArray(int size) {
                return new TaskSnapshot[size];
            }
        };
    }

    /** @hide */
    public TaskThumbnail getTaskThumbnail(int id) throws SecurityException {
        try {
+1 −1
Original line number Diff line number Diff line
@@ -600,7 +600,7 @@ interface IActivityManager {
    /**
     * @return a graphic buffer representing a screenshot of a task
     */
    GraphicBuffer getTaskSnapshot(int taskId);
    ActivityManager.TaskSnapshot getTaskSnapshot(int taskId);

    // WARNING: when these transactions are updated, check if they are any callers on the native
    // side. If so, make sure they are using the correct transaction ids and arguments.
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.view.InputDevice;
import android.view.IInputFilter;
import android.view.AppTransitionAnimationSpec;
import android.view.WindowContentFrameStats;
import android.view.WindowManager;

/**
 * System private interface to the window manager.
+2 −1
Original line number Diff line number Diff line
@@ -18,4 +18,5 @@
package android.view;

parcelable WindowManager.LayoutParams;
/** @hide */
parcelable WindowManager.TaskSnapshot;
Loading