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

Commit 98fcae42 authored by Evan Rosky's avatar Evan Rosky Committed by Automerger Merge Worker
Browse files

Merge "Make WindowState.isVisibleRequested actually report requested" into...

Merge "Make WindowState.isVisibleRequested actually report requested" into sc-v2-dev am: 33e7c4c6 am: 40f497c3

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

Change-Id: I013ddf48a0810dfeff992685cee9705cceb2c93f
parents c4f2cef8 40f497c3
Loading
Loading
Loading
Loading
+22 −6
Original line number Diff line number Diff line
@@ -1842,21 +1842,27 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return super.hasContentToDisplay();
    }

    @Override
    boolean isVisible() {
        return wouldBeVisibleIfPolicyIgnored() && isVisibleByPolicy()
    private boolean isVisibleByPolicyOrInsets() {
        return isVisibleByPolicy()
                // If we don't have a provider, this window isn't used as a window generating
                // insets, so nobody can hide it over the inset APIs.
                && (mControllableInsetProvider == null
                        || mControllableInsetProvider.isClientVisible());
    }

    @Override
    boolean isVisible() {
        return wouldBeVisibleIfPolicyIgnored() && isVisibleByPolicyOrInsets();
    }

    @Override
    boolean isVisibleRequested() {
        if (shouldCheckTokenVisibleRequested()) {
            return isVisible() && mToken.isVisibleRequested();
        final boolean localVisibleRequested =
                wouldBeVisibleRequestedIfPolicyIgnored() && isVisibleByPolicyOrInsets();
        if (localVisibleRequested && shouldCheckTokenVisibleRequested()) {
            return mToken.isVisibleRequested();
        }
        return isVisible();
        return localVisibleRequested;
    }

    /**
@@ -1903,6 +1909,16 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return !isWallpaper || mToken.isVisible();
    }

    private boolean wouldBeVisibleRequestedIfPolicyIgnored() {
        final WindowState parent = getParentWindow();
        final boolean isParentHiddenRequested = parent != null && !parent.isVisibleRequested();
        if (isParentHiddenRequested || mAnimatingExit || mDestroying) {
            return false;
        }
        final boolean isWallpaper = mToken.asWallpaperToken() != null;
        return !isWallpaper || mToken.isVisibleRequested();
    }

    /**
     * Is this window visible, ignoring its app token? It is not visible if there is no surface,
     * or we are in the process of running an exit animation that will remove the surface.
+15 −0
Original line number Diff line number Diff line
@@ -946,4 +946,19 @@ public class WindowStateTests extends WindowTestsBase {
        assertNotNull(state.peekSource(ITYPE_IME));
        assertTrue(state.getSource(ITYPE_IME).isVisible());
    }

    @Test
    public void testRequestedVisibility() {
        final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
        app.mActivityRecord.setVisible(false);
        app.mActivityRecord.setVisibility(false /* visible */, false /* deferHidingClient */);
        assertFalse(app.isVisibleRequested());

        // It doesn't have a surface yet, but should still be visible requested.
        app.setHasSurface(false);
        app.mActivityRecord.setVisibility(true /* visible */, false /* deferHidingClient */);

        assertFalse(app.isVisible());
        assertTrue(app.isVisibleRequested());
    }
}