diff options
4 files changed, 49 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 0a833f4f2dba..7433c7e58392 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -2035,6 +2035,10 @@ class Task extends TaskFragment { Rect outOverrideBounds = getResolvedOverrideConfiguration().windowConfiguration.getBounds(); if (windowingMode == WINDOWING_MODE_FULLSCREEN) { + if (!mCreatedByOrganizer) { + // Use empty bounds to indicate "fill parent". + outOverrideBounds.setEmpty(); + } // The bounds for fullscreen mode shouldn't be adjusted by minimal size. Otherwise if // the parent or display is smaller than the size, the content may be cropped. return; diff --git a/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java b/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java index 8cc362c1820c..17f6d51a74f3 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java @@ -35,6 +35,8 @@ import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.never; +import android.app.WindowConfiguration; +import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.graphics.Point; import android.graphics.Rect; @@ -45,6 +47,7 @@ import android.platform.test.annotations.Presubmit; import android.provider.DeviceConfig; import android.util.DisplayMetrics; import android.view.ContentRecordingSession; +import android.view.Gravity; import android.view.Surface; import android.view.SurfaceControl; @@ -258,8 +261,17 @@ public class ContentRecorderTests extends WindowTestsBase { @Test public void testOnTaskBoundsConfigurationChanged_notifiesCallback() { + mTask.getRootTask().setWindowingMode(WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW); + final int recordedWidth = 333; final int recordedHeight = 999; + + final ActivityInfo info = new ActivityInfo(); + info.windowLayout = new ActivityInfo.WindowLayout(-1 /* width */, + -1 /* widthFraction */, -1 /* height */, -1 /* heightFraction */, + Gravity.NO_GRAVITY, recordedWidth, recordedHeight); + mTask.setMinDimensions(info); + // WHEN a recording is ongoing. mContentRecorder.setContentRecordingSession(mTaskSession); mContentRecorder.updateRecording(); @@ -267,7 +279,6 @@ public class ContentRecorderTests extends WindowTestsBase { // WHEN a configuration change arrives, and the recorded content is a different size. mTask.setBounds(new Rect(0, 0, recordedWidth, recordedHeight)); - mContentRecorder.onConfigurationChanged(mDefaultDisplay.getLastOrientation()); assertThat(mContentRecorder.isCurrentlyRecording()).isTrue(); // THEN content in the captured DisplayArea is scaled to fit the surface size. diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java index 9cd80a34b714..5208e5a2dc2f 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java @@ -535,6 +535,34 @@ public class TaskTests extends WindowTestsBase { assertEquals(reqBounds.height(), task.getBounds().height()); } + /** Tests that the task bounds adjust properly to changes between FULLSCREEN and FREEFORM */ + @Test + public void testBoundsOnModeChangeFreeformToFullscreen() { + DisplayContent display = mAtm.mRootWindowContainer.getDefaultDisplay(); + Task rootTask = new TaskBuilder(mSupervisor).setDisplay(display).setCreateActivity(true) + .setWindowingMode(WINDOWING_MODE_FREEFORM).build(); + Task task = rootTask.getBottomMostTask(); + task.getRootActivity().setOrientation(SCREEN_ORIENTATION_UNSPECIFIED); + DisplayInfo info = new DisplayInfo(); + display.mDisplay.getDisplayInfo(info); + final Rect fullScreenBounds = new Rect(0, 0, info.logicalWidth, info.logicalHeight); + final Rect freeformBounds = new Rect(fullScreenBounds); + freeformBounds.inset((int) (freeformBounds.width() * 0.2), + (int) (freeformBounds.height() * 0.2)); + task.setBounds(freeformBounds); + + assertEquals(freeformBounds, task.getBounds()); + + // FULLSCREEN inherits bounds + rootTask.setWindowingMode(WINDOWING_MODE_FULLSCREEN); + assertEquals(fullScreenBounds, task.getBounds()); + assertEquals(freeformBounds, task.mLastNonFullscreenBounds); + + // FREEFORM restores bounds + rootTask.setWindowingMode(WINDOWING_MODE_FREEFORM); + assertEquals(freeformBounds, task.getBounds()); + } + /** * Tests that a task with forced orientation has orientation-consistent bounds within the * parent. diff --git a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java index 3f14217b7a18..9bb9020ffb26 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java @@ -19,6 +19,7 @@ package com.android.server.wm; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; +import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS; @@ -1696,7 +1697,8 @@ public class TransitionTests extends WindowTestsBase { @Test public void testTransitionVisibleChange() { registerTestTransitionPlayer(); - final ActivityRecord app = createActivityRecord(mDisplayContent); + final ActivityRecord app = createActivityRecord( + mDisplayContent, WINDOWING_MODE_MULTI_WINDOW, ACTIVITY_TYPE_STANDARD); final Transition transition = new Transition(TRANSIT_OPEN, 0 /* flags */, app.mTransitionController, mWm.mSyncEngine); app.mTransitionController.moveToCollecting(transition, BLASTSyncEngine.METHOD_NONE); @@ -1746,7 +1748,8 @@ public class TransitionTests extends WindowTestsBase { @Test public void testVisibleChange_snapshot() { registerTestTransitionPlayer(); - final ActivityRecord app = createActivityRecord(mDisplayContent); + final ActivityRecord app = createActivityRecord( + mDisplayContent, WINDOWING_MODE_MULTI_WINDOW, ACTIVITY_TYPE_STANDARD); final Transition transition = new Transition(TRANSIT_CHANGE, 0 /* flags */, app.mTransitionController, mWm.mSyncEngine); app.mTransitionController.moveToCollecting(transition, BLASTSyncEngine.METHOD_NONE); |