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

Commit 6557fb49 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Notifier: Chained attribution support for noteLongPartialWakeLock[finish|start]"

parents 102f5632 96a9256f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -81,7 +81,11 @@ interface IBatteryStats {
    void noteStopWakelockFromSource(in WorkSource ws, int pid, String name, String historyName,
            int type);
    void noteLongPartialWakelockStart(String name, String historyName, int uid);
    void noteLongPartialWakelockStartFromSource(String name, String historyName,
            in WorkSource workSource);
    void noteLongPartialWakelockFinish(String name, String historyName, int uid);
    void noteLongPartialWakelockFinishFromSource(String name, String historyName,
            in WorkSource workSource);

    void noteVibratorOn(int uid, long durationMillis);
    void noteVibratorOff(int uid);
+57 −2
Original line number Diff line number Diff line
@@ -4321,6 +4321,34 @@ public class BatteryStatsImpl extends BatteryStats {
    public void noteLongPartialWakelockStart(String name, String historyName, int uid) {
        uid = mapUid(uid);
        noteLongPartialWakeLockStartInternal(name, historyName, uid);
        StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 1);
    }
    public void noteLongPartialWakelockStartFromSource(String name, String historyName,
            WorkSource workSource) {
        final int N = workSource.size();
        for (int i = 0; i < N; ++i) {
            final int uid = mapUid(workSource.get(i));
            noteLongPartialWakeLockStartInternal(name, historyName, uid);
            StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 1);
        }
        final ArrayList<WorkChain> workChains = workSource.getWorkChains();
        if (workChains != null) {
            for (int i = 0; i < workChains.size(); ++i) {
                final WorkChain workChain = workChains.get(i);
                final int uid = workChain.getAttributionUid();
                noteLongPartialWakeLockStartInternal(name, historyName, uid);
                // TODO(statsd): the Log WorkChain to statds, and not just the uid.
                StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName,
                        1);
            }
        }
    }
    private void noteLongPartialWakeLockStartInternal(String name, String historyName, int uid) {
        final long elapsedRealtime = mClocks.elapsedRealtime();
        final long uptime = mClocks.uptimeMillis();
        if (historyName == null) {
@@ -4332,11 +4360,39 @@ public class BatteryStatsImpl extends BatteryStats {
        }
        addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_LONG_WAKE_LOCK_START,
                historyName, uid);
        StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 1);
    }
    public void noteLongPartialWakelockFinish(String name, String historyName, int uid) {
        uid = mapUid(uid);
        noteLongPartialWakeLockFinishInternal(name, historyName, uid);
        StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 0);
    }
    public void noteLongPartialWakelockFinishFromSource(String name, String historyName,
            WorkSource workSource) {
        final int N = workSource.size();
        for (int i = 0; i < N; ++i) {
            final int uid = mapUid(workSource.get(i));
            noteLongPartialWakeLockFinishInternal(name, historyName, uid);
            StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 0);
        }
        final ArrayList<WorkChain> workChains = workSource.getWorkChains();
        if (workChains != null) {
            for (int i = 0; i < workChains.size(); ++i) {
                final WorkChain workChain = workChains.get(i);
                final int uid = workChain.getAttributionUid();
                noteLongPartialWakeLockFinishInternal(name, historyName, uid);
                // TODO(statsd): the Log WorkChain to statds, and not just the uid.
                StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName,
                        0);
            }
        }
    }
    private void noteLongPartialWakeLockFinishInternal(String name, String historyName, int uid) {
        final long elapsedRealtime = mClocks.elapsedRealtime();
        final long uptime = mClocks.uptimeMillis();
        if (historyName == null) {
@@ -4348,7 +4404,6 @@ public class BatteryStatsImpl extends BatteryStats {
        }
        addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_LONG_WAKE_LOCK_FINISH,
                historyName, uid);
        StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 0);
    }
    void aggregateLastWakeupUptimeLocked(long uptimeMs) {
+20 −0
Original line number Diff line number Diff line
@@ -514,6 +514,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
        }
    }

    @Override
    public void noteLongPartialWakelockStart(String name, String historyName, int uid) {
        enforceCallingPermission();
        synchronized (mStats) {
@@ -521,6 +522,16 @@ public final class BatteryStatsService extends IBatteryStats.Stub
        }
    }

    @Override
    public void noteLongPartialWakelockStartFromSource(String name, String historyName,
            WorkSource workSource) {
        enforceCallingPermission();
        synchronized (mStats) {
            mStats.noteLongPartialWakelockStartFromSource(name, historyName, workSource);
        }
    }

    @Override
    public void noteLongPartialWakelockFinish(String name, String historyName, int uid) {
        enforceCallingPermission();
        synchronized (mStats) {
@@ -528,6 +539,15 @@ public final class BatteryStatsService extends IBatteryStats.Stub
        }
    }

    @Override
    public void noteLongPartialWakelockFinishFromSource(String name, String historyName,
            WorkSource workSource) {
        enforceCallingPermission();
        synchronized (mStats) {
            mStats.noteLongPartialWakelockFinishFromSource(name, historyName, workSource);
        }
    }

    public void noteStartSensor(int uid, int sensor) {
        enforceCallingPermission();
        synchronized (mStats) {
+2 −8
Original line number Diff line number Diff line
@@ -209,10 +209,7 @@ final class Notifier {

        try {
            if (workSource != null) {
                final int N = workSource.size();
                for (int i=0; i<N; i++) {
                    mBatteryStats.noteLongPartialWakelockStart(tag, historyTag, workSource.get(i));
                }
                mBatteryStats.noteLongPartialWakelockStartFromSource(tag, historyTag, workSource);
            } else {
                mBatteryStats.noteLongPartialWakelockStart(tag, historyTag, ownerUid);
            }
@@ -230,10 +227,7 @@ final class Notifier {

        try {
            if (workSource != null) {
                final int N = workSource.size();
                for (int i=0; i<N; i++) {
                    mBatteryStats.noteLongPartialWakelockFinish(tag, historyTag, workSource.get(i));
                }
                mBatteryStats.noteLongPartialWakelockFinishFromSource(tag, historyTag, workSource);
            } else {
                mBatteryStats.noteLongPartialWakelockFinish(tag, historyTag, ownerUid);
            }