public class DeviceBatteryMetricsCollector extends SystemMetricsCollector<DeviceBatteryMetrics>
DeviceBatteryMetrics
. This relies on maintaining the charging state
and hence will probably not work in Doze mode (N+) where the broadcasts for power
connected/disconnected are not guranteed to be relayed to the app.Constructor and Description |
---|
DeviceBatteryMetricsCollector(Context context) |
Modifier and Type | Method and Description |
---|---|
DeviceBatteryMetrics |
createMetrics()
Creates an empty instance of the corresponding system metrics.
|
boolean |
getSnapshot(DeviceBatteryMetrics snapshot)
Note that access to snapshot instances is not synchronized and must be taken care of
by the caller requesting getSnapshot.
|
public DeviceBatteryMetricsCollector(Context context)
public boolean getSnapshot(DeviceBatteryMetrics snapshot)
SystemMetricsCollector
getSnapshot
in class SystemMetricsCollector<DeviceBatteryMetrics>
snapshot
- snapshot on which the data will be writtenpublic DeviceBatteryMetrics createMetrics()
SystemMetricsCollector
Explicitly having this function available reduces a significant amount of boilerplate
createMetrics
in class SystemMetricsCollector<DeviceBatteryMetrics>