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

Commit 6c313d32 authored by Eliot Courtney's avatar Eliot Courtney
Browse files

Initialise Notification*Manager dependencies directly.

Currently, adding a new dependency to any of these classes means
updating the constructors of any subclasses, and the construction in the
corresponding SystemUIFactory classes and subclasses. In particular,
updating these in separate vendor/ projects is annoying. So, initialise
the dependencies using field initialisers. The downside is that it's
harder to notice circular Dependencys.

Bug: 63874929
Bug: 62602530
Test: runtest systemui
Test: Compile and run
Change-Id: I21d58d0cc0edeb6d53fb7b387c9baeec7bd80589
parent 4a96b36f
Loading
Loading
Loading
Loading
+7 −29
Original line number Diff line number Diff line
@@ -127,35 +127,13 @@ public class SystemUIFactory {
        providers.put(VisualStabilityManager.class, VisualStabilityManager::new);
        providers.put(NotificationGroupManager.class, NotificationGroupManager::new);
        providers.put(NotificationMediaManager.class, () -> new NotificationMediaManager(context));
        providers.put(NotificationGutsManager.class, () -> new NotificationGutsManager(
                Dependency.get(NotificationLockscreenUserManager.class), context));
        providers.put(NotificationGutsManager.class, () -> new NotificationGutsManager(context));
        providers.put(NotificationRemoteInputManager.class,
                () -> new NotificationRemoteInputManager(
                        Dependency.get(NotificationLockscreenUserManager.class), context));
        providers.put(NotificationListener.class, () -> new NotificationListener(
                Dependency.get(NotificationRemoteInputManager.class), context));
        providers.put(NotificationLogger.class, () -> new NotificationLogger(
                Dependency.get(NotificationListener.class),
                Dependency.get(UiOffloadThread.class)));
        providers.put(NotificationViewHierarchyManager.class, () ->
                new NotificationViewHierarchyManager(
                        Dependency.get(NotificationLockscreenUserManager.class),
                        Dependency.get(NotificationGroupManager.class),
                        Dependency.get(VisualStabilityManager.class),
                        context));
        providers.put(NotificationEntryManager.class, () ->
                new NotificationEntryManager(
                        Dependency.get(NotificationLockscreenUserManager.class),
                        Dependency.get(NotificationGroupManager.class),
                        Dependency.get(NotificationGutsManager.class),
                        Dependency.get(NotificationRemoteInputManager.class),
                        Dependency.get(NotificationMediaManager.class),
                        Dependency.get(ForegroundServiceController.class),
                        Dependency.get(NotificationListener.class),
                        Dependency.get(MetricsLogger.class),
                        Dependency.get(DeviceProvisionedController.class),
                        Dependency.get(VisualStabilityManager.class),
                        Dependency.get(UiOffloadThread.class),
                        context));
                () -> new NotificationRemoteInputManager(context));
        providers.put(NotificationListener.class, () -> new NotificationListener(context));
        providers.put(NotificationLogger.class, NotificationLogger::new);
        providers.put(NotificationViewHierarchyManager.class,
                () -> new NotificationViewHierarchyManager(context));
        providers.put(NotificationEntryManager.class, () -> new NotificationEntryManager(context));
    }
}
+2 −26
Original line number Diff line number Diff line
@@ -18,37 +18,13 @@ package com.android.systemui.car;
import android.content.Context;
import android.service.notification.StatusBarNotification;

import com.android.internal.logging.MetricsLogger;
import com.android.systemui.ForegroundServiceController;
import com.android.systemui.UiOffloadThread;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.NotificationEntryManager;
import com.android.systemui.statusbar.NotificationGutsManager;
import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;

