Merge changes from topic "cherrypicker-L77300030007239273:N00600030116629593" into main
* changes:
Consider letterbox offset as size mismatch
Skip initializing unused system bar painter
diff --git a/core/java/android/window/SnapshotDrawerUtils.java b/core/java/android/window/SnapshotDrawerUtils.java
index 4c8bad6..5dc6875 100644
--- a/core/java/android/window/SnapshotDrawerUtils.java
+++ b/core/java/android/window/SnapshotDrawerUtils.java
@@ -152,9 +152,13 @@
@VisibleForTesting
public void setFrames(Rect frame, Rect systemBarInsets) {
mFrame.set(frame);
- mSystemBarInsets.set(systemBarInsets);
- mSizeMismatch = (mFrame.width() != mSnapshotW || mFrame.height() != mSnapshotH);
- mSystemBarBackgroundPainter.setInsets(systemBarInsets);
+ final Rect letterboxInsets = mSnapshot.getLetterboxInsets();
+ mSizeMismatch = (mFrame.width() != mSnapshotW || mFrame.height() != mSnapshotH)
+ || letterboxInsets.left != 0 || letterboxInsets.top != 0;
+ if (!Flags.drawSnapshotAspectRatioMatch() && systemBarInsets != null) {
+ mSystemBarInsets.set(systemBarInsets);
+ mSystemBarBackgroundPainter.setInsets(systemBarInsets);
+ }
}
private void drawSnapshot(boolean releaseAfterDraw) {
@@ -396,9 +400,12 @@
final ActivityManager.RunningTaskInfo runningTaskInfo = info.taskInfo;
final ActivityManager.TaskDescription taskDescription =
getOrCreateTaskDescription(runningTaskInfo);
- drawSurface.initiateSystemBarPainter(lp.flags, lp.privateFlags,
- attrs.insetsFlags.appearance, taskDescription, info.requestedVisibleTypes);
- final Rect systemBarInsets = getSystemBarInsets(windowBounds, topWindowInsetsState);
+ Rect systemBarInsets = null;
+ if (!Flags.drawSnapshotAspectRatioMatch()) {
+ drawSurface.initiateSystemBarPainter(lp.flags, lp.privateFlags,
+ attrs.insetsFlags.appearance, taskDescription, info.requestedVisibleTypes);
+ systemBarInsets = getSystemBarInsets(windowBounds, topWindowInsetsState);
+ }
drawSurface.setFrames(windowBounds, systemBarInsets);
drawSurface.drawSnapshot(releaseAfterDraw);
}