Preserve notification stats on update

Change-Id: I519b31e83c32ac00e7c5838abbc5e3127430106b
This commit is contained in:
Christoph Studer
2014-05-09 12:28:55 +02:00
parent 37a61c5e84
commit 061dee22df
2 changed files with 5 additions and 3 deletions

View File

@@ -444,7 +444,7 @@ public class NotificationManagerService extends SystemService {
public static final class NotificationRecord
{
final StatusBarNotification sbn;
final SingleNotificationStats stats = new SingleNotificationStats();
SingleNotificationStats stats;
IBinder statusBarKey;
NotificationRecord(StatusBarNotification sbn)
@@ -1638,7 +1638,7 @@ public class NotificationManagerService extends SystemService {
} else {
old = mNotificationList.get(index);
mNotificationList.set(index, r);
mUsageStats.registerUpdatedByApp(r);
mUsageStats.registerUpdatedByApp(r, old);
// Make sure we don't lose the foreground service state.
if (old != null) {
notification.flags |=

View File

@@ -58,6 +58,7 @@ public class NotificationUsageStats {
* Called when a notification has been posted.
*/
public synchronized void registerPostedByApp(NotificationRecord notification) {
notification.stats = new SingleNotificationStats();
notification.stats.posttimeElapsedMs = SystemClock.elapsedRealtime();
for (AggregatedStats stats : getAggregatedStatsLocked(notification)) {
stats.numPostedByApp++;
@@ -68,7 +69,8 @@ public class NotificationUsageStats {
/**
* Called when a notification has been updated.
*/
public void registerUpdatedByApp(NotificationRecord notification) {
public void registerUpdatedByApp(NotificationRecord notification, NotificationRecord old) {
notification.stats = old.stats;
for (AggregatedStats stats : getAggregatedStatsLocked(notification)) {
stats.numUpdatedByApp++;
}