Loading core/java/android/window/TaskSnapshot.java +30 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.window; import android.annotation.IntDef; import android.annotation.IntRange; import android.annotation.NonNull; import android.compat.annotation.UnsupportedAppUsage; import android.content.ComponentName; Loading @@ -30,6 +31,7 @@ import android.os.Build; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; import android.util.DisplayMetrics; import android.view.Surface; import android.view.WindowInsetsController; Loading Loading @@ -74,6 +76,7 @@ public class TaskSnapshot implements Parcelable { private final boolean mIsTranslucent; private final boolean mHasImeSurface; private final int mUiMode; private final int mDensityDpi; // Must be one of the named color spaces, otherwise, always use SRGB color space. private final ColorSpace mColorSpace; private int mInternalReferences; Loading Loading @@ -110,7 +113,7 @@ public class TaskSnapshot implements Parcelable { Rect contentInsets, Rect letterboxInsets, boolean isLowResolution, boolean isRealSnapshot, int windowingMode, @WindowInsetsController.Appearance int appearance, boolean isTranslucent, boolean hasImeSurface, int uiMode) { boolean hasImeSurface, int uiMode, @IntRange(from = 1) int densityDpi) { mId = id; mCaptureTime = captureTime; mTopActivityComponent = topActivityComponent; Loading @@ -129,6 +132,7 @@ public class TaskSnapshot implements Parcelable { mIsTranslucent = isTranslucent; mHasImeSurface = hasImeSurface; mUiMode = uiMode; mDensityDpi = densityDpi; } private TaskSnapshot(Parcel source) { Loading @@ -152,6 +156,8 @@ public class TaskSnapshot implements Parcelable { mIsTranslucent = source.readBoolean(); mHasImeSurface = source.readBoolean(); mUiMode = source.readInt(); int densityDpi = source.readInt(); mDensityDpi = densityDpi > 0 ? densityDpi : DisplayMetrics.DENSITY_DEVICE_STABLE; } /** Loading Loading @@ -296,6 +302,13 @@ public class TaskSnapshot implements Parcelable { return mUiMode; } /** * @return The pixel density the screenshot was taken in. */ public int getDensityDpi() { return mDensityDpi; } @Override public int describeContents() { return 0; Loading @@ -319,6 +332,7 @@ public class TaskSnapshot implements Parcelable { dest.writeBoolean(mIsTranslucent); dest.writeBoolean(mHasImeSurface); dest.writeInt(mUiMode); dest.writeInt(mDensityDpi); synchronized (this) { if ((mInternalReferences & REFERENCE_WRITE_TO_PARCEL) != 0) { mWriteToParcelCount--; Loading Loading @@ -359,7 +373,8 @@ public class TaskSnapshot implements Parcelable { + " mHasImeSurface=" + mHasImeSurface + " mInternalReferences=" + mInternalReferences + " mWriteToParcelCount=" + mWriteToParcelCount + " mUiMode=" + Integer.toHexString(mUiMode); + " mUiMode=" + Integer.toHexString(mUiMode) + " mDensityDpi=" + mDensityDpi; } /** Loading Loading @@ -431,6 +446,7 @@ public class TaskSnapshot implements Parcelable { private boolean mHasImeSurface; private int mPixelFormat; private int mUiMode; private int mDensityDpi = DisplayMetrics.DENSITY_DEVICE_STABLE; public Builder setId(long id) { mId = id; Loading Loading @@ -514,13 +530,22 @@ public class TaskSnapshot implements Parcelable { } /** * Sets the original uiMode while capture * Sets the original uiMode while capturing */ public Builder setUiMode(int uiMode) { mUiMode = uiMode; return this; } /** * Sets the original density while capturing. Throws IllegalArgumentException if * densityDpi is outside the range (0,100000) (exclusive). */ public Builder setDensityDpi(@IntRange(from = 1) int densityDpi) { mDensityDpi = densityDpi; return this; } public int getPixelFormat() { return mPixelFormat; } Loading Loading @@ -551,7 +576,8 @@ public class TaskSnapshot implements Parcelable { mAppearance, mIsTranslucent, mHasImeSurface, mUiMode); mUiMode, mDensityDpi); } } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java +1 −1 Original line number Diff line number Diff line Loading @@ -357,6 +357,6 @@ public class StartingSurfaceDrawerTests extends ShellTestCase { Surface.ROTATION_0, taskSize, contentInsets, new Rect() /* letterboxInsets */, false, true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN, 0 /* systemUiVisibility */, false /* isTranslucent */, hasImeSurface /* hasImeSurface */, 0 /* uiMode */); hasImeSurface /* hasImeSurface */, 0 /* uiMode */, 300 /* densityDpi */); } } packages/SystemUI/multivalentTests/src/com/android/systemui/mediaprojection/appselector/data/ActivityTaskManagerThumbnailLoaderTest.kt +3 −2 Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ class ActivityTaskManagerThumbnailLoaderTest : SysuiTestCase() { /* height= */ 100, HardwareBuffer.RGBA_8888, /* layers= */ 1, /* usage= */ HardwareBuffer.USAGE_CPU_READ_OFTEN /* usage= */ HardwareBuffer.USAGE_CPU_READ_OFTEN, ), ColorSpace.get(ColorSpace.Named.SRGB), Configuration.ORIENTATION_PORTRAIT, Loading @@ -103,6 +103,7 @@ class ActivityTaskManagerThumbnailLoaderTest : SysuiTestCase() { /* appearance= */ 0, /* isTranslucent= */ false, /* hasImeSurface= */ false, /* uiMode */ 0 /* uiMode */ 0, /* densityDpi */ 300, ) } packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.kt +13 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,8 @@ data class ThumbnailData( } companion object { private const val TAG = "ThumbnailData" private fun makeThumbnail(snapshot: TaskSnapshot): Bitmap { var thumbnail: Bitmap? = null try { Loading @@ -55,13 +57,22 @@ data class ThumbnailData( // TODO(b/157562905): Workaround for a crash when we get a snapshot without this // state Log.e( "ThumbnailData", TAG, "Unexpected snapshot without USAGE_GPU_SAMPLED_IMAGE: " + "${snapshot.hardwareBuffer}", ex, ) } if (snapshot.densityDpi > 0 && thumbnail?.density != snapshot.densityDpi) { Log.d( TAG, "Updating thumbnail.density from " + thumbnail?.density + " to " + snapshot.densityDpi, ) thumbnail?.density = snapshot.densityDpi } return thumbnail ?: Bitmap.createBitmap(snapshot.taskSize.x, snapshot.taskSize.y, ARGB_8888).apply { eraseColor(Color.BLACK) Loading proto/src/windowmanager.proto +1 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ message TaskSnapshotProto { int32 letterbox_inset_right = 19; int32 letterbox_inset_bottom = 20; int32 ui_mode = 21; int32 density_dpi = 22; } // Persistent letterboxing configurations Loading Loading
core/java/android/window/TaskSnapshot.java +30 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.window; import android.annotation.IntDef; import android.annotation.IntRange; import android.annotation.NonNull; import android.compat.annotation.UnsupportedAppUsage; import android.content.ComponentName; Loading @@ -30,6 +31,7 @@ import android.os.Build; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; import android.util.DisplayMetrics; import android.view.Surface; import android.view.WindowInsetsController; Loading Loading @@ -74,6 +76,7 @@ public class TaskSnapshot implements Parcelable { private final boolean mIsTranslucent; private final boolean mHasImeSurface; private final int mUiMode; private final int mDensityDpi; // Must be one of the named color spaces, otherwise, always use SRGB color space. private final ColorSpace mColorSpace; private int mInternalReferences; Loading Loading @@ -110,7 +113,7 @@ public class TaskSnapshot implements Parcelable { Rect contentInsets, Rect letterboxInsets, boolean isLowResolution, boolean isRealSnapshot, int windowingMode, @WindowInsetsController.Appearance int appearance, boolean isTranslucent, boolean hasImeSurface, int uiMode) { boolean hasImeSurface, int uiMode, @IntRange(from = 1) int densityDpi) { mId = id; mCaptureTime = captureTime; mTopActivityComponent = topActivityComponent; Loading @@ -129,6 +132,7 @@ public class TaskSnapshot implements Parcelable { mIsTranslucent = isTranslucent; mHasImeSurface = hasImeSurface; mUiMode = uiMode; mDensityDpi = densityDpi; } private TaskSnapshot(Parcel source) { Loading @@ -152,6 +156,8 @@ public class TaskSnapshot implements Parcelable { mIsTranslucent = source.readBoolean(); mHasImeSurface = source.readBoolean(); mUiMode = source.readInt(); int densityDpi = source.readInt(); mDensityDpi = densityDpi > 0 ? densityDpi : DisplayMetrics.DENSITY_DEVICE_STABLE; } /** Loading Loading @@ -296,6 +302,13 @@ public class TaskSnapshot implements Parcelable { return mUiMode; } /** * @return The pixel density the screenshot was taken in. */ public int getDensityDpi() { return mDensityDpi; } @Override public int describeContents() { return 0; Loading @@ -319,6 +332,7 @@ public class TaskSnapshot implements Parcelable { dest.writeBoolean(mIsTranslucent); dest.writeBoolean(mHasImeSurface); dest.writeInt(mUiMode); dest.writeInt(mDensityDpi); synchronized (this) { if ((mInternalReferences & REFERENCE_WRITE_TO_PARCEL) != 0) { mWriteToParcelCount--; Loading Loading @@ -359,7 +373,8 @@ public class TaskSnapshot implements Parcelable { + " mHasImeSurface=" + mHasImeSurface + " mInternalReferences=" + mInternalReferences + " mWriteToParcelCount=" + mWriteToParcelCount + " mUiMode=" + Integer.toHexString(mUiMode); + " mUiMode=" + Integer.toHexString(mUiMode) + " mDensityDpi=" + mDensityDpi; } /** Loading Loading @@ -431,6 +446,7 @@ public class TaskSnapshot implements Parcelable { private boolean mHasImeSurface; private int mPixelFormat; private int mUiMode; private int mDensityDpi = DisplayMetrics.DENSITY_DEVICE_STABLE; public Builder setId(long id) { mId = id; Loading Loading @@ -514,13 +530,22 @@ public class TaskSnapshot implements Parcelable { } /** * Sets the original uiMode while capture * Sets the original uiMode while capturing */ public Builder setUiMode(int uiMode) { mUiMode = uiMode; return this; } /** * Sets the original density while capturing. Throws IllegalArgumentException if * densityDpi is outside the range (0,100000) (exclusive). */ public Builder setDensityDpi(@IntRange(from = 1) int densityDpi) { mDensityDpi = densityDpi; return this; } public int getPixelFormat() { return mPixelFormat; } Loading Loading @@ -551,7 +576,8 @@ public class TaskSnapshot implements Parcelable { mAppearance, mIsTranslucent, mHasImeSurface, mUiMode); mUiMode, mDensityDpi); } } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java +1 −1 Original line number Diff line number Diff line Loading @@ -357,6 +357,6 @@ public class StartingSurfaceDrawerTests extends ShellTestCase { Surface.ROTATION_0, taskSize, contentInsets, new Rect() /* letterboxInsets */, false, true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN, 0 /* systemUiVisibility */, false /* isTranslucent */, hasImeSurface /* hasImeSurface */, 0 /* uiMode */); hasImeSurface /* hasImeSurface */, 0 /* uiMode */, 300 /* densityDpi */); } }
packages/SystemUI/multivalentTests/src/com/android/systemui/mediaprojection/appselector/data/ActivityTaskManagerThumbnailLoaderTest.kt +3 −2 Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ class ActivityTaskManagerThumbnailLoaderTest : SysuiTestCase() { /* height= */ 100, HardwareBuffer.RGBA_8888, /* layers= */ 1, /* usage= */ HardwareBuffer.USAGE_CPU_READ_OFTEN /* usage= */ HardwareBuffer.USAGE_CPU_READ_OFTEN, ), ColorSpace.get(ColorSpace.Named.SRGB), Configuration.ORIENTATION_PORTRAIT, Loading @@ -103,6 +103,7 @@ class ActivityTaskManagerThumbnailLoaderTest : SysuiTestCase() { /* appearance= */ 0, /* isTranslucent= */ false, /* hasImeSurface= */ false, /* uiMode */ 0 /* uiMode */ 0, /* densityDpi */ 300, ) }
packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.kt +13 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,8 @@ data class ThumbnailData( } companion object { private const val TAG = "ThumbnailData" private fun makeThumbnail(snapshot: TaskSnapshot): Bitmap { var thumbnail: Bitmap? = null try { Loading @@ -55,13 +57,22 @@ data class ThumbnailData( // TODO(b/157562905): Workaround for a crash when we get a snapshot without this // state Log.e( "ThumbnailData", TAG, "Unexpected snapshot without USAGE_GPU_SAMPLED_IMAGE: " + "${snapshot.hardwareBuffer}", ex, ) } if (snapshot.densityDpi > 0 && thumbnail?.density != snapshot.densityDpi) { Log.d( TAG, "Updating thumbnail.density from " + thumbnail?.density + " to " + snapshot.densityDpi, ) thumbnail?.density = snapshot.densityDpi } return thumbnail ?: Bitmap.createBitmap(snapshot.taskSize.x, snapshot.taskSize.y, ARGB_8888).apply { eraseColor(Color.BLACK) Loading
proto/src/windowmanager.proto +1 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ message TaskSnapshotProto { int32 letterbox_inset_right = 19; int32 letterbox_inset_bottom = 20; int32 ui_mode = 21; int32 density_dpi = 22; } // Persistent letterboxing configurations Loading