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

Commit 55102ab0 authored by Dmitri Plotnikov's avatar Dmitri Plotnikov
Browse files

Include released wake lock UID and name in battery history event

Bug: 236393844
Test: atest FrameworksServicesTests:BatteryStatsTests
Change-Id: I0c27a094a0e1658de9392333ea3dabdf1cedb3d9
parent 391604fd
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1046,6 +1046,17 @@ public class BatteryStatsHistory {
        return true;
    }

    /**
     * Records a wakelock release event.
     */
    public void recordWakelockStopEvent(long elapsedRealtimeMs, long uptimeMs, String historyName,
            int uid) {
        mHistoryCur.wakelockTag = mHistoryCur.localWakelockTag;
        mHistoryCur.wakelockTag.string = historyName != null ? historyName : "";
        mHistoryCur.wakelockTag.uid = uid;
        recordStateStopEvent(elapsedRealtimeMs, uptimeMs, HistoryItem.STATE_WAKE_LOCK_FLAG);
    }

    /**
     * Records an event when some state flag changes to true.
     */
+5 −5
Original line number Diff line number Diff line
@@ -4658,10 +4658,10 @@ public class BatteryStatsImpl extends BatteryStats {
        final int mappedUid = mapUid(uid);
        if (type == WAKE_TYPE_PARTIAL) {
            mWakeLockNesting--;
            if (mRecordAllHistory) {
            if (historyName == null) {
                historyName = name;
            }
            if (mRecordAllHistory) {
                if (mActiveEvents.updateState(HistoryItem.EVENT_WAKE_LOCK_FINISH, historyName,
                        mappedUid, 0)) {
                    mHistory.recordEvent(elapsedRealtimeMs, uptimeMs,
@@ -4669,8 +4669,8 @@ public class BatteryStatsImpl extends BatteryStats {
                }
            }
            if (mWakeLockNesting == 0) {
                mHistory.recordStateStopEvent(elapsedRealtimeMs, uptimeMs,
                        HistoryItem.STATE_WAKE_LOCK_FLAG);
                mHistory.recordWakelockStopEvent(elapsedRealtimeMs, uptimeMs, historyName,
                        mappedUid);
            }
        }
        if (mappedUid >= 0) {