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

Commit a9921924 authored by Bryce Lee's avatar Bryce Lee Committed by android-build-merger
Browse files

Merge "Do not always skip preparing window to display when already visible."...

Merge "Do not always skip preparing window to display when already visible." into oc-dev am: 4dfc067b
am: 0cf1febd

Change-Id: I8e09bad0c1bb0b0d2ab042b9fac6ed4dc09738b5
parents 2e98a5fe 0cf1febd
Loading
Loading
Loading
Loading
+20 −8
Original line number Diff line number Diff line
@@ -2202,18 +2202,30 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        }
    }

    void prepareWindowToDisplayDuringRelayout(MergedConfiguration mergedConfiguration) {
    void prepareWindowToDisplayDuringRelayout(MergedConfiguration mergedConfiguration,
            boolean wasVisible) {
        // We need to turn on screen regardless of visibility.
        if ((mAttrs.flags & FLAG_TURN_SCREEN_ON) != 0) {
            if (DEBUG_VISIBILITY) Slog.v(TAG, "Relayout window turning screen on: " + this);
            mTurnOnScreen = true;
        }

        // If we were already visible, skip rest of preparation.
        if (wasVisible) {
            if (DEBUG_VISIBILITY) Slog.v(TAG,
                    "Already visible and does not turn on screen, skip preparing: " + this);
            return;
        }

        if ((mAttrs.softInputMode & SOFT_INPUT_MASK_ADJUST)
                == SOFT_INPUT_ADJUST_RESIZE) {
            mLayoutNeeded = true;
        }

        if (isDrawnLw() && mService.okToDisplay()) {
            mWinAnimator.applyEnterAnimationLocked();
        }
        if ((mAttrs.flags & FLAG_TURN_SCREEN_ON) != 0) {
            if (DEBUG_VISIBILITY) Slog.v(TAG, "Relayout window turning screen on: " + this);
            mTurnOnScreen = true;
        }

        if (isConfigChanged()) {
            final Configuration globalConfig = mService.mRoot.getConfiguration();
            final Configuration overrideConfig = getMergedOverrideConfiguration();
@@ -4348,9 +4360,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        mLastVisibleLayoutRotation = getDisplayContent().getRotation();

        mWinAnimator.mEnteringAnimation = true;
        if (!wasVisible) {
            prepareWindowToDisplayDuringRelayout(mergedConfiguration);
        }

        prepareWindowToDisplayDuringRelayout(mergedConfiguration, wasVisible);

        if ((attrChanges & FORMAT_CHANGED) != 0) {
            // If the format can't be changed in place, preserve the old surface until the app draws
            // on the new one. This prevents blinking when we change elevation of freeform and
+18 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.wm;

import android.util.MergedConfiguration;
import android.view.WindowManager;
import org.junit.Test;
import org.junit.runner.RunWith;

@@ -204,4 +206,20 @@ public class WindowStateTests extends WindowTestsBase {
        assertEquals(mediaChild, windows.pollFirst());
        assertTrue(windows.isEmpty());
    }

    @Test
    public void testPrepareWindowToDisplayDuringRelayout() throws Exception {
        testPrepareWindowToDisplayDuringRelayout(false /*wasVisible*/);
        testPrepareWindowToDisplayDuringRelayout(true /*wasVisible*/);
    }

    private void testPrepareWindowToDisplayDuringRelayout(boolean wasVisible) {
        final WindowState root = createWindow(null, TYPE_APPLICATION, "root");
        root.mAttrs.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
        root.mTurnOnScreen = false;

        root.prepareWindowToDisplayDuringRelayout(new MergedConfiguration(),
                wasVisible /*wasVisible*/);
        assertTrue(root.mTurnOnScreen);
    }
}