@ThreadSafe public class WakeLockMetricsCollector extends SystemMetricsCollector<WakeLockMetrics>
Snapshots can be attributed (at the cost of extra memory) or unattributed, in which case the collector will only record total wakelock time instead.
This must be instrumented by hand as well, with - PowerManager#newWakeLock(int,
String)
-> newWakeLock(PowerManager.WakeLock, int, String)
- PowerManager.WakeLock#acquire()
, PowerManager.WakeLock#acquire(long)
-> acquire(PowerManager.WakeLock, long)
- PowerManager.WakeLock#release()
, PowerManager.WakeLock#release()
-> release(PowerManager.WakeLock, int)
- PowerManager.WakeLock#setReferenceCounted(boolean)
-> setReferenceCounted(PowerManager.WakeLock, boolean)
Constructor and Description |
---|
WakeLockMetricsCollector() |
Modifier and Type | Method and Description |
---|---|
void |
acquire(PowerManager.WakeLock wakelock,
long timeout) |
WakeLockMetrics |
createMetrics()
Creates an empty instance of the corresponding system metrics.
|
boolean |
getSnapshot(WakeLockMetrics snapshot)
Note that access to snapshot instances is not synchronized and must be taken care of
by the caller requesting getSnapshot.
|
void |
newWakeLock(PowerManager.WakeLock wakelock,
int levelAndFlags,
java.lang.String tag) |
void |
release(PowerManager.WakeLock wakelock,
int flags) |
void |
setReferenceCounted(PowerManager.WakeLock wakelock,
boolean value) |
public void newWakeLock(PowerManager.WakeLock wakelock, int levelAndFlags, java.lang.String tag)
public void acquire(PowerManager.WakeLock wakelock, long timeout)
public void release(PowerManager.WakeLock wakelock, int flags)
public void setReferenceCounted(PowerManager.WakeLock wakelock, boolean value)
public boolean getSnapshot(WakeLockMetrics snapshot)
SystemMetricsCollector
getSnapshot
in class SystemMetricsCollector<WakeLockMetrics>
snapshot
- snapshot on which the data will be writtenpublic WakeLockMetrics createMetrics()
SystemMetricsCollector
Explicitly having this function available reduces a significant amount of boilerplate
createMetrics
in class SystemMetricsCollector<WakeLockMetrics>