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.
|
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.
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. |
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 2025-02-17 UTC.
[null,null,["Last updated 2025-02-17 UTC."],[],[],null,["# CarPowerManager\n\nSummary: [Nested Classes](#nestedclasses) \\| [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nCarPowerManager\n===============\n\n\n`\npublic\n\n\nclass\nCarPowerManager\n`\n\n\n`\n\nextends Object\n\n\n`\n\n`\n\n\n`\n\n|---|--------------------------------------------|\n| java.lang.Object ||\n| ↳ | android.car.hardware.power.CarPowerManager |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nAPI to receive power policy change notifications.\n\nSummary\n-------\n\n| ### Nested classes ||\n|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` interface` | [CarPowerManager.CarPowerPolicyListener](/reference/android/car/hardware/power/CarPowerManager.CarPowerPolicyListener) Listeners to receive power policy change. |\n\n| ### Public methods ||\n|---------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` void` | ` `[addPowerPolicyListener](/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](/reference/android/car/hardware/power/CarPowerPolicyFilter)` filter, `[CarPowerManager.CarPowerPolicyListener](/reference/android/car/hardware/power/CarPowerManager.CarPowerPolicyListener)` listener) ` Subscribes to power policy change. |\n| ` `[CarPowerPolicy](/reference/android/car/hardware/power/CarPowerPolicy) | ` `[getCurrentPowerPolicy](/reference/android/car/hardware/power/CarPowerManager#getCurrentPowerPolicy())`() ` Gets the current power policy. |\n| ` void` | ` `[removePowerPolicyListener](/reference/android/car/hardware/power/CarPowerManager#removePowerPolicyListener(android.car.hardware.power.CarPowerManager.CarPowerPolicyListener))`(`[CarPowerManager.CarPowerPolicyListener](/reference/android/car/hardware/power/CarPowerManager.CarPowerPolicyListener)` listener) ` Unsubscribes from power policy change. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` java.lang.Object ` |-------------------|-------------------------------| | ` Object` | ` clone() ` | | ` boolean` | ` equals(Object arg0) ` | | ` void` | ` finalize() ` | | ` final Class\u003c?\u003e` | ` 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() ` | ||\n\nPublic methods\n--------------\n\n### addPowerPolicyListener\n\n```\npublic void addPowerPolicyListener (Executor executor, \n CarPowerPolicyFilter filter, \n CarPowerManager.CarPowerPolicyListener listener)\n```\n\nSubscribes to power policy change.\n\nIf the same listener is added with different filters, the listener is notified based on\nthe last added filter.\n\n\u003cbr /\u003e\n\n\nRequires [Car.PERMISSION_READ_CAR_POWER_POLICY](/reference/android/car/Car#PERMISSION_READ_CAR_POWER_POLICY)\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|--------------------------------------------------------------------------------|\n| `executor` | `Executor`: Executor where the listener method is called. \u003cbr /\u003e |\n| `filter` | `CarPowerPolicyFilter`: Filter specifying power components of interest. \u003cbr /\u003e |\n| `listener` | `CarPowerManager.CarPowerPolicyListener`: Listener to be notified. \u003cbr /\u003e |\n\n| Throws ||\n|----------------------------|-------------------------------------------------|\n| `IllegalArgumentException` | if `executor`, `listener`, or `filter` is null. |\n\n### getCurrentPowerPolicy\n\n```\npublic CarPowerPolicy getCurrentPowerPolicy ()\n```\n\nGets the current power policy.\n\nThe returned power policy has ID of the power policy applied most recently. If no power\npolicy has been applied, the ID is an empty string. Note that enabled components and disabled\ncomponents might be different from those of the latest power policy applied. This is because\nthe returned power policy contains the current state of all power components determined by\napplying power policies in an accumulative way.\n\n\u003cbr /\u003e\n\n\nRequires [Car.PERMISSION_READ_CAR_POWER_POLICY](/reference/android/car/Car#PERMISSION_READ_CAR_POWER_POLICY)\n\n\u003cbr /\u003e\n\n| Returns ||\n|------------------------------------------------------------------------|------------------------------------------------------------------------------|\n| [CarPowerPolicy](/reference/android/car/hardware/power/CarPowerPolicy) | The power policy containing the latest state of all power components. \u003cbr /\u003e |\n\n### removePowerPolicyListener\n\n```\npublic void removePowerPolicyListener (CarPowerManager.CarPowerPolicyListener listener)\n```\n\nUnsubscribes from power policy change.\n\n\u003cbr /\u003e\n\n\nRequires [Car.PERMISSION_READ_CAR_POWER_POLICY](/reference/android/car/Car#PERMISSION_READ_CAR_POWER_POLICY)\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|-----------------------------------------------------------------------------------------------|\n| `listener` | `CarPowerManager.CarPowerPolicyListener`: Listener that will not be notified any more. \u003cbr /\u003e |\n\n| Throws ||\n|----------------------------|------------------------|\n| `IllegalArgumentException` | if `listener` is null. |"]]