From 9b53d2ecabe2472a464007dd463593f95b4e19d5 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 23 Nov 2021 06:42:28 +0000 Subject: [PATCH] Fix issue with alphas not being applied to the same view on unlock - It's possible for the nav bar configuration to change between locking and unlocking the phone, which will prevent the alpha from being restored on the bar layout correctly. This change updates the alpha of both vertical/horizontal layouts in NavBarView since they should always be in sync. Bug: 206733387 Test: atest SystemUITests Test: Lock screen in landscape app, turn screen on and unlock Change-Id: I265d04e6e2192f2bb57b1f8d77390664236427fc --- .../navigationbar/NavigationBarView.java | 19 +++++++--- .../phone/StatusBarKeyguardViewManager.java | 37 +++++++------------ 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java index 680cc5cb5cba1..364a8aea7ee4c 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java @@ -110,6 +110,7 @@ public class NavigationBarView extends FrameLayout implements private final int mNavColorSampleMargin; private final SysUiState mSysUiFlagContainer; + // The current view is one of mHorizontal or mVertical depending on the current configuration View mCurrentView = null; private View mVertical; private View mHorizontal; @@ -397,12 +398,6 @@ public class NavigationBarView extends FrameLayout implements } } - @Override - protected boolean onSetAlpha(int alpha) { - Log.e(TAG, "onSetAlpha", new Throwable()); - return super.onSetAlpha(alpha); - } - public void setAutoHideController(AutoHideController autoHideController) { mAutoHideController = autoHideController; } @@ -505,6 +500,18 @@ public class NavigationBarView extends FrameLayout implements return mCurrentView; } + /** + * Applies {@param consumer} to each of the nav bar views. + */ + public void forEachView(Consumer consumer) { + if (mVertical != null) { + consumer.accept(mVertical); + } + if (mHorizontal != null) { + consumer.accept(mHorizontal); + } + } + public RotationButtonController getRotationButtonController() { return mRotationButtonController; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index 0d23d663c51c1..e2bf0db6eb1df 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -555,12 +555,13 @@ 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(); + NavigationBarView navBarView = mStatusBar.getNavigationBarView(); + if (navBarView != null) { + navBarView.forEachView(view -> + view.animate() + .alpha(1f) + .setDuration(NAV_BAR_CONTENT_FADE_DURATION) + .start()); } } @@ -568,12 +569,13 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb 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(); + NavigationBarView navBarView = mStatusBar.getNavigationBarView(); + if (navBarView != null) { + navBarView.forEachView(view -> + view.animate() + .alpha(0f) + .setDuration(NAV_BAR_CONTENT_FADE_DURATION) + .start()); } } @@ -1015,17 +1017,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb 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;