CarWatchdogManager

public final class CarWatchdogManager
extends Object

java.lang.Object
   ↳ android.car.watchdog.CarWatchdogManager


CarWatchdogManager allows applications to collect latest system resource overuse statistics, add listener for resource overuse notifications, and update resource overuse configurations.

Summary

Nested classes

interface CarWatchdogManager.ResourceOveruseListener

Listener to get resource overuse notifications. 

Constants

int FLAG_RESOURCE_OVERUSE_IO

Constants that define the type of resource overuse.

int STATS_PERIOD_CURRENT_DAY

Constants that define the stats period in days.

int STATS_PERIOD_PAST_15_DAYS

int STATS_PERIOD_PAST_30_DAYS

int STATS_PERIOD_PAST_3_DAYS

int STATS_PERIOD_PAST_7_DAYS

Public methods

void addResourceOveruseListener(Executor executor, int resourceOveruseFlag, CarWatchdogManager.ResourceOveruseListener listener)

Adds the ResourceOveruseListener for the calling package.

ResourceOveruseStats getResourceOveruseStats(int resourceOveruseFlag, int maxStatsPeriod)

Returns resource overuse stats for the calling package.

void removeResourceOveruseListener(CarWatchdogManager.ResourceOveruseListener listener)

Removes the ResourceOveruseListener for the calling package.

Inherited methods

Constants

FLAG_RESOURCE_OVERUSE_IO

Added in API level 31
public static final int FLAG_RESOURCE_OVERUSE_IO

Constants that define the type of resource overuse.

Constant Value: 1 (0x00000001)

STATS_PERIOD_CURRENT_DAY

Added in API level 31
public static final int STATS_PERIOD_CURRENT_DAY

Constants that define the stats period in days.

Constant Value: 1 (0x00000001)

STATS_PERIOD_PAST_15_DAYS

Added in API level 31
public static final int STATS_PERIOD_PAST_15_DAYS

Constant Value: 4 (0x00000004)

STATS_PERIOD_PAST_30_DAYS

Added in API level 31
public static final int STATS_PERIOD_PAST_30_DAYS

Constant Value: 5 (0x00000005)

STATS_PERIOD_PAST_3_DAYS

Added in API level 31
public static final int STATS_PERIOD_PAST_3_DAYS

Constant Value: 2 (0x00000002)

STATS_PERIOD_PAST_7_DAYS

Added in API level 31
public static final int STATS_PERIOD_PAST_7_DAYS

Constant Value: 3 (0x00000003)

Public methods

addResourceOveruseListener

Added in API level 31
public void addResourceOveruseListener (Executor executor, 
                int resourceOveruseFlag, 
                CarWatchdogManager.ResourceOveruseListener listener)

Adds the ResourceOveruseListener for the calling package.

Resource overuse notifications are sent only for the calling package's resource overuse.

Parameters
executor Executor

resourceOveruseFlag int: Flag to indicate the types of resource overuses to listen. Value is either 0 or FLAG_RESOURCE_OVERUSE_IO

listener CarWatchdogManager.ResourceOveruseListener: Listener implementing ResourceOveruseListener interface.

Throws
IllegalStateException if listener is already added.

getResourceOveruseStats

Added in API level 31
public ResourceOveruseStats getResourceOveruseStats (int resourceOveruseFlag, 
                int maxStatsPeriod)

Returns resource overuse stats for the calling package. Returns null, if no stats.

Parameters
resourceOveruseFlag int: Flag to indicate the types of resource overuse stats to return. Value is either 0 or FLAG_RESOURCE_OVERUSE_IO

maxStatsPeriod int: Maximum period to aggregate the resource overuse stats. Value is STATS_PERIOD_CURRENT_DAY, STATS_PERIOD_PAST_3_DAYS, STATS_PERIOD_PAST_7_DAYS, STATS_PERIOD_PAST_15_DAYS, or STATS_PERIOD_PAST_30_DAYS

Returns
ResourceOveruseStats Resource overuse stats for the calling package. If the calling package has no stats for a specified resource overuse type, null value is returned for the corresponding resource overuse stats. If the calling package doesn't have sufficient stats for maxStatsPeriod for a specified resource overuse type, the stats are returned only for the period returned in the individual resource overuse stats.

removeResourceOveruseListener

Added in API level 31
public void removeResourceOveruseListener (CarWatchdogManager.ResourceOveruseListener listener)

Removes the ResourceOveruseListener for the calling package.

Parameters
listener CarWatchdogManager.ResourceOveruseListener: Listener implementing ResourceOveruseListener interface.