From d0443e345709a32e145f64becd8554265d737015 Mon Sep 17 00:00:00 2001 From: Dave Mankoff Date: Mon, 13 Apr 2020 16:15:20 -0400 Subject: [PATCH] Remove VisualStabilityManager from rom NSSL Remove VisualStabilityManager from NotificationStackScrollLayout and put it in the NotificationStackScrollLayoutController. Bug: 147245740 Test: atest SystemUITests Change-Id: I29f068ad275d6aeedc1d2093ce6b322125bcefc2 --- .../stack/NotificationStackScrollLayout.java | 22 ------------ ...tificationStackScrollLayoutController.java | 34 ++++++++++++++----- .../NotificationStackScrollLayoutTest.java | 1 - ...tificationStackScrollerControllerTest.java | 7 ++-- 4 files changed, 30 insertions(+), 34 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index 7a12464bd4ff6..64a6114c5e1a5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -453,8 +453,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable private final DisplayMetrics mDisplayMetrics = Dependency.get(DisplayMetrics.class); private final LockscreenGestureLogger mLockscreenGestureLogger = Dependency.get(LockscreenGestureLogger.class); - private final VisualStabilityManager mVisualStabilityManager = - Dependency.get(VisualStabilityManager.class); protected boolean mClearAllEnabled; private Interpolator mHideXInterpolator = Interpolators.FAST_OUT_SLOW_IN; @@ -580,9 +578,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable if (mFgsSectionView != null) { return; } - mFgsSectionView = fgsSectionView; - addView(mFgsSectionView, -1); } @@ -603,7 +599,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable inflateEmptyShadeView(); inflateFooterView(); - mVisualStabilityManager.setVisibilityLocationProvider(this::isInVisibleLocation); } /** @@ -1020,23 +1015,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mScrollAnchorView = scrollAnchorView; } - @ShadeViewRefactor(RefactorComponent.LAYOUT_ALGORITHM) - public boolean isInVisibleLocation(NotificationEntry entry) { - ExpandableNotificationRow row = entry.getRow(); - ExpandableViewState childViewState = row.getViewState(); - - if (childViewState == null) { - return false; - } - if ((childViewState.location & ExpandableViewState.VISIBLE_LOCATIONS) == 0) { - return false; - } - if (row.getVisibility() != View.VISIBLE) { - return false; - } - return true; - } - @ShadeViewRefactor(RefactorComponent.LAYOUT_ALGORITHM) private void setMaxLayoutHeight(int maxLayoutHeight) { mMaxLayoutHeight = maxLayoutHeight; 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 231ff2cec8f5d..4da44970a5489 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 @@ -85,6 +85,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy; import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy.NotificationGroup; import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy.OnGroupChangeListener; +import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager; import com.android.systemui.statusbar.notification.collection.notifcollection.DismissedByUserStats; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener; import com.android.systemui.statusbar.notification.collection.render.GroupExpansionManager; @@ -139,7 +140,6 @@ public class NotificationStackScrollLayoutController { private final ZenModeController mZenModeController; private final MetricsLogger mMetricsLogger; private final FalsingManager mFalsingManager; - private final NotificationSectionsManager mNotificationSectionsManager; private final Resources mResources; private final NotificationSwipeHelper.Builder mNotificationSwipeHelperBuilder; private final ScrimController mScrimController; @@ -153,6 +153,7 @@ public class NotificationStackScrollLayoutController { private final ForegroundServiceSectionController mFgServicesSectionController; private final LayoutInflater mLayoutInflater; private final NotificationRemoteInputManager mRemoteInputManager; + private final VisualStabilityManager mVisualStabilityManager; private final KeyguardMediaController mKeyguardMediaController; private final SysuiStatusBarStateController mStatusBarStateController; private final KeyguardBypassController mKeyguardBypassController; @@ -559,7 +560,6 @@ public class NotificationStackScrollLayoutController { NotificationLockscreenUserManager lockscreenUserManager, MetricsLogger metricsLogger, FalsingManager falsingManager, - NotificationSectionsManager notificationSectionsManager, @Main Resources resources, NotificationSwipeHelper.Builder notificationSwipeHelperBuilder, StatusBar statusBar, @@ -576,7 +576,8 @@ public class NotificationStackScrollLayoutController { ForegroundServiceDismissalFeatureController fgFeatureController, ForegroundServiceSectionController fgServicesSectionController, LayoutInflater layoutInflater, - NotificationRemoteInputManager remoteInputManager) { + NotificationRemoteInputManager remoteInputManager, + VisualStabilityManager visualStabilityManager) { mAllowLongPress = allowLongPress; mNotificationGutsManager = notificationGutsManager; mHeadsUpManager = headsUpManager; @@ -592,14 +593,12 @@ public class NotificationStackScrollLayoutController { mLockscreenUserManager = lockscreenUserManager; mMetricsLogger = metricsLogger; mFalsingManager = falsingManager; - mNotificationSectionsManager = notificationSectionsManager; mResources = resources; mNotificationSwipeHelperBuilder = notificationSwipeHelperBuilder; mStatusBar = statusBar; mScrimController = scrimController; - groupManager.registerGroupExpansionChangeListener((changedRow, expanded) -> { - mView.onGroupExpandChanged(changedRow, expanded); - }); + groupManager.registerGroupExpansionChangeListener( + (changedRow, expanded) -> mView.onGroupExpandChanged(changedRow, expanded)); legacyGroupManager.registerGroupChangeListener(new OnGroupChangeListener() { @Override public void onGroupCreatedFromChildren(NotificationGroup group) { @@ -622,6 +621,7 @@ public class NotificationStackScrollLayoutController { mFgServicesSectionController = fgServicesSectionController; mLayoutInflater = layoutInflater; mRemoteInputManager = remoteInputManager; + mVisualStabilityManager = visualStabilityManager; } public void attach(NotificationStackScrollLayout view) { @@ -681,6 +681,8 @@ public class NotificationStackScrollLayoutController { mNotificationRoundnessManager.setOnRoundingChangedCallback(mView::invalidate); mView.addOnExpandedHeightChangedListener(mNotificationRoundnessManager::setExpanded); + mVisualStabilityManager.setVisibilityLocationProvider(this::isInVisibleLocation); + mTunerService.addTunable( (key, newValue) -> { switch (key) { @@ -723,6 +725,22 @@ public class NotificationStackScrollLayoutController { mSilentHeaderController.setOnClearAllClickListener(v -> clearSilentNotifications()); } + private boolean isInVisibleLocation(NotificationEntry entry) { + ExpandableNotificationRow row = entry.getRow(); + ExpandableViewState childViewState = row.getViewState(); + + if (childViewState == null) { + return false; + } + if ((childViewState.location & ExpandableViewState.VISIBLE_LOCATIONS) == 0) { + return false; + } + if (row.getVisibility() != View.VISIBLE) { + return false; + } + return true; + } + public void addOnExpandedHeightChangedListener(BiConsumer listener) { mView.addOnExpandedHeightChangedListener(listener); } @@ -1459,7 +1477,7 @@ public class NotificationStackScrollLayoutController { @Override public boolean isInVisibleLocation(NotificationEntry entry) { - return mView.isInVisibleLocation(entry); + return NotificationStackScrollLayoutController.this.isInVisibleLocation(entry); } @Override diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index 0d283ce039608..1ed9a5cd81f4c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -117,7 +117,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { 1, UserHandle.USER_CURRENT); // Inject dependencies before initializing the layout - mDependency.injectMockDependency(VisualStabilityManager.class); mDependency.injectTestDependency( NotificationBlockingHelperManager.class, mBlockingHelperManager); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java index d83417638cc57..9e9fa8816fdce 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java @@ -60,6 +60,7 @@ import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.NotifCollection; import com.android.systemui.statusbar.notification.collection.NotifPipeline; import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy; +import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager; import com.android.systemui.statusbar.notification.collection.render.SectionHeaderController; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.ForegroundServiceDungeonView; @@ -105,7 +106,6 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase { @Mock private NotificationLockscreenUserManager mNotificationLockscreenUserManager; @Mock private MetricsLogger mMetricsLogger; @Mock private FalsingManager mFalsingManager; - @Mock private NotificationSectionsManager mNotificationSectionsManager; @Mock private Resources mResources; @Mock(answer = Answers.RETURNS_SELF) private NotificationSwipeHelper.Builder mNotificationSwipeHelperBuilder; @@ -126,6 +126,7 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase { @Mock private LayoutInflater mLayoutInflater; @Mock private NotificationRemoteInputManager mRemoteInputManager; @Mock private RemoteInputController mRemoteInputController; + @Mock private VisualStabilityManager mVisualStabilityManager; @Captor private ArgumentCaptor mStateListenerArgumentCaptor; @@ -158,7 +159,6 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase { mNotificationLockscreenUserManager, mMetricsLogger, mFalsingManager, - mNotificationSectionsManager, mResources, mNotificationSwipeHelperBuilder, mStatusBar, @@ -175,7 +175,8 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase { mFgFeatureController, mFgServicesSectionController, mLayoutInflater, - mRemoteInputManager + mRemoteInputManager, + mVisualStabilityManager ); when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(true);