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

Commit 8b696832 authored by Kevin Han's avatar Kevin Han
Browse files

Convert NotificationContentInflater to singleton

Convert NotificationContentInflater into a singleton since it has
almost no state, making it easier to inject and re-use.

Move the only per-row state it has, cached remote views, to a separate
class NotifRemoteViewCacheImpl that manages the lifetime of the cached
remote views based off the notification's lifecycle. This has the added
benefit of being re-usable for content recycling later on.

Bug: 145749521
Test: atest SystemUITests
Test: atest NotificationContentInflaterTest w/o @Suppress locally
Test: smoke test
Change-Id: Iedda71d7e5edea9e30580e99eb5b6ec545bb708d
parent 804ce8e6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ import com.android.systemui.statusbar.notification.VisualStabilityManager;
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;
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder;
import com.android.systemui.statusbar.phone.AutoHideController;
import com.android.systemui.statusbar.phone.BiometricUnlockController;
import com.android.systemui.statusbar.phone.CollapsedStatusBarFragment;
@@ -276,6 +277,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
            NotificationGutsManager notificationGutsManager,
            NotificationLogger notificationLogger,
            NotificationEntryManager notificationEntryManager,
            NotificationRowContentBinder notificationRowContentBinder,
            NotificationInterruptionStateProvider notificationInterruptionStateProvider,
            NotificationViewHierarchyManager notificationViewHierarchyManager,
            KeyguardViewMediator keyguardViewMediator,
@@ -363,6 +365,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
                notificationGutsManager,
                notificationLogger,
                notificationEntryManager,
                notificationRowContentBinder,
                notificationInterruptionStateProvider,
                notificationViewHierarchyManager,
                keyguardViewMediator,
+3 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ import com.android.systemui.statusbar.notification.VisualStabilityManager;
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;
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder;
import com.android.systemui.statusbar.phone.AutoHideController;
import com.android.systemui.statusbar.phone.BiometricUnlockController;
import com.android.systemui.statusbar.phone.DozeParameters;
@@ -146,6 +147,7 @@ public class CarStatusBarModule {
            NotificationGutsManager notificationGutsManager,
            NotificationLogger notificationLogger,
            NotificationEntryManager notificationEntryManager,
            NotificationRowContentBinder notificationRowContentBinder,
            NotificationInterruptionStateProvider notificationInterruptionStateProvider,
            NotificationViewHierarchyManager notificationViewHierarchyManager,
            KeyguardViewMediator keyguardViewMediator,
@@ -232,6 +234,7 @@ public class CarStatusBarModule {
                notificationGutsManager,
                notificationLogger,
                notificationEntryManager,
                notificationRowContentBinder,
                notificationInterruptionStateProvider,
                notificationViewHierarchyManager,
                keyguardViewMediator,
+9 −1
Original line number Diff line number Diff line
@@ -584,7 +584,15 @@ public class NotificationRemoteInputManager implements Dumpable {

    public void bindRow(ExpandableNotificationRow row) {
        row.setRemoteInputController(mRemoteInputController);
        row.setRemoteViewClickHandler(mOnClickHandler);
    }

    /**
     * Return on-click handler for notification remote views
     *
     * @return on-click handler
     */
    public RemoteViews.OnClickHandler getRemoteViewsOnClickHandler() {
        return mOnClickHandler;
    }

    @VisibleForTesting
+3 −1
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.systemui.statusbar;

import android.content.Context;

import com.android.systemui.statusbar.notification.row.NotificationRowModule;

import javax.inject.Singleton;

import dagger.Module;
@@ -26,7 +28,7 @@ import dagger.Provides;
/**
 * Dagger Module providing common dependencies of StatusBar.
 */
@Module
@Module(includes = {NotificationRowModule.class})
public class StatusBarDependenciesModule {
    /**
     * Provides our instance of CommandQueue which is considered optional.
+7 −3
Original line number Diff line number Diff line
@@ -41,8 +41,8 @@ import com.android.systemui.statusbar.notification.NotificationClicker;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationContentInflater;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder;
import com.android.systemui.statusbar.notification.row.RowInflaterTask;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
@@ -65,6 +65,7 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
            Dependency.get(NotificationInterruptionStateProvider.class);

    private final Context mContext;
    private final NotificationRowContentBinder mRowContentBinder;
    private final NotificationMessagingUtil mMessagingUtil;
    private final ExpandableNotificationRow.ExpansionLogger mExpansionLogger =
            this::logNotificationExpansion;
@@ -76,7 +77,7 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
    private NotificationPresenter mPresenter;
    private NotificationListContainer mListContainer;
    private HeadsUpManager mHeadsUpManager;
    private NotificationContentInflater.InflationCallback mInflationCallback;
    private NotificationRowContentBinder.InflationCallback mInflationCallback;
    private ExpandableNotificationRow.OnAppOpsClickListener mOnAppOpsClickListener;
    private BindRowCallback mBindRowCallback;
    private NotificationClicker mNotificationClicker;
@@ -84,11 +85,13 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {

    public NotificationRowBinderImpl(
            Context context,
            NotificationRowContentBinder rowContentBinder,
            boolean allowLongPress,
            KeyguardBypassController keyguardBypassController,
            StatusBarStateController statusBarStateController,
            NotificationLogger logger) {
        mContext = context;
        mRowContentBinder = rowContentBinder;
        mMessagingUtil = new NotificationMessagingUtil(context);
        mAllowLongPress = allowLongPress;
        mKeyguardBypassController = keyguardBypassController;
@@ -117,7 +120,7 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
        mOnAppOpsClickListener = mGutsManager::openGuts;
    }

    public void setInflationCallback(NotificationContentInflater.InflationCallback callback) {
    public void setInflationCallback(NotificationRowContentBinder.InflationCallback callback) {
        mInflationCallback = callback;
    }

@@ -162,6 +165,7 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
        row.setGroupManager(mGroupManager);
        row.setHeadsUpManager(mHeadsUpManager);
        row.setOnExpandClickListener(mPresenter);
        row.setContentBinder(mRowContentBinder);
        row.setInflationCallback(mInflationCallback);
        if (mAllowLongPress) {
            row.setLongPressListener(mGutsManager::openGuts);
Loading