# CarWatchdogManager

Summary:[Nested Classes](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#nestedclasses)\|[Constants](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#constants)\|[Methods](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#inhmethods)  

# CarWatchdogManager

`
public

final

class
CarWatchdogManager
`  
`

extends Object


``


`

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

<br />

*** ** * ** ***

CarWatchdogManager enables applications to track and manage system resource usage.

It 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](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager.ResourceOveruseListener) Listener to get resource overuse notifications. |

|                                                                                          ### Constants                                                                                          ||
|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [FLAG_RESOURCE_OVERUSE_IO](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#FLAG_RESOURCE_OVERUSE_IO) Constants that define the type of resource overuse. |
| `int` | [STATS_PERIOD_CURRENT_DAY](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#STATS_PERIOD_CURRENT_DAY) Constants that define the stats period in days.     |
| `int` | [STATS_PERIOD_PAST_15_DAYS](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#STATS_PERIOD_PAST_15_DAYS) The stats period for the past 15 days             |
| `int` | [STATS_PERIOD_PAST_30_DAYS](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#STATS_PERIOD_PAST_30_DAYS) The stats period for the past 30 days             |
| `int` | [STATS_PERIOD_PAST_3_DAYS](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#STATS_PERIOD_PAST_3_DAYS) The stats period for the past 3 days.               |
| `int` | [STATS_PERIOD_PAST_7_DAYS](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#STATS_PERIOD_PAST_7_DAYS) The stats period for the past 7 days                |

|                                                                                                                                                                                                                                                                                                                                                                   ### Public methods                                                                                                                                                                                                                                                                                                                                                                   ||
|--------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                                                      | ` `[addResourceOveruseListener](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#addResourceOveruseListener(java.util.concurrent.Executor,%20int,%20android.car.watchdog.CarWatchdogManager.ResourceOveruseListener))`(Executor executor, int resourceOveruseFlag, `[CarWatchdogManager.ResourceOveruseListener](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager.ResourceOveruseListener)` listener) ` Adds the[ResourceOveruseListener](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager.ResourceOveruseListener)for the calling package. |
| ` `[ResourceOveruseStats](https://developer.android.com/reference/android/car/watchdog/ResourceOveruseStats) | ` `[getResourceOveruseStats](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#getResourceOveruseStats(int,%20int))`(int resourceOveruseFlag, int maxStatsPeriod) ` Returns resource overuse stats for the calling package.                                                                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                                                      | ` `[removeResourceOveruseListener](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#removeResourceOveruseListener(android.car.watchdog.CarWatchdogManager.ResourceOveruseListener))`(`[CarWatchdogManager.ResourceOveruseListener](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager.ResourceOveruseListener)` listener) ` Removes the[ResourceOveruseListener](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager.ResourceOveruseListener)for the calling package.                                                                            |

| ### Inherited methods |
|-----------------------|---|
| From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Constants

### FLAG_RESOURCE_OVERUSE_IO

```
public static final int FLAG_RESOURCE_OVERUSE_IO
```

Constants that define the type of resource overuse.

<br />

Constant Value: 1 (0x00000001)  

### STATS_PERIOD_CURRENT_DAY

```
public static final int STATS_PERIOD_CURRENT_DAY
```

Constants that define the stats period in days.

The following constants represent the stats period for the past N days, It is used to specify that the stats should be gathered for the last N days, including today and the N-1 previous days.

The stats period for the current day.

<br />

Constant Value: 1 (0x00000001)  

### STATS_PERIOD_PAST_15_DAYS

```
public static final int STATS_PERIOD_PAST_15_DAYS
```

The stats period for the past 15 days

<br />

Constant Value: 4 (0x00000004)  

### STATS_PERIOD_PAST_30_DAYS

```
public static final int STATS_PERIOD_PAST_30_DAYS
```

The stats period for the past 30 days

<br />

Constant Value: 5 (0x00000005)  

### STATS_PERIOD_PAST_3_DAYS

```
public static final int STATS_PERIOD_PAST_3_DAYS
```

The stats period for the past 3 days.

<br />

Constant Value: 2 (0x00000002)  

### STATS_PERIOD_PAST_7_DAYS

```
public static final int STATS_PERIOD_PAST_7_DAYS
```

The stats period for the past 7 days

<br />

Constant Value: 3 (0x00000003)

## Public methods

### addResourceOveruseListener

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

Adds the[ResourceOveruseListener](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager.ResourceOveruseListener)for the calling package.

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

<br />

|                                                                                                                        Parameters                                                                                                                        ||
|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `executor`            | `Executor` <br />                                                                                                                                                                                                                 |
| `resourceOveruseFlag` | `int`: Flag to indicate the types of resource overuses to listen. Value is either`0`or[FLAG_RESOURCE_OVERUSE_IO](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#FLAG_RESOURCE_OVERUSE_IO) <br /> |
| `listener`            | `CarWatchdogManager.ResourceOveruseListener`: Listener implementing[ResourceOveruseListener](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager.ResourceOveruseListener)interface. <br />            |

|                         Throws                         ||
|-------------------------|-------------------------------|
| `IllegalStateException` | if`listener`is already added. |

### getResourceOveruseStats

```
public ResourceOveruseStats getResourceOveruseStats (int resourceOveruseFlag, 
                int maxStatsPeriod)
```

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

<br />

|                                                                                                                                                                                                                                                                                                                                                                                              Parameters                                                                                                                                                                                                                                                                                                                                                                                              ||
|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `resourceOveruseFlag` | `int`: Flag to indicate the types of resource overuse stats to return. Value is either`0`or[FLAG_RESOURCE_OVERUSE_IO](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#FLAG_RESOURCE_OVERUSE_IO) <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `maxStatsPeriod`      | `int`: Maximum period to aggregate the resource overuse stats. Value is[STATS_PERIOD_CURRENT_DAY](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#STATS_PERIOD_CURRENT_DAY),[STATS_PERIOD_PAST_3_DAYS](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#STATS_PERIOD_PAST_3_DAYS),[STATS_PERIOD_PAST_7_DAYS](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#STATS_PERIOD_PAST_7_DAYS),[STATS_PERIOD_PAST_15_DAYS](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#STATS_PERIOD_PAST_15_DAYS), or[STATS_PERIOD_PAST_30_DAYS](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager#STATS_PERIOD_PAST_30_DAYS) <br /> |

|                                                                                                                                                                                                                                                            Returns                                                                                                                                                                                                                                                             ||
|-----------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ResourceOveruseStats](https://developer.android.com/reference/android/car/watchdog/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. <br /> |

### removeResourceOveruseListener

```
public void removeResourceOveruseListener (CarWatchdogManager.ResourceOveruseListener listener)
```

Removes the[ResourceOveruseListener](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager.ResourceOveruseListener)for the calling package.

<br />

|                                                                                                             Parameters                                                                                                             ||
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `listener` | `CarWatchdogManager.ResourceOveruseListener`: Listener implementing[ResourceOveruseListener](https://developer.android.com/reference/android/car/watchdog/CarWatchdogManager.ResourceOveruseListener)interface. <br /> |