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

Commit b320cbcc authored by Vinit Nayak's avatar Vinit Nayak Committed by Android (Google) Code Review
Browse files

Merge "Add rotation field to ThumbnailData for task snapshots"

parents 5abf503b ffd9dff1
Loading
Loading
Loading
Loading
+25 −1
Original line number Original line Diff line number Diff line
@@ -73,6 +73,7 @@ import android.util.DisplayMetrics;
import android.util.Singleton;
import android.util.Singleton;
import android.util.Size;
import android.util.Size;
import android.view.IWindowContainer;
import android.view.IWindowContainer;
import android.view.Surface;


import com.android.internal.app.LocalePicker;
import com.android.internal.app.LocalePicker;
import com.android.internal.app.procstats.ProcessStats;
import com.android.internal.app.procstats.ProcessStats;
@@ -1928,7 +1929,12 @@ public class ActivityManager {
        // Top activity in task when snapshot was taken
        // Top activity in task when snapshot was taken
        private final ComponentName mTopActivityComponent;
        private final ComponentName mTopActivityComponent;
        private final GraphicBuffer mSnapshot;
        private final GraphicBuffer mSnapshot;
        /** Indicates whether task was in landscape or portrait */
        @Configuration.Orientation
        private final int mOrientation;
        private final int mOrientation;
        /** See {@link android.view.Surface.Rotation} */
        @Surface.Rotation
        private int mRotation;
        private final Rect mContentInsets;
        private final Rect mContentInsets;
        // Whether this snapshot is a down-sampled version of the full resolution, used mainly for
        // Whether this snapshot is a down-sampled version of the full resolution, used mainly for
        // low-ram devices
        // low-ram devices
@@ -1945,7 +1951,7 @@ public class ActivityManager {


        public TaskSnapshot(long id,
        public TaskSnapshot(long id,
                @NonNull ComponentName topActivityComponent, GraphicBuffer snapshot,
                @NonNull ComponentName topActivityComponent, GraphicBuffer snapshot,
                @NonNull ColorSpace colorSpace, int orientation, Rect contentInsets,
                @NonNull ColorSpace colorSpace, int orientation, int rotation, Rect contentInsets,
                boolean reducedResolution, float scale, boolean isRealSnapshot, int windowingMode,
                boolean reducedResolution, float scale, boolean isRealSnapshot, int windowingMode,
                int systemUiVisibility, boolean isTranslucent) {
                int systemUiVisibility, boolean isTranslucent) {
            mId = id;
            mId = id;
@@ -1954,6 +1960,7 @@ public class ActivityManager {
            mColorSpace = colorSpace.getId() < 0
            mColorSpace = colorSpace.getId() < 0
                    ? ColorSpace.get(ColorSpace.Named.SRGB) : colorSpace;
                    ? ColorSpace.get(ColorSpace.Named.SRGB) : colorSpace;
            mOrientation = orientation;
            mOrientation = orientation;
            mRotation = rotation;
            mContentInsets = new Rect(contentInsets);
            mContentInsets = new Rect(contentInsets);
            mReducedResolution = reducedResolution;
            mReducedResolution = reducedResolution;
            mScale = scale;
            mScale = scale;
@@ -1972,6 +1979,7 @@ public class ActivityManager {
                    ? ColorSpace.get(ColorSpace.Named.values()[colorSpaceId])
                    ? ColorSpace.get(ColorSpace.Named.values()[colorSpaceId])
                    : ColorSpace.get(ColorSpace.Named.SRGB);
                    : ColorSpace.get(ColorSpace.Named.SRGB);
            mOrientation = source.readInt();
            mOrientation = source.readInt();
            mRotation = source.readInt();
            mContentInsets = source.readParcelable(null /* classLoader */);
            mContentInsets = source.readParcelable(null /* classLoader */);
            mReducedResolution = source.readBoolean();
            mReducedResolution = source.readBoolean();
            mScale = source.readFloat();
            mScale = source.readFloat();
@@ -2018,6 +2026,13 @@ public class ActivityManager {
            return mOrientation;
            return mOrientation;
        }
        }


        /**
         * @return The screen rotation the screenshot was taken in.
         */
        public int getRotation() {
            return mRotation;
        }

        /**
        /**
         * @return The system/content insets on the snapshot. These can be clipped off in order to
         * @return The system/content insets on the snapshot. These can be clipped off in order to
         *         remove any areas behind system bars in the snapshot.
         *         remove any areas behind system bars in the snapshot.
@@ -2087,6 +2102,7 @@ public class ActivityManager {
            dest.writeParcelable(mSnapshot, 0);
            dest.writeParcelable(mSnapshot, 0);
            dest.writeInt(mColorSpace.getId());
            dest.writeInt(mColorSpace.getId());
            dest.writeInt(mOrientation);
            dest.writeInt(mOrientation);
            dest.writeInt(mRotation);
            dest.writeParcelable(mContentInsets, 0);
            dest.writeParcelable(mContentInsets, 0);
            dest.writeBoolean(mReducedResolution);
            dest.writeBoolean(mReducedResolution);
            dest.writeFloat(mScale);
            dest.writeFloat(mScale);
@@ -2106,6 +2122,7 @@ public class ActivityManager {
                    + " mSnapshot=" + mSnapshot + " (" + width + "x" + height + ")"
                    + " mSnapshot=" + mSnapshot + " (" + width + "x" + height + ")"
                    + " mColorSpace=" + mColorSpace.toString()
                    + " mColorSpace=" + mColorSpace.toString()
                    + " mOrientation=" + mOrientation
                    + " mOrientation=" + mOrientation
                    + " mRotation=" + mRotation
                    + " mContentInsets=" + mContentInsets.toShortString()
                    + " mContentInsets=" + mContentInsets.toShortString()
                    + " mReducedResolution=" + mReducedResolution + " mScale=" + mScale
                    + " mReducedResolution=" + mReducedResolution + " mScale=" + mScale
                    + " mIsRealSnapshot=" + mIsRealSnapshot + " mWindowingMode=" + mWindowingMode
                    + " mIsRealSnapshot=" + mIsRealSnapshot + " mWindowingMode=" + mWindowingMode
@@ -2129,6 +2146,7 @@ public class ActivityManager {
            private GraphicBuffer mSnapshot;
            private GraphicBuffer mSnapshot;
            private ColorSpace mColorSpace;
            private ColorSpace mColorSpace;
            private int mOrientation;
            private int mOrientation;
            private int mRotation;
            private Rect mContentInsets;
            private Rect mContentInsets;
            private boolean mReducedResolution;
            private boolean mReducedResolution;
            private float mScaleFraction;
            private float mScaleFraction;
@@ -2163,6 +2181,11 @@ public class ActivityManager {
                return this;
                return this;
            }
            }


            public Builder setRotation(int rotation) {
                mRotation = rotation;
                return this;
            }

            public Builder setContentInsets(Rect contentInsets) {
            public Builder setContentInsets(Rect contentInsets) {
                mContentInsets = contentInsets;
                mContentInsets = contentInsets;
                return this;
                return this;
@@ -2218,6 +2241,7 @@ public class ActivityManager {
                        mSnapshot,
                        mSnapshot,
                        mColorSpace,
                        mColorSpace,
                        mOrientation,
                        mOrientation,
                        mRotation,
                        mContentInsets,
                        mContentInsets,
                        mReducedResolution,
                        mReducedResolution,
                        mScaleFraction,
                        mScaleFraction,
+4 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.systemui.shared.recents.model;
package com.android.systemui.shared.recents.model;


import static android.app.WindowConfiguration.ROTATION_UNDEFINED;
import static android.content.res.Configuration.ORIENTATION_UNDEFINED;
import static android.content.res.Configuration.ORIENTATION_UNDEFINED;


import static com.android.systemui.shared.system.WindowManagerWrapper.WINDOWING_MODE_UNDEFINED;
import static com.android.systemui.shared.system.WindowManagerWrapper.WINDOWING_MODE_UNDEFINED;
@@ -31,6 +32,7 @@ public class ThumbnailData {


    public final Bitmap thumbnail;
    public final Bitmap thumbnail;
    public int orientation;
    public int orientation;
    public int rotation;
    public Rect insets;
    public Rect insets;
    public boolean reducedResolution;
    public boolean reducedResolution;
    public boolean isRealSnapshot;
    public boolean isRealSnapshot;
@@ -43,6 +45,7 @@ public class ThumbnailData {
    public ThumbnailData() {
    public ThumbnailData() {
        thumbnail = null;
        thumbnail = null;
        orientation = ORIENTATION_UNDEFINED;
        orientation = ORIENTATION_UNDEFINED;
        rotation = ROTATION_UNDEFINED;
        insets = new Rect();
        insets = new Rect();
        reducedResolution = false;
        reducedResolution = false;
        scale = 1f;
        scale = 1f;
@@ -57,6 +60,7 @@ public class ThumbnailData {
        thumbnail = Bitmap.wrapHardwareBuffer(snapshot.getSnapshot(), snapshot.getColorSpace());
        thumbnail = Bitmap.wrapHardwareBuffer(snapshot.getSnapshot(), snapshot.getColorSpace());
        insets = new Rect(snapshot.getContentInsets());
        insets = new Rect(snapshot.getContentInsets());
        orientation = snapshot.getOrientation();
        orientation = snapshot.getOrientation();
        rotation = snapshot.getRotation();
        reducedResolution = snapshot.isReducedResolution();
        reducedResolution = snapshot.isReducedResolution();
        scale = snapshot.getScale();
        scale = snapshot.getScale();
        isRealSnapshot = snapshot.isRealSnapshot();
        isRealSnapshot = snapshot.isRealSnapshot();
+1 −0
Original line number Original line Diff line number Diff line
@@ -34,4 +34,5 @@
     string top_activity_component = 10;
     string top_activity_component = 10;
     float scale = 11;
     float scale = 11;
     int64 id = 12;
     int64 id = 12;
     int32 rotation = 13;
 }
 }
+3 −1
Original line number Original line Diff line number Diff line
@@ -343,6 +343,7 @@ class TaskSnapshotController {
        builder.setPixelFormat(pixelFormat);
        builder.setPixelFormat(pixelFormat);
        builder.setIsTranslucent(isTranslucent);
        builder.setIsTranslucent(isTranslucent);
        builder.setOrientation(activity.getTask().getConfiguration().orientation);
        builder.setOrientation(activity.getTask().getConfiguration().orientation);
        builder.setRotation(activity.getTask().getDisplayContent().getRotation());
        builder.setWindowingMode(task.getWindowingMode());
        builder.setWindowingMode(task.getWindowingMode());
        builder.setSystemUiVisibility(getSystemUiVisibility(task));
        builder.setSystemUiVisibility(getSystemUiVisibility(task));
        return true;
        return true;
@@ -492,7 +493,8 @@ class TaskSnapshotController {
        return new TaskSnapshot(
        return new TaskSnapshot(
                System.currentTimeMillis() /* id */,
                System.currentTimeMillis() /* id */,
                topChild.mActivityComponent, hwBitmap.createGraphicBufferHandle(),
                topChild.mActivityComponent, hwBitmap.createGraphicBufferHandle(),
                hwBitmap.getColorSpace(), topChild.getTask().getConfiguration().orientation,
                hwBitmap.getColorSpace(), mainWindow.getConfiguration().orientation,
                mainWindow.getWindowConfiguration().getRotation(),
                getInsets(mainWindow), ActivityManager.isLowRamDeviceStatic() /* reduced */,
                getInsets(mainWindow), ActivityManager.isLowRamDeviceStatic() /* reduced */,
                mFullSnapshotScale, false /* isRealSnapshot */, task.getWindowingMode(),
                mFullSnapshotScale, false /* isRealSnapshot */, task.getWindowingMode(),
                getSystemUiVisibility(task), false);
                getSystemUiVisibility(task), false);
+2 −2
Original line number Original line Diff line number Diff line
@@ -102,8 +102,8 @@ class TaskSnapshotLoader {
            // For legacy snapshots, restore the scale based on the reduced resolution state
            // For legacy snapshots, restore the scale based on the reduced resolution state
            final float legacyScale = reducedResolution ? mPersister.getReducedScale() : 1f;
            final float legacyScale = reducedResolution ? mPersister.getReducedScale() : 1f;
            final float scale = Float.compare(proto.scale, 0f) != 0 ? proto.scale : legacyScale;
            final float scale = Float.compare(proto.scale, 0f) != 0 ? proto.scale : legacyScale;
            return new TaskSnapshot(proto.id, topActivityComponent, buffer,
            return new TaskSnapshot(proto.id, topActivityComponent, buffer, hwBitmap.getColorSpace(),
                    hwBitmap.getColorSpace(), proto.orientation,
                    proto.orientation, proto.rotation,
                    new Rect(proto.insetLeft, proto.insetTop, proto.insetRight, proto.insetBottom),
                    new Rect(proto.insetLeft, proto.insetTop, proto.insetRight, proto.insetBottom),
                    reducedResolution, scale, proto.isRealSnapshot, proto.windowingMode,
                    reducedResolution, scale, proto.isRealSnapshot, proto.windowingMode,
                    proto.systemUiVisibility, proto.isTranslucent);
                    proto.systemUiVisibility, proto.isTranslucent);
Loading