[Central Surfaces] Make NotificationShelf & classes singletons.

Bug: 277762009
Test: verify notif shelf still works, across restarts and display
size/font changes
Test: verify notif shelf still works with NOTIFICATION_SHELF_REFACTOR
flag on
Test: atest CentralSurfacesImplTest

Change-Id: Iabb1d67f167d3134d08a341aa3865b6fa64aeb8b
This commit is contained in:
Caitlin Shkuratov
2023-06-07 20:54:43 +00:00
parent 061d85a4bc
commit 3bbe012397
7 changed files with 41 additions and 55 deletions

View File

@@ -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<NotificationShelfViewBinderWrapperControllerImpl>,
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

View File

@@ -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(

View File

@@ -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 {

View File

@@ -744,6 +744,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
Lazy<AssistManager> assistManagerLazy,
ConfigurationController configurationController,
NotificationShadeWindowController notificationShadeWindowController,
NotificationShelfController notificationShelfController,
DozeParameters dozeParameters,
ScrimController scrimController,
Lazy<LockscreenWallpaper> lockscreenWallpaperLazy,
@@ -840,6 +841,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
mAssistManagerLazy = assistManagerLazy;
mConfigurationController = configurationController;
mNotificationShadeWindowController = notificationShadeWindowController;
mNotificationShelfController = notificationShelfController;
mDozeServiceHost = dozeServiceHost;
mPowerManager = powerManager;
mDozeParameters = dozeParameters;
@@ -1651,7 +1653,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
mNotifListContainer = mCentralSurfacesComponent.getNotificationListContainer();
mPresenter = mCentralSurfacesComponent.getNotificationPresenter();
mNotificationActivityStarter = mCentralSurfacesComponent.getNotificationActivityStarter();
mNotificationShelfController = mCentralSurfacesComponent.getNotificationShelfController();
mHeadsUpManager.addListener(mCentralSurfacesComponent.getStatusBarHeadsUpChangeListener());
@@ -3408,7 +3409,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
protected Display mDisplay;
private int mDisplayId;
protected NotificationShelfController mNotificationShelfController;
private final NotificationShelfController mNotificationShelfController;
private final Lazy<AssistManager> mAssistManagerLazy;

View File

@@ -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.collection.inflation.NotificationRowBinderImpl;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
@@ -89,9 +88,6 @@ public interface CentralSurfacesComponent {
*/
NotificationShadeWindowView getNotificationShadeWindowView();
/** */
NotificationShelfController getNotificationShelfController();
/** */
NotificationStackScrollLayoutController getNotificationStackScrollLayoutController();

View File

@@ -23,7 +23,6 @@ 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;
@@ -32,15 +31,9 @@ import com.android.systemui.shade.NotificationsQuickSettingsContainer;
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;
@@ -68,7 +61,6 @@ import dagger.multibindings.IntoSet;
import java.util.concurrent.Executor;
import javax.inject.Named;
import javax.inject.Provider;
@Module(subcomponents = StatusBarFragmentComponent.class,
includes = {
@@ -79,43 +71,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<NotificationShelfViewBinderWrapperControllerImpl> 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

View File

@@ -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<LockscreenWallpaper> mLockscreenWallpaperLazy;
@Mock private LockscreenWallpaper mLockscreenWallpaper;
@@ -499,6 +501,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
() -> mAssistManager,
configurationController,
mNotificationShadeWindowController,
mNotificationShelfController,
mDozeParameters,
mScrimController,
mLockscreenWallpaperLazy,