Merge "[Dagger] Remove the simple Dependency.get calls from StatusBarNotificationPresenter." into sc-v2-dev

This commit is contained in:
TreeHugger Robot
2021-08-13 19:41:29 +00:00
committed by Android (Google) Code Review
3 changed files with 62 additions and 39 deletions

View File

@@ -1511,14 +1511,32 @@ public class StatusBar extends SystemUI implements
); );
// TODO: inject this. // TODO: inject this.
mPresenter = new StatusBarNotificationPresenter(mContext, mNotificationPanelViewController, mPresenter = new StatusBarNotificationPresenter(
mHeadsUpManager, mNotificationShadeWindowView, mStackScrollerController, mContext,
mDozeScrimController, mScrimController, mNotificationShadeWindowController, mNotificationPanelViewController,
mDynamicPrivacyController, mKeyguardStateController, mHeadsUpManager,
mNotificationShadeWindowView,
mStackScrollerController,
mDozeScrimController,
mScrimController,
mNotificationShadeWindowController,
mDynamicPrivacyController,
mKeyguardStateController,
mKeyguardIndicationController, mKeyguardIndicationController,
this /* statusBar */, mShadeController, this /* statusBar */,
mLockscreenShadeTransitionController, mCommandQueue, mInitController, mShadeController,
mNotificationInterruptStateProvider); mLockscreenShadeTransitionController,
mCommandQueue,
mViewHierarchyManager,
mLockscreenUserManager,
mStatusBarStateController,
mMediaManager,
mGutsManager,
mKeyguardUpdateMonitor,
mInitController,
mNotificationInterruptStateProvider,
mRemoteInputManager,
mConfigurationController);
mNotificationShelfController.setOnActivatedListener(mPresenter); mNotificationShelfController.setOnActivatedListener(mPresenter);
mRemoteInputManager.addControllerCallback(mNotificationShadeWindowController); mRemoteInputManager.addControllerCallback(mNotificationShadeWindowController);

View File

