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

Commit ffd9dff1 authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Add rotation field to ThumbnailData for task snapshots

Add the rotation a task was in when its snapshot
is taken. This is used by launcher to know which
way to orient the bitmap when performing quickswitch

fixes: 143892437
Test: Test: With launcher in portrait
* Thumbnail in reverse portrait,
landscape, seascape, normal
With launcher in landscape
* Thumbnail in seascape, normal,
reverse portrait, landscape
With launcher in seascape
* Thumbnail in seascape, normal,
reverse portrait, landscape

Change-Id: Iaf32341d0db1fc023c29676e0d365eee03b98959
parent c8e17b66
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import android.util.DisplayMetrics;
import android.util.Singleton;
import android.util.Size;
import android.view.IWindowContainer;
import android.view.Surface;

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

        public TaskSnapshot(long id,
                @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,
                int systemUiVisibility, boolean isTranslucent) {
            mId = id;
@@ -1954,6 +1960,7 @@ public class ActivityManager {
            mColorSpace = colorSpace.getId() < 0
                    ? ColorSpace.get(ColorSpace.Named.SRGB) : colorSpace;
            mOrientation = orientation;
            mRotation = rotation;
            mContentInsets = new Rect(contentInsets);
            mReducedResolution = reducedResolution;
            mScale = scale;
@@ -1972,6 +1979,7 @@ public class ActivityManager {
                    ? ColorSpace.get(ColorSpace.Named.values()[colorSpaceId])
                    : ColorSpace.get(ColorSpace.Named.SRGB);
            mOrientation = source.readInt();
            mRotation = source.readInt();
            mContentInsets = source.readParcelable(null /* classLoader */);
            mReducedResolution = source.readBoolean();
            mScale = source.readFloat();
@@ -2018,6 +2026,13 @@ public class ActivityManager {
            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
         *         remove any areas behind system bars in the snapshot.
@@ -2087,6 +2102,7 @@ public class ActivityManager {
            dest.writeParcelable(mSnapshot, 0);
            dest.writeInt(mColorSpace.getId());
            dest.writeInt(mOrientation);
            dest.writeInt(mRotation);
            dest.writeParcelable(mContentInsets, 0);
            dest.writeBoolean(mReducedResolution);
            dest.writeFloat(mScale);
@@ -2106,6 +2122,7 @@ public class ActivityManager {
                    + " mSnapshot=" + mSnapshot + " (" + width + "x" + height + ")"
                    + " mColorSpace=" + mColorSpace.toString()
                    + " mOrientation=" + mOrientation
                    + " mRotation=" + mRotation
                    + " mContentInsets=" + mContentInsets.toShortString()
                    + " mReducedResolution=" + mReducedResolution + " mScale=" + mScale
                    + " mIsRealSnapshot=" + mIsRealSnapshot + " mWindowingMode=" + mWindowingMode
@@ -2129,6 +2146,7 @@ public class ActivityManager {
            private GraphicBuffer mSnapshot;
            private ColorSpace mColorSpace;
            private int mOrientation;
            private int mRotation;
            private Rect mContentInsets;
            private boolean mReducedResolution;
            private float mScaleFraction;
@@ -2163,6 +2181,11 @@ public class ActivityManager {
                return this;
            }

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

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

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

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

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

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