From c0f5aea4e5cd0870c8729a02f34e56caabad222d Mon Sep 17 00:00:00 2001 From: Steve Elliott Date: Fri, 13 Aug 2021 14:18:33 -0400 Subject: [PATCH] Move KeyguardBypassController from RoundnessManager to NSSLCtrlr Part of an effort to refactor NSSL for uni-directional data flow. Bug: 193539698 Test: manual, atest Change-Id: Ic188828918fd3a803962f6d48e370cf373f3c50a --- .../stack/NotificationRoundnessManager.java | 28 +++++++++---------- ...tificationStackScrollLayoutController.java | 5 ++++ .../NotificationRoundnessManagerTest.java | 6 +--- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java index 23aefd9bfd8e4..2619905fbcc0e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java @@ -24,7 +24,6 @@ import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.statusbar.notification.NotificationSectionsFeatureManager; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.ExpandableView; -import com.android.systemui.statusbar.phone.KeyguardBypassController; import java.util.HashSet; @@ -40,27 +39,24 @@ public class NotificationRoundnessManager { private final ExpandableView[] mLastInSectionViews; private final ExpandableView[] mTmpFirstInSectionViews; private final ExpandableView[] mTmpLastInSectionViews; - private final KeyguardBypassController mBypassController; private boolean mExpanded; private HashSet mAnimatedChildren; private Runnable mRoundingChangedCallback; private ExpandableNotificationRow mTrackedHeadsUp; private float mAppearFraction; + private boolean mRoundForPulsingViews; private ExpandableView mSwipedView = null; private ExpandableView mViewBeforeSwipedView = null; private ExpandableView mViewAfterSwipedView = null; @Inject - NotificationRoundnessManager( - KeyguardBypassController keyguardBypassController, - NotificationSectionsFeatureManager sectionsFeatureManager) { + NotificationRoundnessManager(NotificationSectionsFeatureManager sectionsFeatureManager) { int numberOfSections = sectionsFeatureManager.getNumberOfBuckets(); mFirstInSectionViews = new ExpandableView[numberOfSections]; mLastInSectionViews = new ExpandableView[numberOfSections]; mTmpFirstInSectionViews = new ExpandableView[numberOfSections]; mTmpLastInSectionViews = new ExpandableView[numberOfSections]; - mBypassController = keyguardBypassController; } public void updateView(ExpandableView view, boolean animate) { @@ -85,8 +81,8 @@ public class NotificationRoundnessManager { return false; } - final float topRoundness = getRoundness(view, true /* top */); - final float bottomRoundness = getRoundness(view, false /* top */); + final float topRoundness = getRoundnessFraction(view, true /* top */); + final float bottomRoundness = getRoundnessFraction(view, false /* top */); final boolean topChanged = view.setTopRoundness(topRoundness, animate); final boolean bottomChanged = view.setBottomRoundness(bottomRoundness, animate); @@ -131,7 +127,7 @@ public class NotificationRoundnessManager { ExpandableView oldViewBefore = mViewBeforeSwipedView; mViewBeforeSwipedView = viewBefore; if (oldViewBefore != null) { - final float bottomRoundness = getRoundness(oldViewBefore, false /* top */); + final float bottomRoundness = getRoundnessFraction(oldViewBefore, false /* top */); oldViewBefore.setBottomRoundness(bottomRoundness, animate); } if (viewBefore != null) { @@ -141,8 +137,8 @@ public class NotificationRoundnessManager { ExpandableView oldSwipedview = mSwipedView; mSwipedView = viewSwiped; if (oldSwipedview != null) { - final float bottomRoundness = getRoundness(oldSwipedview, false /* top */); - final float topRoundness = getRoundness(oldSwipedview, true /* top */); + final float bottomRoundness = getRoundnessFraction(oldSwipedview, false /* top */); + final float topRoundness = getRoundnessFraction(oldSwipedview, true /* top */); oldSwipedview.setTopRoundness(topRoundness, animate); oldSwipedview.setBottomRoundness(bottomRoundness, animate); } @@ -154,7 +150,7 @@ public class NotificationRoundnessManager { ExpandableView oldViewAfter = mViewAfterSwipedView; mViewAfterSwipedView = viewAfter; if (oldViewAfter != null) { - final float topRoundness = getRoundness(oldViewAfter, true /* top */); + final float topRoundness = getRoundnessFraction(oldViewAfter, true /* top */); oldViewAfter.setTopRoundness(topRoundness, animate); } if (viewAfter != null) { @@ -162,7 +158,7 @@ public class NotificationRoundnessManager { } } - private float getRoundness(ExpandableView view, boolean top) { + private float getRoundnessFraction(ExpandableView view, boolean top) { if (view == null) { return 0f; } @@ -186,7 +182,7 @@ public class NotificationRoundnessManager { // rounded. return MathUtils.saturate(1.0f - mAppearFraction); } - if (view.showingPulsing() && !mBypassController.getBypassEnabled()) { + if (view.showingPulsing() && mRoundForPulsingViews) { return 1.0f; } final Resources resources = view.getResources(); @@ -289,4 +285,8 @@ public class NotificationRoundnessManager { updateView(previous, true /* animate */); } } + + public void setShouldRoundPulsingViews(boolean shouldRoundPulsingViews) { + mRoundForPulsingViews = shouldRoundPulsingViews; + } } 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 04129b52b4ea3..5b0faf63df609 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 @@ -698,6 +698,11 @@ public class NotificationStackScrollLayoutController { }); mView.setShadeController(mShadeController); + mKeyguardBypassController.registerOnBypassStateChangedListener( + isEnabled -> mNotificationRoundnessManager.setShouldRoundPulsingViews(!isEnabled)); + mNotificationRoundnessManager.setShouldRoundPulsingViews( + !mKeyguardBypassController.getBypassEnabled()); + if (mFgFeatureController.isForegroundServiceDismissalEnabled()) { mView.initializeForegroundServiceSection( (ForegroundServiceDungeonView) mFgServicesSectionController.createView( diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManagerTest.java index 0772c03d10d02..d3c1dc9db218b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManagerTest.java @@ -37,14 +37,12 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.ExpandableView; import com.android.systemui.statusbar.notification.row.NotificationTestHelper; -import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.util.DeviceConfigProxy; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.util.HashSet; @@ -59,8 +57,6 @@ public class NotificationRoundnessManagerTest extends SysuiTestCase { private Runnable mRoundnessCallback = mock(Runnable.class); private ExpandableNotificationRow mFirst; private ExpandableNotificationRow mSecond; - @Mock - private KeyguardBypassController mBypassController; private float mSmallRadiusRatio; @Before @@ -70,7 +66,6 @@ public class NotificationRoundnessManagerTest extends SysuiTestCase { mSmallRadiusRatio = resources.getDimension(R.dimen.notification_corner_radius_small) / resources.getDimension(R.dimen.notification_corner_radius); mRoundnessManager = new NotificationRoundnessManager( - mBypassController, new NotificationSectionsFeatureManager(new DeviceConfigProxy(), mContext)); allowTestableLooperAsMainThread(); NotificationTestHelper testHelper = new NotificationTestHelper( @@ -90,6 +85,7 @@ public class NotificationRoundnessManagerTest extends SysuiTestCase { createSection(null, null) }); mRoundnessManager.setExpanded(1.0f, 1.0f); + mRoundnessManager.setShouldRoundPulsingViews(true); reset(mRoundnessCallback); }