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

Commit d674624a authored by Bookatz's avatar Bookatz
Browse files

Add wakelock atom to statsd

The wakelock event is logged in statsd.

Test: manually confirmed that the event appears in statslog.
Change-Id: I9ffa4b0042264aabf3526843b4fb1832d183de61
parent 8c6571bd
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ message StatsEvent {
        ScheduledJobStateChanged scheduled_job_state_changed = 8;
        ScreenBrightnessChanged screen_brightness_changed = 9;
        // 10-20 are temporarily reserved for wakelocks etc.
        WakelockStateChanged wakelock_state_changed = 10;
        UidWakelockStateChanged uid_wakelock_state_changed = 11;
        LongPartialWakelockStateChanged long_partial_wakelock_state_changed = 12;
        BatterySaverModeStateChanged battery_saver_mode_state_changed = 21;
@@ -364,7 +365,7 @@ message CameraStateChanged {
 * Logged from:
 *   TODO
 */
message WakelockChanged {
message WakelockStateChanged {
    // TODO: Add attribution instead of uid.
    optional int32 uid = 1;

+8 −1
Original line number Diff line number Diff line
@@ -8877,6 +8877,8 @@ public class BatteryStatsImpl extends BatteryStats {
            Wakelock wl = mWakelockStats.startObject(name);
            if (wl != null) {
                getWakelockTimerLocked(wl, type).startRunningLocked(elapsedRealtimeMs);
                // TODO(statsd): Hopefully use a worksource instead of a uid (so move elsewhere)
                StatsLog.write(StatsLog.WAKELOCK_STATE_CHANGED, getUid(), type, name, 1);
            }
            if (type == WAKE_TYPE_PARTIAL) {
                createAggregatedPartialWakelockTimerLocked().startRunningLocked(elapsedRealtimeMs);
@@ -8894,7 +8896,12 @@ public class BatteryStatsImpl extends BatteryStats {
        public void noteStopWakeLocked(int pid, String name, int type, long elapsedRealtimeMs) {
            Wakelock wl = mWakelockStats.stopObject(name);
            if (wl != null) {
                getWakelockTimerLocked(wl, type).stopRunningLocked(elapsedRealtimeMs);
                StopwatchTimer wlt = getWakelockTimerLocked(wl, type);
                wlt.stopRunningLocked(elapsedRealtimeMs);
                if (!wlt.isRunningLocked()) { // only tell statsd if truly stopped
                    // TODO(statsd): Possibly use a worksource instead of a uid.
                    StatsLog.write(StatsLog.WAKELOCK_STATE_CHANGED, getUid(), type, name, 0);
                }
            }
            if (type == WAKE_TYPE_PARTIAL) {
                if (mAggregatedPartialWakelockTimer != null) {