summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/window/TaskSnapshot.java27
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java4
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/TaskSnapshotWindowTest.java4
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.java3
-rw-r--r--proto/src/task_snapshot.proto4
-rw-r--r--services/core/java/com/android/server/wm/TaskSnapshotController.java13
-rw-r--r--services/core/java/com/android/server/wm/TaskSnapshotLoader.java4
-rw-r--r--services/core/java/com/android/server/wm/TaskSnapshotPersister.java6
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java3
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskSnapshotControllerTest.java5
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java5
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java2
12 files changed, 61 insertions, 19 deletions
diff --git a/core/java/android/window/TaskSnapshot.java b/core/java/android/window/TaskSnapshot.java
index f1e5fb95ea54..b7bb6082296e 100644
--- a/core/java/android/window/TaskSnapshot.java
+++ b/core/java/android/window/TaskSnapshot.java
@@ -50,6 +50,7 @@ public class TaskSnapshot implements Parcelable {
/** The size of the snapshot before scaling */
private final Point mTaskSize;
private final Rect mContentInsets;
+ private final Rect mLetterboxInsets;
// Whether this snapshot is a down-sampled version of the high resolution snapshot, used
// mainly for loading snapshots quickly from disk when user is flinging fast
private final boolean mIsLowResolution;
@@ -67,9 +68,10 @@ public class TaskSnapshot implements Parcelable {
public TaskSnapshot(long id,
@NonNull ComponentName topActivityComponent, HardwareBuffer snapshot,
@NonNull ColorSpace colorSpace, int orientation, int rotation, Point taskSize,
- Rect contentInsets, boolean isLowResolution, boolean isRealSnapshot,
- int windowingMode, @WindowInsetsController.Appearance int appearance,
- boolean isTranslucent, boolean hasImeSurface) {
+ Rect contentInsets, Rect letterboxInsets, boolean isLowResolution,
+ boolean isRealSnapshot, int windowingMode,
+ @WindowInsetsController.Appearance int appearance, boolean isTranslucent,
+ boolean hasImeSurface) {
mId = id;
mTopActivityComponent = topActivityComponent;
mSnapshot = snapshot;
@@ -79,6 +81,7 @@ public class TaskSnapshot implements Parcelable {
mRotation = rotation;
mTaskSize = new Point(taskSize);
mContentInsets = new Rect(contentInsets);
+ mLetterboxInsets = new Rect(letterboxInsets);
mIsLowResolution = isLowResolution;
mIsRealSnapshot = isRealSnapshot;
mWindowingMode = windowingMode;
@@ -99,6 +102,7 @@ public class TaskSnapshot implements Parcelable {
mRotation = source.readInt();
mTaskSize = source.readTypedObject(Point.CREATOR);
mContentInsets = source.readTypedObject(Rect.CREATOR);
+ mLetterboxInsets = source.readTypedObject(Rect.CREATOR);
mIsLowResolution = source.readBoolean();
mIsRealSnapshot = source.readBoolean();
mWindowingMode = source.readInt();
@@ -179,6 +183,14 @@ public class TaskSnapshot implements Parcelable {
}
/**
+ * @return The letterbox insets on the snapshot. These can be clipped off in order to
+ * remove any letterbox areas in the snapshot.
+ */
+ public Rect getLetterboxInsets() {
+ return mLetterboxInsets;
+ }
+
+ /**
* @return Whether this snapshot is a down-sampled version of the full resolution.
*/
@UnsupportedAppUsage
@@ -241,6 +253,7 @@ public class TaskSnapshot implements Parcelable {
dest.writeInt(mRotation);
dest.writeTypedObject(mTaskSize, 0);
dest.writeTypedObject(mContentInsets, 0);
+ dest.writeTypedObject(mLetterboxInsets, 0);
dest.writeBoolean(mIsLowResolution);
dest.writeBoolean(mIsRealSnapshot);
dest.writeInt(mWindowingMode);
@@ -262,6 +275,7 @@ public class TaskSnapshot implements Parcelable {
+ " mRotation=" + mRotation
+ " mTaskSize=" + mTaskSize.toString()
+ " mContentInsets=" + mContentInsets.toShortString()
+ + " mLetterboxInsets=" + mLetterboxInsets.toShortString()
+ " mIsLowResolution=" + mIsLowResolution
+ " mIsRealSnapshot=" + mIsRealSnapshot
+ " mWindowingMode=" + mWindowingMode
@@ -289,6 +303,7 @@ public class TaskSnapshot implements Parcelable {
private int mRotation;
private Point mTaskSize;
private Rect mContentInsets;
+ private Rect mLetterboxInsets;
private boolean mIsRealSnapshot;
private int mWindowingMode;
private @WindowInsetsController.Appearance
@@ -340,6 +355,11 @@ public class TaskSnapshot implements Parcelable {
return this;
}
+ public Builder setLetterboxInsets(Rect letterboxInsets) {
+ mLetterboxInsets = letterboxInsets;
+ return this;
+ }
+
public Builder setIsRealSnapshot(boolean realSnapshot) {
mIsRealSnapshot = realSnapshot;
return this;
@@ -387,6 +407,7 @@ public class TaskSnapshot implements Parcelable {
mRotation,
mTaskSize,
mContentInsets,
+ mLetterboxInsets,
// When building a TaskSnapshot with the Builder class, isLowResolution
// is always false. Low-res snapshots are only created when loading from
// disk.
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java
index b866bf9d4192..70b7c6793492 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java
@@ -301,8 +301,8 @@ public class StartingSurfaceDrawerTests {
System.currentTimeMillis(),
new ComponentName("", ""), buffer,
ColorSpace.get(ColorSpace.Named.SRGB), ORIENTATION_PORTRAIT,
- Surface.ROTATION_0, taskSize, contentInsets, false,
- true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN,
+ Surface.ROTATION_0, taskSize, contentInsets, new Rect() /* letterboxInsets */,
+ false, true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN,
0 /* systemUiVisibility */, false /* isTranslucent */,
hasImeSurface /* hasImeSurface */);
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/TaskSnapshotWindowTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/TaskSnapshotWindowTest.java
index aad9528bd527..78e27c956807 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/TaskSnapshotWindowTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/TaskSnapshotWindowTest.java
@@ -94,8 +94,8 @@ public class TaskSnapshotWindowTest {
System.currentTimeMillis(),
new ComponentName("", ""), buffer,
ColorSpace.get(ColorSpace.Named.SRGB), ORIENTATION_PORTRAIT,
- Surface.ROTATION_0, taskSize, contentInsets, false,
- true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN,
+ Surface.ROTATION_0, taskSize, contentInsets, new Rect() /* letterboxInsets */,
+ false, true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN,
0 /* systemUiVisibility */, false /* isTranslucent */, false /* hasImeSurface */);
}
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.java b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.java
index 2f2876d2e9f3..1142e05f4649 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.java
@@ -42,6 +42,7 @@ public class ThumbnailData {
public int orientation;
public int rotation;
public Rect insets;
+ public Rect letterboxInsets;
public boolean reducedResolution;
public boolean isRealSnapshot;
public boolean isTranslucent;
@@ -55,6 +56,7 @@ public class ThumbnailData {
orientation = ORIENTATION_UNDEFINED;
rotation = ROTATION_UNDEFINED;
insets = new Rect();
+ letterboxInsets = new Rect();
reducedResolution = false;
scale = 1f;
isRealSnapshot = true;
@@ -97,6 +99,7 @@ public class ThumbnailData {
public ThumbnailData(TaskSnapshot snapshot) {
thumbnail = makeThumbnail(snapshot);
insets = new Rect(snapshot.getContentInsets());
+ letterboxInsets = new Rect(snapshot.getLetterboxInsets());
orientation = snapshot.getOrientation();
rotation = snapshot.getRotation();
reducedResolution = snapshot.isLowResolution();
diff --git a/proto/src/task_snapshot.proto b/proto/src/task_snapshot.proto
index 4b0e4c218c86..1cbc17ed9f41 100644
--- a/proto/src/task_snapshot.proto
+++ b/proto/src/task_snapshot.proto
@@ -41,4 +41,8 @@
// The task height when the snapshot was taken
int32 task_height = 15;
int32 appearance = 16;
+ int32 letterbox_inset_left = 17;
+ int32 letterbox_inset_top = 18;
+ int32 letterbox_inset_right = 19;
+ int32 letterbox_inset_bottom = 20;
}
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotController.java b/services/core/java/com/android/server/wm/TaskSnapshotController.java
index 83ea1e22e6ea..141d889c1804 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotController.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotController.java
@@ -290,11 +290,13 @@ class TaskSnapshotController {
final WindowState mainWindow = result.second;
final Rect contentInsets = getSystemBarInsets(task.getBounds(),
mainWindow.getInsetsStateWithVisibilityOverride());
- InsetUtils.addInsets(contentInsets, activity.getLetterboxInsets());
+ final Rect letterboxInsets = activity.getLetterboxInsets();
+ InsetUtils.addInsets(contentInsets, letterboxInsets);
builder.setIsRealSnapshot(true);
builder.setId(System.currentTimeMillis());
builder.setContentInsets(contentInsets);
+ builder.setLetterboxInsets(letterboxInsets);
final boolean isWindowTranslucent = mainWindow.getAttrs().format != PixelFormat.OPAQUE;
final boolean isShowWallpaper = mainWindow.hasWallpaper();
@@ -575,7 +577,8 @@ class TaskSnapshotController {
return null;
}
final Rect contentInsets = new Rect(systemBarInsets);
- InsetUtils.addInsets(contentInsets, topChild.getLetterboxInsets());
+ final Rect letterboxInsets = topChild.getLetterboxInsets();
+ InsetUtils.addInsets(contentInsets, letterboxInsets);
// Note, the app theme snapshot is never translucent because we enforce a non-translucent
// color above
@@ -584,9 +587,9 @@ class TaskSnapshotController {
topChild.mActivityComponent, hwBitmap.getHardwareBuffer(),
hwBitmap.getColorSpace(), mainWindow.getConfiguration().orientation,
mainWindow.getWindowConfiguration().getRotation(), new Point(taskWidth, taskHeight),
- contentInsets, false /* isLowResolution */, false /* isRealSnapshot */,
- task.getWindowingMode(), getAppearance(task), false /* isTranslucent */,
- false /* hasImeSurface */);
+ contentInsets, letterboxInsets, false /* isLowResolution */,
+ false /* isRealSnapshot */, task.getWindowingMode(),
+ getAppearance(task), false /* isTranslucent */, false /* hasImeSurface */);
}
/**
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotLoader.java b/services/core/java/com/android/server/wm/TaskSnapshotLoader.java
index d3bfbab8106f..9189e51f860c 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotLoader.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotLoader.java
@@ -20,7 +20,6 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import android.app.ActivityManager;
-import android.window.TaskSnapshot;
import android.content.ComponentName;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
@@ -30,6 +29,7 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.hardware.HardwareBuffer;
import android.util.Slog;
+import android.window.TaskSnapshot;
import com.android.server.wm.nano.WindowManagerProtos.TaskSnapshotProto;
@@ -196,6 +196,8 @@ class TaskSnapshotLoader {
return new TaskSnapshot(proto.id, topActivityComponent, buffer,
hwBitmap.getColorSpace(), proto.orientation, proto.rotation, taskSize,
new Rect(proto.insetLeft, proto.insetTop, proto.insetRight, proto.insetBottom),
+ new Rect(proto.letterboxInsetLeft, proto.letterboxInsetTop,
+ proto.letterboxInsetRight, proto.letterboxInsetBottom),
loadLowResolutionBitmap, proto.isRealSnapshot, proto.windowingMode,
proto.appearance, proto.isTranslucent, false /* hasImeSurface */);
} catch (IOException e) {
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotPersister.java b/services/core/java/com/android/server/wm/TaskSnapshotPersister.java
index 60c4766ea18f..9fbcd7cc5d84 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotPersister.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotPersister.java
@@ -23,7 +23,6 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import android.annotation.NonNull;
import android.annotation.TestApi;
-import android.window.TaskSnapshot;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.os.Process;
@@ -31,6 +30,7 @@ import android.os.SystemClock;
import android.util.ArraySet;
import android.util.AtomicFile;
import android.util.Slog;
+import android.window.TaskSnapshot;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
@@ -380,6 +380,10 @@ class TaskSnapshotPersister {
proto.insetTop = mSnapshot.getContentInsets().top;
proto.insetRight = mSnapshot.getContentInsets().right;
proto.insetBottom = mSnapshot.getContentInsets().bottom;
+ proto.letterboxInsetLeft = mSnapshot.getLetterboxInsets().left;
+ proto.letterboxInsetTop = mSnapshot.getLetterboxInsets().top;
+ proto.letterboxInsetRight = mSnapshot.getLetterboxInsets().right;
+ proto.letterboxInsetBottom = mSnapshot.getLetterboxInsets().bottom;
proto.isRealSnapshot = mSnapshot.isRealSnapshot();
proto.windowingMode = mSnapshot.getWindowingMode();
proto.appearance = mSnapshot.getAppearance();
diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
index 22e687a0bb15..284728397c9f 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
@@ -1244,7 +1244,8 @@ public class RecentTasksTest extends WindowTestsBase {
}
return new TaskSnapshot(1, new ComponentName("", ""), buffer,
ColorSpace.get(ColorSpace.Named.SRGB), ORIENTATION_PORTRAIT,
- Surface.ROTATION_0, taskSize, new Rect() /* insets */, false /* isLowResolution */,
+ Surface.ROTATION_0, taskSize, new Rect() /* contentInsets */,
+ new Rect() /* letterboxInsets*/, false /* isLowResolution */,
true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN, 0 /* mSystemUiVisibility */,
false /* isTranslucent */, false /* hasImeSurface */);
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotControllerTest.java
index 97afc165624a..f573b70352af 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotControllerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotControllerTest.java
@@ -144,7 +144,8 @@ public class TaskSnapshotControllerTest extends WindowTestsBase {
final int orientation = Configuration.ORIENTATION_PORTRAIT;
final float scaleFraction = 0.25f;
final Rect contentInsets = new Rect(1, 2, 3, 4);
- final Point taskSize = new Point(5, 6);
+ final Rect letterboxInsets = new Rect(5, 6, 7, 8);
+ final Point taskSize = new Point(9, 10);
try {
TaskSnapshot.Builder builder =
@@ -156,6 +157,7 @@ public class TaskSnapshotControllerTest extends WindowTestsBase {
builder.setColorSpace(sRGB);
builder.setOrientation(orientation);
builder.setContentInsets(contentInsets);
+ builder.setLetterboxInsets(letterboxInsets);
builder.setIsTranslucent(true);
builder.setSnapshot(buffer);
builder.setIsRealSnapshot(true);
@@ -176,6 +178,7 @@ public class TaskSnapshotControllerTest extends WindowTestsBase {
assertFalse(snapshot.isLowResolution());
assertEquals(orientation, snapshot.getOrientation());
assertEquals(contentInsets, snapshot.getContentInsets());
+ assertEquals(letterboxInsets, snapshot.getLetterboxInsets());
assertTrue(snapshot.isTranslucent());
assertSame(buffer, snapshot.getHardwareBuffer());
assertTrue(snapshot.isRealSnapshot());
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java
index b5219fda1cc8..b8ac0be250a4 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java
@@ -59,7 +59,8 @@ import java.util.function.Predicate;
*/
class TaskSnapshotPersisterTestBase extends WindowTestsBase {
- private static final Rect TEST_INSETS = new Rect(10, 20, 30, 40);
+ private static final Rect TEST_CONTENT_INSETS = new Rect(10, 20, 30, 40);
+ private static final Rect TEST_LETTERBOX_INSETS = new Rect();
static final File FILES_DIR = getInstrumentation().getTargetContext().getFilesDir();
static final long MOCK_SNAPSHOT_ID = 12345678;
@@ -208,7 +209,7 @@ class TaskSnapshotPersisterTestBase extends WindowTestsBase {
return new TaskSnapshot(MOCK_SNAPSHOT_ID, mTopActivityComponent,
HardwareBuffer.createFromGraphicBuffer(buffer),
ColorSpace.get(ColorSpace.Named.SRGB), ORIENTATION_PORTRAIT,
- mRotation, taskSize, TEST_INSETS,
+ mRotation, taskSize, TEST_CONTENT_INSETS, TEST_LETTERBOX_INSETS,
// When building a TaskSnapshot with the Builder class, isLowResolution
// is always false. Low-res snapshots are only created when loading from
// disk.
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java
index 9372530f0e80..294aad237977 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java
@@ -100,7 +100,7 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
System.currentTimeMillis(),
new ComponentName("", ""), buffer,
ColorSpace.get(ColorSpace.Named.SRGB), ORIENTATION_PORTRAIT,
- Surface.ROTATION_0, taskSize, contentInsets, false,
+ Surface.ROTATION_0, taskSize, contentInsets, new Rect() /* letterboxInsets*/, false,
true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN,
0 /* systemUiVisibility */, false /* isTranslucent */, false /* hasImeSurface */);
}