From f6ad63293a3a3f38fcbcc7978f0782b652043af6 Mon Sep 17 00:00:00 2001 From: Sergey Nikolaienkov Date: Mon, 10 Feb 2020 15:46:32 +0100 Subject: [PATCH 1/4] Expand NotificationsModule This CL is the 1st in the series of CLs which intend to "unbind" StatusBar on TV. In order to make StatusBar really optional and thus to allow us to unbind it, we also need to make some of the classes that depends on it optional as well. For all these cases we need to move from @Inject-annotated contructors to @Provides annotated methods. For this we are expanding NotificationsModule. Change-Id: Icccafd2170f2fdffb8412370056aab7042ffd580 Test: make SystemUI; make CarSystemUI; atest SystemUITests Bug: 146188087 --- .../android/systemui/CarSystemUIBinder.java | 3 +- .../systemui/dagger/SystemUIBinder.java | 3 +- .../systemui/dagger/SystemUIModule.java | 3 - .../NotificationAlertingManager.java | 9 +- .../NotificationEntryManager.java | 9 +- .../notification/VisualStabilityManager.java | 9 +- .../dagger/NotificationsModule.java | 132 +++++++++++++++++- .../logging/NotificationLogger.java | 7 +- .../NotificationBlockingHelperManager.java | 37 ++--- .../row/NotificationContentInflater.java | 24 +++- .../row/NotificationGutsManager.java | 10 +- ...NotificationBlockingHelperManagerTest.java | 7 +- .../row/NotificationContentInflaterTest.java | 9 +- .../row/NotificationTestHelper.java | 7 +- 14 files changed, 209 insertions(+), 60 deletions(-) diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIBinder.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIBinder.java index 07b7b22d23200..0a76c7ddbe8d4 100644 --- a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIBinder.java +++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIBinder.java @@ -29,6 +29,7 @@ import com.android.systemui.stackdivider.Divider; import com.android.systemui.statusbar.car.CarStatusBar; import com.android.systemui.statusbar.car.CarStatusBarModule; import com.android.systemui.statusbar.notification.InstantAppNotifier; +import com.android.systemui.statusbar.notification.dagger.NotificationsModule; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.tv.TvStatusBar; import com.android.systemui.theme.ThemeOverlayController; @@ -42,7 +43,7 @@ import dagger.multibindings.ClassKey; import dagger.multibindings.IntoMap; /** Binder for car specific {@link SystemUI} modules. */ -@Module(includes = {RecentsModule.class, CarStatusBarModule.class}) +@Module(includes = {RecentsModule.class, CarStatusBarModule.class, NotificationsModule.class}) public abstract class CarSystemUIBinder { /** Inject into AuthController. */ @Binds diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java index 5de88e17d320f..c08c3cbc869ba 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java @@ -33,6 +33,7 @@ import com.android.systemui.recents.RecentsModule; import com.android.systemui.shortcut.ShortcutKeyDispatcher; import com.android.systemui.stackdivider.Divider; import com.android.systemui.statusbar.notification.InstantAppNotifier; +import com.android.systemui.statusbar.notification.dagger.NotificationsModule; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.StatusBarModule; import com.android.systemui.statusbar.tv.TvStatusBar; @@ -49,7 +50,7 @@ import dagger.multibindings.IntoMap; /** * SystemUI objects that are injectable should go here. */ -@Module(includes = {RecentsModule.class, StatusBarModule.class}) +@Module(includes = {RecentsModule.class, StatusBarModule.class, NotificationsModule.class}) public abstract class SystemUIBinder { /** Inject into AuthController. */ @Binds diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index 91aeb224e143f..030b504c9a7a3 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -35,10 +35,8 @@ import com.android.systemui.statusbar.BlurUtils; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.NotificationShadeWindowBlurController; import com.android.systemui.statusbar.SysuiStatusBarStateController; -import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder; import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinderImpl; -import com.android.systemui.statusbar.notification.dagger.NotificationsModule; import com.android.systemui.statusbar.notification.people.PeopleHubModule; import com.android.systemui.statusbar.notification.row.dagger.ExpandableNotificationRowComponent; import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent; @@ -69,7 +67,6 @@ import dagger.Provides; AssistModule.class, ConcurrencyModule.class, LogModule.class, - NotificationsModule.class, PeopleHubModule.class, }, subcomponents = {StatusBarComponent.class, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationAlertingManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationAlertingManager.java index d0e238a663303..72a7e11d8543e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationAlertingManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationAlertingManager.java @@ -28,13 +28,10 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.notification.collection.NotificationEntry; +import com.android.systemui.statusbar.notification.dagger.NotificationsModule; import com.android.systemui.statusbar.policy.HeadsUpManager; -import javax.inject.Inject; -import javax.inject.Singleton; - /** Handles heads-up and pulsing behavior driven by notification changes. */ -@Singleton public class NotificationAlertingManager { private static final String TAG = "NotifAlertManager"; @@ -47,7 +44,9 @@ public class NotificationAlertingManager { private HeadsUpManager mHeadsUpManager; - @Inject + /** + * Injected constructor. See {@link NotificationsModule}. + */ public NotificationAlertingManager( NotificationEntryManager notificationEntryManager, NotificationRemoteInputManager remoteInputManager, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java index b0bf8130f3a91..4f55e02bddfbc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java @@ -47,6 +47,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationRankin import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener; +import com.android.systemui.statusbar.notification.dagger.NotificationsModule; import com.android.systemui.statusbar.notification.logging.NotificationLogger; import com.android.systemui.statusbar.notification.stack.NotificationListContainer; import com.android.systemui.statusbar.phone.NotificationGroupManager; @@ -64,9 +65,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import javax.inject.Inject; -import javax.inject.Singleton; - import dagger.Lazy; /** @@ -94,7 +92,6 @@ import dagger.Lazy; * aware of * @see #getActiveNotificationsForCurrentUser() to see every notification that the current user owns */ -@Singleton public class NotificationEntryManager implements CommonNotifCollection, Dumpable, @@ -181,7 +178,9 @@ public class NotificationEntryManager implements } } - @Inject + /** + * Injected constructor. See {@link NotificationsModule}. + */ public NotificationEntryManager( NotificationEntryManagerLogger logger, NotificationGroupManager groupManager, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java index 99718abb64922..616c110ea7cc8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java @@ -26,6 +26,7 @@ import com.android.systemui.Dumpable; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.statusbar.NotificationPresenter; import com.android.systemui.statusbar.notification.collection.NotificationEntry; +import com.android.systemui.statusbar.notification.dagger.NotificationsModule; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener; @@ -33,14 +34,10 @@ import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; -import javax.inject.Inject; -import javax.inject.Singleton; - /** * A manager that ensures that notifications are visually stable. It will suppress reorderings * and reorder at the right time when they are out of view. */ -@Singleton public class VisualStabilityManager implements OnHeadsUpChangedListener, Dumpable { private static final long TEMPORARY_REORDERING_ALLOWED_DURATION = 1000; @@ -60,7 +57,9 @@ public class VisualStabilityManager implements OnHeadsUpChangedListener, Dumpabl private ArraySet mAddedChildren = new ArraySet<>(); private boolean mPulsing; - @Inject + /** + * Injected constructor. See {@link NotificationsModule}. + */ public VisualStabilityManager( NotificationEntryManager notificationEntryManager, @Main Handler handler) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java index 39f4dfacc2c51..8f8f7422c4496 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java @@ -17,15 +17,39 @@ package com.android.systemui.statusbar.notification.dagger; import android.content.Context; +import android.os.Handler; +import android.view.accessibility.AccessibilityManager; +import com.android.internal.logging.MetricsLogger; import com.android.systemui.R; +import com.android.systemui.dagger.qualifiers.Main; +import com.android.systemui.dagger.qualifiers.UiBackground; +import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.FeatureFlags; +import com.android.systemui.statusbar.NotificationListener; +import com.android.systemui.statusbar.NotificationRemoteInputManager; +import com.android.systemui.statusbar.notification.ForegroundServiceDismissalFeatureController; +import com.android.systemui.statusbar.notification.NotificationAlertingManager; import com.android.systemui.statusbar.notification.NotificationEntryManager; +import com.android.systemui.statusbar.notification.NotificationEntryManagerLogger; +import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider; +import com.android.systemui.statusbar.notification.VisualStabilityManager; import com.android.systemui.statusbar.notification.collection.NotifPipeline; +import com.android.systemui.statusbar.notification.collection.NotificationRankingManager; +import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; +import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider; import com.android.systemui.statusbar.notification.init.NotificationsController; import com.android.systemui.statusbar.notification.init.NotificationsControllerImpl; import com.android.systemui.statusbar.notification.init.NotificationsControllerStub; +import com.android.systemui.statusbar.notification.logging.NotificationLogger; +import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager; +import com.android.systemui.statusbar.notification.row.NotificationGutsManager; +import com.android.systemui.statusbar.phone.NotificationGroupManager; +import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.util.leak.LeakDetector; + +import java.util.concurrent.Executor; import javax.inject.Singleton; @@ -33,9 +57,111 @@ import dagger.Lazy; import dagger.Module; import dagger.Provides; -/** Module for classes related to the notifications data pipeline */ +/** + * Dagger Module for classes found within the com.android.systemui.statusbar.notification package. + */ @Module -public class NotificationsModule { +public interface NotificationsModule { + /** Provides an instance of {@link NotificationEntryManager} */ + @Singleton + @Provides + static NotificationEntryManager provideNotificationEntryManager( + NotificationEntryManagerLogger logger, + NotificationGroupManager groupManager, + NotificationRankingManager rankingManager, + NotificationEntryManager.KeyguardEnvironment keyguardEnvironment, + FeatureFlags featureFlags, + Lazy notificationRowBinderLazy, + Lazy notificationRemoteInputManagerLazy, + LeakDetector leakDetector, + ForegroundServiceDismissalFeatureController fgsFeatureController) { + return new NotificationEntryManager( + logger, + groupManager, + rankingManager, + keyguardEnvironment, + featureFlags, + notificationRowBinderLazy, + notificationRemoteInputManagerLazy, + leakDetector, + fgsFeatureController); + } + + /** Provides an instance of {@link NotificationGutsManager} */ + @Singleton + @Provides + static NotificationGutsManager provideNotificationGutsManager( + Context context, + VisualStabilityManager visualStabilityManager, + Lazy statusBarLazy, + @Main Handler mainHandler, + AccessibilityManager accessibilityManager, + HighPriorityProvider highPriorityProvider) { + return new NotificationGutsManager( + context, + visualStabilityManager, + statusBarLazy, + mainHandler, + accessibilityManager, + highPriorityProvider); + } + + /** Provides an instance of {@link VisualStabilityManager} */ + @Singleton + @Provides + static VisualStabilityManager provideVisualStabilityManager( + NotificationEntryManager notificationEntryManager, Handler handler) { + return new VisualStabilityManager(notificationEntryManager, handler); + } + + /** Provides an instance of {@link NotificationAlertingManager} */ + @Singleton + @Provides + static NotificationAlertingManager provideNotificationAlertingManager( + NotificationEntryManager notificationEntryManager, + NotificationRemoteInputManager remoteInputManager, + VisualStabilityManager visualStabilityManager, + StatusBarStateController statusBarStateController, + NotificationInterruptionStateProvider notificationInterruptionStateProvider, + NotificationListener notificationListener) { + return new NotificationAlertingManager( + notificationEntryManager, + remoteInputManager, + visualStabilityManager, + statusBarStateController, + notificationInterruptionStateProvider, + notificationListener); + } + + /** Provides an instance of {@link NotificationLogger} */ + @Singleton + @Provides + static NotificationLogger provideNotificationLogger( + NotificationListener notificationListener, + @UiBackground Executor uiBgExecutor, + NotificationEntryManager entryManager, + StatusBarStateController statusBarStateController, + NotificationLogger.ExpansionStateLogger expansionStateLogger) { + return new NotificationLogger( + notificationListener, + uiBgExecutor, + entryManager, + statusBarStateController, + expansionStateLogger); + } + + /** Provides an instance of {@link NotificationBlockingHelperManager} */ + @Singleton + @Provides + static NotificationBlockingHelperManager provideNotificationBlockingHelperManager( + Context context, + NotificationGutsManager notificationGutsManager, + NotificationEntryManager notificationEntryManager, + MetricsLogger metricsLogger) { + return new NotificationBlockingHelperManager( + context, notificationGutsManager, notificationEntryManager, metricsLogger); + } + /** Initializes the notification data pipeline (can be disabled via config). */ @Singleton @Provides @@ -55,7 +181,7 @@ public class NotificationsModule { */ @Provides @Singleton - public CommonNotifCollection provideCommonNotifCollection( + static CommonNotifCollection provideCommonNotifCollection( FeatureFlags featureFlags, Lazy pipeline, NotificationEntryManager entryManager) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java index 89e5f55962918..becb758bf470f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java @@ -39,6 +39,7 @@ import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.notification.NotificationEntryListener; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.NotificationEntry; +import com.android.systemui.statusbar.notification.dagger.NotificationsModule; import com.android.systemui.statusbar.notification.stack.ExpandableViewState; import com.android.systemui.statusbar.notification.stack.NotificationListContainer; import com.android.systemui.statusbar.policy.HeadsUpManager; @@ -50,13 +51,11 @@ import java.util.Map; import java.util.concurrent.Executor; import javax.inject.Inject; -import javax.inject.Singleton; /** * Handles notification logging, in particular, logging which notifications are visible and which * are not. */ -@Singleton public class NotificationLogger implements StateListener { private static final String TAG = "NotificationLogger"; @@ -192,7 +191,9 @@ public class NotificationLogger implements StateListener { } } - @Inject + /** + * Injected constructor. See {@link NotificationsModule}. + */ public NotificationLogger(NotificationListener notificationListener, @UiBackground Executor uiBgExecutor, NotificationEntryManager entryManager, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManager.java index 7b758aa09e5c1..921232568755c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManager.java @@ -16,8 +16,7 @@ package com.android.systemui.statusbar.notification.row; -import static android.service.notification.NotificationListenerService.Ranking - .USER_SENTIMENT_NEGATIVE; +import static android.service.notification.NotificationListenerService.Ranking.USER_SENTIMENT_NEGATIVE; import android.content.Context; import android.metrics.LogMaker; @@ -27,29 +26,28 @@ import androidx.annotation.VisibleForTesting; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; -import com.android.systemui.Dependency; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; import com.android.systemui.statusbar.notification.NotificationEntryManager; +import com.android.systemui.statusbar.notification.dagger.NotificationsModule; import com.android.systemui.statusbar.notification.logging.NotificationCounters; import java.util.Collections; import java.util.HashSet; import java.util.Set; -import javax.inject.Inject; -import javax.inject.Singleton; - /** * Manager for the notification blocking helper - tracks and helps create the blocking helper * affordance. */ -@Singleton public class NotificationBlockingHelperManager { /** Enables debug logging and always makes the blocking helper show up after a dismiss. */ private static final boolean DEBUG = false; private static final String TAG = "BlockingHelper"; private final Context mContext; + private final NotificationGutsManager mNotificationGutsManager; + private final NotificationEntryManager mNotificationEntryManager; + private final MetricsLogger mMetricsLogger; /** Row that the blocking helper will be shown in (via {@link NotificationGuts}. */ private ExpandableNotificationRow mBlockingHelperRow; private Set mNonBlockablePkgs; @@ -60,11 +58,18 @@ public class NotificationBlockingHelperManager { */ private boolean mIsShadeExpanded; - private MetricsLogger mMetricsLogger = new MetricsLogger(); - - @Inject - public NotificationBlockingHelperManager(Context context) { + /** + * Injected constructor. See {@link NotificationsModule}. + */ + public NotificationBlockingHelperManager( + Context context, + NotificationGutsManager notificationGutsManager, + NotificationEntryManager notificationEntryManager, + MetricsLogger metricsLogger) { mContext = context; + mNotificationGutsManager = notificationGutsManager; + mNotificationEntryManager = notificationEntryManager; + mMetricsLogger = metricsLogger; mNonBlockablePkgs = new HashSet<>(); Collections.addAll(mNonBlockablePkgs, mContext.getResources().getStringArray( com.android.internal.R.array.config_nonBlockableNotificationPackages)); @@ -99,7 +104,6 @@ public class NotificationBlockingHelperManager { if (DEBUG) { Log.d(TAG, "Manager.perhapsShowBlockingHelper: Showing new blocking helper"); } - NotificationGutsManager manager = Dependency.get(NotificationGutsManager.class); // Enable blocking helper on the row before moving forward so everything in the guts is // correctly prepped. @@ -113,10 +117,10 @@ public class NotificationBlockingHelperManager { // We don't care about the touch origin (x, y) since we're opening guts without any // explicit user interaction. - manager.openGuts(mBlockingHelperRow, 0, 0, menuRow.getLongpressMenuItem(mContext)); + mNotificationGutsManager.openGuts( + mBlockingHelperRow, 0, 0, menuRow.getLongpressMenuItem(mContext)); - Dependency.get(MetricsLogger.class) - .count(NotificationCounters.BLOCKING_HELPER_SHOWN, 1); + mMetricsLogger.count(NotificationCounters.BLOCKING_HELPER_SHOWN, 1); return true; } return false; @@ -139,8 +143,7 @@ public class NotificationBlockingHelperManager { mBlockingHelperRow.setBlockingHelperShowing(false); if (mBlockingHelperRow.isAttachedToWindow()) { - Dependency.get(NotificationEntryManager.class).updateNotifications( - "dismissCurrentBlockingHelper"); + mNotificationEntryManager.updateNotifications("dismissCurrentBlockingHelper"); } mBlockingHelperRow = null; return true; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java index 566da65e37f3f..e3ca283d13ad3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java @@ -33,7 +33,6 @@ import android.widget.RemoteViews; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.widget.ImageMessageConsumer; -import com.android.systemui.Dependency; import com.android.systemui.statusbar.InflationTask; import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.SmartReplyController; @@ -53,6 +52,8 @@ import java.util.HashMap; import javax.inject.Inject; import javax.inject.Singleton; +import dagger.Lazy; + /** * {@link NotificationContentInflater} binds content to a {@link ExpandableNotificationRow} by * asynchronously building the content's {@link RemoteViews} and applying it to the row. @@ -66,13 +67,19 @@ public class NotificationContentInflater implements NotificationRowContentBinder private boolean mInflateSynchronously = false; private final NotificationRemoteInputManager mRemoteInputManager; private final NotifRemoteViewCache mRemoteViewCache; + private final Lazy mSmartReplyConstants; + private final Lazy mSmartReplyController; @Inject NotificationContentInflater( NotifRemoteViewCache remoteViewCache, - NotificationRemoteInputManager remoteInputManager) { + NotificationRemoteInputManager remoteInputManager, + Lazy smartReplyConstants, + Lazy smartReplyController) { mRemoteViewCache = remoteViewCache; mRemoteInputManager = remoteInputManager; + mSmartReplyConstants = smartReplyConstants; + mSmartReplyController = smartReplyController; } @Override @@ -104,6 +111,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder contentToBind, mRemoteViewCache, entry, + mSmartReplyConstants.get(), + mSmartReplyController.get(), row, bindParams.isLowPriority, bindParams.isChildInGroup, @@ -136,6 +145,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder packageContext); result = inflateSmartReplyViews(result, reInflateFlags, entry, row.getContext(), packageContext, row.getHeadsUpManager(), + mSmartReplyConstants.get(), mSmartReplyController.get(), row.getExistingSmartRepliesAndActions()); apply( @@ -204,9 +214,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder private static InflationProgress inflateSmartReplyViews(InflationProgress result, @InflationFlag int reInflateFlags, NotificationEntry entry, Context context, Context packageContext, HeadsUpManager headsUpManager, + SmartReplyConstants smartReplyConstants, SmartReplyController smartReplyController, SmartRepliesAndActions previousSmartRepliesAndActions) { - SmartReplyConstants smartReplyConstants = Dependency.get(SmartReplyConstants.class); - SmartReplyController smartReplyController = Dependency.get(SmartReplyController.class); if ((reInflateFlags & FLAG_CONTENT_VIEW_EXPANDED) != 0 && result.newExpandedView != null) { result.expandedInflatedSmartReplies = InflatedSmartReplies.inflate( @@ -643,6 +652,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder private final boolean mUsesIncreasedHeadsUpHeight; private final @InflationFlag int mReInflateFlags; private final NotifRemoteViewCache mRemoteViewCache; + private final SmartReplyConstants mSmartReplyConstants; + private final SmartReplyController mSmartReplyController; private ExpandableNotificationRow mRow; private Exception mError; private RemoteViews.OnClickHandler mRemoteViewClickHandler; @@ -653,6 +664,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder @InflationFlag int reInflateFlags, NotifRemoteViewCache cache, NotificationEntry entry, + SmartReplyConstants smartReplyConstants, + SmartReplyController smartReplyController, ExpandableNotificationRow row, boolean isLowPriority, boolean isChildInGroup, @@ -662,6 +675,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder RemoteViews.OnClickHandler remoteViewClickHandler) { mEntry = entry; mRow = row; + mSmartReplyConstants = smartReplyConstants; + mSmartReplyController = smartReplyController; mInflateSynchronously = inflateSynchronously; mReInflateFlags = reInflateFlags; mRemoteViewCache = cache; @@ -701,6 +716,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder mUsesIncreasedHeadsUpHeight, packageContext); return inflateSmartReplyViews(inflationProgress, mReInflateFlags, mEntry, mRow.getContext(), packageContext, mRow.getHeadsUpManager(), + mSmartReplyConstants, mSmartReplyController, mRow.getExistingSmartRepliesAndActions()); } catch (Exception e) { mError = e; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java index 352abcfc9214f..8a0b21a488ea0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java @@ -56,25 +56,21 @@ import com.android.systemui.statusbar.notification.NotificationActivityStarter; import com.android.systemui.statusbar.notification.VisualStabilityManager; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider; +import com.android.systemui.statusbar.notification.dagger.NotificationsModule; import com.android.systemui.statusbar.notification.row.NotificationInfo.CheckSaveListener; import com.android.systemui.statusbar.notification.stack.NotificationListContainer; -import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import java.io.FileDescriptor; import java.io.PrintWriter; -import javax.inject.Inject; -import javax.inject.Singleton; - import dagger.Lazy; /** * Handles various NotificationGuts related tasks, such as binding guts to a row, opening and * closing guts, and keeping track of the currently exposed notification guts. */ -@Singleton public class NotificationGutsManager implements Dumpable, NotificationLifetimeExtender { private static final String TAG = "NotificationGutsManager"; @@ -111,7 +107,9 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx private final Handler mMainHandler; private Runnable mOpenRunnable; - @Inject + /** + * Injected constructor. See {@link NotificationsModule}. + */ public NotificationGutsManager(Context context, VisualStabilityManager visualStabilityManager, Lazy statusBarLazy, @Main Handler mainHandler, AccessibilityManager accessibilityManager, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManagerTest.java index 1dfe7bc333733..a8c438a390ef5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManagerTest.java @@ -28,6 +28,7 @@ import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; @@ -43,6 +44,7 @@ import android.view.View; import androidx.test.filters.FlakyTest; import androidx.test.filters.SmallTest; +import com.android.internal.logging.MetricsLogger; import com.android.systemui.SysuiTestCase; import com.android.systemui.bubbles.BubbleController; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; @@ -83,13 +85,12 @@ public class NotificationBlockingHelperManagerTest extends SysuiTestCase { any(NotificationMenuRowPlugin.MenuItem.class))) .thenReturn(true); when(mMenuRow.getLongpressMenuItem(any(Context.class))).thenReturn(mMenuItem); - mDependency.injectTestDependency(NotificationGutsManager.class, mGutsManager); - mDependency.injectTestDependency(NotificationEntryManager.class, mEntryManager); mDependency.injectMockDependency(BubbleController.class); mHelper = new NotificationTestHelper(mContext, mDependency); - mBlockingHelperManager = new NotificationBlockingHelperManager(mContext); + mBlockingHelperManager = new NotificationBlockingHelperManager( + mContext, mGutsManager, mEntryManager, mock(MetricsLogger.class)); // By default, have the shade visible/expanded. mBlockingHelperManager.setNotificationShadeExpanded(1f); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java index 8a42e5fb4ea0f..149a95ae4cb5a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java @@ -50,10 +50,12 @@ import androidx.test.filters.Suppress; import com.android.systemui.SysuiTestCase; import com.android.systemui.statusbar.NotificationRemoteInputManager; +import com.android.systemui.statusbar.SmartReplyController; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.BindParams; import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.InflationCallback; import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.InflationFlag; +import com.android.systemui.statusbar.policy.SmartReplyConstants; import com.android.systemui.tests.R; import org.junit.Assert; @@ -92,9 +94,14 @@ public class NotificationContentInflaterTest extends SysuiTestCase { ExpandableNotificationRow row = new NotificationTestHelper(mContext, mDependency).createRow( mBuilder.build()); mRow = spy(row); + + final SmartReplyConstants smartReplyConstants = mock(SmartReplyConstants.class); + final SmartReplyController smartReplyController = mock(SmartReplyController.class); mNotificationInflater = new NotificationContentInflater( mCache, - mock(NotificationRemoteInputManager.class)); + mock(NotificationRemoteInputManager.class), + () -> smartReplyConstants, + () -> smartReplyController); } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java index 7a1bd052a3360..9a52ee8d6af7d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java @@ -60,6 +60,7 @@ import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.NotificationGroupManager; import com.android.systemui.statusbar.phone.NotificationShadeWindowController; +import com.android.systemui.statusbar.policy.SmartReplyConstants; import com.android.systemui.tests.R; import org.mockito.ArgumentCaptor; @@ -98,7 +99,6 @@ public class NotificationTestHelper { dependency.injectMockDependency(NotificationMediaManager.class); dependency.injectMockDependency(BubbleController.class); dependency.injectMockDependency(NotificationShadeWindowController.class); - dependency.injectMockDependency(SmartReplyController.class); mStatusBarStateController = mock(StatusBarStateController.class); mGroupManager = new NotificationGroupManager(mStatusBarStateController); mHeadsUpManager = new HeadsUpManagerPhone(mContext, mStatusBarStateController, @@ -106,10 +106,11 @@ public class NotificationTestHelper { mHeadsUpManager.setUp(null, mGroupManager, null, null); mGroupManager.setHeadsUpManager(mHeadsUpManager); - NotificationContentInflater contentBinder = new NotificationContentInflater( mock(NotifRemoteViewCache.class), - mock(NotificationRemoteInputManager.class)); + mock(NotificationRemoteInputManager.class), + () -> mock(SmartReplyConstants.class), + () -> mock(SmartReplyController.class)); contentBinder.setInflateSynchronously(true); mBindStage = new RowContentBindStage(contentBinder, mock(NotifInflationErrorManager.class), From 6f157bd670d78fd9ab355f1dfb861c9cd66d3cf6 Mon Sep 17 00:00:00 2001 From: Sergey Nikolaienkov Date: Mon, 10 Feb 2020 16:39:11 +0100 Subject: [PATCH 2/4] Introduce StatusBarPhoneModule This CL is the 2nd in the series of CLs which intend to "unbind" StatusBar on TV. In order to make StatusBar really optional and thus to allow us to unbind it, we also need to make some of the classes that depends on it optional as well. For all these cases we need to move from @Inject-annotated contructors to @Provides annotated methods. For this we are introducing StatusBarNotificationModule. Change-Id: Id56f970d21323f49e859715b6874f5cd773aa62a Test: make SystemUI; atest SystemUITests Bug: 146188087 --- .../statusbar/car/CarStatusBarModule.java | 24 +++++++++ .../systemui/dagger/DependencyProvider.java | 13 ----- .../systemui/dagger/SystemUIBinder.java | 6 +-- .../statusbar/phone/AutoHideController.java | 7 +-- .../NotificationGroupAlertTransferHelper.java | 9 ++-- .../systemui/statusbar/phone/StatusBar.java | 3 +- .../StatusBarPhoneModule.java} | 51 +++++++++++++++++-- 7 files changed, 84 insertions(+), 29 deletions(-) rename packages/SystemUI/src/com/android/systemui/statusbar/phone/{StatusBarModule.java => dagger/StatusBarPhoneModule.java} (82%) diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java index 498bd8780f29d..6ae7ab5fabce2 100644 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java +++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java @@ -22,6 +22,7 @@ import android.content.Context; import android.os.Handler; import android.os.PowerManager; import android.util.DisplayMetrics; +import android.view.IWindowManager; import com.android.internal.logging.MetricsLogger; import com.android.keyguard.KeyguardUpdateMonitor; @@ -33,6 +34,7 @@ import com.android.systemui.bubbles.BubbleController; import com.android.systemui.car.CarServiceProvider; import com.android.systemui.car.SystemUIPrimaryWindowController; import com.android.systemui.colorextraction.SysuiColorExtractor; +import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dagger.qualifiers.UiBackground; import com.android.systemui.keyguard.DismissCallbackRegistry; import com.android.systemui.keyguard.KeyguardViewMediator; @@ -67,6 +69,7 @@ import com.android.systemui.statusbar.notification.VisualStabilityManager; import com.android.systemui.statusbar.notification.init.NotificationsController; import com.android.systemui.statusbar.notification.logging.NotificationLogger; import com.android.systemui.statusbar.notification.row.NotificationGutsManager; +import com.android.systemui.statusbar.notification.row.RowContentBindStage; import com.android.systemui.statusbar.phone.AutoHideController; import com.android.systemui.statusbar.phone.BiometricUnlockController; import com.android.systemui.statusbar.phone.DozeParameters; @@ -79,6 +82,7 @@ import com.android.systemui.statusbar.phone.LightBarController; import com.android.systemui.statusbar.phone.LightsOutNotifController; import com.android.systemui.statusbar.phone.LockscreenLockIconController; import com.android.systemui.statusbar.phone.LockscreenWallpaper; +import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper; import com.android.systemui.statusbar.phone.NotificationGroupManager; import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.ScrimController; @@ -281,4 +285,24 @@ public class CarStatusBarModule { carNavigationBarController, flingAnimationUtilsBuilder); } + + + /** */ + @Singleton + @Provides + static AutoHideController newAutoHideController(Context context, + @Main Handler handler, + NotificationRemoteInputManager notificationRemoteInputManager, + IWindowManager iWindowManager) { + return new AutoHideController(context, handler, notificationRemoteInputManager, + iWindowManager); + } + + /** */ + @Singleton + @Provides + static NotificationGroupAlertTransferHelper provideNotificationGroupAlertTransferHelper( + RowContentBindStage bindStage) { + return new NotificationGroupAlertTransferHelper(bindStage); + } } diff --git a/packages/SystemUI/src/com/android/systemui/dagger/DependencyProvider.java b/packages/SystemUI/src/com/android/systemui/dagger/DependencyProvider.java index bf501ced62936..7c0033c1d4ec3 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/DependencyProvider.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/DependencyProvider.java @@ -27,7 +27,6 @@ import android.os.HandlerThread; import android.os.ServiceManager; import android.util.DisplayMetrics; import android.view.Choreographer; -import android.view.IWindowManager; import android.view.LayoutInflater; import android.view.WindowManager; @@ -46,8 +45,6 @@ import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.DevicePolicyManagerWrapper; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.NavigationBarController; -import com.android.systemui.statusbar.NotificationRemoteInputManager; -import com.android.systemui.statusbar.phone.AutoHideController; import com.android.systemui.statusbar.phone.ConfigurationControllerImpl; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.DataSaverController; @@ -160,16 +157,6 @@ public class DependencyProvider { return new ConfigurationControllerImpl(context); } - @Singleton - @Provides - public AutoHideController provideAutoHideController(Context context, - @Main Handler mainHandler, - NotificationRemoteInputManager notificationRemoteInputManager, - IWindowManager iWindowManager) { - return new AutoHideController(context, mainHandler, notificationRemoteInputManager, - iWindowManager); - } - @Singleton @Provides public ActivityManagerWrapper provideActivityManagerWrapper() { diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java index c08c3cbc869ba..700da715e9309 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java @@ -35,7 +35,7 @@ import com.android.systemui.stackdivider.Divider; import com.android.systemui.statusbar.notification.InstantAppNotifier; import com.android.systemui.statusbar.notification.dagger.NotificationsModule; import com.android.systemui.statusbar.phone.StatusBar; -import com.android.systemui.statusbar.phone.StatusBarModule; +import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule; import com.android.systemui.statusbar.tv.TvStatusBar; import com.android.systemui.theme.ThemeOverlayController; import com.android.systemui.toast.ToastUI; @@ -50,7 +50,7 @@ import dagger.multibindings.IntoMap; /** * SystemUI objects that are injectable should go here. */ -@Module(includes = {RecentsModule.class, StatusBarModule.class, NotificationsModule.class}) +@Module(includes = {RecentsModule.class, StatusBarPhoneModule.class, NotificationsModule.class}) public abstract class SystemUIBinder { /** Inject into AuthController. */ @Binds @@ -143,7 +143,7 @@ public abstract class SystemUIBinder { @ClassKey(StatusBar.class) public abstract SystemUI bindsStatusBar(StatusBar sysui); - /** Inject into SystemActions. */ + /** Inject into SystemActions. */ @Binds @IntoMap @ClassKey(SystemActions.class) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoHideController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoHideController.java index 3165597d4b9bc..971f045e3fb4f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoHideController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoHideController.java @@ -25,8 +25,7 @@ import android.view.MotionEvent; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.statusbar.NotificationRemoteInputManager; - -import javax.inject.Inject; +import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule; /** A controller to control all auto-hide things. */ public class AutoHideController { @@ -51,7 +50,9 @@ public class AutoHideController { } }; - @Inject + /** + * Injected constructor. See {@link StatusBarPhoneModule}. + */ public AutoHideController(Context context, @Main Handler handler, NotificationRemoteInputManager notificationRemoteInputManager, IWindowManager iWindowManager) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java index bdca9a452484d..d709e029d0ee3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java @@ -36,21 +36,18 @@ import com.android.systemui.statusbar.notification.row.RowContentBindParams; import com.android.systemui.statusbar.notification.row.RowContentBindStage; import com.android.systemui.statusbar.phone.NotificationGroupManager.NotificationGroup; import com.android.systemui.statusbar.phone.NotificationGroupManager.OnGroupChangeListener; +import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule; import com.android.systemui.statusbar.policy.HeadsUpManager; import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener; import java.util.ArrayList; import java.util.Objects; -import javax.inject.Inject; -import javax.inject.Singleton; - /** * A helper class dealing with the alert interactions between {@link NotificationGroupManager} and * {@link HeadsUpManager}. In particular, this class deals with keeping * the correct notification in a group alerting based off the group suppression. */ -@Singleton public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedListener, StateListener { @@ -76,7 +73,9 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis private boolean mIsDozing; - @Inject + /** + * Injected constructor. See {@link StatusBarPhoneModule}. + */ public NotificationGroupAlertTransferHelper(RowContentBindStage bindStage) { Dependency.get(StatusBarStateController.class).addCallback(this); mRowContentBindStage = bindStage; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 823adff6cb91e..301eac2e82bd2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -199,6 +199,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.notification.row.NotificationGutsManager; import com.android.systemui.statusbar.notification.stack.NotificationListContainer; import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; +import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback; import com.android.systemui.statusbar.policy.BrightnessMirrorController; @@ -597,7 +598,7 @@ public class StatusBar extends SystemUI implements DemoMode, * Public constructor for StatusBar. * * StatusBar is considered optional, and therefore can not be marked as @Inject directly. - * Instead, an @Provide method is included. + * Instead, an @Provide method is included. See {@link StatusBarPhoneModule}. */ @SuppressWarnings("OptionalUsedAsFieldOrParameterType") public StatusBar( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java similarity index 82% rename from packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarModule.java rename to packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java index 15a0e08e285f8..3c3fb43945245 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 The Android Open Source Project + * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.statusbar.phone; +package com.android.systemui.statusbar.phone.dagger; import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME; @@ -22,6 +22,7 @@ import android.content.Context; import android.os.Handler; import android.os.PowerManager; import android.util.DisplayMetrics; +import android.view.IWindowManager; import androidx.annotation.Nullable; @@ -33,6 +34,7 @@ import com.android.systemui.assist.AssistManager; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.bubbles.BubbleController; import com.android.systemui.colorextraction.SysuiColorExtractor; +import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dagger.qualifiers.UiBackground; import com.android.systemui.keyguard.DismissCallbackRegistry; import com.android.systemui.keyguard.KeyguardViewMediator; @@ -65,7 +67,29 @@ import com.android.systemui.statusbar.notification.VisualStabilityManager; import com.android.systemui.statusbar.notification.init.NotificationsController; import com.android.systemui.statusbar.notification.logging.NotificationLogger; import com.android.systemui.statusbar.notification.row.NotificationGutsManager; -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; +import com.android.systemui.statusbar.notification.row.RowContentBindStage; +import com.android.systemui.statusbar.phone.AutoHideController; +import com.android.systemui.statusbar.phone.BiometricUnlockController; +import com.android.systemui.statusbar.phone.DozeParameters; +import com.android.systemui.statusbar.phone.DozeScrimController; +import com.android.systemui.statusbar.phone.DozeServiceHost; +import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; +import com.android.systemui.statusbar.phone.KeyguardBypassController; +import com.android.systemui.statusbar.phone.KeyguardDismissUtil; +import com.android.systemui.statusbar.phone.KeyguardLiftController; +import com.android.systemui.statusbar.phone.LightBarController; +import com.android.systemui.statusbar.phone.LightsOutNotifController; +import com.android.systemui.statusbar.phone.LockscreenLockIconController; +import com.android.systemui.statusbar.phone.LockscreenWallpaper; +import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper; +import com.android.systemui.statusbar.phone.NotificationGroupManager; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; +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.StatusBarIconController; +import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; +import com.android.systemui.statusbar.phone.StatusBarNotificationActivityStarter; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.DeviceProvisionedController; @@ -92,7 +116,7 @@ import dagger.Provides; * Dagger Module providing {@link StatusBar}. */ @Module(includes = {StatusBarDependenciesModule.class}) -public class StatusBarModule { +public interface StatusBarPhoneModule { /** * Provides our instance of StatusBar which is considered optional. */ @@ -250,4 +274,23 @@ public class StatusBarModule { userInfoControllerImpl, dismissCallbackRegistry); } + + /** */ + @Singleton + @Provides + static AutoHideController newAutoHideController(Context context, + @Main Handler handler, + NotificationRemoteInputManager notificationRemoteInputManager, + IWindowManager iWindowManager) { + return new AutoHideController(context, handler, notificationRemoteInputManager, + iWindowManager); + } + + /** */ + @Singleton + @Provides + static NotificationGroupAlertTransferHelper provideNotificationGroupAlertTransferHelper( + RowContentBindStage bindStage) { + return new NotificationGroupAlertTransferHelper(bindStage); + } } From 3d84cb4a45b0a546435aba54ef209828cdeb029e Mon Sep 17 00:00:00 2001 From: Sergey Nikolaienkov Date: Mon, 10 Feb 2020 16:54:31 +0100 Subject: [PATCH 3/4] Introduce StatusBarModule This CL is the 3rd in the series of CLs which intend to "unbind" StatusBar on TV. In order to make StatusBar really optional and thus to allow us to unbind it, we also need to make some of the classes that depends on it optional as well. For all these cases we need to move from @Inject-annotated contructors to @Provides annotated methods. For this we are introducing StatusBarModule, as well as StatusBarPhoneDependenciesModule and StatusBarDependenciesModule - these two provide dependecies needed to build StatusBar, but not the StatusBar itself Change-Id: Ie3551bda7056465159f2c7fde4989e009f277304 Test: make SystemUI; atest SystemUITests Bug: 146188087 --- .../statusbar/car/CarStatusBarModule.java | 31 +--- .../systemui/dagger/SystemUIBinder.java | 5 +- .../statusbar/NotificationListener.java | 9 +- .../statusbar/NotificationMediaManager.java | 19 +-- .../NotificationRemoteInputManager.java | 9 +- .../NotificationViewHierarchyManager.java | 16 +- .../statusbar/SmartReplyController.java | 9 +- .../StatusBarDependenciesModule.java | 44 ----- .../dagger/StatusBarDependenciesModule.java | 157 ++++++++++++++++++ .../statusbar/dagger/StatusBarModule.java | 29 ++++ .../StatusBarPhoneDependenciesModule.java | 60 +++++++ .../phone/dagger/StatusBarPhoneModule.java | 26 +-- 12 files changed, 283 insertions(+), 131 deletions(-) delete mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/StatusBarDependenciesModule.java create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarDependenciesModule.java create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarModule.java create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneDependenciesModule.java diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java index 6ae7ab5fabce2..7f64990723284 100644 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java +++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java @@ -22,7 +22,6 @@ import android.content.Context; import android.os.Handler; import android.os.PowerManager; import android.util.DisplayMetrics; -import android.view.IWindowManager; import com.android.internal.logging.MetricsLogger; import com.android.keyguard.KeyguardUpdateMonitor; @@ -34,7 +33,6 @@ import com.android.systemui.bubbles.BubbleController; import com.android.systemui.car.CarServiceProvider; import com.android.systemui.car.SystemUIPrimaryWindowController; import com.android.systemui.colorextraction.SysuiColorExtractor; -import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dagger.qualifiers.UiBackground; import com.android.systemui.keyguard.DismissCallbackRegistry; import com.android.systemui.keyguard.KeyguardViewMediator; @@ -56,10 +54,10 @@ import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.NotificationViewHierarchyManager; import com.android.systemui.statusbar.PulseExpansionHandler; -import com.android.systemui.statusbar.StatusBarDependenciesModule; import com.android.systemui.statusbar.SuperStatusBarViewFactory; import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.VibratorHelper; +import com.android.systemui.statusbar.dagger.StatusBarDependenciesModule; import com.android.systemui.statusbar.notification.BypassHeadsUpNotifier; import com.android.systemui.statusbar.notification.DynamicPrivacyController; import com.android.systemui.statusbar.notification.NotificationAlertingManager; @@ -69,7 +67,7 @@ import com.android.systemui.statusbar.notification.VisualStabilityManager; import com.android.systemui.statusbar.notification.init.NotificationsController; import com.android.systemui.statusbar.notification.logging.NotificationLogger; import com.android.systemui.statusbar.notification.row.NotificationGutsManager; -import com.android.systemui.statusbar.notification.row.RowContentBindStage; +import com.android.systemui.statusbar.notification.row.NotificationRowModule; import com.android.systemui.statusbar.phone.AutoHideController; import com.android.systemui.statusbar.phone.BiometricUnlockController; import com.android.systemui.statusbar.phone.DozeParameters; @@ -82,7 +80,6 @@ import com.android.systemui.statusbar.phone.LightBarController; import com.android.systemui.statusbar.phone.LightsOutNotifController; import com.android.systemui.statusbar.phone.LockscreenLockIconController; import com.android.systemui.statusbar.phone.LockscreenWallpaper; -import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper; import com.android.systemui.statusbar.phone.NotificationGroupManager; import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.ScrimController; @@ -91,6 +88,7 @@ import com.android.systemui.statusbar.phone.StatusBarIconController; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.StatusBarNotificationActivityStarter; import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; +import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneDependenciesModule; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.DeviceProvisionedController; @@ -116,7 +114,8 @@ import dagger.Provides; /** * Dagger Module providing {@link CarStatusBar}. */ -@Module(includes = {StatusBarDependenciesModule.class}) +@Module(includes = {StatusBarDependenciesModule.class, StatusBarPhoneDependenciesModule.class, + NotificationRowModule.class}) public class CarStatusBarModule { /** * Provides our instance of StatusBar which is considered optional. @@ -285,24 +284,4 @@ public class CarStatusBarModule { carNavigationBarController, flingAnimationUtilsBuilder); } - - - /** */ - @Singleton - @Provides - static AutoHideController newAutoHideController(Context context, - @Main Handler handler, - NotificationRemoteInputManager notificationRemoteInputManager, - IWindowManager iWindowManager) { - return new AutoHideController(context, handler, notificationRemoteInputManager, - iWindowManager); - } - - /** */ - @Singleton - @Provides - static NotificationGroupAlertTransferHelper provideNotificationGroupAlertTransferHelper( - RowContentBindStage bindStage) { - return new NotificationGroupAlertTransferHelper(bindStage); - } } diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java index 700da715e9309..c3226d3c7b5ee 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java @@ -32,10 +32,9 @@ import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsModule; import com.android.systemui.shortcut.ShortcutKeyDispatcher; import com.android.systemui.stackdivider.Divider; +import com.android.systemui.statusbar.dagger.StatusBarModule; import com.android.systemui.statusbar.notification.InstantAppNotifier; -import com.android.systemui.statusbar.notification.dagger.NotificationsModule; import com.android.systemui.statusbar.phone.StatusBar; -import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule; import com.android.systemui.statusbar.tv.TvStatusBar; import com.android.systemui.theme.ThemeOverlayController; import com.android.systemui.toast.ToastUI; @@ -50,7 +49,7 @@ import dagger.multibindings.IntoMap; /** * SystemUI objects that are injectable should go here. */ -@Module(includes = {RecentsModule.class, StatusBarPhoneModule.class, NotificationsModule.class}) +@Module(includes = {RecentsModule.class, StatusBarModule.class}) public abstract class SystemUIBinder { /** Inject into AuthController. */ @Binds diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java index 4d6764e0a29e4..b43fe73945cd8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java @@ -31,20 +31,17 @@ import android.service.notification.StatusBarNotification; import android.util.Log; import com.android.systemui.dagger.qualifiers.Main; +import com.android.systemui.statusbar.dagger.StatusBarModule; import com.android.systemui.statusbar.phone.NotificationListenerWithPlugins; import java.util.ArrayList; import java.util.List; -import javax.inject.Inject; -import javax.inject.Singleton; - /** * This class handles listening to notification updates and passing them along to * NotificationPresenter to be displayed to the user. */ @SuppressLint("OverrideAbstract") -@Singleton public class NotificationListener extends NotificationListenerWithPlugins { private static final String TAG = "NotificationListener"; @@ -54,7 +51,9 @@ public class NotificationListener extends NotificationListenerWithPlugins { private final List mNotificationHandlers = new ArrayList<>(); private final ArrayList mSettingsListeners = new ArrayList<>(); - @Inject + /** + * Injected constructor. See {@link StatusBarModule}. + */ public NotificationListener( Context context, NotificationManager notificationManager, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java index a4572665ebf13..d0af106d4a0cc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java @@ -53,6 +53,7 @@ import com.android.systemui.Dumpable; import com.android.systemui.Interpolators; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.plugins.statusbar.StatusBarStateController; +import com.android.systemui.statusbar.dagger.StatusBarModule; import com.android.systemui.statusbar.notification.NotificationEntryListener; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.NotificationEntry; @@ -73,16 +74,12 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import javax.inject.Inject; -import javax.inject.Singleton; - import dagger.Lazy; /** * Handles tasks and state related to media notifications. For example, there is a 'current' media * notification, which this class keeps track of. */ -@Singleton public class NotificationMediaManager implements Dumpable { private static final String TAG = "NotificationMediaManager"; public static final boolean DEBUG_MEDIA = false; @@ -101,11 +98,10 @@ public class NotificationMediaManager implements Dumpable { PAUSED_MEDIA_STATES.add(PlaybackState.STATE_ERROR); } - private final NotificationEntryManager mEntryManager; @Nullable - private Lazy mStatusBarWindowController; + private Lazy mNotificationShadeWindowController; @Nullable private BiometricUnlockController mBiometricUnlockController; @@ -176,11 +172,13 @@ public class NotificationMediaManager implements Dumpable { } }; - @Inject + /** + * Injected constructor. See {@link StatusBarModule}. + */ public NotificationMediaManager( Context context, Lazy statusBarLazy, - Lazy statusBarWindowController, + Lazy notificationShadeWindowController, NotificationEntryManager notificationEntryManager, MediaArtworkProcessor mediaArtworkProcessor, KeyguardBypassController keyguardBypassController) { @@ -194,7 +192,7 @@ public class NotificationMediaManager implements Dumpable { Context.MEDIA_SESSION_SERVICE); // TODO: use KeyguardStateController#isOccluded to remove this dependency mStatusBarLazy = statusBarLazy; - mStatusBarWindowController = statusBarWindowController; + mNotificationShadeWindowController = notificationShadeWindowController; mEntryManager = notificationEntryManager; notificationEntryManager.addNotificationEntryListener(new NotificationEntryListener() { @Override @@ -525,7 +523,8 @@ public class NotificationMediaManager implements Dumpable { } } - NotificationShadeWindowController windowController = mStatusBarWindowController.get(); + NotificationShadeWindowController windowController = + mNotificationShadeWindowController.get(); boolean hideBecauseOccluded = mStatusBarLazy.get().isOccluded(); final boolean hasArtwork = artworkDrawable != null; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java index f3783c83a3017..ebc2fa60d3e8c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java @@ -54,6 +54,7 @@ import com.android.systemui.Dumpable; import com.android.systemui.R; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.plugins.statusbar.StatusBarStateController; +import com.android.systemui.statusbar.dagger.StatusBarModule; import com.android.systemui.statusbar.notification.NotificationEntryListener; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.NotificationEntry; @@ -70,9 +71,6 @@ import java.util.ArrayList; import java.util.Objects; import java.util.Set; -import javax.inject.Inject; -import javax.inject.Singleton; - import dagger.Lazy; /** @@ -81,7 +79,6 @@ import dagger.Lazy; * interaction, keeping track of notifications to remove when NotificationPresenter is collapsed, * and handling clicks on remote views. */ -@Singleton public class NotificationRemoteInputManager implements Dumpable { public static final boolean ENABLE_REMOTE_INPUT = SystemProperties.getBoolean("debug.enable_remote_input", true); @@ -257,7 +254,9 @@ public class NotificationRemoteInputManager implements Dumpable { } }; - @Inject + /** + * Injected constructor. See {@link StatusBarModule}. + */ public NotificationRemoteInputManager( Context context, NotificationLockscreenUserManager lockscreenUserManager, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java index 37f9f88f63288..7e70c2059e60f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java @@ -29,6 +29,7 @@ import com.android.systemui.R; import com.android.systemui.bubbles.BubbleController; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.plugins.statusbar.StatusBarStateController; +import com.android.systemui.statusbar.dagger.StatusBarModule; import com.android.systemui.statusbar.notification.DynamicPrivacyController; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.VisualStabilityManager; @@ -46,9 +47,6 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; -import javax.inject.Inject; -import javax.inject.Singleton; - /** * NotificationViewHierarchyManager manages updating the view hierarchy of notification views based * on their group structure. For example, if a notification becomes bundled with another, @@ -56,7 +54,6 @@ import javax.inject.Singleton; * tell NotificationListContainer which notifications to display, and inform it of changes to those * notifications that might affect their display. */ -@Singleton public class NotificationViewHierarchyManager implements DynamicPrivacyController.Listener { private static final String TAG = "NotificationViewHierarchyManager"; @@ -94,8 +91,12 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle // the problem. private boolean mIsHandleDynamicPrivacyChangeScheduled; - @Inject - public NotificationViewHierarchyManager(Context context, @Main Handler mainHandler, + /** + * Injected constructor. See {@link StatusBarModule}. + */ + public NotificationViewHierarchyManager( + Context context, + @Main Handler mainHandler, NotificationLockscreenUserManager notificationLockscreenUserManager, NotificationGroupManager groupManager, VisualStabilityManager visualStabilityManager, @@ -104,8 +105,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle KeyguardBypassController bypassController, BubbleController bubbleController, DynamicPrivacyController privacyController, - ForegroundServiceSectionController fgsSectionController - ) { + ForegroundServiceSectionController fgsSectionController) { mContext = context; mHandler = mainHandler; mLockscreenUserManager = notificationLockscreenUserManager; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java b/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java index 40f8e394f0542..bb96f42758e6e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java @@ -21,27 +21,26 @@ import android.util.ArraySet; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.statusbar.NotificationVisibility; +import com.android.systemui.statusbar.dagger.StatusBarModule; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.logging.NotificationLogger; import java.util.Set; -import javax.inject.Inject; -import javax.inject.Singleton; - /** * Handles when smart replies are added to a notification * and clicked upon. */ -@Singleton public class SmartReplyController { private final IStatusBarService mBarService; private final NotificationEntryManager mEntryManager; private Set mSendingKeys = new ArraySet<>(); private Callback mCallback; - @Inject + /** + * Injected constructor. See {@link StatusBarModule}. + */ public SmartReplyController(NotificationEntryManager entryManager, IStatusBarService statusBarService) { mBarService = statusBarService; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarDependenciesModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarDependenciesModule.java deleted file mode 100644 index 493482aacce5f..0000000000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarDependenciesModule.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2019 The Android Open Source Project - * - * 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 - * - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar; - -import android.content.Context; - -import com.android.systemui.statusbar.notification.row.NotificationRowModule; -import com.android.systemui.recents.OverviewProxyService; -import com.android.systemui.tracing.ProtoTracer; - -import javax.inject.Singleton; - -import dagger.Module; -import dagger.Provides; - -/** - * Dagger Module providing common dependencies of StatusBar. - */ -@Module(includes = {NotificationRowModule.class}) -public class StatusBarDependenciesModule { - /** - * Provides our instance of CommandQueue which is considered optional. - */ - @Provides - @Singleton - public CommandQueue provideCommandQueue(Context context, ProtoTracer protoTracer) { - return new CommandQueue(context, protoTracer); - } - -} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarDependenciesModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarDependenciesModule.java new file mode 100644 index 0000000000000..0b37c229555f7 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarDependenciesModule.java @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * 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 + * + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.dagger; + +import android.app.NotificationManager; +import android.content.Context; +import android.os.Handler; + +import com.android.internal.statusbar.IStatusBarService; +import com.android.systemui.bubbles.BubbleController; +import com.android.systemui.dagger.qualifiers.Main; +import com.android.systemui.plugins.statusbar.StatusBarStateController; +import com.android.systemui.statusbar.CommandQueue; +import com.android.systemui.statusbar.MediaArtworkProcessor; +import com.android.systemui.statusbar.NotificationListener; +import com.android.systemui.statusbar.NotificationLockscreenUserManager; +import com.android.systemui.statusbar.NotificationMediaManager; +import com.android.systemui.statusbar.NotificationRemoteInputManager; +import com.android.systemui.statusbar.NotificationViewHierarchyManager; +import com.android.systemui.statusbar.SmartReplyController; +import com.android.systemui.statusbar.notification.DynamicPrivacyController; +import com.android.systemui.statusbar.notification.NotificationEntryManager; +import com.android.systemui.statusbar.notification.VisualStabilityManager; +import com.android.systemui.statusbar.notification.stack.ForegroundServiceSectionController; +import com.android.systemui.statusbar.phone.KeyguardBypassController; +import com.android.systemui.statusbar.phone.NotificationGroupManager; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; +import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.policy.RemoteInputUriController; +import com.android.systemui.tracing.ProtoTracer; + +import javax.inject.Singleton; + +import dagger.Lazy; +import dagger.Module; +import dagger.Provides; + +/** + * This module provides instances needed to construct {@link StatusBar}. These are moved to this + * separate from {@link StatusBarModule} module so that components that wish to build their own + * version of StatusBar can include just dependencies, without injecting StatusBar itself. + */ +@Module +public interface StatusBarDependenciesModule { + /** */ + @Singleton + @Provides + static NotificationRemoteInputManager provideNotificationRemoteInputManager( + Context context, + NotificationLockscreenUserManager lockscreenUserManager, + SmartReplyController smartReplyController, + NotificationEntryManager notificationEntryManager, + Lazy statusBarLazy, + StatusBarStateController statusBarStateController, + Handler mainHandler, + RemoteInputUriController remoteInputUriController) { + return new NotificationRemoteInputManager( + context, + lockscreenUserManager, + smartReplyController, + notificationEntryManager, + statusBarLazy, + statusBarStateController, + mainHandler, + remoteInputUriController); + } + + /** */ + @Singleton + @Provides + static NotificationMediaManager provideNotificationMediaManager( + Context context, + Lazy statusBarLazy, + Lazy notificationShadeWindowController, + NotificationEntryManager notificationEntryManager, + MediaArtworkProcessor mediaArtworkProcessor, + KeyguardBypassController keyguardBypassController) { + return new NotificationMediaManager( + context, + statusBarLazy, + notificationShadeWindowController, + notificationEntryManager, + mediaArtworkProcessor, + keyguardBypassController); + } + + /** */ + @Singleton + @Provides + static NotificationListener provideNotificationListener( + Context context, + NotificationManager notificationManager, + @Main Handler mainHandler) { + return new NotificationListener( + context, notificationManager, mainHandler); + } + + /** */ + @Singleton + @Provides + static SmartReplyController provideSmartReplyController( + NotificationEntryManager entryManager, IStatusBarService statusBarService) { + return new SmartReplyController(entryManager, statusBarService); + } + + /** */ + @Singleton + @Provides + static NotificationViewHierarchyManager provideNotificationViewHierarchyManager( + Context context, + @Main Handler mainHandler, + NotificationLockscreenUserManager notificationLockscreenUserManager, + NotificationGroupManager groupManager, + VisualStabilityManager visualStabilityManager, + StatusBarStateController statusBarStateController, + NotificationEntryManager notificationEntryManager, + KeyguardBypassController bypassController, + BubbleController bubbleController, + DynamicPrivacyController privacyController, + ForegroundServiceSectionController fgsSectionController) { + return new NotificationViewHierarchyManager( + context, + mainHandler, + notificationLockscreenUserManager, + groupManager, + visualStabilityManager, + statusBarStateController, + notificationEntryManager, + bypassController, + bubbleController, + privacyController, + fgsSectionController); + } + + /** + * Provides our instance of CommandQueue which is considered optional. + */ + @Provides + @Singleton + static CommandQueue provideCommandQueue(Context context, ProtoTracer protoTracer) { + return new CommandQueue(context, protoTracer); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarModule.java new file mode 100644 index 0000000000000..ad5ef2043ccd5 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarModule.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * 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 + * + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.dagger; + +import com.android.systemui.statusbar.notification.dagger.NotificationsModule; +import com.android.systemui.statusbar.notification.row.NotificationRowModule; +import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule; + +import dagger.Module; + +/** */ +@Module(includes = {StatusBarPhoneModule.class, StatusBarDependenciesModule.class, + NotificationsModule.class, NotificationRowModule.class}) +public interface StatusBarModule { +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneDependenciesModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneDependenciesModule.java new file mode 100644 index 0000000000000..fcf698cae49bf --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneDependenciesModule.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * 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 + * + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.phone.dagger; + +import android.content.Context; +import android.os.Handler; +import android.view.IWindowManager; + +import com.android.systemui.dagger.qualifiers.Main; +import com.android.systemui.statusbar.NotificationRemoteInputManager; +import com.android.systemui.statusbar.notification.row.RowContentBindStage; +import com.android.systemui.statusbar.phone.AutoHideController; +import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper; +import com.android.systemui.statusbar.phone.StatusBar; + +import javax.inject.Singleton; + +import dagger.Module; +import dagger.Provides; + +/** + * This module provides instances needed to construct {@link StatusBar}. These are moved to this + * separate from {@link StatusBarPhoneModule} module so that components that wish to build their own + * version of StatusBar can include just dependencies, without injecting StatusBar itself. + */ +@Module +public interface StatusBarPhoneDependenciesModule { + /** */ + @Singleton + @Provides + static AutoHideController newAutoHideController(Context context, + @Main Handler handler, + NotificationRemoteInputManager notificationRemoteInputManager, + IWindowManager iWindowManager) { + return new AutoHideController(context, handler, notificationRemoteInputManager, + iWindowManager); + } + + /** */ + @Singleton + @Provides + static NotificationGroupAlertTransferHelper provideNotificationGroupAlertTransferHelper( + RowContentBindStage bindStage) { + return new NotificationGroupAlertTransferHelper(bindStage); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java index 3c3fb43945245..26459a9a66ba3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java @@ -22,7 +22,6 @@ import android.content.Context; import android.os.Handler; import android.os.PowerManager; import android.util.DisplayMetrics; -import android.view.IWindowManager; import androidx.annotation.Nullable; @@ -34,7 +33,6 @@ import com.android.systemui.assist.AssistManager; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.bubbles.BubbleController; import com.android.systemui.colorextraction.SysuiColorExtractor; -import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dagger.qualifiers.UiBackground; import com.android.systemui.keyguard.DismissCallbackRegistry; import com.android.systemui.keyguard.KeyguardViewMediator; @@ -54,7 +52,6 @@ import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.NotificationViewHierarchyManager; import com.android.systemui.statusbar.PulseExpansionHandler; -import com.android.systemui.statusbar.StatusBarDependenciesModule; import com.android.systemui.statusbar.SuperStatusBarViewFactory; import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.VibratorHelper; @@ -67,7 +64,6 @@ import com.android.systemui.statusbar.notification.VisualStabilityManager; import com.android.systemui.statusbar.notification.init.NotificationsController; import com.android.systemui.statusbar.notification.logging.NotificationLogger; import com.android.systemui.statusbar.notification.row.NotificationGutsManager; -import com.android.systemui.statusbar.notification.row.RowContentBindStage; import com.android.systemui.statusbar.phone.AutoHideController; import com.android.systemui.statusbar.phone.BiometricUnlockController; import com.android.systemui.statusbar.phone.DozeParameters; @@ -81,7 +77,6 @@ import com.android.systemui.statusbar.phone.LightBarController; import com.android.systemui.statusbar.phone.LightsOutNotifController; import com.android.systemui.statusbar.phone.LockscreenLockIconController; import com.android.systemui.statusbar.phone.LockscreenWallpaper; -import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper; import com.android.systemui.statusbar.phone.NotificationGroupManager; import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.ScrimController; @@ -115,7 +110,7 @@ import dagger.Provides; /** * Dagger Module providing {@link StatusBar}. */ -@Module(includes = {StatusBarDependenciesModule.class}) +@Module(includes = {StatusBarPhoneDependenciesModule.class}) public interface StatusBarPhoneModule { /** * Provides our instance of StatusBar which is considered optional. @@ -274,23 +269,4 @@ public interface StatusBarPhoneModule { userInfoControllerImpl, dismissCallbackRegistry); } - - /** */ - @Singleton - @Provides - static AutoHideController newAutoHideController(Context context, - @Main Handler handler, - NotificationRemoteInputManager notificationRemoteInputManager, - IWindowManager iWindowManager) { - return new AutoHideController(context, handler, notificationRemoteInputManager, - iWindowManager); - } - - /** */ - @Singleton - @Provides - static NotificationGroupAlertTransferHelper provideNotificationGroupAlertTransferHelper( - RowContentBindStage bindStage) { - return new NotificationGroupAlertTransferHelper(bindStage); - } } From 5cb6e52e813d7be813436962c5ce186ecb64bd7b Mon Sep 17 00:00:00 2001 From: Sergey Nikolaienkov Date: Mon, 10 Feb 2020 17:33:00 +0100 Subject: [PATCH 4/4] Introduce BubbleModule and KeyguardModule This CL is the 4th in the series of CLs which intend to "unbind" StatusBar on TV. In order to make StatusBar really optional and thus to allow us to unbind it, we also need to make some of the classes that depends on it optional as well. For all these cases we need to move from @Inject-annotated contructors to @Provides annotated methods. For this we are introducing BubbleModule and KeyguardModule. Change-Id: I57009153e2279078ac88c42a53d3963a96eb8452 Test: make SystemUI; atest SystemUITests Bug: 146188087 --- .../android/systemui/CarSystemUIBinder.java | 5 +- .../systemui/bubbles/BubbleController.java | 12 +-- .../systemui/bubbles/dagger/BubbleModule.java | 81 +++++++++++++++++++ .../systemui/dagger/SystemUIBinder.java | 5 +- .../keyguard/KeyguardViewMediator.java | 9 +-- .../keyguard/dagger/KeyguardModule.java | 68 ++++++++++++++++ 6 files changed, 165 insertions(+), 15 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/bubbles/dagger/BubbleModule.java create mode 100644 packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIBinder.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIBinder.java index 0a76c7ddbe8d4..8eeaefda0920f 100644 --- a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIBinder.java +++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIBinder.java @@ -17,8 +17,10 @@ package com.android.systemui; import com.android.systemui.biometrics.AuthController; +import com.android.systemui.bubbles.dagger.BubbleModule; import com.android.systemui.globalactions.GlobalActionsComponent; import com.android.systemui.keyguard.KeyguardViewMediator; +import com.android.systemui.keyguard.dagger.KeyguardModule; import com.android.systemui.navigationbar.car.CarNavigationBar; import com.android.systemui.pip.PipUI; import com.android.systemui.power.PowerUI; @@ -43,7 +45,8 @@ import dagger.multibindings.ClassKey; import dagger.multibindings.IntoMap; /** Binder for car specific {@link SystemUI} modules. */ -@Module(includes = {RecentsModule.class, CarStatusBarModule.class, NotificationsModule.class}) +@Module(includes = {RecentsModule.class, CarStatusBarModule.class, NotificationsModule.class, + BubbleModule.class, KeyguardModule.class}) public abstract class CarSystemUIBinder { /** Inject into AuthController. */ @Binds diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index 762e5f21cd63c..1f94dbd5e59af 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -72,9 +72,7 @@ import com.android.internal.statusbar.NotificationVisibility; import com.android.systemui.DumpController; import com.android.systemui.Dumpable; import com.android.systemui.R; -import com.android.systemui.bubbles.BubbleController.BubbleExpandListener; -import com.android.systemui.bubbles.BubbleController.BubbleStateChangeListener; -import com.android.systemui.bubbles.BubbleController.NotifCallback; +import com.android.systemui.bubbles.dagger.BubbleModule; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.PinnedStackListenerForwarder; @@ -105,16 +103,12 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; -import javax.inject.Inject; -import javax.inject.Singleton; - /** * Bubbles are a special type of content that can "float" on top of other apps or System UI. * Bubbles can be expanded to show more content. * * The controller manages addition, removal, and visible state of bubbles on screen. */ -@Singleton public class BubbleController implements ConfigurationController.ConfigurationListener, Dumpable { private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleController" : TAG_BUBBLES; @@ -277,7 +271,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi } } - @Inject public BubbleController(Context context, NotificationShadeWindowController notificationShadeWindowController, StatusBarStateController statusBarStateController, @@ -298,6 +291,9 @@ public class BubbleController implements ConfigurationController.ConfigurationLi notifPipeline, featureFlags, dumpController); } + /** + * Injected constructor. See {@link BubbleModule}. + */ public BubbleController(Context context, NotificationShadeWindowController notificationShadeWindowController, StatusBarStateController statusBarStateController, diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/dagger/BubbleModule.java b/packages/SystemUI/src/com/android/systemui/bubbles/dagger/BubbleModule.java new file mode 100644 index 0000000000000..0337ee37bd374 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/bubbles/dagger/BubbleModule.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * 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 + * + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.bubbles.dagger; + +import android.content.Context; + +import com.android.systemui.DumpController; +import com.android.systemui.bubbles.BubbleController; +import com.android.systemui.bubbles.BubbleData; +import com.android.systemui.plugins.statusbar.StatusBarStateController; +import com.android.systemui.statusbar.FeatureFlags; +import com.android.systemui.statusbar.NotificationLockscreenUserManager; +import com.android.systemui.statusbar.notification.NotificationEntryManager; +import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider; +import com.android.systemui.statusbar.notification.collection.NotifPipeline; +import com.android.systemui.statusbar.phone.NotificationGroupManager; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; +import com.android.systemui.statusbar.phone.ShadeController; +import com.android.systemui.statusbar.policy.ConfigurationController; +import com.android.systemui.statusbar.policy.ZenModeController; + +import javax.inject.Singleton; + +import dagger.Module; +import dagger.Provides; + +/** */ +@Module +public interface BubbleModule { + + /** + */ + @Singleton + @Provides + static BubbleController newBubbleController( + Context context, + NotificationShadeWindowController notificationShadeWindowController, + StatusBarStateController statusBarStateController, + ShadeController shadeController, + BubbleData data, + ConfigurationController configurationController, + NotificationInterruptionStateProvider interruptionStateProvider, + ZenModeController zenModeController, + NotificationLockscreenUserManager notifUserManager, + NotificationGroupManager groupManager, + NotificationEntryManager entryManager, + NotifPipeline notifPipeline, + FeatureFlags featureFlags, + DumpController dumpController) { + return new BubbleController( + context, + notificationShadeWindowController, + statusBarStateController, + shadeController, + data, + /* synchronizer */null, + configurationController, + interruptionStateProvider, + zenModeController, + notifUserManager, + groupManager, + entryManager, + notifPipeline, + featureFlags, + dumpController); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java index c3226d3c7b5ee..413a522bccdce 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java @@ -24,8 +24,10 @@ import com.android.systemui.SystemUI; import com.android.systemui.accessibility.SystemActions; import com.android.systemui.accessibility.WindowMagnification; import com.android.systemui.biometrics.AuthController; +import com.android.systemui.bubbles.dagger.BubbleModule; import com.android.systemui.globalactions.GlobalActionsComponent; import com.android.systemui.keyguard.KeyguardViewMediator; +import com.android.systemui.keyguard.dagger.KeyguardModule; import com.android.systemui.pip.PipUI; import com.android.systemui.power.PowerUI; import com.android.systemui.recents.Recents; @@ -49,7 +51,8 @@ import dagger.multibindings.IntoMap; /** * SystemUI objects that are injectable should go here. */ -@Module(includes = {RecentsModule.class, StatusBarModule.class}) +@Module(includes = {RecentsModule.class, StatusBarModule.class, BubbleModule.class, + KeyguardModule.class}) public abstract class SystemUIBinder { /** Inject into AuthController. */ @Binds diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 83a6d7528dbb8..b1db7dfc5be9a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -86,6 +86,7 @@ import com.android.systemui.SystemUI; import com.android.systemui.SystemUIFactory; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dagger.qualifiers.UiBackground; +import com.android.systemui.keyguard.dagger.KeyguardModule; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.statusbar.phone.BiometricUnlockController; import com.android.systemui.statusbar.phone.KeyguardBypassController; @@ -100,9 +101,6 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.concurrent.Executor; -import javax.inject.Inject; -import javax.inject.Singleton; - import dagger.Lazy; /** @@ -146,7 +144,6 @@ import dagger.Lazy; * directly to the keyguard UI is posted to a {@link android.os.Handler} to ensure it is taken on the UI * thread of the keyguard. */ -@Singleton public class KeyguardViewMediator extends SystemUI { private static final int KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT = 30000; private static final long KEYGUARD_DONE_PENDING_TIMEOUT_MS = 3000; @@ -688,7 +685,9 @@ public class KeyguardViewMediator extends SystemUI { } }; - @Inject + /** + * Injected constructor. See {@link KeyguardModule}. + */ public KeyguardViewMediator( Context context, FalsingManager falsingManager, diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java b/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java new file mode 100644 index 0000000000000..2c023cadd9ead --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * 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 + * + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.keyguard.dagger; + +import android.content.Context; + +import com.android.internal.widget.LockPatternUtils; +import com.android.systemui.broadcast.BroadcastDispatcher; +import com.android.systemui.dagger.qualifiers.UiBackground; +import com.android.systemui.keyguard.DismissCallbackRegistry; +import com.android.systemui.keyguard.KeyguardViewMediator; +import com.android.systemui.plugins.FalsingManager; +import com.android.systemui.statusbar.phone.NotificationShadeWindowController; +import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; + +import java.util.concurrent.Executor; + +import javax.inject.Singleton; + +import dagger.Lazy; +import dagger.Module; +import dagger.Provides; + +/** + * Dagger Module providing {@link StatusBar}. + */ +@Module +public class KeyguardModule { + /** + * Provides our instance of KeyguardViewMediator which is considered optional. + */ + @Provides + @Singleton + public static KeyguardViewMediator newKeyguardViewMediator( + Context context, + FalsingManager falsingManager, + LockPatternUtils lockPatternUtils, + BroadcastDispatcher broadcastDispatcher, + NotificationShadeWindowController notificationShadeWindowController, + Lazy statusBarKeyguardViewManagerLazy, + DismissCallbackRegistry dismissCallbackRegistry, + @UiBackground Executor uiBgExecutor) { + return new KeyguardViewMediator( + context, + falsingManager, + lockPatternUtils, + broadcastDispatcher, + notificationShadeWindowController, + statusBarKeyguardViewManagerLazy, + dismissCallbackRegistry, + uiBgExecutor); + } +}