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

Commit dd8848f1 authored by Chris Li's avatar Chris Li Committed by Automerger Merge Worker
Browse files

Merge "Restrict DisplayArea appBounds to the override bounds" into sc-dev am: 6809b5c0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13454386

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Iebb4f67435f7039afbfd1ba9f34c6dc90f41fa3a
parents c0e3d41a 6809b5c0
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -461,6 +461,23 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
        }
    }

    @Override
    void resolveOverrideConfiguration(Configuration newParentConfiguration) {
        super.resolveOverrideConfiguration(newParentConfiguration);
        final Configuration resolvedConfig = getResolvedOverrideConfiguration();
        final Rect overrideBounds = resolvedConfig.windowConfiguration.getBounds();
        final Rect overrideAppBounds = resolvedConfig.windowConfiguration.getAppBounds();
        final Rect parentAppBounds = newParentConfiguration.windowConfiguration.getAppBounds();

        // If there is no override of appBounds, restrict appBounds to the override bounds.
        if (!overrideBounds.isEmpty() && (overrideAppBounds == null || overrideAppBounds.isEmpty())
                && parentAppBounds != null && !parentAppBounds.isEmpty()) {
            final Rect appBounds = new Rect(overrideBounds);
            appBounds.intersect(parentAppBounds);
            resolvedConfig.windowConfiguration.setAppBounds(appBounds);
        }
    }

    @Override
    boolean isOrganized() {
        return mOrganizer != null;
+28 −1
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

package com.android.server.wm;

import static android.content.ActivityInfoProto.SCREEN_ORIENTATION_PORTRAIT;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION;
@@ -50,6 +50,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;

import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Binder;
import android.platform.test.annotations.Presubmit;
@@ -407,6 +408,32 @@ public class DisplayAreaTest extends WindowTestsBase {
                childBounds1, windowToken.getMaxBounds());
    }

    @Test
    public void testRestrictAppBoundsToOverrideBounds() {
        final RootDisplayArea root =
                new DisplayAreaPolicyBuilderTest.SurfacelessDisplayAreaRoot(mWm);
        final DisplayArea<DisplayArea> da = new DisplayArea<>(mWm, ANY, "Test_DA");
        root.addChild(da, POSITION_TOP);
        final Rect displayBounds = new Rect(0, 0, 1800, 2800);
        final Rect displayAppBounds = new Rect(0, 100, 1800, 2800);
        final Rect daBounds = new Rect(0, 1400, 1800, 2800);
        root.setBounds(displayBounds);

        // DA inherit parent app bounds.
        final Configuration displayConfig = new Configuration();
        displayConfig.windowConfiguration.setAppBounds(displayAppBounds);
        root.onRequestedOverrideConfigurationChanged(displayConfig);

        assertEquals(displayAppBounds, da.getConfiguration().windowConfiguration.getAppBounds());

        // Restrict DA appBounds to override Bounds
        da.setBounds(daBounds);

        final Rect expectedDaAppBounds = new Rect(daBounds);
        expectedDaAppBounds.intersect(displayAppBounds);
        assertEquals(expectedDaAppBounds, da.getConfiguration().windowConfiguration.getAppBounds());
    }

    @Test
    public void testGetOrientation() {
        final DisplayArea.Tokens area = new DisplayArea.Tokens(mWm, ABOVE_TASKS, "test");
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package com.android.server.wm;

import static android.content.ActivityInfoProto.SCREEN_ORIENTATION_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;