# CarPowerManager

Summary: [Nested Classes](https://developer.android.com/reference/android/car/hardware/power/CarPowerManager#nestedclasses) \| [Methods](https://developer.android.com/reference/android/car/hardware/power/CarPowerManager#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/car/hardware/power/CarPowerManager#inhmethods)  

# CarPowerManager


`
public


class
CarPowerManager
`


`

extends Object


`

`


`

|---|--------------------------------------------|
| java.lang.Object                              ||
| ↳ | android.car.hardware.power.CarPowerManager |

<br />

*** ** * ** ***

API to receive power policy change notifications.

## Summary

|                                                                                             ### Nested classes                                                                                              ||
|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` interface` | [CarPowerManager.CarPowerPolicyListener](https://developer.android.com/reference/android/car/hardware/power/CarPowerManager.CarPowerPolicyListener) Listeners to receive power policy change. |

|                                                                                                                                                                                                                                                                                                                                                                    ### Public methods                                                                                                                                                                                                                                                                                                                                                                    ||
|--------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                                                | ` `[addPowerPolicyListener](https://developer.android.com/reference/android/car/hardware/power/CarPowerManager#addPowerPolicyListener(java.util.concurrent.Executor,%20android.car.hardware.power.CarPowerPolicyFilter,%20android.car.hardware.power.CarPowerManager.CarPowerPolicyListener))`(Executor executor, `[CarPowerPolicyFilter](https://developer.android.com/reference/android/car/hardware/power/CarPowerPolicyFilter)` filter, `[CarPowerManager.CarPowerPolicyListener](https://developer.android.com/reference/android/car/hardware/power/CarPowerManager.CarPowerPolicyListener)` listener) ` Subscribes to power policy change. |
| ` `[CarPowerPolicy](https://developer.android.com/reference/android/car/hardware/power/CarPowerPolicy) | ` `[getCurrentPowerPolicy](https://developer.android.com/reference/android/car/hardware/power/CarPowerManager#getCurrentPowerPolicy())`() ` Gets the current power policy.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` void`                                                                                                | ` `[removePowerPolicyListener](https://developer.android.com/reference/android/car/hardware/power/CarPowerManager#removePowerPolicyListener(android.car.hardware.power.CarPowerManager.CarPowerPolicyListener))`(`[CarPowerManager.CarPowerPolicyListener](https://developer.android.com/reference/android/car/hardware/power/CarPowerManager.CarPowerPolicyListener)` listener) ` Unsubscribes from power policy change.                                                                                                                                                                                                                        |

| ### 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() `                    | ||

## Public methods

### addPowerPolicyListener

```
public void addPowerPolicyListener (Executor executor, 
                CarPowerPolicyFilter filter, 
                CarPowerManager.CarPowerPolicyListener listener)
```

Subscribes to power policy change.

If the same listener is added with different filters, the listener is notified based on
the last added filter.

<br />


Requires [Car.PERMISSION_READ_CAR_POWER_POLICY](https://developer.android.com/reference/android/car/Car#PERMISSION_READ_CAR_POWER_POLICY)

<br />

|                                         Parameters                                         ||
|------------|--------------------------------------------------------------------------------|
| `executor` | `Executor`: Executor where the listener method is called. <br />               |
| `filter`   | `CarPowerPolicyFilter`: Filter specifying power components of interest. <br /> |
| `listener` | `CarPowerManager.CarPowerPolicyListener`: Listener to be notified. <br />      |

|                                   Throws                                    ||
|----------------------------|-------------------------------------------------|
| `IllegalArgumentException` | if `executor`, `listener`, or `filter` is null. |

### getCurrentPowerPolicy

```
public CarPowerPolicy getCurrentPowerPolicy ()
```

Gets the current power policy.

The returned power policy has ID of the power policy applied most recently. If no power
policy has been applied, the ID is an empty string. Note that enabled components and disabled
components might be different from those of the latest power policy applied. This is because
the returned power policy contains the current state of all power components determined by
applying power policies in an accumulative way.

<br />


Requires [Car.PERMISSION_READ_CAR_POWER_POLICY](https://developer.android.com/reference/android/car/Car#PERMISSION_READ_CAR_POWER_POLICY)

<br />

|                                                                                      Returns                                                                                      ||
|-----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
| [CarPowerPolicy](https://developer.android.com/reference/android/car/hardware/power/CarPowerPolicy) | The power policy containing the latest state of all power components. <br /> |

### removePowerPolicyListener

```
public void removePowerPolicyListener (CarPowerManager.CarPowerPolicyListener listener)
```

Unsubscribes from power policy change.

<br />


Requires [Car.PERMISSION_READ_CAR_POWER_POLICY](https://developer.android.com/reference/android/car/Car#PERMISSION_READ_CAR_POWER_POLICY)

<br />

|                                                Parameters                                                 ||
|------------|-----------------------------------------------------------------------------------------------|
| `listener` | `CarPowerManager.CarPowerPolicyListener`: Listener that will not be notified any more. <br /> |

|                       Throws                       ||
|----------------------------|------------------------|
| `IllegalArgumentException` | if `listener` is null. |