Merge "DO NOT MERGE Log notification interruptions to TRON" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-06-27 01:09:48 +00:00
committed by Android (Google) Code Review
2 changed files with 40 additions and 2 deletions

View File

@@ -6116,7 +6116,21 @@ message MetricsEvent {
// OS: P
FIELD_AUTOFILL_SESSION_ID = 1456;
// NOTIFICATION_SINCE_INTERRUPTION_MILLIS added to P
// NOTIFICATION_INTERRUPTION added to P
// ---- End P Constants, all P constants go above this line ----
// Time since this notification last interrupted (visibly or audible) the user
NOTIFICATION_SINCE_INTERRUPTION_MILLIS = 1500;
// OPEN: Notification interrupted the user, either audibly or visually.
// Tagged data: NOTIFICATION_SINCE_INTERRUPTION_MILLIS
// CATEGORY: NOTIFICATION
NOTIFICATION_INTERRUPTION = 1501;
// ---- End Q Constants, all Q constants go above this line ----
// Add new aosp constants above this line.
// END OF AOSP CONSTANTS
}

View File

@@ -128,6 +128,11 @@ public final class NotificationRecord {
// The most recent update time, or the creation time if no updates.
private long mUpdateTimeMs;
// The most recent interruption time, or the creation time if no updates. Differs from the
// above value because updates are filtered based on whether they actually interrupted the
// user
private long mInterruptionTimeMs;
// Is this record an update of an old record?
public boolean isUpdate;
private int mPackagePriority;
@@ -180,6 +185,7 @@ public final class NotificationRecord {
mRankingTimeMs = calculateRankingTimeMs(0L);
mCreationTimeMs = sbn.getPostTime();
mUpdateTimeMs = mCreationTimeMs;
mInterruptionTimeMs = mCreationTimeMs;
mContext = context;
stats = new NotificationUsageStats.SingleNotificationStats();
mChannel = channel;
@@ -525,6 +531,7 @@ public final class NotificationRecord {
pw.println(prefix + "mCreationTimeMs=" + mCreationTimeMs);
pw.println(prefix + "mVisibleSinceMs=" + mVisibleSinceMs);
pw.println(prefix + "mUpdateTimeMs=" + mUpdateTimeMs);
pw.println(prefix + "mInterruptionTimeMs=" + mInterruptionTimeMs);
pw.println(prefix + "mSuppressedVisualEffects= " + mSuppressedVisualEffects);
if (mPreChannelsNotification) {
pw.println(prefix + String.format("defaults=0x%08x flags=0x%08x",
@@ -786,6 +793,10 @@ public final class NotificationRecord {
return mVisibleSinceMs == 0 ? 0 : (int) (now - mVisibleSinceMs);
}
public int getInterruptionMs(long now) {
return (int) (now - mInterruptionTimeMs);
}
/**
* Set the visibility of the notification.
*/
@@ -844,7 +855,7 @@ public final class NotificationRecord {
public void setSeen() {
mStats.setSeen();
if (mTextChanged) {
mIsInterruptive = true;
setInterruptive(true);
}
}
@@ -940,6 +951,17 @@ public final class NotificationRecord {
public void setInterruptive(boolean interruptive) {
mIsInterruptive = interruptive;
final long now = System.currentTimeMillis();
mInterruptionTimeMs = interruptive ? now : mInterruptionTimeMs;
if (interruptive) {
MetricsLogger.action(getLogMaker()
.setCategory(MetricsEvent.NOTIFICATION_INTERRUPTION)
.setType(MetricsEvent.TYPE_OPEN)
.addTaggedData(MetricsEvent.NOTIFICATION_SINCE_INTERRUPTION_MILLIS,
getInterruptionMs(now)));
MetricsLogger.histogram(mContext, "note_interruptive", getInterruptionMs(now));
}
}
public void setTextChanged(boolean textChanged) {
@@ -1116,7 +1138,9 @@ public final class NotificationRecord {
sbn.getNotification().isGroupSummary() ? 1 : 0)
.addTaggedData(MetricsEvent.NOTIFICATION_SINCE_CREATE_MILLIS, getLifespanMs(now))
.addTaggedData(MetricsEvent.NOTIFICATION_SINCE_UPDATE_MILLIS, getFreshnessMs(now))
.addTaggedData(MetricsEvent.NOTIFICATION_SINCE_VISIBLE_MILLIS, getExposureMs(now));
.addTaggedData(MetricsEvent.NOTIFICATION_SINCE_VISIBLE_MILLIS, getExposureMs(now))
.addTaggedData(MetricsEvent.NOTIFICATION_SINCE_INTERRUPTION_MILLIS,
getInterruptionMs(now));
}
public LogMaker getLogMaker() {