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

Commit 02dcaf53 authored by Dave Mankoff's avatar Dave Mankoff
Browse files

Make NotificationRowBinder injectable.

Part of prepatory work for changes coming to
ActivatableNotificationView.

Bug: 147245740
Test: atest SystemUITests
Change-Id: Id85767ab3365e0da659941f267b5d925d6da9dd9
parent f2be9da2
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -19,14 +19,19 @@ import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;

import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotificationRankingManager;
import com.android.systemui.statusbar.notification.collection.NotificationRowBinder;
import com.android.systemui.statusbar.notification.logging.NotifLog;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.util.leak.LeakDetector;

import javax.inject.Inject;
import javax.inject.Singleton;

import dagger.Lazy;

/**
 * Car specific notification entry manager that does nothing when adding a notification.
 *
@@ -42,8 +47,12 @@ public class CarNotificationEntryManager extends NotificationEntryManager {
            NotificationGroupManager groupManager,
            NotificationRankingManager rankingManager,
            KeyguardEnvironment keyguardEnvironment,
            FeatureFlags featureFlags) {
        super(notifLog, groupManager, rankingManager, keyguardEnvironment, featureFlags);
            FeatureFlags featureFlags,
            Lazy<NotificationRowBinder> notificationRowBinderLazy,
            Lazy<NotificationRemoteInputManager> notificationRemoteInputManagerLazy,
            LeakDetector leakDetector) {
        super(notifLog, groupManager, rankingManager, keyguardEnvironment, featureFlags,
                notificationRowBinderLazy, notificationRemoteInputManagerLazy, leakDetector);
    }

    @Override
+3 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.statusbar.car;

import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME;

import android.animation.Animator;
@@ -107,6 +106,7 @@ import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
import com.android.systemui.statusbar.notification.collection.NotificationRowBinderImpl;
import com.android.systemui.statusbar.notification.collection.init.NewNotifPipeline;
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
@@ -268,7 +268,6 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
            HeadsUpManagerPhone headsUpManagerPhone,
            DynamicPrivacyController dynamicPrivacyController,
            BypassHeadsUpNotifier bypassHeadsUpNotifier,
            @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowNotificationLongPress,
            Lazy<NewNotifPipeline> newNotifPipeline,
            FalsingManager falsingManager,
            BroadcastDispatcher broadcastDispatcher,
@@ -334,6 +333,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
            KeyguardDismissUtil keyguardDismissUtil,
            ExtensionController extensionController,
            UserInfoControllerImpl userInfoControllerImpl,
            NotificationRowBinderImpl notificationRowBinder,
            DismissCallbackRegistry dismissCallbackRegistry,
            /* Car Settings injected components. */
            CarServiceProvider carServiceProvider,
@@ -355,7 +355,6 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
                headsUpManagerPhone,
                dynamicPrivacyController,
                bypassHeadsUpNotifier,
                allowNotificationLongPress,
                newNotifPipeline,
                falsingManager,
                broadcastDispatcher,
@@ -421,6 +420,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
                keyguardDismissUtil,
                extensionController,
                userInfoControllerImpl,
                notificationRowBinder,
                dismissCallbackRegistry);
        mScrimController = scrimController;
        mLockscreenLockIconController = lockscreenLockIconController;
+3 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.statusbar.car;

import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME;

