Added in API level 24

SystemHealthManager


public class SystemHealthManager
extends Object

java.lang.Object
   ↳ android.os.health.SystemHealthManager


Provides access to data about how various system resources are used by applications.

Public methods

void getPowerMonitorReadings(List<PowerMonitor> powerMonitors, Executor executor, OutcomeReceiver<PowerMonitorReadings, RuntimeException> onResult)

Asynchronously retrieves the accumulated power consumption reported by the specified power monitors.

void getSupportedPowerMonitors(Executor executor, Consumer<List<PowerMonitor>> onResult)

Asynchronously retrieves a list of supported PowerMonitor's, which include raw ODPM (on-device power rail monitor) rails and modeled energy consumers.

HealthStats takeMyUidSnapshot()

Return a HealthStats object containing a snapshot of system health metrics for the application calling this API.

HealthStats takeUidSnapshot(int uid)

Return a HealthStats object containing a snapshot of system health metrics for the given uid (user-id, which in usually corresponds to application).

HealthStats[] takeUidSnapshots(int[] uids)

Return a HealthStats object containing a snapshot of system health metrics for the given uids (user-id, which in usually corresponds to application).

Inherited methods

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public methods

getPowerMonitorReadings

Added in API level 35
public void getPowerMonitorReadings (List<PowerMonitor> powerMonitors, 
                Executor executor, 
                OutcomeReceiver<PowerMonitorReadingsRuntimeException> onResult)

Asynchronously retrieves the accumulated power consumption reported by the specified power monitors.

Parameters
powerMonitors List: power monitors to be retrieved. This value cannot be null.

executor Executor: optional Executor to deliver the callbacks. If not supplied, the callback may be invoked on an arbitrary thread. This value may be null.

onResult OutcomeReceiver: callback for the result This value cannot be null.

getSupportedPowerMonitors

Added in API level 35
public void getSupportedPowerMonitors (Executor executor, 
                Consumer<List<PowerMonitor>> onResult)

Asynchronously retrieves a list of supported PowerMonitor's, which include raw ODPM (on-device power rail monitor) rails and modeled energy consumers. If ODPM is unsupported on this device this method delivers an empty list.

Parameters
executor Executor: optional Handler to deliver the callback. If not supplied, the callback may be invoked on an arbitrary thread. This value may be null.

onResult Consumer: callback for the result This value cannot be null.

takeMyUidSnapshot

Added in API level 24
public HealthStats takeMyUidSnapshot ()

Return a HealthStats object containing a snapshot of system health metrics for the application calling this API. This method is the same as calling takeUidSnapshot(Process.myUid()).

Returns
HealthStats A HealthStats object containing the metrics for this application. The keys for this HealthStats object will be from the UidHealthStats class.

takeUidSnapshot

Added in API level 24
public HealthStats takeUidSnapshot (int uid)

Return a HealthStats object containing a snapshot of system health metrics for the given uid (user-id, which in usually corresponds to application).

Parameters
uid int: User ID for a given application.

Returns
HealthStats A HealthStats object containing the metrics for the requested application. The keys for this HealthStats object will be from the UidHealthStats class.

See also:

takeUidSnapshots

Added in API level 24
public HealthStats[] takeUidSnapshots (int[] uids)

Return a HealthStats object containing a snapshot of system health metrics for the given uids (user-id, which in usually corresponds to application).

Parameters
uids int: An array of User IDs to retrieve.

Returns
HealthStats[] An array of HealthStats objects containing the metrics for each of the requested uids. The keys for this HealthStats object will be from the UidHealthStats class.

Discover the latest app development tools, platform updates, training, and documentation for developers across every Android device.

Diperbarui Apr 4, 2024