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

Commit 640e387c authored by Chris Wren's avatar Chris Wren
Browse files

Add notification lifetime to the cancel message.

Also track the total lifetime in the notificaiton record.

Bug: 20122735
Change-Id: I09668be0161de0e1d8201b069e533a9a2203c83c
parent 3db024af
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ option java_package com.android.server
# when a notification action button has been clicked
27521 notification_action_clicked (key|3),(action_index|1)
# when a notification has been canceled
27530 notification_canceled (key|3),(reason|1)
27530 notification_canceled (key|3),(reason|1),(lifespan|1)

# ---------------------------
# Watchdog.java
+2 −1
Original line number Diff line number Diff line
@@ -2663,7 +2663,8 @@ public class NotificationManagerService extends SystemService {
        // Save it for users of getHistoricalNotifications()
        mArchive.record(r.sbn);

        EventLogTags.writeNotificationCanceled(canceledKey, reason);
        int lifespan = (int) (System.currentTimeMillis() - r.getCreationTimeMs());
        EventLogTags.writeNotificationCanceled(canceledKey, reason, lifespan);
    }

    /**
+13 −0
Original line number Diff line number Diff line
@@ -62,6 +62,9 @@ public final class NotificationRecord {
    // The timestamp used for ranking.
    private long mRankingTimeMs;

    // The first post time, stable across updates.
    private long mCreationTimeMs;

    // Is this record an update of an old record?
    public boolean isUpdate;
    private int mPackagePriority;
@@ -77,6 +80,7 @@ public final class NotificationRecord {
        this.score = score;
        mOriginalFlags = sbn.getNotification().flags;
        mRankingTimeMs = calculateRankingTimeMs(0L);
        mCreationTimeMs = sbn.getPostTime();
    }

    // copy any notes that the ranking system may have made before the update
@@ -87,6 +91,7 @@ public final class NotificationRecord {
        mPackageVisibility = previous.mPackageVisibility;
        mIntercept = previous.mIntercept;
        mRankingTimeMs = calculateRankingTimeMs(previous.getRankingTimeMs());
        mCreationTimeMs = previous.mCreationTimeMs;
        // Don't copy mGlobalSortKey, recompute it.
    }

@@ -167,6 +172,7 @@ public final class NotificationRecord {
        pw.println(prefix + "  mIntercept=" + mIntercept);
        pw.println(prefix + "  mGlobalSortKey=" + mGlobalSortKey);
        pw.println(prefix + "  mRankingTimeMs=" + mRankingTimeMs);
        pw.println(prefix + "  mCreationTimeMs=" + mCreationTimeMs);
    }


@@ -262,6 +268,13 @@ public final class NotificationRecord {
        return mRankingTimeMs;
    }

    /**
     * Returns the timestamp of the first post, ignoring updates.
     */
    public long getCreationTimeMs() {
        return mCreationTimeMs;
    }

    /**
     * @param previousRankingTimeMs for updated notifications, {@link #getRankingTimeMs()}
     *     of the previous notification record, 0 otherwise