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

Commit 4aee38fd authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Expose whether a snapshot is a real snapshot" into pi-dev

parents 6964e754 f3e412e5
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -2101,15 +2101,17 @@ public class ActivityManager {
        private final int mOrientation;
        private final Rect mContentInsets;
        private final boolean mReducedResolution;
        private final boolean mIsRealSnapshot;
        private final float mScale;

        public TaskSnapshot(GraphicBuffer snapshot, int orientation, Rect contentInsets,
                boolean reducedResolution, float scale) {
                boolean reducedResolution, float scale, boolean isRealSnapshot) {
            mSnapshot = snapshot;
            mOrientation = orientation;
            mContentInsets = new Rect(contentInsets);
            mReducedResolution = reducedResolution;
            mScale = scale;
            mIsRealSnapshot = isRealSnapshot;
        }

        private TaskSnapshot(Parcel source) {
@@ -2118,6 +2120,7 @@ public class ActivityManager {
            mContentInsets = source.readParcelable(null /* classLoader */);
            mReducedResolution = source.readBoolean();
            mScale = source.readFloat();
            mIsRealSnapshot = source.readBoolean();
        }

        /**
@@ -2149,6 +2152,14 @@ public class ActivityManager {
            return mReducedResolution;
        }

        /**
         * @return Whether or not the snapshot is a real snapshot or an app-theme generated snapshot
         * due to the task having a secure window or having previews disabled.
         */
        public boolean isRealSnapshot() {
            return mIsRealSnapshot;
        }

        /**
         * @return The scale this snapshot was taken in.
         */
@@ -2168,13 +2179,15 @@ public class ActivityManager {
            dest.writeParcelable(mContentInsets, 0);
            dest.writeBoolean(mReducedResolution);
            dest.writeFloat(mScale);
            dest.writeBoolean(mIsRealSnapshot);
        }

        @Override
        public String toString() {
            return "TaskSnapshot{mSnapshot=" + mSnapshot + " mOrientation=" + mOrientation
                    + " mContentInsets=" + mContentInsets.toShortString()
                    + " mReducedResolution=" + mReducedResolution + " mScale=" + mScale;
                    + " mReducedResolution=" + mReducedResolution + " mScale=" + mScale
                    + " mIsRealSnapshot=" + mIsRealSnapshot;
        }

        public static final Creator<TaskSnapshot> CREATOR = new Creator<TaskSnapshot>() {
+3 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ public class ThumbnailData {
    public int orientation;
    public Rect insets;
    public boolean reducedResolution;
    public boolean isRealSnapshot;
    public float scale;

    public ThumbnailData() {
@@ -39,6 +40,7 @@ public class ThumbnailData {
        insets = new Rect();
        reducedResolution = false;
        scale = 1f;
        isRealSnapshot = true;
    }

    public ThumbnailData(TaskSnapshot snapshot) {
@@ -47,5 +49,6 @@ public class ThumbnailData {
        orientation = snapshot.getOrientation();
        reducedResolution = snapshot.isReducedResolution();
        scale = snapshot.getScale();
        isRealSnapshot = snapshot.isRealSnapshot();
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -27,4 +27,5 @@
     int32 inset_top = 3;
     int32 inset_right = 4;
     int32 inset_bottom = 5;
     bool is_real_snapshot = 6;
 }
 No newline at end of file
+4 −2
Original line number Diff line number Diff line
@@ -273,7 +273,8 @@ class TaskSnapshotController {
        }
        return new TaskSnapshot(buffer, top.getConfiguration().orientation,
                getInsetsFromTaskBounds(mainWindow, task),
                isLowRamDevice /* reduced */, scaleFraction /* scale */);
                isLowRamDevice /* reduced */, scaleFraction /* scale */,
                true /* isRealSnapshot */);
    }

    private boolean shouldDisableSnapshots() {
@@ -369,7 +370,8 @@ class TaskSnapshotController {
        }
        return new TaskSnapshot(hwBitmap.createGraphicBufferHandle(),
                topChild.getConfiguration().orientation, mainWindow.mStableInsets,
                ActivityManager.isLowRamDeviceStatic() /* reduced */, 1.0f /* scale */);
                ActivityManager.isLowRamDeviceStatic() /* reduced */, 1.0f /* scale */,
                false /* isRealSnapshot */);
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -89,7 +89,8 @@ class TaskSnapshotLoader {
            }
            return new TaskSnapshot(buffer, proto.orientation,
                    new Rect(proto.insetLeft, proto.insetTop, proto.insetRight, proto.insetBottom),
                    reducedResolution, reducedResolution ? REDUCED_SCALE : 1f);
                    reducedResolution, reducedResolution ? REDUCED_SCALE : 1f,
                    proto.isRealSnapshot);
        } catch (IOException e) {
            Slog.w(TAG, "Unable to load task snapshot data for taskId=" + taskId);
            return null;
Loading