diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt index 7c161d518adf8..4b2a65f36aa1e 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt @@ -37,6 +37,10 @@ import com.android.systemui.privacy.OngoingPrivacyChip import com.android.systemui.scene.ui.view.WindowRootView import com.android.systemui.settings.UserTracker import com.android.systemui.statusbar.LightRevealScrim +import com.android.systemui.statusbar.NotificationShelf +import com.android.systemui.statusbar.NotificationShelfController +import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent +import com.android.systemui.statusbar.notification.shelf.ui.viewbinder.NotificationShelfViewBinderWrapperControllerImpl import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout import com.android.systemui.statusbar.phone.StatusIconContainer import com.android.systemui.statusbar.phone.TapAgainView @@ -49,6 +53,7 @@ import dagger.Provides import dagger.multibindings.ClassKey import dagger.multibindings.IntoMap import javax.inject.Named +import javax.inject.Provider /** Module for classes related to the notification shade. */ @Module @@ -102,6 +107,32 @@ abstract class ShadeModule { return notificationShadeWindowView.findViewById(R.id.notification_stack_scroller) } + @Provides + @SysUISingleton + fun providesNotificationShelfController( + featureFlags: FeatureFlags, + newImpl: Provider, + notificationShelfComponentBuilder: NotificationShelfComponent.Builder, + layoutInflater: LayoutInflater, + notificationStackScrollLayout: NotificationStackScrollLayout, + ): NotificationShelfController { + return if (featureFlags.isEnabled(Flags.NOTIFICATION_SHELF_REFACTOR)) { + newImpl.get() + } else { + val shelfView = + layoutInflater.inflate( + R.layout.status_bar_notification_shelf, + notificationStackScrollLayout, + false + ) as NotificationShelf + val component = + notificationShelfComponentBuilder.notificationShelf(shelfView).build() + val notificationShelfController = component.notificationShelfController + notificationShelfController.init() + notificationShelfController + } + } + // TODO(b/277762009): Only allow this view's controller to inject the view. See above. @Provides @SysUISingleton diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/domain/interactor/NotificationShelfInteractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/domain/interactor/NotificationShelfInteractor.kt index 014406fe49f99..69484b06c776a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/domain/interactor/NotificationShelfInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/domain/interactor/NotificationShelfInteractor.kt @@ -17,19 +17,19 @@ package com.android.systemui.statusbar.notification.shelf.domain.interactor import android.os.PowerManager +import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.data.repository.DeviceEntryFaceAuthRepository import com.android.systemui.keyguard.data.repository.KeyguardRepository import com.android.systemui.statusbar.LockscreenShadeTransitionController import com.android.systemui.statusbar.NotificationShelf import com.android.systemui.statusbar.phone.CentralSurfaces -import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent import com.android.systemui.util.time.SystemClock import javax.inject.Inject import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine /** Interactor for the [NotificationShelf] */ -@CentralSurfacesComponent.CentralSurfacesScope +@SysUISingleton class NotificationShelfInteractor @Inject constructor( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/ui/viewbinder/NotificationShelfViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/ui/viewbinder/NotificationShelfViewBinder.kt index 12956ab9498a4..252073825bced 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/ui/viewbinder/NotificationShelfViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/ui/viewbinder/NotificationShelfViewBinder.kt @@ -19,6 +19,7 @@ package com.android.systemui.statusbar.notification.shelf.ui.viewbinder import android.view.View import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle +import com.android.systemui.dagger.SysUISingleton import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags import com.android.systemui.lifecycle.repeatWhenAttached @@ -32,7 +33,6 @@ import com.android.systemui.statusbar.notification.stack.AmbientState import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController import com.android.systemui.statusbar.phone.NotificationIconAreaController import com.android.systemui.statusbar.phone.NotificationIconContainer -import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent.CentralSurfacesScope import javax.inject.Inject import kotlinx.coroutines.awaitCancellation import kotlinx.coroutines.launch @@ -43,7 +43,7 @@ import kotlinx.coroutines.launch * [NotificationShelfController] interface. Once the [LegacyNotificationShelfControllerImpl] is * removed, this class can go away and the ViewBinder can be used directly. */ -@CentralSurfacesScope +@SysUISingleton class NotificationShelfViewBinderWrapperControllerImpl @Inject constructor() : NotificationShelfController { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index c239113bf40da..50e286f545cd8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -746,6 +746,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { Lazy assistManagerLazy, ConfigurationController configurationController, NotificationShadeWindowController notificationShadeWindowController, + NotificationShelfController notificationShelfController, DozeParameters dozeParameters, ScrimController scrimController, Lazy lockscreenWallpaperLazy, @@ -842,6 +843,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mAssistManagerLazy = assistManagerLazy; mConfigurationController = configurationController; mNotificationShadeWindowController = notificationShadeWindowController; + mNotificationShelfController = notificationShelfController; mDozeServiceHost = dozeServiceHost; mPowerManager = powerManager; mDozeParameters = dozeParameters; @@ -1652,7 +1654,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mNotifListContainer = mCentralSurfacesComponent.getNotificationListContainer(); mPresenter = mCentralSurfacesComponent.getNotificationPresenter(); mNotificationActivityStarter = mCentralSurfacesComponent.getNotificationActivityStarter(); - mNotificationShelfController = mCentralSurfacesComponent.getNotificationShelfController(); mHeadsUpManager.addListener(mCentralSurfacesComponent.getStatusBarHeadsUpChangeListener()); @@ -3410,7 +3411,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { protected Display mDisplay; private int mDisplayId; - protected NotificationShelfController mNotificationShelfController; + private final NotificationShelfController mNotificationShelfController; private final Lazy mAssistManagerLazy; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesComponent.java index 62aa7eb4f341b..64c798b99a18c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesComponent.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesComponent.java @@ -27,7 +27,6 @@ import com.android.systemui.shade.NotificationShadeWindowViewController; import com.android.systemui.shade.QuickSettingsController; import com.android.systemui.shade.ShadeHeaderController; import com.android.systemui.statusbar.NotificationPresenter; -import com.android.systemui.statusbar.NotificationShelfController; import com.android.systemui.statusbar.notification.NotificationActivityStarter; import com.android.systemui.statusbar.notification.stack.NotificationListContainer; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; @@ -88,9 +87,6 @@ public interface CentralSurfacesComponent { */ NotificationShadeWindowView getNotificationShadeWindowView(); - /** */ - NotificationShelfController getNotificationShelfController(); - /** */ NotificationStackScrollLayoutController getNotificationStackScrollLayoutController(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java index 76409c26be8f3..260d986db6c0d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java @@ -23,22 +23,15 @@ import com.android.systemui.R; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FeatureFlags; -import com.android.systemui.flags.Flags; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.shade.NotificationPanelView; import com.android.systemui.shade.NotificationPanelViewController; import com.android.systemui.shade.ShadeExpansionStateManager; import com.android.systemui.shade.ShadeViewController; import com.android.systemui.statusbar.CommandQueue; -import com.android.systemui.statusbar.LegacyNotificationShelfControllerImpl; -import com.android.systemui.statusbar.NotificationShelf; -import com.android.systemui.statusbar.NotificationShelfController; import com.android.systemui.statusbar.OperatorNameViewController; import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler; -import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent; import com.android.systemui.statusbar.notification.row.ui.viewmodel.ActivatableNotificationViewModelModule; -import com.android.systemui.statusbar.notification.shelf.ui.viewbinder.NotificationShelfViewBinderWrapperControllerImpl; -import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationListViewModelModule; import com.android.systemui.statusbar.phone.KeyguardBottomAreaView; import com.android.systemui.statusbar.phone.NotificationIconAreaController; @@ -66,7 +59,6 @@ import dagger.multibindings.IntoSet; import java.util.concurrent.Executor; import javax.inject.Named; -import javax.inject.Provider; @Module(subcomponents = StatusBarFragmentComponent.class, includes = { @@ -77,43 +69,6 @@ public abstract class StatusBarViewModule { public static final String STATUS_BAR_FRAGMENT = "status_bar_fragment"; - /** */ - @Provides - @CentralSurfacesComponent.CentralSurfacesScope - public static NotificationShelf providesNotificationShelf(LayoutInflater layoutInflater, - NotificationStackScrollLayout notificationStackScrollLayout) { - NotificationShelf view = (NotificationShelf) layoutInflater.inflate( - R.layout.status_bar_notification_shelf, notificationStackScrollLayout, false); - - if (view == null) { - throw new IllegalStateException( - "R.layout.status_bar_notification_shelf could not be properly inflated"); - } - return view; - } - - /** */ - @Provides - @CentralSurfacesComponent.CentralSurfacesScope - public static NotificationShelfController providesStatusBarWindowView( - FeatureFlags featureFlags, - Provider newImpl, - NotificationShelfComponent.Builder notificationShelfComponentBuilder, - NotificationShelf notificationShelf) { - if (featureFlags.isEnabled(Flags.NOTIFICATION_SHELF_REFACTOR)) { - return newImpl.get(); - } else { - NotificationShelfComponent component = notificationShelfComponentBuilder - .notificationShelf(notificationShelf) - .build(); - LegacyNotificationShelfControllerImpl notificationShelfController = - component.getNotificationShelfController(); - notificationShelfController.init(); - - return notificationShelfController; - } - } - /** */ @Binds @CentralSurfacesComponent.CentralSurfacesScope diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java index 771af11459345..21dae039f4145 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java @@ -145,6 +145,7 @@ import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.NotificationShadeDepthController; import com.android.systemui.statusbar.NotificationShadeWindowController; +import com.android.systemui.statusbar.NotificationShelfController; import com.android.systemui.statusbar.OperatorNameViewController; import com.android.systemui.statusbar.PulseExpansionHandler; import com.android.systemui.statusbar.StatusBarState; @@ -273,6 +274,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { @Mock private NotificationShadeWindowController mNotificationShadeWindowController; @Mock private NotificationIconAreaController mNotificationIconAreaController; @Mock private NotificationShadeWindowViewController mNotificationShadeWindowViewController; + @Mock private NotificationShelfController mNotificationShelfController; @Mock private DozeParameters mDozeParameters; @Mock private Lazy mLockscreenWallpaperLazy; @Mock private LockscreenWallpaper mLockscreenWallpaper; @@ -499,6 +501,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { () -> mAssistManager, configurationController, mNotificationShadeWindowController, + mNotificationShelfController, mDozeParameters, mScrimController, mLockscreenWallpaperLazy,