From a036c1127be026e6c865a50a9142a026c673bc64 Mon Sep 17 00:00:00 2001 From: Dave Mankoff Date: Mon, 13 Apr 2020 18:05:44 -0400 Subject: [PATCH] Remove ShadeController from NSSL Remove ShadeController from NotificationStackScrollLayout and move it into the NotificationStackScrollLayoutController. This removes the last call to Depedency.get from the NSSL, (and its controller). Bug: 147245740 Test: atest SystemUITests && manual Change-Id: I2eeaee6273a2bec933126051a722ad0659bcec49 --- .../stack/NotificationStackScrollLayout.java | 16 ++++++++++------ .../NotificationStackScrollLayoutController.java | 11 ++++++++--- .../stack/NotificationStackScrollLayoutTest.java | 8 ++++---- .../NotificationStackScrollerControllerTest.java | 5 ++++- 4 files changed, 26 insertions(+), 14 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 3092b76e93460..500de2d29d03a 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 @@ -448,6 +448,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable private DismissListener mDismissListener; private DismissAllAnimationListener mDismissAllAnimationListener; private NotificationRemoteInputManager mRemoteInputManager; + private ShadeController mShadeController; private final DisplayMetrics mDisplayMetrics = Dependency.get(DisplayMetrics.class); private final LockscreenGestureLogger mLockscreenGestureLogger = @@ -5341,9 +5342,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable } if (viewsToRemove.isEmpty()) { - if (closeShade) { - Dependency.get(ShadeController.class).animateCollapsePanels( - CommandQueue.FLAG_EXCLUDE_NONE); + if (closeShade && mShadeController != null) { + mShadeController.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); } return; } @@ -5379,11 +5379,11 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable final Runnable onSlideAwayAnimationComplete = () -> { if (closeShade) { - Dependency.get(ShadeController.class).addPostCollapseAction(() -> { + mShadeController.addPostCollapseAction(() -> { setDismissAllInProgress(false); onAnimationComplete.run(); }); - Dependency.get(ShadeController.class).animateCollapsePanels( + mShadeController.animateCollapsePanels( CommandQueue.FLAG_EXCLUDE_NONE); } else { setDismissAllInProgress(false); @@ -5667,6 +5667,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mRemoteInputManager = remoteInputManager; } + void setShadeController(ShadeController shadeController) { + mShadeController = shadeController; + } + /** * A listener that is notified when the empty space below the notifications is clicked on */ @@ -6066,7 +6070,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable if (!mAmbientState.isDozing() || startingChild != null) { // We have notifications, go to locked shade. - Dependency.get(ShadeController.class).goToLockedShade(startingChild); + mShadeController.goToLockedShade(startingChild); if (startingChild instanceof ExpandableNotificationRow) { ExpandableNotificationRow row = (ExpandableNotificationRow) startingChild; row.onExpandedByGesture(true /* drag down is always an open */); 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 bfbae4e3e1c59..ab241e6721eea 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 @@ -21,11 +21,11 @@ import static android.service.notification.NotificationStats.DISMISS_SENTIMENT_N import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME; import static com.android.systemui.statusbar.StatusBarState.KEYGUARD; -import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_GENTLE; -import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_HIGH_PRIORITY; import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.OnEmptySpaceClickListener; import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.OnOverscrollTopChangedListener; import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_ALL; +import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_GENTLE; +import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_HIGH_PRIORITY; import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.SelectedRows; import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.canChildBeDismissed; import static com.android.systemui.statusbar.phone.NotificationIconAreaController.HIGH_PRIORITY; @@ -106,6 +106,7 @@ import com.android.systemui.statusbar.phone.HeadsUpTouchHelper; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.NotificationPanelViewController; import com.android.systemui.statusbar.phone.ScrimController; +import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; import com.android.systemui.statusbar.policy.ConfigurationController; @@ -156,6 +157,7 @@ public class NotificationStackScrollLayoutController { private final NotificationRemoteInputManager mRemoteInputManager; private final VisualStabilityManager mVisualStabilityManager; private final NotificationBlockingHelperManager mNotificationBlockingHelperManager; + private final ShadeController mShadeController; private final KeyguardMediaController mKeyguardMediaController; private final SysuiStatusBarStateController mStatusBarStateController; private final KeyguardBypassController mKeyguardBypassController; @@ -580,7 +582,8 @@ public class NotificationStackScrollLayoutController { LayoutInflater layoutInflater, NotificationRemoteInputManager remoteInputManager, VisualStabilityManager visualStabilityManager, - NotificationBlockingHelperManager notificationBlockingHelperManager) { + NotificationBlockingHelperManager notificationBlockingHelperManager, + ShadeController shadeController) { mAllowLongPress = allowLongPress; mNotificationGutsManager = notificationGutsManager; mHeadsUpManager = headsUpManager; @@ -626,6 +629,7 @@ public class NotificationStackScrollLayoutController { mRemoteInputManager = remoteInputManager; mVisualStabilityManager = visualStabilityManager; mNotificationBlockingHelperManager = notificationBlockingHelperManager; + mShadeController = shadeController; } public void attach(NotificationStackScrollLayout view) { @@ -639,6 +643,7 @@ public class NotificationStackScrollLayoutController { mView.setFooterDismissListener(() -> mMetricsLogger.action(MetricsEvent.ACTION_DISMISS_ALL_NOTES)); mView.setRemoteInputManager(mRemoteInputManager); + mView.setShadeController(mShadeController); if (mFgFeatureController.isForegroundServiceDismissalEnabled()) { mView.initializeForegroundServiceSection( 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 a2a6514f4b571..5bef2573b48a1 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 @@ -3,7 +3,10 @@ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,7 +34,6 @@ import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -75,8 +77,6 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; -import java.util.function.BiConsumer; - /** * Tests for {@link NotificationStackScrollLayout}. */ 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 969805f61c9a3..74a57bf7cc55a 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 @@ -71,6 +71,7 @@ import com.android.systemui.statusbar.notification.stack.NotificationStackScroll import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.ScrimController; +import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.ZenModeController; @@ -132,6 +133,7 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase { @Mock private RemoteInputController mRemoteInputController; @Mock private VisualStabilityManager mVisualStabilityManager; @Mock private NotificationBlockingHelperManager mNotificationBlockingHelperManager; + @Mock private ShadeController mShadeController; @Captor private ArgumentCaptor mStateListenerArgumentCaptor; @@ -182,7 +184,8 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase { mLayoutInflater, mRemoteInputManager, mVisualStabilityManager, - mNotificationBlockingHelperManager + mNotificationBlockingHelperManager, + mShadeController ); when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(true);