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

Commit c570b68a authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Fix notification interruption stats"

parents b948136d 5dc1edfe
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
            }
+13 −0
Original line number Diff line number Diff line
@@ -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);
+3 −0
Original line number Diff line number Diff line
@@ -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();
    }