summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Dave Mankoff <mankoff@google.com> 2020-04-06 15:39:48 -0400
committer Steve Elliott <steell@google.com> 2020-08-18 13:30:32 -0400
commitaa6aff0ebbbadd330872967b9abbef476b7cf79e (patch)
treecf3478cc2dabeed1bce9ddf6c7159fb32cf1be8e
parenta5041a2047a494ff049badc8c8f197eda13e963b (diff)
Move NotificationLockscreenUserManager out of NSSL
The NotificationLockscreenUserManager is no longer injected into the NotificationStackScrollLayout. It is instead supplied to NotificationStackScrollLayoutController, which registers an appropriate listener and tells the NSSL when relevant information changes. Bug: 147245740 Test: atest SystemUITests Change-Id: I4a979715e73c1c82bdd2d0759051b7e3c8814a73
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java35
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java22
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java17
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java47
4 files changed, 76 insertions, 45 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 c4f1e39b1a10..f17050a9faf8 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
@@ -95,19 +95,15 @@ import com.android.systemui.ExpandHelper;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.SwipeHelper;
-import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.OnMenuEventListener;
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper;
-import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.DragDownHelper.DragDownCallback;
import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.FeatureFlags;
-import com.android.systemui.statusbar.NotificationLockscreenUserManager;
-import com.android.systemui.statusbar.NotificationLockscreenUserManager.UserChangedListener;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.NotificationShelfController;
@@ -242,6 +238,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
private int mBottomMargin;
private int mBottomInset = 0;
private float mQsExpansionFraction;
+ private int mCurrentUserId;
/**
* The algorithm which calculates the properties for our children
@@ -341,12 +338,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
return true;
}
};
- private final UserChangedListener mLockscreenUserChangeListener = new UserChangedListener() {
- @Override
- public void onUserChanged(int userId) {
- updateSensitiveness(false /* animated */);
- }
- };
+
private StatusBar mStatusBar;
private int[] mTempInt2 = new int[2];
private boolean mGenerateChildOrderChangedEvent;
@@ -490,7 +482,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
private ArrayList<BiConsumer<Float, Float>> mExpandedHeightListeners = new ArrayList<>();
private int mHeadsUpInset;
private HeadsUpAppearanceController mHeadsUpAppearanceController;
- private final NotificationLockscreenUserManager mLockscreenUserManager;
private final Rect mTmpRect = new Rect();
private final FeatureFlags mFeatureFlags;
private final NotifPipeline mNotifPipeline;
@@ -579,7 +570,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
SysuiStatusBarStateController statusbarStateController,
HeadsUpManagerPhone headsUpManager,
FalsingManager falsingManager,
- NotificationLockscreenUserManager notificationLockscreenUserManager,
NotificationGutsManager notificationGutsManager,
NotificationSectionsManager notificationSectionsManager,
ForegroundServiceSectionController fgsSectionController,
@@ -595,7 +585,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
mRoundnessManager = notificationRoundnessManager;
- mLockscreenUserManager = notificationLockscreenUserManager;
mNotificationGutsManager = notificationGutsManager;
mHeadsUpManager = headsUpManager;
mHeadsUpManager.setAnimationStateHandler(this::setHeadsUpGoingAwayAnimationsAllowed);
@@ -626,7 +615,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
res.getBoolean(R.bool.config_drawNotificationBackground);
mFadeNotificationsOnDismiss =
res.getBoolean(R.bool.config_fadeNotificationsOnDismiss);
- mLockscreenUserManager.addUserChangedListener(mLockscreenUserChangeListener);
setOutlineProvider(mOutlineProvider);
// Blocking helper manager wants to know the expanded state, update as well.
@@ -4706,8 +4694,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
}
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
- private void updateSensitiveness(boolean animate) {
- boolean hideSensitive = mLockscreenUserManager.isAnyProfilePublicMode();
+ void updateSensitiveness(boolean animate, boolean hideSensitive) {
if (hideSensitive != mAmbientState.isHideSensitive()) {
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
@@ -5403,8 +5390,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
mAmbientState.setStatusBarState(statusBarState);
}
- void onStatePostChange() {
-
+ void onStatePostChange(boolean fromShadeLocked) {
boolean onKeyguard = onKeyguard();
mAmbientState.setActivatedChild(null);
@@ -5414,10 +5400,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
mHeadsUpAppearanceController.onStateChanged();
}
- SysuiStatusBarStateController state = (SysuiStatusBarStateController)
- Dependency.get(StatusBarStateController.class);
- updateSensitiveness(state.goingToFullShade() /* animate */);
- setDimmed(onKeyguard, state.fromShadeLocked() /* animate */);
+ setDimmed(onKeyguard, fromShadeLocked);
setExpandingEnabled(!onKeyguard);
ActivatableNotificationView activatedChild = getActivatedChild();
setActivatedChild(null);
@@ -5825,6 +5808,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
return mController;
}
+ void setCurrentUserid(int userId) {
+ mCurrentUserId = userId;
+ }
+
/**
* A listener that is notified when the empty space below the notifications is clicked on
*/
@@ -6473,7 +6460,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
@SelectedRows int selectedRows) {
if (mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
if (selectedRows == ROWS_ALL) {
- mNotifCollection.dismissAllNotifications(mLockscreenUserManager.getCurrentUserId());
+ mNotifCollection.dismissAllNotifications(mCurrentUserId);
} else {
final List<Pair<NotificationEntry, DismissedByUserStats>>
entriesWithRowsDismissedFromShade = new ArrayList<>();
@@ -6502,7 +6489,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
}
if (selectedRows == ROWS_ALL) {
try {
- mBarService.onClearAllNotifications(mLockscreenUserManager.getCurrentUserId());
+ mBarService.onClearAllNotifications(mCurrentUserId);
} catch (Exception ex) {
}
}
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 924122289e23..b396ce18fba6 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
@@ -31,6 +31,8 @@ import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.media.KeyguardMediaController;
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
+import com.android.systemui.statusbar.NotificationLockscreenUserManager;
+import com.android.systemui.statusbar.NotificationLockscreenUserManager.UserChangedListener;
import com.android.systemui.statusbar.NotificationShelfController;
import com.android.systemui.statusbar.RemoteInputController;
import com.android.systemui.statusbar.StatusBarState;
@@ -82,6 +84,7 @@ public class NotificationStackScrollLayoutController {
private final SysuiStatusBarStateController mStatusBarStateController;
private final KeyguardBypassController mKeyguardBypassController;
private final SysuiColorExtractor mColorExtractor;
+ private final NotificationLockscreenUserManager mLockscreenUserManager;
private NotificationStackScrollLayout mView;
@@ -158,10 +161,20 @@ public class NotificationStackScrollLayoutController {
@Override
public void onStatePostChange() {
- mView.onStatePostChange();
+ mView.updateSensitiveness(mStatusBarStateController.goingToFullShade(),
+ mLockscreenUserManager.isAnyProfilePublicMode());
+ mView.onStatePostChange(mStatusBarStateController.fromShadeLocked());
}
};
+ private final UserChangedListener mLockscreenUserChangeListener = new UserChangedListener() {
+ @Override
+ public void onUserChanged(int userId) {
+ mView.setCurrentUserid(userId);
+ mView.updateSensitiveness(false, mLockscreenUserManager.isAnyProfilePublicMode());
+ }
+ };
+
@Inject
public NotificationStackScrollLayoutController(
@Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowLongPress,
@@ -175,7 +188,8 @@ public class NotificationStackScrollLayoutController {
KeyguardMediaController keyguardMediaController,
KeyguardBypassController keyguardBypassController,
ZenModeController zenModeController,
- SysuiColorExtractor colorExtractor) {
+ SysuiColorExtractor colorExtractor,
+ NotificationLockscreenUserManager lockscreenUserManager) {
mAllowLongPress = allowLongPress;
mNotificationGutsManager = notificationGutsManager;
mHeadsUpManager = headsUpManager;
@@ -188,6 +202,7 @@ public class NotificationStackScrollLayoutController {
mKeyguardBypassController = keyguardBypassController;
mZenModeController = zenModeController;
mColorExtractor = colorExtractor;
+ mLockscreenUserManager = lockscreenUserManager;
}
public void attach(NotificationStackScrollLayout view) {
@@ -202,6 +217,9 @@ public class NotificationStackScrollLayoutController {
mHeadsUpManager.addListener(mNotificationRoundnessManager); // TODO: why is this here?
mDynamicPrivacyController.addListener(mDynamicPrivacyControllerListener);
+ mLockscreenUserManager.addUserChangedListener(mLockscreenUserChangeListener);
+ mView.setCurrentUserid(mLockscreenUserManager.getCurrentUserId());
+
mNotificationRoundnessManager.setOnRoundingChangedCallback(mView::invalidate);
mView.addOnExpandedHeightChangedListener(mNotificationRoundnessManager::setExpanded);
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 d79557d8a352..afb1e9414e55 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
@@ -54,12 +54,9 @@ import com.android.systemui.ExpandHelper;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.classifier.FalsingManagerFake;
-import com.android.systemui.media.KeyguardMediaController;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.FeatureFlags;
-import com.android.systemui.statusbar.NotificationLockscreenUserManager;
-import com.android.systemui.statusbar.NotificationLockscreenUserManager.UserChangedListener;
import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.NotificationPresenter;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
@@ -137,11 +134,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
@Mock private KeyguardBypassEnabledProvider mKeyguardBypassEnabledProvider;
@Mock private NotificationSectionsManager mNotificationSectionsManager;
@Mock private NotificationSection mNotificationSection;
- @Mock private NotificationLockscreenUserManager mLockscreenUserManager;
@Mock private FeatureFlags mFeatureFlags;
- @Mock private KeyguardMediaController mKeyguardMediaController;
@Mock private SysuiStatusBarStateController mStatusBarStateController;
- private UserChangedListener mUserChangedListener;
private NotificationEntryManager mEntryManager;
private int mOriginalInterruptionModelSetting;
private UiEventLoggerFake mUiEventLoggerFake = new UiEventLoggerFake();
@@ -171,8 +165,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
mDependency.injectMockDependency(ShadeController.class);
when(mRemoteInputManager.getController()).thenReturn(mRemoteInputController);
- ArgumentCaptor<UserChangedListener> userChangedCaptor = ArgumentCaptor
- .forClass(UserChangedListener.class);
mEntryManager = new NotificationEntryManager(
mock(NotificationEntryManagerLogger.class),
mock(NotificationGroupManager.class),
@@ -218,7 +210,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
mStatusBarStateController,
mHeadsUpManager,
new FalsingManagerFake(),
- mLockscreenUserManager,
mock(NotificationGutsManager.class),
mNotificationSectionsManager,
mock(ForegroundServiceSectionController.class),
@@ -230,8 +221,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
mUiEventLoggerFake
);
mStackScrollerInternal.initView(getContext(), mKeyguardBypassEnabledProvider);
- verify(mLockscreenUserManager).addUserChangedListener(userChangedCaptor.capture());
- mUserChangedListener = userChangedCaptor.getValue();
mStackScroller = spy(mStackScrollerInternal);
mStackScroller.setShelfController(notificationShelfController);
mStackScroller.setStatusBar(mBar);
@@ -307,12 +296,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
}
@Test
- public void testOnStatePostChange_verifyIfProfileIsPublic() {
- mUserChangedListener.onUserChanged(0);
- verify(mLockscreenUserManager).isAnyProfilePublicMode();
- }
-
- @Test
public void manageNotifications_visible() {
FooterView view = mock(FooterView.class);
mStackScroller.setFooterView(view);
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 129996e17a06..0b2cb0e39841 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
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.notification.stack;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
@@ -29,6 +30,9 @@ import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.media.KeyguardMediaController;
+import com.android.systemui.plugins.statusbar.StatusBarStateController;
+import com.android.systemui.statusbar.NotificationLockscreenUserManager;
+import com.android.systemui.statusbar.NotificationLockscreenUserManager.UserChangedListener;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
@@ -41,6 +45,7 @@ import com.android.systemui.tuner.TunerService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -75,6 +80,8 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase {
private KeyguardBypassController mKeyguardBypassController;
@Mock
private SysuiColorExtractor mColorExtractor;
+ @Mock
+ private NotificationLockscreenUserManager mNotificationLockscreenUserManager;
NotificationStackScrollLayoutController mController;
@@ -94,8 +101,8 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase {
mKeyguardMediaController,
mKeyguardBypassController,
mZenModeController,
- mColorExtractor
- );
+ mColorExtractor,
+ mNotificationLockscreenUserManager);
when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(true);
}
@@ -162,4 +169,40 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase {
false /* visible */,
false /* notifVisibleInShade */);
}
+
+ @Test
+ public void testOnUserChange_verifySensitiveProfile() {
+ when(mNotificationLockscreenUserManager.isAnyProfilePublicMode()).thenReturn(true);
+
+ ArgumentCaptor<UserChangedListener> userChangedCaptor = ArgumentCaptor
+ .forClass(UserChangedListener.class);
+
+ mController.attach(mNotificationStackScrollLayout);
+ verify(mNotificationLockscreenUserManager)
+ .addUserChangedListener(userChangedCaptor.capture());
+ reset(mNotificationStackScrollLayout);
+
+ UserChangedListener changedListener = userChangedCaptor.getValue();
+ changedListener.onUserChanged(0);
+ verify(mNotificationStackScrollLayout).setCurrentUserid(0);
+ verify(mNotificationStackScrollLayout).updateSensitiveness(false, true);
+ }
+
+ @Test
+ public void testOnStatePostChange_verifyIfProfileIsPublic() {
+ when(mNotificationLockscreenUserManager.isAnyProfilePublicMode()).thenReturn(true);
+
+ ArgumentCaptor<StatusBarStateController.StateListener> stateListenerArgumentCaptor =
+ ArgumentCaptor.forClass(StatusBarStateController.StateListener.class);
+
+ mController.attach(mNotificationStackScrollLayout);
+ verify(mSysuiStatusBarStateController).addCallback(
+ stateListenerArgumentCaptor.capture(), anyInt());
+
+ StatusBarStateController.StateListener stateListener =
+ stateListenerArgumentCaptor.getValue();
+
+ stateListener.onStatePostChange();
+ verify(mNotificationStackScrollLayout).updateSensitiveness(false, true);
+ }
}