Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9fe67af4 authored by Dave Mankoff's avatar Dave Mankoff
Browse files

Remove injected parametser from NSSL

This substitutes in calls to Dependency#get. While this feels like
a step backwards, it is the last step necessary before removing
acual view injection.

Removal of Dependency#get is ongoing and will include cleanup of this
class.

Bug: 149942757
Test: manual
Change-Id: I129f0751f101cdce7ae92554b2a09d2091b7c13b
parent 4de18a55
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -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<StatusBarContentInsetsProvider> mContentInsetsProviderLazy;
    @Inject Lazy<InternetDialogFactory> mInternetDialogFactory;
    @Inject Lazy<FeatureFlags> mFeatureFlagsLazy;
    @Inject Lazy<NotificationSectionsManager> mNotificationSectionsManagerLazy;
    @Inject Lazy<UnlockedScreenOffAnimationController> mUnlockedScreenOffAnimationControllerLazy;
    @Inject Lazy<AmbientState> mAmbientStateLazy;
    @Inject Lazy<GroupMembershipManager> mGroupMembershipManagerLazy;
    @Inject Lazy<GroupExpansionManager> 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);
    }
+9 −13
Original line number Diff line number Diff line
@@ -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);
    }

+14 −11
Original line number Diff line number Diff line
@@ -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);