import android.content.Context;
@@ -67,6 +66,7 @@ import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
import com.android.systemui.statusbar.notification.collection.NotificationRowBinderImpl;
import com.android.systemui.statusbar.notification.collection.init.NewNotifPipeline;
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
@@ -138,7 +138,6 @@ public class CarStatusBarModule {
            HeadsUpManagerPhone headsUpManagerPhone,
            DynamicPrivacyController dynamicPrivacyController,
            BypassHeadsUpNotifier bypassHeadsUpNotifier,
            @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowNotificationLongPress,
            Lazy<NewNotifPipeline> newNotifPipeline,
            FalsingManager falsingManager,
            BroadcastDispatcher broadcastDispatcher,
@@ -204,6 +203,7 @@ public class CarStatusBarModule {
            KeyguardDismissUtil keyguardDismissUtil,
            ExtensionController extensionController,
            UserInfoControllerImpl userInfoControllerImpl,
            NotificationRowBinderImpl notificationRowBinder,
            DismissCallbackRegistry dismissCallbackRegistry,
            CarServiceProvider carServiceProvider,
            Lazy<PowerManagerHelper> powerManagerHelperLazy,
@@ -224,7 +224,6 @@ public class CarStatusBarModule {
                headsUpManagerPhone,
                dynamicPrivacyController,
                bypassHeadsUpNotifier,
                allowNotificationLongPress,
                newNotifPipeline,
                falsingManager,
                broadcastDispatcher,
@@ -289,6 +288,7 @@ public class CarStatusBarModule {
                keyguardDismissUtil,
                extensionController,
                userInfoControllerImpl,
                notificationRowBinder,
                dismissCallbackRegistry,
                carServiceProvider,
                powerManagerHelperLazy,
+7 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import com.android.systemui.recents.Recents;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.notification.collection.NotifListBuilderImpl;
import com.android.systemui.statusbar.notification.collection.NotificationRowBinder;
import com.android.systemui.statusbar.notification.collection.NotificationRowBinderImpl;
import com.android.systemui.statusbar.notification.collection.listbuilder.NotifListBuilder;
import com.android.systemui.statusbar.notification.people.PeopleHubModule;
import com.android.systemui.statusbar.phone.KeyguardLiftController;
@@ -82,6 +84,11 @@ public abstract class SystemUIModule {
                keyguardUpdateMonitor, dumpController);
    }

    /** */
    @Binds
    public abstract NotificationRowBinder bindNotificationRowBinder(
            NotificationRowBinderImpl notificationRowBinder);

    @Singleton
    @Provides
    static SysUiState provideSysUiState() {
+29 −40
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.Dependency;
import com.android.systemui.Dumpable;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.NotificationLifetimeExtender;
@@ -68,6 +67,8 @@ import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;

import dagger.Lazy;

/**
 * NotificationEntryManager is responsible for the adding, removing, and updating of
 * {@link NotificationEntry}s. It also handles tasks such as their inflation and their interaction
@@ -126,8 +127,9 @@ public class NotificationEntryManager implements
            new ArrayMap<>();

    // Lazily retrieved dependencies
    private NotificationRemoteInputManager mRemoteInputManager;
    private NotificationRowBinder mNotificationRowBinder;
    private final Lazy<NotificationRowBinder> mNotificationRowBinderLazy;
    private final Lazy<NotificationRemoteInputManager> mRemoteInputManagerLazy;
    private final LeakDetector mLeakDetector;

    private final KeyguardEnvironment mKeyguardEnvironment;
    private final NotificationGroupManager mGroupManager;
@@ -173,12 +175,18 @@ public class NotificationEntryManager implements
            NotificationGroupManager groupManager,
            NotificationRankingManager rankingManager,
            KeyguardEnvironment keyguardEnvironment,
            FeatureFlags featureFlags) {
            FeatureFlags featureFlags,
            Lazy<NotificationRowBinder> notificationRowBinderLazy,
            Lazy<NotificationRemoteInputManager> notificationRemoteInputManagerLazy,
            LeakDetector leakDetector) {
        mNotifLog = notifLog;
        mGroupManager = groupManager;
        mRankingManager = rankingManager;
        mKeyguardEnvironment = keyguardEnvironment;
        mFeatureFlags = featureFlags;
        mNotificationRowBinderLazy = notificationRowBinderLazy;
        mRemoteInputManagerLazy = notificationRemoteInputManagerLazy;
        mLeakDetector = leakDetector;
    }

    /** Once called, the NEM will start processing notification events from system server. */
@@ -204,20 +212,6 @@ public class NotificationEntryManager implements
        mRemoveInterceptor = interceptor;
    }

    /**
     * Our dependencies can have cyclic references, so some need to be lazy
     */
    private NotificationRemoteInputManager getRemoteInputManager() {
        if (mRemoteInputManager == null) {
            mRemoteInputManager = Dependency.get(NotificationRemoteInputManager.class);
        }
        return mRemoteInputManager;
    }

    public void setRowBinder(NotificationRowBinder notificationRowBinder) {
        mNotificationRowBinder = notificationRowBinder;
    }

    public void setUpWithPresenter(NotificationPresenter presenter,
            NotificationListContainer listContainer,
            HeadsUpManager headsUpManager) {
@@ -468,7 +462,7 @@ public class NotificationEntryManager implements
                handleGroupSummaryRemoved(key);
                removeVisibleNotification(key);
                updateNotifications("removeNotificationInternal");
                Dependency.get(LeakDetector.class).trackGarbage(entry);
                mLeakDetector.trackGarbage(entry);
                removedByUser |= entryDismissed;

                mNotifLog.log(NotifEvent.NOTIF_REMOVED, entry.getSbn(),
@@ -507,8 +501,8 @@ public class NotificationEntryManager implements
                boolean isForeground = (entry.getSbn().getNotification().flags
                        & Notification.FLAG_FOREGROUND_SERVICE) != 0;
                boolean keepForReply =
                        getRemoteInputManager().shouldKeepForRemoteInputHistory(childEntry)
                        || getRemoteInputManager().shouldKeepForSmartReplyHistory(childEntry);
                        mRemoteInputManagerLazy.get().shouldKeepForRemoteInputHistory(childEntry)
                        || mRemoteInputManagerLazy.get().shouldKeepForSmartReplyHistory(childEntry);
                if (isForeground || keepForReply) {
                    // the child is a foreground service notification which we can't remove or it's
                    // a child we're keeping around for reply!
@@ -536,11 +530,12 @@ public class NotificationEntryManager implements

        NotificationEntry entry = new NotificationEntry(notification, ranking);

        Dependency.get(LeakDetector.class).trackInstance(entry);
        mLeakDetector.trackInstance(entry);

        // Construct the expanded view.
        if (!mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
            requireBinder().inflateViews(entry, () -> performRemoveNotification(notification,
            mNotificationRowBinderLazy.get()
                    .inflateViews(entry, () -> performRemoveNotification(notification,
                            REASON_CANCEL));
        }

@@ -586,7 +581,8 @@ public class NotificationEntryManager implements
        }

        if (!mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
            requireBinder().inflateViews(entry, () -> performRemoveNotification(notification,
            mNotificationRowBinderLazy.get()
                    .inflateViews(entry, () -> performRemoveNotification(notification,
                            REASON_CANCEL));
        }

@@ -594,7 +590,7 @@ public class NotificationEntryManager implements

        if (DEBUG) {
            // Is this for you?
            boolean isForCurrentUser = Dependency.get(KeyguardEnvironment.class)
            boolean isForCurrentUser = mKeyguardEnvironment
                    .isNotificationForCurrentProfiles(notification);
            Log.d(TAG, "notification is " + (isForCurrentUser ? "" : "not ") + "for you");
        }
@@ -644,7 +640,8 @@ public class NotificationEntryManager implements

        // By comparing the old and new UI adjustments, reinflate the view accordingly.
        for (NotificationEntry entry : entries) {
            requireBinder().onNotificationRankingUpdated(
            mNotificationRowBinderLazy.get()
                    .onNotificationRankingUpdated(
                            entry,
                            oldImportances.get(entry.getKey()),
                            oldAdjustments.get(entry.getKey()),
@@ -728,14 +725,6 @@ public class NotificationEntryManager implements
        }
    }

    private NotificationRowBinder requireBinder() {
        if (mNotificationRowBinder == null) {
            throw new RuntimeException("You must initialize NotificationEntryManager by calling"
                    + "setRowBinder() before using.");
        }
        return mNotificationRowBinder;
    }

    /*
     * -----
     * Annexed from NotificationData below:
Loading