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

Commit ef2ef6c9 authored by Ned Burns's avatar Ned Burns
Browse files

Change onRemoteEntry() to only fire when entries are removed

Conceptually, this should be a paired match with
onNotificationAdded(). Previously we were firing this method even
if the notification was no longer present (already removed) or
if it hadn't been added yet (was in pending).

Test: atest

Change-Id: I613f60aa8cf4e1aeb7bb13ff5883a221c9b623c6
parent 1a08863f
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -61,15 +61,10 @@ public class ForegroundServiceNotificationListener {
            @Override
            public void onEntryRemoved(
                    NotificationData.Entry entry,
                    String key,
                    StatusBarNotification old,
                    NotificationVisibility visibility,
                    boolean lifetimeExtended,
                    boolean removedByUser) {
                if (entry != null && !lifetimeExtended) {
                removeNotification(entry.notification);
            }
            }
        });
    }

+2 −8
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import android.media.session.PlaybackState;
import android.os.Handler;
import android.os.Trace;
import android.os.UserHandle;
import android.service.notification.StatusBarNotification;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
@@ -157,15 +156,10 @@ public class NotificationMediaManager implements Dumpable {
        notificationEntryManager.addNotificationEntryListener(new NotificationEntryListener() {
            @Override
            public void onEntryRemoved(
                    @Nullable Entry entry,
                    String key,
                    StatusBarNotification old,
                    Entry entry,
                    NotificationVisibility visibility,
                    boolean lifetimeExtended,
                    boolean removedByUser) {
                if (!lifetimeExtended) {
                    onNotificationRemoved(key);
                }
                onNotificationRemoved(entry.key);
            }
        });
    }
+1 −4
Original line number Diff line number Diff line
@@ -254,13 +254,10 @@ public class NotificationRemoteInputManager implements Dumpable {
            @Override
            public void onEntryRemoved(
                    @Nullable NotificationData.Entry entry,
                    String key,
                    StatusBarNotification old,
                    NotificationVisibility visibility,
                    boolean lifetimeExtended,
                    boolean removedByUser) {
                if (removedByUser && entry != null) {
                    onPerformRemoveNotification(entry, key);
                    onPerformRemoveNotification(entry, entry.key);
                }
            }
        });
+2 −6
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static com.android.systemui.statusbar.NotificationRemoteInputManager.FORC
import static com.android.systemui.statusbar.notification.row.NotificationInflater.FLAG_CONTENT_VIEW_AMBIENT;
import static com.android.systemui.statusbar.notification.row.NotificationInflater.FLAG_CONTENT_VIEW_HEADS_UP;

import android.annotation.Nullable;
import android.app.Notification;
import android.service.notification.StatusBarNotification;
import android.util.Log;
@@ -83,13 +82,10 @@ public class NotificationAlertingManager {

            @Override
            public void onEntryRemoved(
                    @Nullable NotificationData.Entry entry,
                    String key,
                    StatusBarNotification old,
                    NotificationData.Entry entry,
                    NotificationVisibility visibility,
                    boolean lifetimeExtended,
                    boolean removedByUser) {
                stopAlerting(key);
                stopAlerting(entry.key);
            }
        });
    }
+1 −7
Original line number Diff line number Diff line
@@ -71,20 +71,14 @@ public interface NotificationEntryListener {
     * because the developer retracted it).
     * @param entry notification data entry that was removed.  Null if no entry existed for the
     *              removed key at the time of removal.
     * @param key key of notification that was removed
     * @param old StatusBarNotification of the notification before it was removed
     * @param visibility logging data related to the visibility of the notification at the time of
     *                   removal, if it was removed by a user action.  Null if it was not removed by
     *                   a user action.
     * @param lifetimeExtended true if something is artificially extending how long the notification
     * @param removedByUser true if the notification was removed by a user action
     */
    default void onEntryRemoved(
            @Nullable NotificationData.Entry entry,
            String key,
            StatusBarNotification old,
            NotificationData.Entry entry,
            @Nullable NotificationVisibility visibility,
            boolean lifetimeExtended,
            boolean removedByUser) {
    }
}
Loading