Merge "Fix notification interruption stats"

This commit is contained in:
Julia Reynolds
2018-06-18 14:11:26 +00:00
committed by Android (Google) Code Review
3 changed files with 17 additions and 1 deletions

View File

@@ -866,7 +866,7 @@ public class UsageStatsService extends SystemService implements
final long token = Binder.clearCallingIdentity();
try {
return UsageStatsService.this.queryEventsForPackage(userId, beginTime,
endTime, callingPackage);
endTime, pkg);
} finally {
Binder.restoreCallingIdentity(token);
}

View File

@@ -68,6 +68,7 @@ final class UsageStatsXmlV1 {
private static final String SHORTCUT_ID_ATTR = "shortcutId";
private static final String STANDBY_BUCKET_ATTR = "standbyBucket";
private static final String APP_LAUNCH_COUNT_ATTR = "appLaunchCount";
private static final String NOTIFICATION_CHANNEL_ATTR = "notificationChannel";
// Time attributes stored as an offset of the beginTime.
private static final String LAST_TIME_ACTIVE_ATTR = "lastTimeActive";
@@ -189,6 +190,11 @@ final class UsageStatsXmlV1 {
case UsageEvents.Event.STANDBY_BUCKET_CHANGED:
event.mBucketAndReason = XmlUtils.readIntAttribute(parser, STANDBY_BUCKET_ATTR, 0);
break;
case UsageEvents.Event.NOTIFICATION_INTERRUPTION:
final String channelId =
XmlUtils.readStringAttribute(parser, NOTIFICATION_CHANNEL_ATTR);
event.mNotificationChannelId = (channelId != null) ? channelId.intern() : null;
break;
}
if (statsOut.events == null) {
@@ -307,6 +313,13 @@ final class UsageStatsXmlV1 {
if (event.mBucketAndReason != 0) {
XmlUtils.writeIntAttribute(xml, STANDBY_BUCKET_ATTR, event.mBucketAndReason);
}
break;
case UsageEvents.Event.NOTIFICATION_INTERRUPTION:
if (event.mNotificationChannelId != null) {
XmlUtils.writeStringAttribute(
xml, NOTIFICATION_CHANNEL_ATTR, event.mNotificationChannelId);
}
break;
}
xml.endTag(null, EVENT_TAG);

View File

@@ -604,6 +604,9 @@ class UserUsageStatsService {
pw.printPair("standbyBucket", event.getStandbyBucket());
pw.printPair("reason", UsageStatsManager.reasonToString(event.getStandbyReason()));
}
if (event.mNotificationChannelId != null) {
pw.printPair("channelId", event.mNotificationChannelId);
}
pw.printHexPair("flags", event.mFlags);
pw.println();
}