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

Commit 5dc1edfe authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Fix notification interruption stats

- Write channelid to xml
- Fix issue querying packages by user

Test: manual
Bug: 79607096
Change-Id: I77b1a532d364fcf97a4dba9d83ce97b93650a88c
parent 218871ee
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -866,7 +866,7 @@ public class UsageStatsService extends SystemService implements
            final long token = Binder.clearCallingIdentity();
            final long token = Binder.clearCallingIdentity();
            try {
            try {
                return UsageStatsService.this.queryEventsForPackage(userId, beginTime,
                return UsageStatsService.this.queryEventsForPackage(userId, beginTime,
                        endTime, callingPackage);
                        endTime, pkg);
            } finally {
            } finally {
                Binder.restoreCallingIdentity(token);
                Binder.restoreCallingIdentity(token);
            }
            }
+13 −0
Original line number Original line Diff line number Diff line
@@ -68,6 +68,7 @@ final class UsageStatsXmlV1 {
    private static final String SHORTCUT_ID_ATTR = "shortcutId";
    private static final String SHORTCUT_ID_ATTR = "shortcutId";
    private static final String STANDBY_BUCKET_ATTR = "standbyBucket";
    private static final String STANDBY_BUCKET_ATTR = "standbyBucket";
    private static final String APP_LAUNCH_COUNT_ATTR = "appLaunchCount";
    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.
    // Time attributes stored as an offset of the beginTime.
    private static final String LAST_TIME_ACTIVE_ATTR = "lastTimeActive";
    private static final String LAST_TIME_ACTIVE_ATTR = "lastTimeActive";
@@ -189,6 +190,11 @@ final class UsageStatsXmlV1 {
            case UsageEvents.Event.STANDBY_BUCKET_CHANGED:
            case UsageEvents.Event.STANDBY_BUCKET_CHANGED:
                event.mBucketAndReason = XmlUtils.readIntAttribute(parser, STANDBY_BUCKET_ATTR, 0);
                event.mBucketAndReason = XmlUtils.readIntAttribute(parser, STANDBY_BUCKET_ATTR, 0);
                break;
                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) {
        if (statsOut.events == null) {
@@ -307,6 +313,13 @@ final class UsageStatsXmlV1 {
                if (event.mBucketAndReason != 0) {
                if (event.mBucketAndReason != 0) {
                    XmlUtils.writeIntAttribute(xml, STANDBY_BUCKET_ATTR, event.mBucketAndReason);
                    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);
        xml.endTag(null, EVENT_TAG);
+3 −0
Original line number Original line Diff line number Diff line
@@ -604,6 +604,9 @@ class UserUsageStatsService {
            pw.printPair("standbyBucket", event.getStandbyBucket());
            pw.printPair("standbyBucket", event.getStandbyBucket());
            pw.printPair("reason", UsageStatsManager.reasonToString(event.getStandbyReason()));
            pw.printPair("reason", UsageStatsManager.reasonToString(event.getStandbyReason()));
        }
        }
        if (event.mNotificationChannelId != null) {
            pw.printPair("channelId", event.mNotificationChannelId);
        }
        pw.printHexPair("flags", event.mFlags);
        pw.printHexPair("flags", event.mFlags);
        pw.println();
        pw.println();
    }
    }