Loading libs/WindowManager/Shell/src/com/android/wm/shell/letterbox/LetterboxTaskListener.java +7 −9 Original line number Diff line number Diff line Loading @@ -107,6 +107,7 @@ public class LetterboxTaskListener implements ShellTaskOrganizer.TaskListener { transaction.setWindowCrop(leash, crop); } // TODO(b/173440321): Correct presentation of letterboxed activities in One-handed mode. private void resolveTaskPositionAndCrop( ActivityManager.RunningTaskInfo taskInfo, Point positionInParent, Loading @@ -125,15 +126,18 @@ public class LetterboxTaskListener implements ShellTaskOrganizer.TaskListener { final Rect activityBounds = taskInfo.letterboxActivityBounds; Insets insets = getInsets(); Rect displayBoundsWithInsets = new Rect(mWindowManager.getMaximumWindowMetrics().getBounds()); displayBoundsWithInsets.inset(insets); Rect taskBoundsWithInsets = new Rect(taskBounds); applyInsets(taskBoundsWithInsets, insets, taskInfo.parentBounds); taskBoundsWithInsets.intersect(displayBoundsWithInsets); Rect activityBoundsWithInsets = new Rect(activityBounds); applyInsets(activityBoundsWithInsets, insets, taskInfo.parentBounds); activityBoundsWithInsets.intersect(displayBoundsWithInsets); Rect parentBoundsWithInsets = new Rect(parentBounds); applyInsets(parentBoundsWithInsets, insets, parentBounds); parentBoundsWithInsets.intersect(displayBoundsWithInsets); // Crop need to be in the task coordinates. crop.set(activityBoundsWithInsets); Loading Loading @@ -217,10 +221,4 @@ public class LetterboxTaskListener implements ShellTaskOrganizer.TaskListener { | WindowInsets.Type.displayCutout()); } private void applyInsets(Rect innerBounds, Insets insets, Rect outerBounds) { Rect outerBoundsWithInsets = new Rect(outerBounds); outerBoundsWithInsets.inset(insets); innerBounds.intersect(outerBoundsWithInsets); } } libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/letterbox/LetterboxTaskListenerTest.java +13 −1 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 200, 100), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 200, 100), /* activityBounds */ new Rect(75, 0, 125, 75), /* taskBounds */ new Rect(50, 0, 125, 100)), Loading @@ -109,6 +110,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskInfoChanged( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 200, 100), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 200, 100), // Activity is offset by 25 to the left /* activityBounds */ new Rect(50, 0, 100, 75), Loading @@ -130,6 +132,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 200, 100), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 200, 100), /* activityBounds */ new Rect(150, 0, 200, 75), /* taskBounds */ new Rect(125, 0, 200, 100)), Loading @@ -150,6 +153,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 200, 100), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 200, 100), /* activityBounds */ new Rect(150, 0, 200, 75), /* taskBounds */ new Rect(125, 0, 200, 100)), Loading @@ -170,6 +174,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 200, 100), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 200, 100), /* activityBounds */ new Rect(50, 0, 100, 75), /* taskBounds */ new Rect(25, 0, 100, 100)), Loading @@ -190,6 +195,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 100, 150), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 100, 150), /* activityBounds */ new Rect(0, 75, 50, 125), /* taskBounds */ new Rect(0, 50, 100, 125)), Loading @@ -210,6 +216,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 100, 150), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 100, 150), /* activityBounds */ new Rect(0, 75, 50, 125), /* taskBounds */ new Rect(0, 50, 100, 125)), Loading @@ -230,6 +237,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 100, 150), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 100, 150), /* activityBounds */ new Rect(0, 75, 50, 125), /* taskBounds */ new Rect(0, 50, 100, 125)), Loading @@ -250,6 +258,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 200, 125), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 200, 125), /* activityBounds */ new Rect(15, 0, 175, 120), /* taskBounds */ new Rect(0, 0, 100, 125)), // equal to parent bounds Loading @@ -272,6 +281,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 100, 150), /* parentBounds */ new Rect(0, 75, 100, 225), /* activityBounds */ new Rect(25, 75, 75, 125), /* taskBounds */ new Rect(0, 75, 100, 125)), Loading @@ -285,7 +295,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { public void testOnTaskAppeared_calledSecondTimeWithSameTaskId_throwsException() { setWindowBoundsAndInsets(new Rect(), Insets.NONE); RunningTaskInfo taskInfo = createTaskInfo(/* taskId */ 1, new Rect(), new Rect(), new Rect()); createTaskInfo(/* taskId */ 1, new Rect(), new Rect(), new Rect(), new Rect()); mLetterboxTaskListener.onTaskAppeared(taskInfo, mLeash); mLetterboxTaskListener.onTaskAppeared(taskInfo, mLeash); } Loading @@ -306,11 +316,13 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { private static RunningTaskInfo createTaskInfo( int taskId, final Rect maxBounds, final Rect parentBounds, final Rect activityBounds, final Rect taskBounds) { RunningTaskInfo taskInfo = new RunningTaskInfo(); taskInfo.taskId = taskId; taskInfo.configuration.windowConfiguration.setMaxBounds(maxBounds); taskInfo.parentBounds = parentBounds; taskInfo.configuration.windowConfiguration.setBounds(taskBounds); taskInfo.letterboxActivityBounds = Rect.copyOrNull(activityBounds); Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/letterbox/LetterboxTaskListener.java +7 −9 Original line number Diff line number Diff line Loading @@ -107,6 +107,7 @@ public class LetterboxTaskListener implements ShellTaskOrganizer.TaskListener { transaction.setWindowCrop(leash, crop); } // TODO(b/173440321): Correct presentation of letterboxed activities in One-handed mode. private void resolveTaskPositionAndCrop( ActivityManager.RunningTaskInfo taskInfo, Point positionInParent, Loading @@ -125,15 +126,18 @@ public class LetterboxTaskListener implements ShellTaskOrganizer.TaskListener { final Rect activityBounds = taskInfo.letterboxActivityBounds; Insets insets = getInsets(); Rect displayBoundsWithInsets = new Rect(mWindowManager.getMaximumWindowMetrics().getBounds()); displayBoundsWithInsets.inset(insets); Rect taskBoundsWithInsets = new Rect(taskBounds); applyInsets(taskBoundsWithInsets, insets, taskInfo.parentBounds); taskBoundsWithInsets.intersect(displayBoundsWithInsets); Rect activityBoundsWithInsets = new Rect(activityBounds); applyInsets(activityBoundsWithInsets, insets, taskInfo.parentBounds); activityBoundsWithInsets.intersect(displayBoundsWithInsets); Rect parentBoundsWithInsets = new Rect(parentBounds); applyInsets(parentBoundsWithInsets, insets, parentBounds); parentBoundsWithInsets.intersect(displayBoundsWithInsets); // Crop need to be in the task coordinates. crop.set(activityBoundsWithInsets); Loading Loading @@ -217,10 +221,4 @@ public class LetterboxTaskListener implements ShellTaskOrganizer.TaskListener { | WindowInsets.Type.displayCutout()); } private void applyInsets(Rect innerBounds, Insets insets, Rect outerBounds) { Rect outerBoundsWithInsets = new Rect(outerBounds); outerBoundsWithInsets.inset(insets); innerBounds.intersect(outerBoundsWithInsets); } }
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/letterbox/LetterboxTaskListenerTest.java +13 −1 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 200, 100), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 200, 100), /* activityBounds */ new Rect(75, 0, 125, 75), /* taskBounds */ new Rect(50, 0, 125, 100)), Loading @@ -109,6 +110,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskInfoChanged( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 200, 100), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 200, 100), // Activity is offset by 25 to the left /* activityBounds */ new Rect(50, 0, 100, 75), Loading @@ -130,6 +132,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 200, 100), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 200, 100), /* activityBounds */ new Rect(150, 0, 200, 75), /* taskBounds */ new Rect(125, 0, 200, 100)), Loading @@ -150,6 +153,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 200, 100), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 200, 100), /* activityBounds */ new Rect(150, 0, 200, 75), /* taskBounds */ new Rect(125, 0, 200, 100)), Loading @@ -170,6 +174,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 200, 100), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 200, 100), /* activityBounds */ new Rect(50, 0, 100, 75), /* taskBounds */ new Rect(25, 0, 100, 100)), Loading @@ -190,6 +195,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 100, 150), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 100, 150), /* activityBounds */ new Rect(0, 75, 50, 125), /* taskBounds */ new Rect(0, 50, 100, 125)), Loading @@ -210,6 +216,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 100, 150), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 100, 150), /* activityBounds */ new Rect(0, 75, 50, 125), /* taskBounds */ new Rect(0, 50, 100, 125)), Loading @@ -230,6 +237,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 100, 150), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 100, 150), /* activityBounds */ new Rect(0, 75, 50, 125), /* taskBounds */ new Rect(0, 50, 100, 125)), Loading @@ -250,6 +258,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 200, 125), // equal to parent bounds /* parentBounds */ new Rect(0, 0, 200, 125), /* activityBounds */ new Rect(15, 0, 175, 120), /* taskBounds */ new Rect(0, 0, 100, 125)), // equal to parent bounds Loading @@ -272,6 +281,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { mLetterboxTaskListener.onTaskAppeared( createTaskInfo( /* taskId */ 1, /* maxBounds= */ new Rect(0, 0, 100, 150), /* parentBounds */ new Rect(0, 75, 100, 225), /* activityBounds */ new Rect(25, 75, 75, 125), /* taskBounds */ new Rect(0, 75, 100, 125)), Loading @@ -285,7 +295,7 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { public void testOnTaskAppeared_calledSecondTimeWithSameTaskId_throwsException() { setWindowBoundsAndInsets(new Rect(), Insets.NONE); RunningTaskInfo taskInfo = createTaskInfo(/* taskId */ 1, new Rect(), new Rect(), new Rect()); createTaskInfo(/* taskId */ 1, new Rect(), new Rect(), new Rect(), new Rect()); mLetterboxTaskListener.onTaskAppeared(taskInfo, mLeash); mLetterboxTaskListener.onTaskAppeared(taskInfo, mLeash); } Loading @@ -306,11 +316,13 @@ public final class LetterboxTaskListenerTest extends ShellTestCase { private static RunningTaskInfo createTaskInfo( int taskId, final Rect maxBounds, final Rect parentBounds, final Rect activityBounds, final Rect taskBounds) { RunningTaskInfo taskInfo = new RunningTaskInfo(); taskInfo.taskId = taskId; taskInfo.configuration.windowConfiguration.setMaxBounds(maxBounds); taskInfo.parentBounds = parentBounds; taskInfo.configuration.windowConfiguration.setBounds(taskBounds); taskInfo.letterboxActivityBounds = Rect.copyOrNull(activityBounds); Loading