@@ -47,7 +47,6 @@ import com.android.systemui.InitController;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.ActivityStarter.OnDismissAction; import com.android.systemui.plugins.ActivityStarter.OnDismissAction;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.KeyguardIndicationController; import com.android.systemui.statusbar.KeyguardIndicationController;
import com.android.systemui.statusbar.LockscreenShadeTransitionController; import com.android.systemui.statusbar.LockscreenShadeTransitionController;
@@ -65,7 +64,6 @@ import com.android.systemui.statusbar.notification.NotificationEntryListener;
import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinderImpl; import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinderImpl;
import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager;
import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider; import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider;
import com.android.systemui.statusbar.notification.interruption.NotificationInterruptSuppressor; import com.android.systemui.statusbar.notification.interruption.NotificationInterruptSuppressor;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView; import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
@@ -92,20 +90,14 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
private final ActivityStarter mActivityStarter = Dependency.get(ActivityStarter.class); private final ActivityStarter mActivityStarter = Dependency.get(ActivityStarter.class);
private final KeyguardStateController mKeyguardStateController; private final KeyguardStateController mKeyguardStateController;
private final NotificationViewHierarchyManager mViewHierarchyManager = private final NotificationViewHierarchyManager mViewHierarchyManager;
Dependency.get(NotificationViewHierarchyManager.class); private final NotificationLockscreenUserManager mLockscreenUserManager;
private final NotificationLockscreenUserManager mLockscreenUserManager = private final SysuiStatusBarStateController mStatusBarStateController;
Dependency.get(NotificationLockscreenUserManager.class);
private final SysuiStatusBarStateController mStatusBarStateController =
(SysuiStatusBarStateController) Dependency.get(StatusBarStateController.class);
private final NotificationEntryManager mEntryManager = private final NotificationEntryManager mEntryManager =
Dependency.get(NotificationEntryManager.class); Dependency.get(NotificationEntryManager.class);
private final NotificationMediaManager mMediaManager = private final NotificationMediaManager mMediaManager;
Dependency.get(NotificationMediaManager.class); private final NotificationGutsManager mGutsManager;
private final VisualStabilityManager mVisualStabilityManager = private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
Dependency.get(VisualStabilityManager.class);
private final NotificationGutsManager mGutsManager =
Dependency.get(NotificationGutsManager.class);
private final NotificationPanelViewController mNotificationPanel; private final NotificationPanelViewController mNotificationPanel;
private final HeadsUpManagerPhone mHeadsUpManager; private final HeadsUpManagerPhone mHeadsUpManager;
@@ -144,8 +136,16 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
ShadeController shadeController, ShadeController shadeController,
LockscreenShadeTransitionController shadeTransitionController, LockscreenShadeTransitionController shadeTransitionController,
CommandQueue commandQueue, CommandQueue commandQueue,
NotificationViewHierarchyManager notificationViewHierarchyManager,
NotificationLockscreenUserManager lockscreenUserManager,
SysuiStatusBarStateController sysuiStatusBarStateController,
NotificationMediaManager notificationMediaManager,
NotificationGutsManager notificationGutsManager,
KeyguardUpdateMonitor keyguardUpdateMonitor,
InitController initController, InitController initController,
NotificationInterruptStateProvider notificationInterruptStateProvider) { NotificationInterruptStateProvider notificationInterruptStateProvider,
NotificationRemoteInputManager remoteInputManager,
ConfigurationController configurationController) {
mKeyguardStateController = keyguardStateController; mKeyguardStateController = keyguardStateController;
mNotificationPanel = panel; mNotificationPanel = panel;
mHeadsUpManager = headsUp; mHeadsUpManager = headsUp;
@@ -156,6 +156,12 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
mShadeController = shadeController; mShadeController = shadeController;
mShadeTransitionController = shadeTransitionController; mShadeTransitionController = shadeTransitionController;
mCommandQueue = commandQueue; mCommandQueue = commandQueue;
mViewHierarchyManager = notificationViewHierarchyManager;
mLockscreenUserManager = lockscreenUserManager;
mStatusBarStateController = sysuiStatusBarStateController;
mMediaManager = notificationMediaManager;
mGutsManager = notificationGutsManager;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mAboveShelfObserver = new AboveShelfObserver(stackScrollerController.getView()); mAboveShelfObserver = new AboveShelfObserver(stackScrollerController.getView());
mNotificationShadeWindowController = notificationShadeWindowController; mNotificationShadeWindowController = notificationShadeWindowController;
mAboveShelfObserver.setListener(statusBarWindow.findViewById( mAboveShelfObserver.setListener(statusBarWindow.findViewById(
@@ -176,8 +182,6 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
Slog.e(TAG, "Failed to register VR mode state listener: " + e); Slog.e(TAG, "Failed to register VR mode state listener: " + e);
} }
} }
NotificationRemoteInputManager remoteInputManager =
Dependency.get(NotificationRemoteInputManager.class);
remoteInputManager.setUpWithCallback( remoteInputManager.setUpWithCallback(
Dependency.get(NotificationRemoteInputManager.Callback.class), Dependency.get(NotificationRemoteInputManager.Callback.class),
mNotificationPanel.createRemoteInputDelegate()); mNotificationPanel.createRemoteInputDelegate());
@@ -220,14 +224,14 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
onUserSwitched(mLockscreenUserManager.getCurrentUserId()); onUserSwitched(mLockscreenUserManager.getCurrentUserId());
}); });
Dependency.get(ConfigurationController.class).addCallback(this); configurationController.addCallback(this);
} }
@Override @Override
public void onDensityOrFontScaleChanged() { public void onDensityOrFontScaleChanged() {
MessagingMessage.dropCache(); MessagingMessage.dropCache();
MessagingGroup.dropCache(); MessagingGroup.dropCache();
if (!Dependency.get(KeyguardUpdateMonitor.class).isSwitchingUser()) { if (!mKeyguardUpdateMonitor.isSwitchingUser()) {
updateNotificationsOnDensityOrFontScaleChanged(); updateNotificationsOnDensityOrFontScaleChanged();
} else { } else {
mReinflateNotificationsOnUserSwitched = true; mReinflateNotificationsOnUserSwitched = true;
@@ -236,7 +240,7 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
@Override @Override
public void onUiModeChanged() { public void onUiModeChanged() {
if (!Dependency.get(KeyguardUpdateMonitor.class).isSwitchingUser()) { if (!mKeyguardUpdateMonitor.isSwitchingUser()) {
updateNotificationOnUiModeChanged(); updateNotificationOnUiModeChanged();
} else { } else {
mDispatchUiModeChangeOnUserSwitched = true; mDispatchUiModeChangeOnUserSwitched = true;

View File

@@ -34,6 +34,7 @@ import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.logging.testing.FakeMetricsLogger; import com.android.internal.logging.testing.FakeMetricsLogger;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.ForegroundServiceNotificationListener; import com.android.systemui.ForegroundServiceNotificationListener;
import com.android.systemui.InitController; import com.android.systemui.InitController;
import com.android.systemui.SysuiTestCase; import com.android.systemui.SysuiTestCase;
@@ -51,7 +52,6 @@ import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder; import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager;
import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider; import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider;
import com.android.systemui.statusbar.notification.interruption.NotificationInterruptSuppressor; import com.android.systemui.statusbar.notification.interruption.NotificationInterruptSuppressor;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView; import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
@@ -59,6 +59,7 @@ import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer; import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.statusbar.policy.KeyguardStateController;
import org.junit.Before; import org.junit.Before;
@@ -86,22 +87,13 @@ public class StatusBarNotificationPresenterTest extends SysuiTestCase {
@Before @Before
public void setup() { public void setup() {
NotificationRemoteInputManager notificationRemoteInputManager =
mock(NotificationRemoteInputManager.class);
mMetricsLogger = new FakeMetricsLogger(); mMetricsLogger = new FakeMetricsLogger();
mDependency.injectTestDependency(MetricsLogger.class, mMetricsLogger); mDependency.injectTestDependency(MetricsLogger.class, mMetricsLogger);
mCommandQueue = new CommandQueue(mContext); mCommandQueue = new CommandQueue(mContext);
mDependency.injectTestDependency(StatusBarStateController.class, mDependency.injectTestDependency(StatusBarStateController.class,
mock(SysuiStatusBarStateController.class)); mock(SysuiStatusBarStateController.class));
mDependency.injectTestDependency(ShadeController.class, mShadeController); mDependency.injectTestDependency(ShadeController.class, mShadeController);
mDependency.injectTestDependency(NotificationRemoteInputManager.class,
notificationRemoteInputManager);
mDependency.injectMockDependency(NotificationViewHierarchyManager.class);
mDependency.injectMockDependency(NotificationRemoteInputManager.Callback.class); mDependency.injectMockDependency(NotificationRemoteInputManager.Callback.class);
mDependency.injectMockDependency(NotificationLockscreenUserManager.class);
mDependency.injectMockDependency(NotificationMediaManager.class);
mDependency.injectMockDependency(VisualStabilityManager.class);
mDependency.injectMockDependency(NotificationGutsManager.class);
mDependency.injectMockDependency(NotificationShadeWindowController.class); mDependency.injectMockDependency(NotificationShadeWindowController.class);
mDependency.injectMockDependency(ForegroundServiceNotificationListener.class); mDependency.injectMockDependency(ForegroundServiceNotificationListener.class);
NotificationEntryManager entryManager = NotificationEntryManager entryManager =
@@ -126,8 +118,17 @@ public class StatusBarNotificationPresenterTest extends SysuiTestCase {
mock(KeyguardStateController.class), mock(KeyguardStateController.class),
mock(KeyguardIndicationController.class), mStatusBar, mock(KeyguardIndicationController.class), mStatusBar,
mock(ShadeControllerImpl.class), mock(LockscreenShadeTransitionController.class), mock(ShadeControllerImpl.class), mock(LockscreenShadeTransitionController.class),
mCommandQueue, mInitController, mCommandQueue,
mNotificationInterruptStateProvider); mock(NotificationViewHierarchyManager.class),
mock(NotificationLockscreenUserManager.class),
mock(SysuiStatusBarStateController.class),
mock(NotificationMediaManager.class),
mock(NotificationGutsManager.class),
mock(KeyguardUpdateMonitor.class),
mInitController,
mNotificationInterruptStateProvider,
mock(NotificationRemoteInputManager.class),
mock(ConfigurationController.class));
mInitController.executePostInitTasks(); mInitController.executePostInitTasks();
ArgumentCaptor<NotificationInterruptSuppressor> suppressorCaptor = ArgumentCaptor<NotificationInterruptSuppressor> suppressorCaptor =
ArgumentCaptor.forClass(NotificationInterruptSuppressor.class); ArgumentCaptor.forClass(NotificationInterruptSuppressor.class);