CarPowerManager
public
class
CarPowerManager
extends Object
java.lang.Object | |
↳ | android.car.hardware.power.CarPowerManager |
API to receive power policy change notifications.
Summary
Nested classes | |
---|---|
interface |
CarPowerManager.CarPowerPolicyListener
Listeners to receive power policy change. |
Public methods | |
---|---|
void
|
addPowerPolicyListener(Executor executor, CarPowerPolicyFilter filter, CarPowerManager.CarPowerPolicyListener listener)
Subscribes to power policy change. |
CarPowerPolicy
|
getCurrentPowerPolicy()
Gets the current power policy. |
void
|
removePowerPolicyListener(CarPowerManager.CarPowerPolicyListener listener)
Unsubscribes from power policy change. |
Inherited methods | |
---|---|
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.
Requires Car.PERMISSION_READ_CAR_POWER_POLICY
Parameters | |
---|---|
executor |
Executor : Executor where the listener method is called. |
filter |
CarPowerPolicyFilter : Filter specifying power components of interest. |
listener |
CarPowerManager.CarPowerPolicyListener : Listener to be notified. |
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.
Requires Car.PERMISSION_READ_CAR_POWER_POLICY
Returns | |
---|---|
CarPowerPolicy |
The power policy containing the latest state of all power components. |
removePowerPolicyListener
public void removePowerPolicyListener (CarPowerManager.CarPowerPolicyListener listener)
Unsubscribes from power policy change.
Requires Car.PERMISSION_READ_CAR_POWER_POLICY
Parameters | |
---|---|
listener |
CarPowerManager.CarPowerPolicyListener : Listener that will not be notified any more. |
Throws | |
---|---|
IllegalArgumentException |
if listener is null. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-11 UTC.