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

Commit 28b4fc8d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Only update non-empty last frame in the first layout"

parents e3c53e70 12c05456
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -772,7 +772,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            // If this is the first layout, we need to initialize the last frames and inset values,
            // as otherwise we'd immediately cause an unnecessary resize.
            if (firstLayout) {
                // The client may compute its actual requested size according to the first layout,
                // so we still request the window to resize if the current frame is empty.
                if (!w.getFrameLw().isEmpty()) {
                    w.updateLastFrames();
                }
                w.updateLastInsetValues();
                w.updateLocationInParentDisplayIfNeeded();
            }
+29 −10
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.server.wm.WindowContainer.POSITION_TOP;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL;

import static com.google.common.truth.Truth.assertThat;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -86,6 +88,7 @@ import android.view.IWindowManager;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.ViewRootImpl;
import android.view.WindowManager;
import android.view.test.InsetsModeSession;

import androidx.test.filters.SmallTest;
@@ -561,8 +564,7 @@ public class DisplayContentTests extends WindowTestsBase {
        final DisplayContent dc = createNewDisplay();
        final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, dc, "w");

        dc.setLayoutNeeded();
        dc.performLayout(true /* initial */, false /* updateImeWindows */);
        performLayout(dc);

        assertThat(win.mLayoutSeq, is(dc.mLayoutSeq));
    }
@@ -829,8 +831,7 @@ public class DisplayContentTests extends WindowTestsBase {
        win.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR;
        win.setSystemGestureExclusion(Collections.singletonList(new Rect(10, 20, 30, 40)));

        dc.setLayoutNeeded();
        dc.performLayout(true /* initial */, false /* updateImeWindows */);
        performLayout(dc);

        win.setHasSurface(true);
        dc.updateSystemGestureExclusion();
@@ -866,8 +867,7 @@ public class DisplayContentTests extends WindowTestsBase {
        win2.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR;
        win2.setSystemGestureExclusion(Collections.singletonList(new Rect(20, 30, 40, 50)));

        dc.setLayoutNeeded();
        dc.performLayout(true /* initial */, false /* updateImeWindows */);
        performLayout(dc);

        win.setHasSurface(true);
        win2.setHasSurface(true);
@@ -898,8 +898,7 @@ public class DisplayContentTests extends WindowTestsBase {
        win2.getAttrs().height = 10;
        win2.setSystemGestureExclusion(Collections.emptyList());

        dc.setLayoutNeeded();
        dc.performLayout(true /* initial */, false /* updateImeWindows */);
        performLayout(dc);

        win.setHasSurface(true);
        win2.setHasSurface(true);
@@ -922,8 +921,7 @@ public class DisplayContentTests extends WindowTestsBase {
                        | SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        win.mActivityRecord.mTargetSdk = P;

        dc.setLayoutNeeded();
        dc.performLayout(true /* initial */, false /* updateImeWindows */);
        performLayout(dc);

        win.setHasSurface(true);

@@ -934,6 +932,22 @@ public class DisplayContentTests extends WindowTestsBase {
        win.setHasSurface(false);
    }

    @Test
    public void testRequestResizeForEmptyFrames() {
        final WindowState win = mChildAppWindowAbove;
        makeWindowVisible(win, win.getParentWindow());
        win.setRequestedSize(mDisplayContent.mBaseDisplayWidth, 0 /* height */);
        win.mAttrs.width = win.mAttrs.height = WindowManager.LayoutParams.WRAP_CONTENT;
        win.mAttrs.gravity = Gravity.CENTER;
        performLayout(mDisplayContent);

        // The frame is empty because the requested height is zero.
        assertTrue(win.getFrameLw().isEmpty());
        // The window should be scheduled to resize then the client may report a new non-empty size.
        win.updateResizingWindowIfNeeded();
        assertThat(mWm.mResizingWindows).contains(win);
    }

    @Test
    public void testOrientationChangeLogging() {
        MetricsLogger mockLogger = mock(MetricsLogger.class);
@@ -1011,6 +1025,11 @@ public class DisplayContentTests extends WindowTestsBase {
        mWm.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, false /* updateInputWindows */);
    }

    private void performLayout(DisplayContent dc) {
        dc.setLayoutNeeded();
        dc.performLayout(true /* initial */, false /* updateImeWindows */);
    }

    /**
     * Create DisplayContent that does not update display base/initial values from device to keep
     * the values set by test.
+11 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.view.Display;
import android.view.DisplayInfo;
import android.view.IWindow;
import android.view.SurfaceControl.Transaction;
import android.view.View;
import android.view.WindowManager;

import com.android.server.AttributeCache;
@@ -312,6 +313,16 @@ class WindowTestsBase extends SystemServiceTestsBase {
        }
    }

    static void makeWindowVisible(WindowState... windows) {
        for (WindowState win : windows) {
            win.mViewVisibility = View.VISIBLE;
            win.mRelayoutCalled = true;
            win.mHasSurface = true;
            win.mHidden = false;
            win.showLw(false /* doAnimation */, false /* requestAnim */);
        }
    }

    /** Creates a {@link ActivityStack} and adds it to the specified {@link DisplayContent}. */
    ActivityStack createTaskStackOnDisplay(DisplayContent dc) {
        return createTaskStackOnDisplay(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, dc);