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

Commit c0211ff8 authored by Dave Mankoff's avatar Dave Mankoff
Browse files

Add new ExpandableNotificationRowController.

This reverts commit 372729e8.

The original commit was fine, but the commit it was built upon had
an issue that needed to be fixed. Checking them both back in now.

Bug: 147245740
Test: atest SystemUITests
Change-Id: I94de0f1feec4d2f11e66a2c38b94e4f874503585
parent a2c24e01
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.view.IWindowManager;
import android.view.LayoutInflater;

import com.android.internal.logging.MetricsLogger;
import com.android.internal.util.NotificationMessagingUtil;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.dagger.qualifiers.Background;
@@ -191,6 +192,12 @@ public class DependencyProvider {
        return new AlwaysOnDisplayPolicy(context);
    }

    /***/
    @Provides
    public NotificationMessagingUtil provideNotificationMessagingUtil(Context context) {
        return new NotificationMessagingUtil(context);
    }

    /** */
    @Provides
    public ViewMediatorCallback providesViewMediatorCallback(KeyguardViewMediator viewMediator) {
+4 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import com.android.systemui.statusbar.notification.collection.inflation.Notifica
import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinderImpl;
import com.android.systemui.statusbar.notification.dagger.NotificationsModule;
import com.android.systemui.statusbar.notification.people.PeopleHubModule;
import com.android.systemui.statusbar.notification.row.dagger.ExpandableNotificationRowComponent;
import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent;
import com.android.systemui.statusbar.phone.KeyguardLiftController;
import com.android.systemui.statusbar.phone.StatusBar;
@@ -68,7 +69,9 @@ import dagger.Provides;
            NotificationsModule.class,
            PeopleHubModule.class,
        },
        subcomponents = {StatusBarComponent.class, NotificationRowComponent.class})
        subcomponents = {StatusBarComponent.class,
                NotificationRowComponent.class,
                ExpandableNotificationRowComponent.class})
public abstract class SystemUIModule {

