Merge "[automerger skipped] Merge "Fix READ/WRITE operation access issues on Restricted appOps." into udc-dev am: bc17b89638 am: 43532ebbb5 am: c814197d55 -s ours" into main
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitPresenter.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitPresenter.java
index eade86e..d888fa9 100644
--- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitPresenter.java
+++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitPresenter.java
@@ -658,27 +658,28 @@
}
/**
- * Returns the expanded bounds if the {@code bounds} violate minimum dimension or are not fully
- * covered by the task bounds. Otherwise, returns {@code bounds}.
+ * Returns the expanded bounds if the {@code relBounds} violate minimum dimension or are not
+ * fully covered by the task bounds. Otherwise, returns {@code relBounds}.
*/
@NonNull
- static Rect sanitizeBounds(@NonNull Rect bounds, @Nullable Size minDimension,
+ static Rect sanitizeBounds(@NonNull Rect relBounds, @Nullable Size minDimension,
@NonNull TaskFragmentContainer container) {
- if (bounds.isEmpty()) {
+ if (relBounds.isEmpty()) {
// Don't need to check if the bounds follows the task bounds.
- return bounds;
+ return relBounds;
}
- if (boundsSmallerThanMinDimensions(bounds, minDimension)) {
+ if (boundsSmallerThanMinDimensions(relBounds, minDimension)) {
// Expand the bounds if the bounds are smaller than minimum dimensions.
return new Rect();
}
final TaskContainer taskContainer = container.getTaskContainer();
- final Rect taskBounds = taskContainer.getBounds();
- if (!taskBounds.contains(bounds)) {
+ final Rect relTaskBounds = new Rect(taskContainer.getBounds());
+ relTaskBounds.offsetTo(0, 0);
+ if (!relTaskBounds.contains(relBounds)) {
// Expand the bounds if the bounds exceed the task bounds.
return new Rect();
}
- return bounds;
+ return relBounds;
}
@Override
diff --git a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/OverlayPresentationTest.java b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/OverlayPresentationTest.java
index 0972d40..7a0b9a0 100644
--- a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/OverlayPresentationTest.java
+++ b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/OverlayPresentationTest.java
@@ -409,6 +409,22 @@
}
@Test
+ public void testSanitizeBounds_taskInSplitScreen() {
+ final TaskFragmentContainer overlayContainer =
+ createTestOverlayContainer(TASK_ID, "test1");
+ TaskContainer taskContainer = overlayContainer.getTaskContainer();
+ spyOn(taskContainer);
+ doReturn(new Rect(TASK_BOUNDS.left + TASK_BOUNDS.width() / 2, TASK_BOUNDS.top,
+ TASK_BOUNDS.right, TASK_BOUNDS.bottom)).when(taskContainer).getBounds();
+ final Rect taskBounds = taskContainer.getBounds();
+ final Rect bounds = new Rect(taskBounds.width() / 2, 0, taskBounds.width(),
+ taskBounds.height());
+
+ assertThat(sanitizeBounds(bounds, null, overlayContainer)
+ .isEmpty()).isFalse();
+ }
+
+ @Test
public void testCreateOrUpdateOverlayTaskFragmentIfNeeded_createOverlay() {
final Rect bounds = new Rect(0, 0, 100, 100);
mSplitController.setActivityStackAttributesCalculator(params ->