diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java index 9023d3a83c53a..2f5a18e1a2e5f 100644 --- a/packages/SystemUI/src/com/android/systemui/Dependency.java +++ b/packages/SystemUI/src/com/android/systemui/Dependency.java @@ -89,8 +89,12 @@ import com.android.systemui.statusbar.notification.NotificationEntryManager.Keyg import com.android.systemui.statusbar.notification.NotificationFilter; import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy; import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager; +import com.android.systemui.statusbar.notification.collection.render.GroupExpansionManager; +import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager; import com.android.systemui.statusbar.notification.logging.NotificationLogger; import com.android.systemui.statusbar.notification.row.NotificationGutsManager; +import com.android.systemui.statusbar.notification.stack.AmbientState; +import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager; import com.android.systemui.statusbar.phone.AutoHideController; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.statusbar.phone.KeyguardDismissUtil; @@ -102,6 +106,7 @@ import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.StatusBarContentInsetsProvider; import com.android.systemui.statusbar.phone.StatusBarIconController; import com.android.systemui.statusbar.phone.StatusBarWindowController; +import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController; import com.android.systemui.statusbar.policy.AccessibilityController; import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper; import com.android.systemui.statusbar.policy.BatteryController; @@ -360,6 +365,11 @@ public class Dependency { @Inject Lazy mContentInsetsProviderLazy; @Inject Lazy mInternetDialogFactory; @Inject Lazy mFeatureFlagsLazy; + @Inject Lazy mNotificationSectionsManagerLazy; + @Inject Lazy mUnlockedScreenOffAnimationControllerLazy; + @Inject Lazy mAmbientStateLazy; + @Inject Lazy mGroupMembershipManagerLazy; + @Inject Lazy mGroupExpansionManagerLazy; @Inject public Dependency() { @@ -574,6 +584,12 @@ public class Dependency { mProviders.put(UiEventLogger.class, mUiEventLogger::get); mProviders.put(FeatureFlags.class, mFeatureFlagsLazy::get); mProviders.put(StatusBarContentInsetsProvider.class, mContentInsetsProviderLazy::get); + mProviders.put(NotificationSectionsManager.class, mNotificationSectionsManagerLazy::get); + mProviders.put(UnlockedScreenOffAnimationController.class, + mUnlockedScreenOffAnimationControllerLazy::get); + mProviders.put(AmbientState.class, mAmbientStateLazy::get); + mProviders.put(GroupMembershipManager.class, mGroupMembershipManagerLazy::get); + mProviders.put(GroupExpansionManager.class, mGroupExpansionManagerLazy::get); Dependency.setInstance(this); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index c7f7b66797185..5162f00dc4ca6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -74,6 +74,7 @@ import com.android.internal.graphics.ColorUtils; import com.android.internal.jank.InteractionJankMonitor; import com.android.keyguard.KeyguardSliceView; import com.android.settingslib.Utils; +import com.android.systemui.Dependency; import com.android.systemui.Dumpable; import com.android.systemui.ExpandHelper; import com.android.systemui.R; @@ -565,24 +566,19 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable @Nullable private OnClickListener mManageButtonClickListener; + // TODO(b/149942757): Remove the @Inject @Inject - public NotificationStackScrollLayout( - @Named(VIEW_CONTEXT) Context context, - AttributeSet attrs, - NotificationSectionsManager notificationSectionsManager, - GroupMembershipManager groupMembershipManager, - GroupExpansionManager groupExpansionManager, - AmbientState ambientState, - UnlockedScreenOffAnimationController unlockedScreenOffAnimationController) { + public NotificationStackScrollLayout(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs) { super(context, attrs, 0, 0); Resources res = getResources(); - mSectionsManager = notificationSectionsManager; - mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController; + mSectionsManager = Dependency.get(NotificationSectionsManager.class); + mUnlockedScreenOffAnimationController = + Dependency.get(UnlockedScreenOffAnimationController.class); updateSplitNotificationShade(); mSectionsManager.initialize(this, LayoutInflater.from(context)); mSections = mSectionsManager.createSectionsForBuckets(); - mAmbientState = ambientState; + mAmbientState = Dependency.get(AmbientState.class); mBgColor = Utils.getColorAttr(mContext, android.R.attr.colorBackgroundFloating) .getDefaultColor(); int minHeight = res.getDimensionPixelSize(R.dimen.notification_min_height); @@ -608,8 +604,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mDebugPaint.setTextSize(25f); } mClearAllEnabled = res.getBoolean(R.bool.config_enableNotificationsClearAll); - mGroupMembershipManager = groupMembershipManager; - mGroupExpansionManager = groupExpansionManager; + mGroupMembershipManager = Dependency.get(GroupMembershipManager.class); + mGroupExpansionManager = Dependency.get(GroupExpansionManager.class); setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index 9f42fa4d2ae7a..185d9cd8733eb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -58,6 +58,8 @@ import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy; +import com.android.systemui.statusbar.notification.collection.render.GroupExpansionManager; +import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.FooterView; import com.android.systemui.statusbar.phone.KeyguardBypassController; @@ -110,9 +112,20 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { Settings.Secure.putIntForUser(mContext.getContentResolver(), NOTIFICATION_HISTORY_ENABLED, 1, UserHandle.USER_CURRENT); + + // Interact with real instance of AmbientState. + mAmbientState = new AmbientState(mContext, mNotificationSectionsManager, mBypassController); + // Inject dependencies before initializing the layout mDependency.injectTestDependency(SysuiStatusBarStateController.class, mBarState); mDependency.injectMockDependency(ShadeController.class); + mDependency.injectTestDependency( + NotificationSectionsManager.class, mNotificationSectionsManager); + mDependency.injectTestDependency(GroupMembershipManager.class, mGroupMembershipManger); + mDependency.injectTestDependency(GroupExpansionManager.class, mGroupExpansionManager); + mDependency.injectTestDependency(AmbientState.class, mAmbientState); + mDependency.injectTestDependency( + UnlockedScreenOffAnimationController.class, mUnlockedScreenOffAnimationController); NotificationShelfController notificationShelfController = mock(NotificationShelfController.class); @@ -123,22 +136,12 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { mNotificationSection }); - // Interact with real instance of AmbientState. - mAmbientState = new AmbientState(mContext, mNotificationSectionsManager, mBypassController); - // The actual class under test. You may need to work with this class directly when // testing anonymous class members of mStackScroller, like mMenuEventListener, // which refer to members of NotificationStackScrollLayout. The spy // holds a copy of the CUT's instances of these KeyguardBypassController, so they still // refer to the CUT's member variables, not the spy's member variables. - mStackScrollerInternal = new NotificationStackScrollLayout( - getContext(), - null, - mNotificationSectionsManager, - mGroupMembershipManger, - mGroupExpansionManager, - mAmbientState, - mUnlockedScreenOffAnimationController); + mStackScrollerInternal = new NotificationStackScrollLayout(getContext(), null); mStackScrollerInternal.initView(getContext(), mNotificationSwipeHelper); mStackScroller = spy(mStackScrollerInternal); mStackScroller.setShelfController(notificationShelfController);