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

Commit 09f4d371 authored by Jason Monk's avatar Jason Monk
Browse files

Remove usages of Dependency#get from NotificationViewHierarchyManager

Test: Update existing tests
Change-Id: Ia2a577e31c6c37a5c905c8d9f87434f8a97bb41e
parent 7fc1f9bb
Loading
Loading
Loading
Loading
+26 −23
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.statusbar.notification.NotificationData;
@@ -44,6 +43,8 @@ import java.util.Stack;
import javax.inject.Inject;
import javax.inject.Singleton;

import dagger.Lazy;

/**
 * NotificationViewHierarchyManager manages updating the view hierarchy of notification views based
 * on their group structure. For example, if a notification becomes bundled with another,
@@ -60,20 +61,15 @@ public class NotificationViewHierarchyManager {
            mTmpChildOrderMap = new HashMap<>();

    // Dependencies:
    protected final NotificationLockscreenUserManager mLockscreenUserManager =
            Dependency.get(NotificationLockscreenUserManager.class);
    protected final NotificationGroupManager mGroupManager =
            Dependency.get(NotificationGroupManager.class);
    protected final VisualStabilityManager mVisualStabilityManager =
            Dependency.get(VisualStabilityManager.class);
    private final StatusBarStateController mStatusBarStateController =
            Dependency.get(StatusBarStateController.class);
    private final NotificationEntryManager mEntryManager =
            Dependency.get(NotificationEntryManager.class);
    private final BubbleController mBubbleController = Dependency.get(BubbleController.class);
    protected final NotificationLockscreenUserManager mLockscreenUserManager;
    protected final NotificationGroupManager mGroupManager;
    protected final VisualStabilityManager mVisualStabilityManager;
    private final StatusBarStateController mStatusBarStateController;
    private final NotificationEntryManager mEntryManager;
    private final BubbleController mBubbleController;

    // Lazy
    private ShadeController mShadeController;
    private final Lazy<ShadeController> mShadeController;

    /**
     * {@code true} if notifications not part of a group should by default be rendered in their
@@ -120,20 +116,27 @@ public class NotificationViewHierarchyManager {
        }
    }

    private ShadeController getShadeController() {
        if (mShadeController == null) {
            mShadeController = Dependency.get(ShadeController.class);
        }
        return mShadeController;
    }

    @Inject
    public NotificationViewHierarchyManager(Context context) {
    public NotificationViewHierarchyManager(Context context,
            NotificationLockscreenUserManager notificationLockscreenUserManager,
            NotificationGroupManager groupManager,
            VisualStabilityManager visualStabilityManager,
            StatusBarStateController statusBarStateController,
            NotificationEntryManager notificationEntryManager,
            BubbleController bubbleController,
            Lazy<ShadeController> shadeController) {
        mLockscreenUserManager = notificationLockscreenUserManager;
        mGroupManager = groupManager;
        mVisualStabilityManager = visualStabilityManager;
        mStatusBarStateController = statusBarStateController;
        mEntryManager = notificationEntryManager;
        mBubbleController = bubbleController;
        mShadeController = shadeController;
        Resources res = context.getResources();
        mAlwaysExpandNonGroupedNotification =
                res.getBoolean(R.bool.config_alwaysExpandNonGroupedNotifications);
        mStatusBarStateListener = new StatusBarStateListener(mBubbleController);
        Dependency.get(StatusBarStateController.class).addCallback(mStatusBarStateListener);
        mStatusBarStateController.addCallback(mStatusBarStateListener);
    }

    public void setUpWithPresenter(NotificationPresenter presenter,
@@ -396,7 +399,7 @@ public class NotificationViewHierarchyManager {
                        && !row.isLowPriority()));
            }

            entry.getRow().setOnAmbient(getShadeController().isDozing());
            entry.getRow().setOnAmbient(mShadeController.get().isDozing());
            int userId = entry.notification.getUserId();
            boolean suppressedSummary = mGroupManager.isSummaryOfSuppressedGroup(
                    entry.notification) && !entry.isRowRemoved();
+6 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static junit.framework.Assert.assertTrue;

import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -35,6 +36,7 @@ import android.widget.LinearLayout;
import com.android.systemui.Dependency;
import com.android.systemui.InitController;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper;
import com.android.systemui.statusbar.notification.NotificationData;
import com.android.systemui.statusbar.notification.NotificationData.Entry;
@@ -90,7 +92,10 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase {

        when(mEntryManager.getNotificationData()).thenReturn(mNotificationData);

        mViewHierarchyManager = new NotificationViewHierarchyManager(mContext);
        mViewHierarchyManager = new NotificationViewHierarchyManager(mContext,
                mLockscreenUserManager, mGroupManager, mVisualStabilityManager,
                mock(StatusBarStateController.class), mEntryManager, mock(BubbleController.class),
                () -> mShadeController);
        Dependency.get(InitController.class).executePostInitTasks();
        mViewHierarchyManager.setUpWithPresenter(mPresenter, mListContainer);
    }