Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5f8bd15 authored by Riddle Hsu's avatar Riddle Hsu Committed by Automerger Merge Worker
Browse files

Merge "Do not apply minimal size for fullscreen task" into rvc-dev am: 5ef61d2f

Change-Id: Id696e0366d46de3507792fadab7eb109dab7e69a
parents ac380004 5ef61d2f
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1192,8 +1192,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        final Configuration newConfig = new Configuration();
        newConfig.setTo(task.getRequestedOverrideConfiguration());
        Rect outBounds = newConfig.windowConfiguration.getBounds();
        task.adjustForMinimalTaskDimensions(outBounds, outBounds);
        task.computeConfigResourceOverrides(newConfig, task.getParent().getConfiguration());
        final Configuration parentConfig = task.getParent().getConfiguration();
        task.adjustForMinimalTaskDimensions(outBounds, outBounds, parentConfig);
        task.computeConfigResourceOverrides(newConfig, parentConfig);
    }

    Task getTask() {
+12 −13
Original line number Diff line number Diff line
@@ -1822,22 +1822,16 @@ class Task extends WindowContainer<WindowContainer> {
        }
    }

    void adjustForMinimalTaskDimensions(Rect bounds, Rect previousBounds) {
        final Rect parentBounds = getParent() != null ? getParent().getBounds() : null;
        if (bounds == null
                || (bounds.isEmpty() && (parentBounds == null || parentBounds.isEmpty()))) {
            return;
        }
    void adjustForMinimalTaskDimensions(@NonNull Rect bounds, @NonNull Rect previousBounds,
            @NonNull Configuration parentConfig) {
        int minWidth = mMinWidth;
        int minHeight = mMinHeight;
        // If the task has no requested minimal size, we'd like to enforce a minimal size
        // so that the user can not render the task too small to manipulate. We don't need
        // to do this for the pinned stack as the bounds are controlled by the system.
        if (!inPinnedWindowingMode() && getStack() != null) {
        if (!inPinnedWindowingMode()) {
            final int defaultMinSizeDp = mRootWindowContainer.mDefaultMinSizeOfResizeableTaskDp;
            final DisplayContent display = getDisplayContent();
            final float density =
                    (float) display.getConfiguration().densityDpi / DisplayMetrics.DENSITY_DEFAULT;
            final float density = (float) parentConfig.densityDpi / DisplayMetrics.DENSITY_DEFAULT;
            final int defaultMinSize = (int) (defaultMinSizeDp * density);

            if (minWidth == INVALID_MIN_SIZE) {
@@ -1850,6 +1844,7 @@ class Task extends WindowContainer<WindowContainer> {
        if (bounds.isEmpty()) {
            // If inheriting parent bounds, check if parent bounds adhere to minimum size. If they
            // do, we can just skip.
            final Rect parentBounds = parentConfig.windowConfiguration.getBounds();
            if (parentBounds.width() >= minWidth && parentBounds.height() >= minHeight) {
                return;
            }
@@ -2444,12 +2439,13 @@ class Task extends WindowContainer<WindowContainer> {
        }

        if (isLeafTask()) {
            resolveLeafOnlyOverrideConfigs(newParentConfig);
            resolveLeafOnlyOverrideConfigs(newParentConfig, mTmpBounds /* previousBounds */);
        }
        computeConfigResourceOverrides(getResolvedOverrideConfiguration(), newParentConfig);
    }

    void resolveLeafOnlyOverrideConfigs(Configuration newParentConfig) {
    private void resolveLeafOnlyOverrideConfigs(Configuration newParentConfig,
            Rect previousBounds) {
        int windowingMode =
                getResolvedOverrideConfiguration().windowConfiguration.getWindowingMode();
        if (windowingMode == WINDOWING_MODE_UNDEFINED) {
@@ -2462,9 +2458,12 @@ class Task extends WindowContainer<WindowContainer> {
            computeFullscreenBounds(outOverrideBounds, null /* refActivity */,
                    newParentConfig.windowConfiguration.getBounds(),
                    newParentConfig.orientation);
            // 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;
        }

        adjustForMinimalTaskDimensions(outOverrideBounds, mTmpBounds);
        adjustForMinimalTaskDimensions(outOverrideBounds, previousBounds, newParentConfig);
        if (windowingMode == WINDOWING_MODE_FREEFORM) {
            // by policy, make sure the window remains within parent somewhere
            final float density =
+15 −0
Original line number Diff line number Diff line
@@ -447,6 +447,21 @@ public class TaskRecordTests extends ActivityTestsBase {
        assertNotEquals(origScreenH, task.getConfiguration().screenHeightDp);
    }

    @Test
    public void testFullScreenTaskNotAdjustedByMinimalSize() {
        final Task fullscreenTask = new TaskBuilder(mSupervisor).build();
        final Rect originalTaskBounds = new Rect(fullscreenTask.getBounds());
        final ActivityInfo aInfo = new ActivityInfo();
        aInfo.windowLayout = new ActivityInfo.WindowLayout(0 /* width */, 0 /* widthFraction */,
                    0 /* height */, 0 /* heightFraction */, 0 /* gravity */,
                    originalTaskBounds.width() * 2 /* minWidth */,
                    originalTaskBounds.height() * 2 /* minHeight */);
        fullscreenTask.setMinDimensions(aInfo);
        fullscreenTask.onConfigurationChanged(fullscreenTask.getParent().getConfiguration());

        assertEquals(originalTaskBounds, fullscreenTask.getBounds());
    }

    @Test
    public void testInsetDisregardedWhenFreeformOverlapsNavBar() {
        TaskDisplayArea taskDisplayArea = mService.mRootWindowContainer.getDefaultTaskDisplayArea();
+1 −1
Original line number Diff line number Diff line
@@ -204,7 +204,7 @@ public class TaskStackTests extends WindowTestsBase {
                .when(windowConfiguration).getWindowingMode();

        // Prevent adjust task dimensions
        doNothing().when(stack).adjustForMinimalTaskDimensions(any(), any());
        doNothing().when(stack).adjustForMinimalTaskDimensions(any(), any(), any());

        final Rect stackBounds = new Rect(200, 200, 800, 1000);
        // Update surface position and size by the given bounds.
+1 −1
Original line number Diff line number Diff line
@@ -507,7 +507,7 @@ public class WindowOrganizerTests extends WindowTestsBase {
        Task task1 = WindowContainer.fromBinder(info1.token.asBinder()).asTask();
        Configuration c = new Configuration(task1.getRequestedOverrideConfiguration());
        c.windowConfiguration.setBounds(newSize);
        doNothing().when(stack).adjustForMinimalTaskDimensions(any(), any());
        doNothing().when(stack).adjustForMinimalTaskDimensions(any(), any(), any());
        task1.onRequestedOverrideConfigurationChanged(c);
        assertEquals(newSize, stack.getBounds());