Merge "fix NPE when dump wins the race against emit" into nyc-dev
This commit is contained in:
@@ -336,6 +336,13 @@ public class NotificationUsageStats {
|
|||||||
finalImportance = new ImportanceHistogram(context, "note_importance_");
|
finalImportance = new ImportanceHistogram(context, "note_importance_");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AggregatedStats getPrevious() {
|
||||||
|
if (mPrevious == null) {
|
||||||
|
mPrevious = new AggregatedStats(mContext, key);
|
||||||
|
}
|
||||||
|
return mPrevious;
|
||||||
|
}
|
||||||
|
|
||||||
public void countApiUse(NotificationRecord record) {
|
public void countApiUse(NotificationRecord record) {
|
||||||
final Notification n = record.getNotification();
|
final Notification n = record.getNotification();
|
||||||
if (n.actions != null) {
|
if (n.actions != null) {
|
||||||
@@ -411,67 +418,64 @@ public class NotificationUsageStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void emit() {
|
public void emit() {
|
||||||
if (mPrevious == null) {
|
AggregatedStats previous = getPrevious();
|
||||||
mPrevious = new AggregatedStats(null, key);
|
maybeCount("note_post", (numPostedByApp - previous.numPostedByApp));
|
||||||
}
|
maybeCount("note_update", (numUpdatedByApp - previous.numUpdatedByApp));
|
||||||
|
maybeCount("note_remove", (numRemovedByApp - previous.numRemovedByApp));
|
||||||
|
maybeCount("note_with_people", (numWithValidPeople - previous.numWithValidPeople));
|
||||||
|
maybeCount("note_with_stars", (numWithStaredPeople - previous.numWithStaredPeople));
|
||||||
|
maybeCount("people_cache_hit", (numPeopleCacheHit - previous.numPeopleCacheHit));
|
||||||
|
maybeCount("people_cache_miss", (numPeopleCacheMiss - previous.numPeopleCacheMiss));
|
||||||
|
maybeCount("note_blocked", (numBlocked - previous.numBlocked));
|
||||||
|
maybeCount("note_suspended", (numSuspendedByAdmin - previous.numSuspendedByAdmin));
|
||||||
|
maybeCount("note_with_actions", (numWithActions - previous.numWithActions));
|
||||||
|
maybeCount("note_private", (numPrivate - previous.numPrivate));
|
||||||
|
maybeCount("note_secret", (numSecret - previous.numSecret));
|
||||||
|
maybeCount("note_interupt", (numInterrupt - previous.numInterrupt));
|
||||||
|
maybeCount("note_big_text", (numWithBigText - previous.numWithBigText));
|
||||||
|
maybeCount("note_big_pic", (numWithBigPicture - previous.numWithBigPicture));
|
||||||
|
maybeCount("note_fg", (numForegroundService - previous.numForegroundService));
|
||||||
|
maybeCount("note_ongoing", (numOngoing - previous.numOngoing));
|
||||||
|
maybeCount("note_auto", (numAutoCancel - previous.numAutoCancel));
|
||||||
|
maybeCount("note_large_icon", (numWithLargeIcon - previous.numWithLargeIcon));
|
||||||
|
maybeCount("note_inbox", (numWithInbox - previous.numWithInbox));
|
||||||
|
maybeCount("note_media", (numWithMediaSession - previous.numWithMediaSession));
|
||||||
|
maybeCount("note_title", (numWithTitle - previous.numWithTitle));
|
||||||
|
maybeCount("note_text", (numWithText - previous.numWithText));
|
||||||
|
maybeCount("note_sub_text", (numWithSubText - previous.numWithSubText));
|
||||||
|
maybeCount("note_info_text", (numWithInfoText - previous.numWithInfoText));
|
||||||
|
noisyImportance.maybeCount(previous.noisyImportance);
|
||||||
|
quietImportance.maybeCount(previous.quietImportance);
|
||||||
|
finalImportance.maybeCount(previous.finalImportance);
|
||||||
|
|
||||||
maybeCount("note_post", (numPostedByApp - mPrevious.numPostedByApp));
|
previous.numPostedByApp = numPostedByApp;
|
||||||
maybeCount("note_update", (numUpdatedByApp - mPrevious.numUpdatedByApp));
|
previous.numUpdatedByApp = numUpdatedByApp;
|
||||||
maybeCount("note_remove", (numRemovedByApp - mPrevious.numRemovedByApp));
|
previous.numRemovedByApp = numRemovedByApp;
|
||||||
maybeCount("note_with_people", (numWithValidPeople - mPrevious.numWithValidPeople));
|
previous.numPeopleCacheHit = numPeopleCacheHit;
|
||||||
maybeCount("note_with_stars", (numWithStaredPeople - mPrevious.numWithStaredPeople));
|
previous.numPeopleCacheMiss = numPeopleCacheMiss;
|
||||||
maybeCount("people_cache_hit", (numPeopleCacheHit - mPrevious.numPeopleCacheHit));
|
previous.numWithStaredPeople = numWithStaredPeople;
|
||||||
maybeCount("people_cache_miss", (numPeopleCacheMiss - mPrevious.numPeopleCacheMiss));
|
previous.numWithValidPeople = numWithValidPeople;
|
||||||
maybeCount("note_blocked", (numBlocked - mPrevious.numBlocked));
|
previous.numBlocked = numBlocked;
|
||||||
maybeCount("note_suspended", (numSuspendedByAdmin - mPrevious.numSuspendedByAdmin));
|
previous.numSuspendedByAdmin = numSuspendedByAdmin;
|
||||||
maybeCount("note_with_actions", (numWithActions - mPrevious.numWithActions));
|
previous.numWithActions = numWithActions;
|
||||||
maybeCount("note_private", (numPrivate - mPrevious.numPrivate));
|
previous.numPrivate = numPrivate;
|
||||||
maybeCount("note_secret", (numSecret - mPrevious.numSecret));
|
previous.numSecret = numSecret;
|
||||||
maybeCount("note_interupt", (numInterrupt - mPrevious.numInterrupt));
|
previous.numInterrupt = numInterrupt;
|
||||||
maybeCount("note_big_text", (numWithBigText - mPrevious.numWithBigText));
|
previous.numWithBigText = numWithBigText;
|
||||||
maybeCount("note_big_pic", (numWithBigPicture - mPrevious.numWithBigPicture));
|
previous.numWithBigPicture = numWithBigPicture;
|
||||||
maybeCount("note_fg", (numForegroundService - mPrevious.numForegroundService));
|
previous.numForegroundService = numForegroundService;
|
||||||
maybeCount("note_ongoing", (numOngoing - mPrevious.numOngoing));
|
previous.numOngoing = numOngoing;
|
||||||
maybeCount("note_auto", (numAutoCancel - mPrevious.numAutoCancel));
|
previous.numAutoCancel = numAutoCancel;
|
||||||
maybeCount("note_large_icon", (numWithLargeIcon - mPrevious.numWithLargeIcon));
|
previous.numWithLargeIcon = numWithLargeIcon;
|
||||||
maybeCount("note_inbox", (numWithInbox - mPrevious.numWithInbox));
|
previous.numWithInbox = numWithInbox;
|
||||||
maybeCount("note_media", (numWithMediaSession - mPrevious.numWithMediaSession));
|
previous.numWithMediaSession = numWithMediaSession;
|
||||||
maybeCount("note_title", (numWithTitle - mPrevious.numWithTitle));
|
previous.numWithTitle = numWithTitle;
|
||||||
maybeCount("note_text", (numWithText - mPrevious.numWithText));
|
previous.numWithText = numWithText;
|
||||||
maybeCount("note_sub_text", (numWithSubText - mPrevious.numWithSubText));
|
previous.numWithSubText = numWithSubText;
|
||||||
maybeCount("note_info_text", (numWithInfoText - mPrevious.numWithInfoText));
|
previous.numWithInfoText = numWithInfoText;
|
||||||
noisyImportance.maybeCount(mPrevious.noisyImportance);
|
noisyImportance.update(previous.noisyImportance);
|
||||||
quietImportance.maybeCount(mPrevious.quietImportance);
|
quietImportance.update(previous.quietImportance);
|
||||||
finalImportance.maybeCount(mPrevious.finalImportance);
|
finalImportance.update(previous.finalImportance);
|
||||||
|
|
||||||
mPrevious.numPostedByApp = numPostedByApp;
|
|
||||||
mPrevious.numUpdatedByApp = numUpdatedByApp;
|
|
||||||
mPrevious.numRemovedByApp = numRemovedByApp;
|
|
||||||
mPrevious.numPeopleCacheHit = numPeopleCacheHit;
|
|
||||||
mPrevious.numPeopleCacheMiss = numPeopleCacheMiss;
|
|
||||||
mPrevious.numWithStaredPeople = numWithStaredPeople;
|
|
||||||
mPrevious.numWithValidPeople = numWithValidPeople;
|
|
||||||
mPrevious.numBlocked = numBlocked;
|
|
||||||
mPrevious.numSuspendedByAdmin = numSuspendedByAdmin;
|
|
||||||
mPrevious.numWithActions = numWithActions;
|
|
||||||
mPrevious.numPrivate = numPrivate;
|
|
||||||
mPrevious.numSecret = numSecret;
|
|
||||||
mPrevious.numInterrupt = numInterrupt;
|
|
||||||
mPrevious.numWithBigText = numWithBigText;
|
|
||||||
mPrevious.numWithBigPicture = numWithBigPicture;
|
|
||||||
mPrevious.numForegroundService = numForegroundService;
|
|
||||||
mPrevious.numOngoing = numOngoing;
|
|
||||||
mPrevious.numAutoCancel = numAutoCancel;
|
|
||||||
mPrevious.numWithLargeIcon = numWithLargeIcon;
|
|
||||||
mPrevious.numWithInbox = numWithInbox;
|
|
||||||
mPrevious.numWithMediaSession = numWithMediaSession;
|
|
||||||
mPrevious.numWithTitle = numWithTitle;
|
|
||||||
mPrevious.numWithText = numWithText;
|
|
||||||
mPrevious.numWithSubText = numWithSubText;
|
|
||||||
mPrevious.numWithInfoText = numWithInfoText;
|
|
||||||
noisyImportance.update(mPrevious.noisyImportance);
|
|
||||||
quietImportance.update(mPrevious.quietImportance);
|
|
||||||
finalImportance.update(mPrevious.finalImportance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void maybeCount(String name, int value) {
|
void maybeCount(String name, int value) {
|
||||||
@@ -553,6 +557,7 @@ public class NotificationUsageStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject dumpJson() throws JSONException {
|
public JSONObject dumpJson() throws JSONException {
|
||||||
|
AggregatedStats previous = getPrevious();
|
||||||
JSONObject dump = new JSONObject();
|
JSONObject dump = new JSONObject();
|
||||||
dump.put("key", key);
|
dump.put("key", key);
|
||||||
dump.put("duration", SystemClock.elapsedRealtime() - mCreated);
|
dump.put("duration", SystemClock.elapsedRealtime() - mCreated);
|
||||||
@@ -581,9 +586,9 @@ public class NotificationUsageStats {
|
|||||||
maybePut(dump, "numWithText", numWithText);
|
maybePut(dump, "numWithText", numWithText);
|
||||||
maybePut(dump, "numWithSubText", numWithSubText);
|
maybePut(dump, "numWithSubText", numWithSubText);
|
||||||
maybePut(dump, "numWithInfoText", numWithInfoText);
|
maybePut(dump, "numWithInfoText", numWithInfoText);
|
||||||
noisyImportance.maybePut(dump, mPrevious.noisyImportance);
|
noisyImportance.maybePut(dump, previous.noisyImportance);
|
||||||
quietImportance.maybePut(dump, mPrevious.quietImportance);
|
quietImportance.maybePut(dump, previous.quietImportance);
|
||||||
finalImportance.maybePut(dump, mPrevious.finalImportance);
|
finalImportance.maybePut(dump, previous.finalImportance);
|
||||||
|
|
||||||
return dump;
|
return dump;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user