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

Commit af95ce5b authored by Winson Chung's avatar Winson Chung
Browse files

Don't factor animating-to-sleep for nav bar visibility

- Instead, just animate the current nav bar view (which doesn't cause
  insets changes).  This should be safe to do because:
  1) Nothing else animates the alpha of this particular part of the
     view hierarchy
  2) Confirmed with SysUI folks that we always get onStartedWakingUp
     after onStartedGoingToSleep
  3) This otherwise reverts to the same nav bar visibility logic in R

Bug: 196789451
Bug: 190368572
Test: atest StatusBarKeyguardViewManagerTest
Test: In three button nav w/ AOD, turn off the screen
      - also try above with interrupting the screen off animation
      - also try above with power button instantly locks disabled
Change-Id: I1be44a9a8dbb8cea17bbf354a2e03dd4bad5a4a2
parent 9e310df1
Loading
Loading
Loading
Loading
+38 −20
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dock.DockManager;
import com.android.systemui.keyguard.FaceAuthScreenBrightnessController;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.navigationbar.NavigationBarView;
import com.android.systemui.navigationbar.NavigationModeController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.shared.system.QuickStepContract;
@@ -92,7 +93,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    // with the appear animations of the PIN/pattern/password views.
    private static final long NAV_BAR_SHOW_DELAY_BOUNCER = 320;

    private static final long WAKE_AND_UNLOCK_SCRIM_FADEOUT_DURATION_MS = 200;
    // The duration to fade the nav bar content in/out when the device starts to sleep
    private static final long NAV_BAR_CONTENT_FADE_DURATION = 125;

    // Duration of the Keyguard dismissal animation in case the user is currently locked. This is to
    // make everything a bit slower to bridge a gap until the user is unlocked and home screen has
@@ -194,10 +196,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    private boolean mLastGesturalNav;
    private boolean mLastIsDocked;
    private boolean mLastPulsing;
    private boolean mLastAnimatedToSleep;
    private int mLastBiometricMode;
    private boolean mQsExpanded;
    private boolean mAnimatedToSleep;

    private OnDismissAction mAfterKeyguardGoneAction;
    private Runnable mKeyguardGoneCancelAction;
@@ -320,20 +320,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
            mDockManager.addListener(mDockEventListener);
            mIsDocked = mDockManager.isDocked();
        }
        mWakefulnessLifecycle.addObserver(new WakefulnessLifecycle.Observer() {
            @Override
            public void onFinishedWakingUp() {
                mAnimatedToSleep = false;
                updateStates();
            }

            @Override
            public void onFinishedGoingToSleep() {
                mAnimatedToSleep =
                        mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying();
                updateStates();
            }
        });
    }

    @Override
@@ -566,12 +552,26 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    public void onStartedWakingUp() {
        mStatusBar.getNotificationShadeWindowView().getWindowInsetsController()
                .setAnimationsDisabled(false);
        View currentView = getCurrentNavBarView();
        if (currentView != null) {
            currentView.animate()
                    .alpha(1f)
                    .setDuration(NAV_BAR_CONTENT_FADE_DURATION)
                    .start();
        }
    }

    @Override
    public void onStartedGoingToSleep() {
        mStatusBar.getNotificationShadeWindowView().getWindowInsetsController()
                .setAnimationsDisabled(true);
        View currentView = getCurrentNavBarView();
        if (currentView != null) {
            currentView.animate()
                    .alpha(0f)
                    .setDuration(NAV_BAR_CONTENT_FADE_DURATION)
                    .start();
        }
    }

    @Override
@@ -993,10 +993,28 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        mLastBiometricMode = mBiometricUnlockController.getMode();
        mLastGesturalNav = mGesturalNav;
        mLastIsDocked = mIsDocked;
        mLastAnimatedToSleep = mAnimatedToSleep;
        mStatusBar.onKeyguardViewManagerStatesUpdated();
    }

    /**
     * Updates the visibility of the nav bar content views.
     */
    private void updateNavigationBarContentVisibility(boolean navBarContentVisible) {
        final NavigationBarView navBarView = mStatusBar.getNavigationBarView();
        if (navBarView != null && navBarView.getCurrentView() != null) {
            final View currentView = navBarView.getCurrentView();
            currentView.setVisibility(navBarContentVisible ? View.VISIBLE : View.INVISIBLE);
        }
    }

    private View getCurrentNavBarView() {
        final NavigationBarView navBarView = mStatusBar.getNavigationBarView();
        return navBarView != null ? navBarView.getCurrentView() : null;
    }

    /**
     * Updates the visibility of the nav bar window (which will cause insets changes).
     */
    protected void updateNavigationBarVisibility(boolean navBarVisible) {
        if (mStatusBar.getNavigationBarView() != null) {
            if (navBarVisible) {
@@ -1024,7 +1042,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        boolean hideWhileDozing = mDozing && biometricMode != MODE_WAKE_AND_UNLOCK_PULSING;
        boolean keyguardWithGestureNav = (keyguardShowing && !mDozing || mPulsing && !mIsDocked)
                && mGesturalNav;
        return (!mAnimatedToSleep && !keyguardShowing && !hideWhileDozing || mBouncer.isShowing()
        return (!keyguardShowing && !hideWhileDozing || mBouncer.isShowing()
                || mRemoteInputActive || keyguardWithGestureNav
                || mGlobalActionsVisible);
    }
@@ -1037,7 +1055,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        boolean hideWhileDozing = mLastDozing && mLastBiometricMode != MODE_WAKE_AND_UNLOCK_PULSING;
        boolean keyguardWithGestureNav = (keyguardShowing && !mLastDozing
                || mLastPulsing && !mLastIsDocked) && mLastGesturalNav;
        return (!mLastAnimatedToSleep && !keyguardShowing && !hideWhileDozing || mLastBouncerShowing
        return (!keyguardShowing && !hideWhileDozing || mLastBouncerShowing
                || mLastRemoteInputActive || keyguardWithGestureNav
                || mLastGlobalActionsVisible);
    }
+0 −14
Original line number Diff line number Diff line
@@ -299,18 +299,4 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {

        verify(mBouncer).updateKeyguardPosition(1.0f);
    }

    @Test
    public void testNavBarHiddenWhenSleepAnimationStarts() {
        mStatusBarKeyguardViewManager.hide(0 /* startTime */, 0 /* fadeoutDuration */);
        assertTrue(mStatusBarKeyguardViewManager.isNavBarVisible());

        // Verify that the nav bar is hidden when the screen off animation starts
        doReturn(true).when(mUnlockedScreenOffAnimationController).isScreenOffAnimationPlaying();
        mWakefulnessLifecycle.dispatchFinishedGoingToSleep();
        assertFalse(mStatusBarKeyguardViewManager.isNavBarVisible());

        mWakefulnessLifecycle.dispatchFinishedWakingUp();
        assertTrue(mStatusBarKeyguardViewManager.isNavBarVisible());
    }
}