    @Binds
+10 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.plugga
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifDismissInterceptor;
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifLifetimeExtender;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRowController;
import com.android.systemui.statusbar.notification.row.NotificationGuts;
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.InflationFlag;
import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager;
@@ -153,6 +154,7 @@ public final class NotificationEntry extends ListEntry {

    private NotificationEntry parent; // our parent (if we're in a group)
    private ExpandableNotificationRow row; // the outer expanded view
    private ExpandableNotificationRowController mRowController;

    private int mCachedContrastColor = COLOR_INVALID;
    private int mCachedContrastColorIsFor = COLOR_INVALID;
@@ -424,6 +426,14 @@ public final class NotificationEntry extends ListEntry {
        this.row = row;
    }

    public ExpandableNotificationRowController getRowController() {
        return mRowController;
    }

    public void setRowController(ExpandableNotificationRowController controller) {
        mRowController = controller;
    }

    @Nullable
    public List<NotificationEntry> getChildren() {
        if (row == null) {
+26 −77
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.statusbar.notification.collection.inflation;

import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
import static com.android.systemui.statusbar.NotificationRemoteInputManager.ENABLE_REMOTE_INPUT;
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_HEADS_UP;

import android.annotation.Nullable;
@@ -40,19 +39,19 @@ import com.android.systemui.statusbar.notification.InflationException;
import com.android.systemui.statusbar.notification.NotificationClicker;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRowController;
import com.android.systemui.statusbar.notification.row.NotifBindPipeline;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder;
import com.android.systemui.statusbar.notification.row.RowContentBindParams;
import com.android.systemui.statusbar.notification.row.RowContentBindStage;
import com.android.systemui.statusbar.notification.row.RowInflaterTask;
import com.android.systemui.statusbar.notification.row.dagger.ExpandableNotificationRowComponent;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.HeadsUpManager;

import java.util.Objects;

@@ -67,35 +66,28 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {

    private static final String TAG = "NotificationViewManager";

    private final NotificationGroupManager mGroupManager;
    private final NotificationGutsManager mGutsManager;
    private final NotificationInterruptionStateProvider mNotificationInterruptionStateProvider;

    private final Context mContext;
    private final NotifBindPipeline mNotifBindPipeline;
    private final RowContentBindStage mRowContentBindStage;
    private final NotificationMessagingUtil mMessagingUtil;
    private final ExpandableNotificationRow.ExpansionLogger mExpansionLogger =
            this::logNotificationExpansion;
    private final NotificationRemoteInputManager mNotificationRemoteInputManager;
    private final NotificationLockscreenUserManager mNotificationLockscreenUserManager;
    private final boolean mAllowLongPress;
    private final KeyguardBypassController mKeyguardBypassController;
    private final StatusBarStateController mStatusBarStateController;

    private NotificationPresenter mPresenter;
    private NotificationListContainer mListContainer;
    private HeadsUpManager mHeadsUpManager;
    private NotificationRowContentBinder.InflationCallback mInflationCallback;
    private ExpandableNotificationRow.OnAppOpsClickListener mOnAppOpsClickListener;
    private BindRowCallback mBindRowCallback;
    private NotificationClicker mNotificationClicker;
    private final Provider<RowInflaterTask> mRowInflaterTaskProvider;
    private final NotificationLogger mNotificationLogger;
    private final ExpandableNotificationRowComponent.Builder
            mExpandableNotificationRowComponentBuilder;

    @Inject
    public NotificationRowBinderImpl(
            Context context,
            NotificationMessagingUtil notificationMessagingUtil,
            NotificationRemoteInputManager notificationRemoteInputManager,
            NotificationLockscreenUserManager notificationLockscreenUserManager,
            NotifBindPipeline notifBindPipeline,
@@ -107,21 +99,16 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
            NotificationGutsManager notificationGutsManager,
            NotificationInterruptionStateProvider notificationInterruptionStateProvider,
            Provider<RowInflaterTask> rowInflaterTaskProvider,
            NotificationLogger logger) {
            ExpandableNotificationRowComponent.Builder expandableNotificationRowComponentBuilder) {
        mContext = context;
        mNotifBindPipeline = notifBindPipeline;
        mRowContentBindStage = rowContentBindStage;
        mMessagingUtil = new NotificationMessagingUtil(context);
        mMessagingUtil = notificationMessagingUtil;
        mNotificationRemoteInputManager = notificationRemoteInputManager;
        mNotificationLockscreenUserManager = notificationLockscreenUserManager;
        mAllowLongPress = allowLongPress;
        mKeyguardBypassController = keyguardBypassController;
        mStatusBarStateController = statusBarStateController;
        mGroupManager = notificationGroupManager;
        mGutsManager = notificationGutsManager;
        mNotificationInterruptionStateProvider = notificationInterruptionStateProvider;
        mRowInflaterTaskProvider = rowInflaterTaskProvider;
        mNotificationLogger = logger;
        mExpandableNotificationRowComponentBuilder = expandableNotificationRowComponentBuilder;
    }

    /**
@@ -129,13 +116,10 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
     */
    public void setUpWithPresenter(NotificationPresenter presenter,
            NotificationListContainer listContainer,
            HeadsUpManager headsUpManager,
            BindRowCallback bindRowCallback) {
        mPresenter = presenter;
        mListContainer = listContainer;
        mHeadsUpManager = headsUpManager;
        mBindRowCallback = bindRowCallback;
        mOnAppOpsClickListener = mGutsManager::openGuts;
    }

    public void setInflationCallback(NotificationRowContentBinder.InflationCallback callback) {
@@ -150,9 +134,7 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
     * Inflates the views for the given entry (possibly asynchronously).
     */
    @Override
    public void inflateViews(
            NotificationEntry entry,
            Runnable onDismissRunnable)
    public void inflateViews(NotificationEntry entry, Runnable onDismissRunnable)
            throws InflationException {
        ViewGroup parent = mListContainer.getViewParentForNotification(entry);
        PackageManager pmUser = StatusBar.getPackageManagerForUser(mContext,
@@ -163,12 +145,26 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
            entry.updateIcons(mContext, sbn);
            entry.reset();
            updateNotification(entry, pmUser, sbn, entry.getRow());
            entry.getRow().setOnDismissRunnable(onDismissRunnable);
            entry.getRowController().setOnDismissRunnable(onDismissRunnable);
        } else {
            entry.createIcons(mContext, sbn);
            mRowInflaterTaskProvider.get().inflate(mContext, parent, entry,
                    row -> {
                        bindRow(entry, pmUser, sbn, row, onDismissRunnable);
                        // Setup the controller for the view.
                        ExpandableNotificationRowComponent component =
                                mExpandableNotificationRowComponentBuilder
                                        .expandableNotificationRow(row)
                                        .notificationEntry(entry)
                                        .onDismissRunnable(onDismissRunnable)
                                        .inflationCallback(mInflationCallback)
                                        .rowContentBindStage(mRowContentBindStage)
                                        .onExpandClickListener(mPresenter)
                                        .build();
                        ExpandableNotificationRowController rowController =
                                component.getExpandableNotificationRowController();
                        rowController.init();
                        entry.setRowController(rowController);
                        bindRow(entry, pmUser, sbn, row);
                        updateNotification(entry, pmUser, sbn, row);
                    });
        }
@@ -176,55 +172,12 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {

    //TODO: This method associates a row with an entry, but eventually needs to not do that
    private void bindRow(NotificationEntry entry, PackageManager pmUser,
            StatusBarNotification sbn, ExpandableNotificationRow row,
            Runnable onDismissRunnable) {
        // Get the app name.
        // Note that Notification.Builder#bindHeaderAppName has similar logic
        // but since this field is used in the guts, it must be accurate.
        // Therefore we will only show the application label, or, failing that, the
        // package name. No substitutions.
        final String pkg = sbn.getPackageName();
        String appname = pkg;
        try {
            final ApplicationInfo info = pmUser.getApplicationInfo(pkg,
                    PackageManager.MATCH_UNINSTALLED_PACKAGES
                            | PackageManager.MATCH_DISABLED_COMPONENTS);
            if (info != null) {
                appname = String.valueOf(pmUser.getApplicationLabel(info));
            }
        } catch (PackageManager.NameNotFoundException e) {
            // Do nothing
        }

        row.initialize(
                appname,
                sbn.getKey(),
                mExpansionLogger,
                mKeyguardBypassController,
                mGroupManager,
                mHeadsUpManager,
                mRowContentBindStage,
                mPresenter);

        // TODO: Either move these into ExpandableNotificationRow#initialize or out of row entirely
        row.setStatusBarStateController(mStatusBarStateController);
        row.setAppOpsOnClickListener(mOnAppOpsClickListener);
        if (mAllowLongPress) {
            row.setLongPressListener(mGutsManager::openGuts);
        }
            StatusBarNotification sbn, ExpandableNotificationRow row) {
        mListContainer.bindRow(row);
        mNotificationRemoteInputManager.bindRow(row);

        row.setOnDismissRunnable(onDismissRunnable);
        row.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
        if (ENABLE_REMOTE_INPUT) {
            row.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
        }

        entry.setRow(row);
        row.setEntry(entry);
        mNotifBindPipeline.manageRow(entry, row);

        mBindRowCallback.onBindRow(entry, pmUser, sbn, row);
    }

@@ -307,10 +260,6 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
        Objects.requireNonNull(mNotificationClicker).register(row, sbn);
    }

    private void logNotificationExpansion(String key, boolean userAction, boolean expanded) {
        mNotificationLogger.onExpansionChanged(key, userAction, expanded);
    }

    /** Callback for when a row is bound to an entry. */
    public interface BindRowCallback {
        /**
+0 −1
Original line number Diff line number Diff line
@@ -90,7 +90,6 @@ class NotificationsControllerImpl @Inject constructor(
        notificationRowBinder.setUpWithPresenter(
                presenter,
                listContainer,
                headsUpManager,
                bindRowCallback)

        if (featureFlags.isNewNotifPipelineEnabled) {
Loading