diff options
| author | 2024-03-06 02:50:05 +0000 | |
|---|---|---|
| committer | 2024-03-09 13:54:11 +0000 | |
| commit | 2df7152d43d578d14ea2932339a5b86b0527a1d2 (patch) | |
| tree | 79d6c9eb884d5df2266044a629b004485e22b84e | |
| parent | b6bab73069a09d7e2af47c8f693fde6f592d78bc (diff) | |
[flexiglass] Fix NSSL alpha during HUN
This CL also renames `maxAlphaForExpansion` to `maxAlphaForKeyguard` since this name was very misleading, and was based on an incorrect assumption that this alpha was supposed to be used by expansion.
This also adds a dump of the NSSLController's alpha source, and when debugging, logs changes to the alpha and source.
Finally, this disables a few calls into NSSLController from legacy code, now that they are bound.
Fix: 328244289
Test: atest SystemUITests
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Change-Id: I9a9b3734a4a502bf4a6b2a3cd4baffd5f5646e4b
7 files changed, 63 insertions, 44 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index 2fd438be9610..33582d26547c 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -1197,7 +1197,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump /* excludeNotifications=*/ true), mMainDispatcher); collectFlow(mView, mPrimaryBouncerToGoneTransitionViewModel.getNotificationAlpha(), (Float alpha) -> { - mNotificationStackScrollLayoutController.setMaxAlphaForExpansion(alpha); + mNotificationStackScrollLayoutController.setMaxAlphaForKeyguard(alpha, + "mPrimaryBouncerToGoneTransitionViewModel.getNotificationAlpha()"); }, mMainDispatcher); } } @@ -2719,7 +2720,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump && !mQsController.getFullyExpanded()) { alpha *= mClockPositionResult.clockAlpha; } - mNotificationStackScrollLayoutController.setMaxAlphaForExpansion(alpha); + mNotificationStackScrollLayoutController.setMaxAlphaForKeyguard(alpha, + "NPVC.updateNotificationTranslucency()"); } } @@ -2770,7 +2772,9 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } private void onExpandingFinished() { - mNotificationStackScrollLayoutController.onExpansionStopped(); + if (!SceneContainerFlag.isEnabled()) { + mNotificationStackScrollLayoutController.onExpansionStopped(); + } mHeadsUpManager.onExpandingFinished(); mConversationNotificationManager.onNotificationPanelExpandStateChanged(isFullyCollapsed()); mIsExpandingOrCollapsing = false; @@ -3085,7 +3089,9 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump // The expandedHeight is always the full panel Height when bypassing expandedHeight = getMaxPanelHeight(); } - mNotificationStackScrollLayoutController.setExpandedHeight(expandedHeight); + if (!SceneContainerFlag.isEnabled()) { + mNotificationStackScrollLayoutController.setExpandedHeight(expandedHeight); + } updateKeyguardBottomAreaAlpha(); updateStatusBarIcons(); } @@ -4718,7 +4724,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump return (Float alpha) -> { mKeyguardStatusViewController.setAlpha(alpha); if (!excludeNotifications) { - stackScroller.setMaxAlphaForExpansion(alpha); + stackScroller.setMaxAlphaForKeyguard(alpha, "NPVC.setTransitionAlpha()"); } if (keyguardBottomAreaRefactor()) { diff --git a/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java b/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java index 19d98a0bb83c..fd68c56149db 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java @@ -76,6 +76,7 @@ import com.android.systemui.media.controls.ui.controller.MediaHierarchyManager; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.qs.QS; import com.android.systemui.res.R; +import com.android.systemui.scene.shared.flag.SceneContainerFlag; import com.android.systemui.screenrecord.RecordingController; import com.android.systemui.shade.data.repository.ShadeRepository; import com.android.systemui.shade.domain.interactor.ShadeInteractor; @@ -964,7 +965,9 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum // Reset scroll position and apply that position to the expanded height. float height = mExpansionHeight; setExpansionHeight(height); - mNotificationStackScrollLayoutController.checkSnoozeLeavebehind(); + if (!SceneContainerFlag.isEnabled()) { + mNotificationStackScrollLayoutController.checkSnoozeLeavebehind(); + } // When expanding QS, let's authenticate the user if possible, // this will speed up notification actions. @@ -1109,7 +1112,9 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum /** Called when shade starts expanding. */ void onExpandingStarted(boolean qsFullyExpanded) { - mNotificationStackScrollLayoutController.onExpansionStarted(); + if (!SceneContainerFlag.isEnabled()) { + mNotificationStackScrollLayoutController.onExpansionStarted(); + } mExpandedWhenExpandingStarted = qsFullyExpanded; mMediaHierarchyManager.setCollapsingShadeFromQS(mExpandedWhenExpandingStarted /* We also start expanding when flinging closed Qs. Let's exclude that */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java index 7c138776d5a5..23345495ba65 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java @@ -363,7 +363,8 @@ public class NotificationStackScrollLayoutController implements Dumpable { }; private NotifStats mNotifStats = NotifStats.getEmpty(); - private float mMaxAlphaForExpansion = 1.0f; + private float mMaxAlphaForKeyguard = 1.0f; + private String mMaxAlphaForKeyguardSource = "constructor"; private float mMaxAlphaForUnhide = 1.0f; /** @@ -1324,9 +1325,14 @@ public class NotificationStackScrollLayoutController implements Dumpable { return mView.getEmptyShadeViewHeight(); } - public void setMaxAlphaForExpansion(float alpha) { - mMaxAlphaForExpansion = alpha; + /** Set the max alpha for keyguard */ + public void setMaxAlphaForKeyguard(float alpha, String source) { + mMaxAlphaForKeyguard = alpha; + mMaxAlphaForKeyguardSource = source; updateAlpha(); + if (DEBUG) { + Log.d(TAG, "setMaxAlphaForKeyguard=" + alpha + " --- from: " + source); + } } private void setMaxAlphaForUnhide(float alpha) { @@ -1345,7 +1351,7 @@ public class NotificationStackScrollLayoutController implements Dumpable { private void updateAlpha() { if (mView != null) { - mView.setAlpha(Math.min(mMaxAlphaForExpansion, + mView.setAlpha(Math.min(mMaxAlphaForKeyguard, Math.min(mMaxAlphaForUnhide, mMaxAlphaForGlanceableHub))); } } @@ -1842,9 +1848,10 @@ public class NotificationStackScrollLayoutController implements Dumpable { @Override public void dump(@NonNull PrintWriter pw, @NonNull String[] args) { - pw.println("mMaxAlphaForExpansion=" + mMaxAlphaForExpansion); pw.println("mMaxAlphaForUnhide=" + mMaxAlphaForUnhide); pw.println("mMaxAlphaForGlanceableHub=" + mMaxAlphaForGlanceableHub); + pw.println("mMaxAlphaForKeyguard=" + mMaxAlphaForKeyguard); + pw.println("mMaxAlphaForKeyguardSource=" + mMaxAlphaForKeyguardSource); } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationStackAppearanceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationStackAppearanceViewBinder.kt index 76495cb23947..8b1b06eb1453 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationStackAppearanceViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationStackAppearanceViewBinder.kt @@ -66,15 +66,18 @@ object NotificationStackAppearanceViewBinder { } launch { + var wasExpanding = false viewModel.expandFraction.collect { expandFraction -> + val nowExpanding = expandFraction != 0f && expandFraction != 1f + if (nowExpanding && !wasExpanding) { + controller.onExpansionStarted() + } ambientState.expansionFraction = expandFraction controller.expandedHeight = expandFraction * controller.view.height - controller.setMaxAlphaForExpansion( - ((expandFraction - 0.5f) / 0.5f).coerceAtLeast(0f) - ) - if (expandFraction == 0f || expandFraction == 1f) { + if (!nowExpanding && wasExpanding) { controller.onExpansionStopped() } + wasExpanding = nowExpanding } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt index 566c0303b286..ece7a7fccc66 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt @@ -106,27 +106,26 @@ object SharedNotificationContainerBinder { val disposableHandleMainImmediate = view.repeatWhenAttached(mainImmediateDispatcher) { repeatOnLifecycle(Lifecycle.State.CREATED) { - if (!sceneContainerFlags.flexiNotifsEnabled()) { - launch { - // Only temporarily needed, until flexi notifs go live - viewModel.shadeCollapseFadeIn.collect { fadeIn -> - if (fadeIn) { - android.animation.ValueAnimator.ofFloat(0f, 1f).apply { - duration = 250 - addUpdateListener { animation -> - controller.setMaxAlphaForExpansion( - animation.getAnimatedFraction() - ) - } - addListener( - object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator) { - viewModel.setShadeCollapseFadeInComplete(true) - } - } + launch { + // Only temporarily needed, until flexi notifs go live + viewModel.shadeCollapseFadeIn.collect { fadeIn -> + if (fadeIn) { + android.animation.ValueAnimator.ofFloat(0f, 1f).apply { + duration = 250 + addUpdateListener { animation -> + controller.setMaxAlphaForKeyguard( + animation.animatedFraction, + "SharedNotificationContainerVB (collapseFadeIn)" ) - start() } + addListener( + object : AnimatorListenerAdapter() { + override fun onAnimationEnd(animation: Animator) { + viewModel.setShadeCollapseFadeInComplete(true) + } + } + ) + start() } } } @@ -164,13 +163,12 @@ object SharedNotificationContainerBinder { launch { viewModel.translationX.collect { x -> controller.translationX = x } } - if (!sceneContainerFlags.isEnabled()) { - launch { - viewModel.expansionAlpha(viewState).collect { - controller.setMaxAlphaForExpansion(it) - } + launch { + viewModel.keyguardAlpha(viewState).collect { + controller.setMaxAlphaForKeyguard(it, "SharedNotificationContainerVB") } } + launch { viewModel.glanceableHubAlpha.collect { controller.setMaxAlphaForGlanceableHub(it) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt index 78fc1471053d..39dd9d05594c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt @@ -376,7 +376,7 @@ constructor( } .dumpWhileCollecting("alphaWhenGoneAndShadeState") - fun expansionAlpha(viewState: ViewStateAccessor): Flow<Float> { + fun keyguardAlpha(viewState: ViewStateAccessor): Flow<Float> { // All transition view models are mututally exclusive, and safe to merge val alphaTransitions = merge( @@ -427,7 +427,7 @@ constructor( }, ) .distinctUntilChanged() - .dumpWhileCollecting("expansionAlpha") + .dumpWhileCollecting("keyguardAlpha") } /** diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java index d24fe1b16ef9..6d5d5be8ae57 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -854,7 +854,7 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo // We are interested in the last value of the stack alpha. ArgumentCaptor<Float> alphaCaptor = ArgumentCaptor.forClass(Float.class); verify(mNotificationStackScrollLayoutController, atLeastOnce()) - .setMaxAlphaForExpansion(alphaCaptor.capture()); + .setMaxAlphaForKeyguard(alphaCaptor.capture(), any()); assertThat(alphaCaptor.getValue()).isEqualTo(1.0f); } @@ -875,7 +875,7 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo // We are interested in the last value of the stack alpha. ArgumentCaptor<Float> alphaCaptor = ArgumentCaptor.forClass(Float.class); verify(mNotificationStackScrollLayoutController, atLeastOnce()) - .setMaxAlphaForExpansion(alphaCaptor.capture()); + .setMaxAlphaForKeyguard(alphaCaptor.capture(), any()); assertThat(alphaCaptor.getValue()).isEqualTo(0.0f); } |