WM: Adjust TaskSnapshot for cutout layout
Makes TaskSnapshot work even when the main window top-left
position is not the same as the stack's.
Bug: 65689439
Test: Enable cutout, open Gmail, open Recents, verify transition did not jump in the end, open Gmail from recents, verify transition did not jump in the end.
Change-Id: I48053f551ed1c118764aa30e0b6408db64d4a5f1
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotController.java b/services/core/java/com/android/server/wm/TaskSnapshotController.java
index 84e475a..a7cb3ed 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotController.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotController.java
@@ -236,7 +236,7 @@
return null;
}
return new TaskSnapshot(buffer, top.getConfiguration().orientation,
- minRect(mainWindow.mContentInsets, mainWindow.mStableInsets),
+ getInsetsFromTaskBounds(mainWindow, task),
isLowRamDevice /* reduced */, scaleFraction /* scale */);
}
@@ -244,11 +244,18 @@
return mIsRunningOnWear || mIsRunningOnTv || mIsRunningOnIoT;
}
- private Rect minRect(Rect rect1, Rect rect2) {
- return new Rect(Math.min(rect1.left, rect2.left),
- Math.min(rect1.top, rect2.top),
- Math.min(rect1.right, rect2.right),
- Math.min(rect1.bottom, rect2.bottom));
+ private Rect getInsetsFromTaskBounds(WindowState state, Task task) {
+ final Rect r = new Rect();
+ r.set(state.getContentFrameLw());
+ r.intersectUnchecked(state.getStableFrameLw());
+
+ final Rect taskBounds = task.getBounds();
+
+ r.set(Math.max(0, r.left - taskBounds.left),
+ Math.max(0, r.top - taskBounds.top),
+ Math.max(0, taskBounds.right - r.right),
+ Math.max(0, taskBounds.bottom - r.bottom));
+ return r;
}
/**