public class CarNotificationEntryManager extends NotificationEntryManager {
    public CarNotificationEntryManager(
            NotificationLockscreenUserManager lockscreenUserManager,
            NotificationGroupManager groupManager,
            NotificationGutsManager gutsManager,
            NotificationRemoteInputManager remoteInputManager,
            NotificationMediaManager mediaManager,
            ForegroundServiceController foregroundServiceController,
            NotificationListener notificationListener,
            MetricsLogger metricsLogger,
            DeviceProvisionedController deviceProvisionedController,
            VisualStabilityManager visualStabilityManager,
            UiOffloadThread uiOffloadThread, Context context) {
        super(lockscreenUserManager, groupManager, gutsManager, remoteInputManager, mediaManager,
                foregroundServiceController, notificationListener, metricsLogger,
                deviceProvisionedController, visualStabilityManager, uiOffloadThread, context);
    public CarNotificationEntryManager(Context context) {
        super(context);
    }

    /**
+2 −13
Original line number Diff line number Diff line
@@ -45,18 +45,7 @@ public class CarSystemUIFactory extends SystemUIFactory {
            Context context) {
        super.injectDependencies(providers, context);
        providers.put(VolumeDialogController.class, () -> new CarVolumeDialogController(context));
        providers.put(NotificationEntryManager.class, () -> new CarNotificationEntryManager(
                Dependency.get(NotificationLockscreenUserManager.class),
                Dependency.get(NotificationGroupManager.class),
                Dependency.get(NotificationGutsManager.class),
                Dependency.get(NotificationRemoteInputManager.class),
                Dependency.get(NotificationMediaManager.class),
                Dependency.get(ForegroundServiceController.class),
                Dependency.get(NotificationListener.class),
                Dependency.get(MetricsLogger.class),
                Dependency.get(DeviceProvisionedController.class),
                Dependency.get(VisualStabilityManager.class),
                Dependency.get(UiOffloadThread.class),
                context));
        providers.put(NotificationEntryManager.class,
                () -> new CarNotificationEntryManager(context));
    }
}
+24 −33
Original line number Diff line number Diff line
@@ -80,24 +80,36 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
    protected static final boolean DEBUG = false;
    protected static final boolean ENABLE_HEADS_UP = true;
    protected static final String SETTING_HEADS_UP_TICKER = "ticker_gets_heads_up";

    protected final NotificationMessagingUtil mMessagingUtil;
    protected final Context mContext;
    protected final NotificationLockscreenUserManager mLockscreenUserManager;
    protected final NotificationGroupManager mGroupManager;
    protected final NotificationGutsManager mGutsManager;
    protected final NotificationRemoteInputManager mRemoteInputManager;
    protected final HashMap<String, NotificationData.Entry> mPendingNotifications = new HashMap<>();
    protected final NotificationMediaManager mMediaManager;
    protected final MetricsLogger mMetricsLogger;
    protected final DeviceProvisionedController mDeviceProvisionedController;
    protected final VisualStabilityManager mVisualStabilityManager;
    protected final UiOffloadThread mUiOffloadThread;
    protected final ForegroundServiceController mForegroundServiceController;
    protected final NotificationListener mNotificationListener;
    protected final NotificationClicker mNotificationClicker = new NotificationClicker();
    protected final ArraySet<NotificationData.Entry> mHeadsUpEntriesToRemoveOnSwitch =
            new ArraySet<>();

    // Dependencies:
    protected final NotificationLockscreenUserManager mLockscreenUserManager =
            Dependency.get(NotificationLockscreenUserManager.class);
    protected final NotificationGroupManager mGroupManager =
            Dependency.get(NotificationGroupManager.class);
    protected final NotificationGutsManager mGutsManager =
            Dependency.get(NotificationGutsManager.class);
    protected final NotificationRemoteInputManager mRemoteInputManager =
            Dependency.get(NotificationRemoteInputManager.class);
    protected final NotificationMediaManager mMediaManager =
            Dependency.get(NotificationMediaManager.class);
    protected final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
    protected final DeviceProvisionedController mDeviceProvisionedController =
            Dependency.get(DeviceProvisionedController.class);
    protected final VisualStabilityManager mVisualStabilityManager =
            Dependency.get(VisualStabilityManager.class);
    protected final UiOffloadThread mUiOffloadThread = Dependency.get(UiOffloadThread.class);
    protected final ForegroundServiceController mForegroundServiceController =
            Dependency.get(ForegroundServiceController.class);
    protected final NotificationListener mNotificationListener =
            Dependency.get(NotificationListener.class);

    protected IStatusBarService mBarService;
    protected NotificationPresenter mPresenter;
    protected Callback mCallback;
@@ -205,28 +217,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
        pw.println(mUseHeadsUp);
    }

    public NotificationEntryManager(NotificationLockscreenUserManager lockscreenUserManager,
            NotificationGroupManager groupManager,
            NotificationGutsManager gutsManager,
            NotificationRemoteInputManager remoteInputManager,
            NotificationMediaManager mediaManager,
            ForegroundServiceController foregroundServiceController,
            NotificationListener notificationListener,
            MetricsLogger metricsLogger,
            DeviceProvisionedController deviceProvisionedController,
            VisualStabilityManager visualStabilityManager,
            UiOffloadThread uiOffloadThread, Context context) {
        mLockscreenUserManager = lockscreenUserManager;
        mGroupManager = groupManager;
        mGutsManager = gutsManager;
        mRemoteInputManager = remoteInputManager;
        mMediaManager = mediaManager;
        mForegroundServiceController = foregroundServiceController;
        mNotificationListener = notificationListener;
        mMetricsLogger = metricsLogger;
        mDeviceProvisionedController = deviceProvisionedController;
        mVisualStabilityManager = visualStabilityManager;
        mUiOffloadThread = uiOffloadThread;
    public NotificationEntryManager(Context context) {
        mContext = context;
        mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        mBarService = IStatusBarService.Stub.asInterface(
+5 −5
Original line number Diff line number Diff line
@@ -66,7 +66,10 @@ public class NotificationGutsManager implements Dumpable {
    private final Set<String> mNonBlockablePkgs;
    private final Context mContext;
    private final AccessibilityManager mAccessibilityManager;
    private final NotificationLockscreenUserManager mLockscreenUserManager;

    // Dependencies:
    private final NotificationLockscreenUserManager mLockscreenUserManager =
            Dependency.get(NotificationLockscreenUserManager.class);

    // which notification is currently being longpress-examined by the user
    private NotificationGuts mNotificationGutsExposed;
@@ -78,10 +81,7 @@ public class NotificationGutsManager implements Dumpable {
    private OnSettingsClickListener mOnSettingsClickListener;
    private String mKeyToRemoveOnGutsClosed;

    public NotificationGutsManager(
            NotificationLockscreenUserManager lockscreenUserManager,
            Context context) {
        mLockscreenUserManager = lockscreenUserManager;
    public NotificationGutsManager(Context context) {
        mContext = context;
        Resources res = context.getResources();

Loading