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

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

Move creationTime into ListEntry (from NotifEntry)

Following CLs will need to examine the creation time of groups as well
as notif entries, so we should store this on the root ListEntry (where
it makes the most sense to exist anyway tbh).

Test: atest
Change-Id: I4cc5ac77a3979198b62524655fda5a97a6fbeaa5
parent 3f4bfd7c
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -39,9 +39,8 @@ public class GroupEntry extends ListEntry {
            Collections.unmodifiableList(mChildren);
    private int mUntruncatedChildCount;

    @VisibleForTesting
    public GroupEntry(String key) {
        super(key);
    public GroupEntry(String key, long creationTime) {
        super(key, creationTime);
    }

    @Override
@@ -98,6 +97,6 @@ public class GroupEntry extends ListEntry {
        return mChildren;
    }

    public static final GroupEntry ROOT_ENTRY = new GroupEntry("<root>");
    public static final GroupEntry ROOT_ENTRY = new GroupEntry("<root>", 0);

}
+26 −1
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package com.android.systemui.statusbar.notification.collection;


import android.annotation.UptimeMillisLong;

import androidx.annotation.Nullable;

import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection;
@@ -27,20 +29,35 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.plugga
 */
public abstract class ListEntry {
    private final String mKey;
    private final long mCreationTime;

    int mFirstAddedIteration = -1;

    private final ListAttachState mPreviousAttachState = ListAttachState.create();
    private final ListAttachState mAttachState = ListAttachState.create();

    ListEntry(String key) {
    ListEntry(String key, long creationTime) {
        mKey = key;
        mCreationTime = creationTime;
    }

    public String getKey() {
        return mKey;
    }

    /**
     * The SystemClock.uptimeMillis() when this object was created. In general, this means the
     * moment when NotificationManager notifies our listener about the existence of this entry.
     *
     * This value will not change if the notification is updated, although it will change if the
     * notification is removed and then re-posted. It is also wholly independent from
     * Notification#when.
     */
    @UptimeMillisLong
    public long getCreationTime() {
        return mCreationTime;
    }

    /**
     * Should return the "representative entry" for this ListEntry. For NotificationEntries, its
     * the entry itself. For groups, it should be the summary (but if a summary doesn't exist,
@@ -78,6 +95,14 @@ public abstract class ListEntry {
        return mPreviousAttachState;
    }

    /**
     * True if this entry has been attached to the shade at least once in its lifetime (it may not
     * currently be attached).
     */
    public boolean hasBeenAttachedBefore() {
        return mFirstAddedIteration != -1;
    }

    /**
     * Stores the current attach state into {@link #getPreviousAttachState()}} and then starts a
     * fresh attach state (all entries will be null/default-initialized).
+1 −19
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import static com.android.systemui.statusbar.notification.stack.NotificationSect

import static java.util.Objects.requireNonNull;

import android.annotation.CurrentTimeMillisLong;
import android.app.Notification;
import android.app.Notification.MessagingStyle.Message;
import android.app.NotificationChannel;
@@ -96,7 +95,6 @@ public final class NotificationEntry extends ListEntry {
    private final String mKey;
    private StatusBarNotification mSbn;
    private Ranking mRanking;
    private long mCreationTime;

    /*
     * Bookkeeping members
@@ -198,11 +196,10 @@ public final class NotificationEntry extends ListEntry {
            boolean allowFgsDismissal,
            long creationTime
    ) {
        super(requireNonNull(requireNonNull(sbn).getKey()));
        super(requireNonNull(requireNonNull(sbn).getKey()), creationTime);

        requireNonNull(ranking);

        mCreationTime = creationTime;
        mKey = sbn.getKey();
        setSbn(sbn);
        setRanking(ranking);
@@ -254,21 +251,6 @@ public final class NotificationEntry extends ListEntry {
        return mRanking;
    }

    /**
     * A timestamp of SystemClock.uptimeMillis() of when this entry was first created, regardless
     * of any changes to the data presented. It is set once on creation and will never change, and
     * allows us to know exactly how long this notification has been alive for in our listener
     * service. It is entirely unrelated to the information inside of the notification.
     *
     * This is different to Notification#when because it persists throughout updates, whereas
     * system server treats every single call to notify() as a new notification and we handle
     * updates to NotificationEntry locally.
     */
    @CurrentTimeMillisLong
    public long getCreationTime() {
        return mCreationTime;
    }

    /**
     * Should only be called by NotificationEntryManager and friends.
     * TODO: Make this package-private
+1 −1
Original line number Diff line number Diff line
@@ -421,7 +421,7 @@ public class ShadeListBuilder implements Dumpable {

                GroupEntry group = mGroups.get(topLevelKey);
                if (group == null) {
                    group = new GroupEntry(topLevelKey);
                    group = new GroupEntry(topLevelKey, mSystemClock.uptimeMillis());
                    group.mFirstAddedIteration = mIterationCount;
                    mGroups.put(topLevelKey, group);
                }