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

Commit 42032812 authored by Tiger's avatar Tiger
Browse files

Play insets animation while forcibly showing system bars

Before this CL, when a system bar is being forcibly shown, InsetsPolicy
would set the control target to null, which just resets the leash
without any animation. This CL sets the proper control target and uses
the InsetsController to play insets animations.

This CL also applies the same logic to the transient bars of immersive
mode.

Fix: 283738201
Test: InsetsPolicyTest
Test: Open an app from kid space, and see if navigation bar is shown
      with animation.
Test: Send a Chat message to a device which is in immersive mode, and
      see if status bar is shown with animation.
Change-Id: I8178a9cabfa62a3942ca6ff51b31df22c0d570d3
parent 8e94c281
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -841,7 +841,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        return mLastDispatchedState;
    }

    @VisibleForTesting
    public boolean onStateChanged(InsetsState state) {
        boolean stateChanged = false;
        if (!CAPTION_ON_SHELL) {
+149 −192

File changed.

Preview size limit exceeded, changes collapsed.

+0 −13
Original line number Diff line number Diff line
@@ -31,17 +31,12 @@ import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.verify;

import android.app.StatusBarManager;
@@ -268,8 +263,6 @@ public class InsetsPolicyTest extends WindowTestsBase {
        navBar.setHasSurface(true);
        navBarProvider.setServerVisible(true);
        final InsetsPolicy policy = mDisplayContent.getInsetsPolicy();
        spyOn(policy);
        doNothing().when(policy).startAnimation(anyBoolean(), any());

        // Make both system bars invisible.
        mAppWindow.setRequestedVisibleTypes(
@@ -305,8 +298,6 @@ public class InsetsPolicyTest extends WindowTestsBase {
        addNavigationBar().getControllableInsetProvider().setServerVisible(true);

        final InsetsPolicy policy = mDisplayContent.getInsetsPolicy();
        spyOn(policy);
        doNothing().when(policy).startAnimation(anyBoolean(), any());
        policy.updateBarControlTarget(mAppWindow);
        policy.showTransient(navigationBars() | statusBars(),
                true /* isGestureOnSystemBar */);
@@ -341,8 +332,6 @@ public class InsetsPolicyTest extends WindowTestsBase {
        mAppWindow.mAboveInsetsState.addSource(navBarSource);
        mAppWindow.mAboveInsetsState.addSource(statusBarSource);
        final InsetsPolicy policy = mDisplayContent.getInsetsPolicy();
        spyOn(policy);
        doNothing().when(policy).startAnimation(anyBoolean(), any());
        policy.updateBarControlTarget(mAppWindow);
        policy.showTransient(navigationBars() | statusBars(),
                true /* isGestureOnSystemBar */);
@@ -390,8 +379,6 @@ public class InsetsPolicyTest extends WindowTestsBase {
        final WindowState app2 = addWindow(TYPE_APPLICATION, "app");

        final InsetsPolicy policy = mDisplayContent.getInsetsPolicy();
        spyOn(policy);
        doNothing().when(policy).startAnimation(anyBoolean(), any());
        policy.updateBarControlTarget(app);
        policy.showTransient(navigationBars() | statusBars(),
                true /* isGestureOnSystemBar */);
+4 −0
Original line number Diff line number Diff line
@@ -77,6 +77,10 @@ class TestDisplayContent extends DisplayContent {
        spyOn(inputMonitor);
        doNothing().when(inputMonitor).resumeDispatchingLw(any());

        final InsetsPolicy insetsPolicy = getInsetsPolicy();
        WindowTestsBase.suppressInsetsAnimation(insetsPolicy.getPermanentControlTarget());
        WindowTestsBase.suppressInsetsAnimation(insetsPolicy.getTransientControlTarget());

        // For devices that set the sysprop ro.bootanim.set_orientation_<display_id>
        // See DisplayRotation#readDefaultDisplayRotation for context.
        // Without that, meaning of height and width in context of the tests can be swapped if
+13 −0
Original line number Diff line number Diff line
@@ -222,6 +222,10 @@ class WindowTestsBase extends SystemServiceTestsBase {
        displayPolicy.finishWindowsDrawn();
        displayPolicy.finishScreenTurningOn();

        final InsetsPolicy insetsPolicy = mDefaultDisplay.getInsetsPolicy();
        suppressInsetsAnimation(insetsPolicy.getTransientControlTarget());
        suppressInsetsAnimation(insetsPolicy.getPermanentControlTarget());

        mTransaction = mSystemServicesTestRule.mTransaction;
        mMockSession = mock(Session.class);

@@ -278,6 +282,15 @@ class WindowTestsBase extends SystemServiceTestsBase {
        checkDeviceSpecificOverridesNotApplied();
    }

    /**
     * The test doesn't create real SurfaceControls, but mocked ones. This prevents the target from
     * controlling them, or it will cause {@link NullPointerException}.
     */
    static void suppressInsetsAnimation(InsetsControlTarget target) {
        spyOn(target);
        Mockito.doNothing().when(target).notifyInsetsControlChanged();
    }

    @After
    public void tearDown() throws Exception {
        if (mUseFakeSettingsProvider) {