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

Commit 3389f152 authored by Ben Murdoch's avatar Ben Murdoch
Browse files

Add worksource AAB bucket to WakeupAlarmOccurred WW atom.

This will enable us to breakdown number of alarms triggered by
app standby bucket.

Bug: 132227621
Test: statsd_testdrive 35

Change-Id: I4cb6c1e631ac940bedaff734cc40b1512405bf33
parent c9fa0716
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -994,6 +994,19 @@ message WakeupAlarmOccurred {

    // Name of source package (for historical reasons, since BatteryStats tracked it).
    optional string package_name = 3;

    // These enum values match the STANDBY_BUCKET_XXX constants defined in UsageStatsManager.java.
    enum Bucket {
        UNKNOWN = 0;
        EXEMPTED = 5;
        ACTIVE = 10;
        WORKING_SET = 20;
        FREQUENT = 30;
        RARE = 40;
        NEVER = 50;
    }
    // The App Standby bucket of the app that scheduled the alarm at the time the alarm fired.
    optional Bucket app_standby_bucket = 4;
}

/**
+31 −6
Original line number Diff line number Diff line
@@ -8457,18 +8457,43 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
        }
        if (DEBUG_POWER) {
            Slog.w(TAG, "noteWakupAlarm[ sourcePkg=" + sourcePkg + ", sourceUid=" + sourceUid
                    + ", workSource=" + workSource + ", tag=" + tag + "]");
        }
        int standbyBucket = 0;
        mBatteryStatsService.noteWakupAlarm(sourcePkg, sourceUid, workSource, tag);
        if (workSource != null) {
            StatsLog.write(StatsLog.WAKEUP_ALARM_OCCURRED, workSource, tag, sourcePkg);
            String workSourcePackage = workSource.getName(0);
            int workSourceUid = workSource.getAttributionUid();
            if (workSourcePackage == null) {
                workSourcePackage = sourcePkg;
                workSourceUid = sourceUid;
            }
            if (mUsageStatsService != null) {
                standbyBucket = mUsageStatsService.getAppStandbyBucket(workSourcePackage,
                        UserHandle.getUserId(workSourceUid), SystemClock.elapsedRealtime());
            }
            StatsLog.write(StatsLog.WAKEUP_ALARM_OCCURRED, workSource, tag, sourcePkg,
                    standbyBucket);
            if (DEBUG_POWER) {
                Slog.w(TAG, "noteWakeupAlarm[ sourcePkg=" + sourcePkg + ", sourceUid=" + sourceUid
                        + ", workSource=" + workSource + ", tag=" + tag + ", standbyBucket="
                        + standbyBucket + " wsName=" + workSourcePackage + ")]");
            }
        } else {
            if (mUsageStatsService != null) {
                standbyBucket = mUsageStatsService.getAppStandbyBucket(sourcePkg,
                        UserHandle.getUserId(sourceUid), SystemClock.elapsedRealtime());
            }
            StatsLog.write_non_chained(StatsLog.WAKEUP_ALARM_OCCURRED, sourceUid, null, tag,
                    sourcePkg);
                    sourcePkg, standbyBucket);
            if (DEBUG_POWER) {
                Slog.w(TAG, "noteWakeupAlarm[ sourcePkg=" + sourcePkg + ", sourceUid=" + sourceUid
                        + ", workSource=" + workSource + ", tag=" + tag + ", standbyBucket="
                        + standbyBucket + "]");
            }
        }
    }
    @Override