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

Commit b302674c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update notif onClick logic"

parents fc5c68ab 134206b1
Loading
Loading
Loading
Loading
+29 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.notification.collection.inflation;

import static android.service.notification.NotificationStats.DISMISS_SENTIMENT_NEUTRAL;

import android.annotation.Nullable;
import android.os.SystemClock;
import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationStats;
@@ -29,6 +30,7 @@ import com.android.systemui.statusbar.notification.collection.NotifPipeline;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.coordinator.VisualStabilityCoordinator;
import com.android.systemui.statusbar.notification.collection.notifcollection.DismissedByUserStats;
import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager;
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
import com.android.systemui.statusbar.notification.row.OnUserInteractionCallback;
import com.android.systemui.statusbar.policy.HeadsUpManager;
@@ -43,19 +45,22 @@ public class OnUserInteractionCallbackImpl implements OnUserInteractionCallback
    private final HeadsUpManager mHeadsUpManager;
    private final StatusBarStateController mStatusBarStateController;
    private final VisualStabilityCoordinator mVisualStabilityCoordinator;
    private final GroupMembershipManager mGroupMembershipManager;

    public OnUserInteractionCallbackImpl(
            NotifPipeline notifPipeline,
            NotifCollection notifCollection,
            HeadsUpManager headsUpManager,
            StatusBarStateController statusBarStateController,
            VisualStabilityCoordinator visualStabilityCoordinator
            VisualStabilityCoordinator visualStabilityCoordinator,
            GroupMembershipManager groupMembershipManager
    ) {
        mNotifPipeline = notifPipeline;
        mNotifCollection = notifCollection;
        mHeadsUpManager = headsUpManager;
        mStatusBarStateController = statusBarStateController;
        mVisualStabilityCoordinator = visualStabilityCoordinator;
        mGroupMembershipManager = groupMembershipManager;
    }

    /**
@@ -67,7 +72,8 @@ public class OnUserInteractionCallbackImpl implements OnUserInteractionCallback
    @Override
    public void onDismiss(
            NotificationEntry entry,
            @NotificationListenerService.NotificationCancelReason int cancellationReason
            @NotificationListenerService.NotificationCancelReason int cancellationReason,
            @Nullable NotificationEntry groupSummaryToDismiss
    ) {
        int dismissalSurface = NotificationStats.DISMISSAL_SHADE;
        if (mHeadsUpManager.isAlerting(entry.getKey())) {
@@ -76,6 +82,10 @@ public class OnUserInteractionCallbackImpl implements OnUserInteractionCallback
            dismissalSurface = NotificationStats.DISMISSAL_AOD;
        }

        if (groupSummaryToDismiss != null) {
            onDismiss(groupSummaryToDismiss, cancellationReason, null);
        }

        mNotifCollection.dismissNotification(
                entry,
                new DismissedByUserStats(
@@ -96,4 +106,21 @@ public class OnUserInteractionCallbackImpl implements OnUserInteractionCallback
                entry,
                SystemClock.uptimeMillis());
    }

    /**
     * @param entry that is being dismissed
     * @return the group summary to dismiss along with this entry if this is the last entry in
     * the group. Else, returns null.
     */
    @Override
    @Nullable
    public NotificationEntry getGroupSummaryToDismiss(NotificationEntry entry) {
        if (entry.getParent() != null
                && entry.getParent().getSummary() != null
                && mGroupMembershipManager.isOnlyChildInGroup(entry)) {
            NotificationEntry groupSummary = entry.getParent().getSummary();
            return groupSummary.isClearable() ? groupSummary : null;
        }
        return null;
    }
}
+24 −6
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.notification.collection.legacy;

import static android.service.notification.NotificationStats.DISMISS_SENTIMENT_NEUTRAL;

import android.annotation.Nullable;
import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationStats;

@@ -60,11 +61,16 @@ public class OnUserInteractionCallbackImplLegacy implements OnUserInteractionCal
     * 1. Manually dismisses a notification {@see ExpandableNotificationRow}.
     * 2. Clicks on a notification with flag {@link android.app.Notification#FLAG_AUTO_CANCEL}.
     * {@see StatusBarNotificationActivityStarter}
     *
     * @param groupSummaryToDismiss the group summary that should be dismissed
     *                              along with this dismissal. If null, does not additionally
     *                              dismiss any notifications.
     */
    @Override
    public void onDismiss(
            NotificationEntry entry,
            @NotificationListenerService.NotificationCancelReason int cancellationReason
            @NotificationListenerService.NotificationCancelReason int cancellationReason,
            @Nullable NotificationEntry groupSummaryToDismiss
    ) {
        int dismissalSurface = NotificationStats.DISMISSAL_SHADE;
        if (mHeadsUpManager.isAlerting(entry.getKey())) {
@@ -73,11 +79,8 @@ public class OnUserInteractionCallbackImplLegacy implements OnUserInteractionCal
            dismissalSurface = NotificationStats.DISMISSAL_AOD;
        }

        if (mGroupMembershipManager.isOnlyChildInGroup(entry)) {
            NotificationEntry groupSummary = mGroupMembershipManager.getLogicalGroupSummary(entry);
            if (groupSummary.isClearable()) {
                onDismiss(groupSummary, cancellationReason);
            }
        if (groupSummaryToDismiss != null) {
            onDismiss(groupSummaryToDismiss, cancellationReason, null);
        }

        mNotificationEntryManager.performRemoveNotification(
@@ -100,5 +103,20 @@ public class OnUserInteractionCallbackImplLegacy implements OnUserInteractionCal
    public void onImportanceChanged(NotificationEntry entry) {
        mVisualStabilityManager.temporarilyAllowReordering();
    }

    /**
     * @param entry that is being dismissed
     * @return the group summary to dismiss along with this entry if this is the last entry in
     * the group. Else, returns null.
     */
    @Override
    @Nullable
    public NotificationEntry getGroupSummaryToDismiss(NotificationEntry entry) {
        if (mGroupMembershipManager.isOnlyChildInGroup(entry)) {
            NotificationEntry groupSummary = mGroupMembershipManager.getLogicalGroupSummary(entry);
            return groupSummary.isClearable() ? groupSummary : null;
        }
        return null;
    }
}
+0 −2
Original line number Diff line number Diff line
@@ -57,8 +57,6 @@ public interface GroupMembershipManager {

    /**
     * Whether this is the only child in a group
     * TODO: remove this when migrating to the new pipeline, this is taken care of in the
     * dismissal logic built into NotifCollection
     */
    boolean isOnlyChildInGroup(NotificationEntry entry);

+2 −1
Original line number Diff line number Diff line
@@ -268,7 +268,8 @@ public interface NotificationsModule {
                        notifCollection.get(),
                        headsUpManager,
                        statusBarStateController,
                        visualStabilityCoordinator.get())
                        visualStabilityCoordinator.get(),
                        groupMembershipManagerLazy.get())
                : new OnUserInteractionCallbackImplLegacy(
                        entryManager,
                        headsUpManager,
+2 −1
Original line number Diff line number Diff line
@@ -1433,7 +1433,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        dismiss(fromAccessibility);
        if (mEntry.isClearable()) {
            if (mOnUserInteractionCallback != null) {
                mOnUserInteractionCallback.onDismiss(mEntry, REASON_CANCEL);
                mOnUserInteractionCallback.onDismiss(mEntry, REASON_CANCEL,
                        mOnUserInteractionCallback.getGroupSummaryToDismiss(mEntry));
            }
        }
    }
Loading