차량별 전원 관리를 지원하기 위해 Android는 CarPowerManagementService
서비스와 CarPowerManager
인터페이스를 제공합니다.
상태 전환은 VMCU(Vehicle Master Control Unit)가 트리거합니다. VMCU와 통신하기 위해 통합자는 여러 구성요소를 구현해야 합니다. 또한 통합자는 VHAL(차량 하드웨어 추상화 계층) 및 커널 구현과의 통합 작업을 진행해야 합니다. 그 외에도 절전 모드 해제 소스를 사용 중지하고 시스템 종료가 무기한으로 연기되지 않도록 해야 합니다.
용어
다음 용어는 이 문서 전체에서 사용됩니다.
용어 | 설명 |
---|---|
AP(애플리케이션 프로세서) | SoC(단일 칩 시스템)의 일부 |
BSP(Board Support Processor) | 제품이 작동하는 데 필요한 모든 하드웨어 관련 코드입니다. 일반적으로 SoC 공급업체 및 하드웨어 제조업체에서 제공하며 여기에는 기기 드라이버, PMIC 시퀀싱 코드, SoC bringup 등의 항목이 포함됩니다. |
CPM(CarPowerManager) | 애플리케이션이 전원 상태 변경을 등록하도록 API를 노출합니다. |
CPMS(CarPowerManagementService) | 자동차 전원 상태 시스템을 구현하고, VHAL과 접속하며, 마지막에 suspend() 및 shutdown() 을 호출합니다. |
CPPD(CarPowerPolicyDaemon) | 네이티브 프로세스의 AIDL 인터페이스를 노출하여 전원 정책 리스너를 등록합니다. |
GPIO(범용 입력/출력) | 범용 디지털 신호 핀입니다. |
하드웨어 추상화 계층(HAL) | 하드웨어 기능에 액세스하기 위해 다른 모든 상위 수준의 모듈에서 상호작용해야 하는 소프트웨어 레이어입니다. |
최대 절전 모드 | Suspend to Disk(S2D/S4)라고도 합니다. SoC는 S4 전원 모드(최대 절전 모드)로 설정되고 RAM 콘텐츠는 플래시나 디스크와 같은 비휘발성 미디어에 기록되며 전체 시스템의 전원이 꺼집니다. |
MP(Media Processor) | SoC(단일 칩 시스템)를 참고하세요. |
PMIC(Power Management Integrated Circuit) | 칩은 호스트 시스템의 전원 요구사항을 관리하는 데 사용됩니다. |
SoC(단일 칩 시스템) | 일반적으로 Intel, MediaTek, Nvidia, Qualcomm, Renesas, Texas Instruments 등의 제조업체에서 제공하는 AAOS를 실행하는 메인 프로세서. |
정지 | Suspend-to-RAM(S2R 또는 STR)이라고도 합니다. SoC는 S3 전원 모드로 설정되고 RAM 전원이 켜져 있는 동안 CPU의 전원은 꺼집니다. |
VHAL(차량 HAL) | 차량 네트워크와의 접속에 사용되는 Android API입니다. Tier 1 파트너 또는 OEM은 이 모듈을 작성할 책임이 있습니다. 차량 네트워크는 CAN, LIN, MOST, 이더넷 등 모든 물리적 레이어를 사용할 수 있습니다. VHAL은 차량 네트워크를 추상화하여 AAOS가 차량과 상호작용할 수 있도록 합니다. |
VIP(차량 인터페이스 프로세서) | 차량 MCU를 참조하세요. |
VMCU(Vehicle Master Control Unit) | 차량 네트워크와 SoC 간의 인터페이스를 제공하는 마이크로 컨트롤러입니다. SoC는 USB, UART, SPI 및 GPIO 신호를 통해 VMCU와 통신합니다. |
시스템 설계
이 섹션에서는 AAOS가 애플리케이션 프로세서의 전원 상태를 나타내는 방식과 전원 관리 시스템을 구현하는 모듈에 관해 설명합니다. 또한 이 자료에서는 이러한 모듈이 함께 작동하는 방식과 일반적으로 상태 전환이 발생하는 방식을 설명합니다.
자동차 전원 상태 시스템
AAOS는 상태 시스템을 사용하여 AP의 전원 상태를 나타냅니다. 상태 시스템은 다음과 같은 상태를 제공합니다.
그림 1. 자동차 전원 상태 시스템
가장 일반적인 전환은 파란색으로 강조표시됩니다. 상태 및 일반적인 전환은 다음과 같습니다.
- Suspend-to-RAM. 차량과 SoC가 꺼져 있고 실행되는 코드는 없습니다. 전원이 SoC RAM에 유지됩니다.
- Wait for VHAL. 운전자가 문을 여는 등의 행동을 통해 차량과 상호작용하면 VMCU는 SoC에 전원을 공급합니다. AAOS는 Suspend-to-RAM에서 다시 작동을 시작하고 Wait for VHAL로 전환합니다. 전환된 이 모드에서 AAOS는 VHAL과의 조정을 기다립니다.
- On. VHAL은 AAOS에 On 상태로 전환하도록 지시합니다. 이 상태에서 AAOS는 완전히 실행 중이며 운전자와 상호작용합니다.
- Shutdown Prepare. 운전자의 운전이 끝나면 VHAL은 AAOS에 Shutdown Prepare로 전환하라고 지시합니다. 이 상태에서는 디스플레이와 오디오가 꺼지고 AAOS는 운전자와 상호작용하지 않습니다. Android 시스템은 여전히 실행 중이며 앱과 Android 시스템을 자유롭게 업데이트합니다. 업데이트가 완료되면 Android 시스템은 Wait for VHAL Finish로 전환합니다.
- Wait for VHAL Finish. 이 시점에서 AAOS는 VHAL에 종료할 준비가 되었음을 알립니다. VMCU는 SoC를 완전 절전으로 설정하고 애플리케이션 프로세서에서 전원을 차단해야 합니다. 그러면 실행 중인 코드는 없지만 AAOS가 Suspend-to-RAM 상태가 됩니다.
전원 관리 모듈
전원 관리 시스템은 다음 모듈로 구성됩니다.
모듈 이름 | 설명 |
---|---|
CarPowerManager | Java/C++ API. |
CarPowerManagementService | 전원 상태 전환을 조정합니다. |
CarPowerPolicyDaemon | 기본 전원 정책 클라이언트와 통신합니다. |
차량 HAL | VMCU에 접속합니다. |
커널 | Suspend to RAM/disk의 구현입니다. |
완전 절전/최대 절전 모드 기능(Android를 RAM/디스크로 정지)은 커널에 구현됩니다.
이 기능은 /sys/power/state
에 있는 특수 파일로 사용자 공간에 노출됩니다. 이 파일에 mem
또는 disk
를 작성하면 AAOS가 정지됩니다.
CPMS는 다른 서비스 및 HAL과 함께 전원 상태를 조정합니다. CPMS는 위에 설명된 상태 시스템을 구현하고 전원 상태 전환이 발생할 때 모든 관찰자에게 알림을 보냅니다. 또한 이 서비스는 VHAL을 사용하여 하드웨어로 메시지를 전송합니다.
CPPD는 CPMS가 제어할 때까지 전원 정책을 관리합니다. 또한 기본 리스너에 전원 정책 변경 알림을 전송합니다.
일부 속성은 VHAL에 정의되어 있습니다. VMCU와 통신하기 위해 CPMS는 이러한 속성을 읽거나 씁니다. 애플리케이션은 CPM에 정의된 인터페이스를 사용하여 전원 상태 변경사항을 모니터링할 수 있습니다. 또한, 이 인터페이스를 통해 애플리케이션은 전원 정책 리스너를 등록할 수 있습니다. 이 API는 자바에서 호출할 수 있고 @hide/@System API로 주석을 달 수 있습니다. 즉, 권한이 있는 애플리케이션만 사용할 수 있습니다. 이러한 모듈, 애플리케이션, 서비스 간의 관계는 다음과 같습니다.
그림 2. 전원 구성요소 참조 다이어그램
메시지 시퀀스
이전 섹션에서는 전원 관리 시스템을 구성하는 모듈에 관해 설명했습니다. 이 섹션에서는 완전 절전으로 전환 및 완전 절전 종료에 관한 예를 기반으로 모듈과 애플리케이션 간의 통신 방법을 설명합니다.
완전 절전으로 전환
VMCU만 완전 절전을 시작할 수 있습니다. 완전 절전이 시작되면 VMCU는 VHAL을 통해 CPMS로 알림을 전송합니다. CPMS는 상태를 SHUTDOWN PREPARE로 변경한 다음, CPM에서 제공한 새 상태 ID와 함께 onStateChanged()
메서드를 호출하여 모든 관찰자(CPMS를 모니터링하는 애플리케이션 및 서비스)에 이 상태 전환을 브로드캐스트합니다.
CPM은 애플리케이션/서비스와 CPMS 사이에서 중재 역할을 합니다. 애플리케이션/서비스의 onStateChanged()
메서드는 CPM의 onStateChanged()
메서드에서 동기식으로 호출됩니다. 대부분의 애플리케이션과 서비스는 이 호출의 응답이 반환되기 전에 준비를 마쳐야 합니다. 권한 있는 서비스는 PRE_SHUTDOWN_PREPARE
, SUSPEND_ENTER
, POST_SUSPEND_ENTER
의 응답이 반환된 후에도 비동기식으로 준비를 계속할 수 있습니다. 이 경우 권한 있는 서비스는 준비가 끝나면 제공된 CompletablePowerStateChangeFuture
객체에서 complete()를 호출합니다. SHUTDOWN_PREPARE
에는 비동기식 준비가 허용되지 않습니다. DEEP_SLEEP_ENTRY is sent to the VHAL, the CPMS
periodically sends shutdown postpone requests to the VHAL.
전에는
When all CPM objects have completed shutdown preparations, the CPMS sends
AP_POWER_STATE_REPORT
to the VHAL, which then notifies the VMCU that the AP is ready to
suspend. The CPMS also calls its suspend method, which suspends the kernel.
The sequence described above is illustrated below:

Figure 3. Enter deep sleep
Programming interfaces provided by CPM
This section describes the Java API provided by the CPM for system applications and services.
This API enables the system software to:
- Monitor power state changes in the AP.
- Apply power policies.
-
Use these steps to call the APIs provided by the CPM:
- To acquire the CPM instance, call the Car API.
- Call the appropriate method on the object created in Step 1.
Creating a CarPowerManager object
To create a CPM object, call the Car object's getCarManager()
method. This method is
a facade used to create CPM objects. Specify android.car.Car.POWER_SERVICE
as an
argument to create a CPM object.
Car car = Car.createCar(this);
CarPowerManager powerManager =
(CarPowerManager) car.getCarManager(android.car.Car.POWER_SERVICE);
CarPowerStateListener and registration
System applications and services can receive power state change notifications by implementing
CarPowerManager.CarPowerStateListener
. This interface defines one method
onStateChanged()
, which is a callback function invoked when the power state of CPMS
is changed. The following example defines a new anonymous class that implements the interface:
private final CarPowerManager.CarPowerStateListener powerListener =
new CarPowerManager.CarPowerStateListener () {
@Override
public void onStateChanged(int state) {
Log.i(TAG, "onStateChanged() state = " + state);
}
};
To instruct this listener object to monitor a power state transition, create a new execution
thread and register the listener and this thread to the CPM object:
executor = new ThreadPerTaskExecutor();
powerManager.setListener(powerListener, executor);
When the power state is changed, the onStateChanged()
method of the listener object
is invoked with a value to represent the new power state. The association between actual value and
power state is defined in CarPowerManager
and is shown in the
following table:
Name
Description
STATE_ON
Enter the on state. The system is fully operational.
STATE_SHUTDOWN_CANCELLED
Shutdown is cancelled and power state is returned to the normal state.
STATE_SHUTDOWN_ENTER
Applications are expected to clean up and be ready for shut down.
STATE_POST_SHUTDOWN_ENTER
Preparations for shutting down have completed and VMCU is ready for shut down. Enter the
shutdown state.
STATE_PRE_SHUTDOWN_PREPARE
Shutdown process is requested but CPMS doesn't start the process yet. Display and audio are
still on
STATE_SHUTDOWN_PREPARE
Garage Mode may run during the period.
STATE_SUSPEND_ENTER
Applications are expected to clean up and be ready for suspend-to-RAM.
STATE_POST_SUSPEND_ENTER
Preparations for suspend-to-RAM have completed and VMCU is ready for suspend-to-RAM. Enter the
suspend state.
STATE_SUSPEND_EXIT
Wake up from suspend or resume from a cancelled suspend.
STATE_HIBERNATION_ENTER
Applications are expected to clean up and be ready for hibernation.
STATE_POST_HIBERNATION_ENTER
Preparations for hibernation have completed and VMCU is ready for hibernation Enter the
hibernation state.
STATE_HIBERNATION_EXIT
Wake up from hibernation or resume from a cancelled hibernation.
STATE_WAIT_FOR_VHAL
The system is starting up, but waiting to establish communication with the VHAL before going to
the ON state.
CarPowerStateListener unregistration
To unregister all listener objects registered to CPM, call the clearListener
method:
powerManager.clearListener();
System integration on your Android implementation
Integrators are responsible for the following items:
- Implementing the kernel interface to suspend Android.
- Implementing the VHAL functions to:
- Propagate the initiation of suspend or shutdown from the car to Android.
- Send the shutdown ready message from Android to the car.
- Initiate shutdown or suspend of Android through the Linux kernel interface.
- Ensure that all wakesources are disabled when the device is in suspend.
- Ensure that applications shut down quickly enough so as not to indefinitely postpone the
shutdown process.
- Ensure that BSP turns on/off device components according to the power policy so as not to block
suspend/hibernation
Kernel interface: /sys/power/state
AAOS places a device into suspend mode when
an application or service writes mem
for suspend-to-RAM or disk
for
suspend-to-disk into a file located at /sys/power/state
. The integrator must provide a
function that monitors this file and puts Linux into the suspend power state. This function may send
a GPIO to the VMCU to notify the VMCU that the device has shut down completely. The Integrator is
also responsible for removing any race conditions between VHAL sending the final message to the VMCU
and the system going into suspend or shutdown mode.
VHAL responsibility
The VHAL provides an interface between the vehicle network and Android. The VHAL:
- Propagates the initiation of suspend or shutdown from the car to Android.
- Sends the shutdown ready message from Android to the car.
- Initiates the shutdown or suspend of Android via the Linux kernel interface.
When the CPMS informs the VHAL that it is ready to shut down, the VHAL sends the shutdown ready
message to the VMCU. Typically, on-chip peripherals such as UART, SPI, and USB transmit the
message. Once the message has been sent, the CPMS calls the kernel command to suspend or shutdown
the device. Before doing so, the VHAL or BSP may toggle a GPIO to
instruct the VMCU that it is safe to remove power from the device.
The VHAL must support the following properties, which control power management via the VHAL:
Name
Description
AP_POWER_STATE_REPORT
Android reports state transitions to the VMCU with this property, using
VehicleApPowerStateReport enum values.
AP_POWER_STATE_REQ
The VMCU uses this property to instruct Android to transition to different power states, using
VehicleApPowerStateReq enum values.
AP_POWER_STATE_REPORT
Use this property to report Android's current power management state. This property contains two
integers:
int32Values[0]
: VehicleApPowerStateReport enum of the current state.
int32Values[1]
: Time in milliseconds to postpone or sleep or shutdown. The meaning
of this value depends on the first value.
The first value can take one of the following values. VehicleApPowerStateReport.aidl
contains more specific descriptions, which are stored in the
hardware/interfaces/automotive/vehicle/aidl/android/hardware/automotive/vehicle
.
Value name
Description
Second value
WAIT_FOR_VHAL
AP is starting and needs to establish communication with the VHAL.
DEEP_SLEEP_ENTRY
AP is entering the deep sleep state. The VMCU should turn the AP back on after the time
specified in the second value.
Must be set
DEEP_SLEEP_EXIT
AP is exiting the deep sleep state.
HIBERNATION_ENTRY
AP is entering the hibernation state. The VMCU should turn the AP back on after the time
specified in the second value.
Must be set
HIBERNATION_EXIT
AP is exiting the hibernation state.
SHUTDOWN_POSTPONE
Android is not ready to shut down. The VMCU should wait the time specified in the second value
before shutting down the AP. Android may request additional postponement by issuing additional
SHUTDOWN_POSTPONE reports.
Must be set
SHUTDOWN_PREPARE
Android is preparing to shut down.
Must be set
SHUTDOWN_START
AP is ready to shut down. The VMCU should turn the AP back on after the time specified in the
second value. (The VMCU is not required to support the timed turn-on feature.)
Must be set
SHUTDOWN_CANCELLED
Android is ceasing to prepare to shut down and will proceed to WAIT_FOR_VHAL.
ON
Android is running normally.
The state can be set autonomously or in response to a request via the VMCU.
AP_POWER_STATE_REQ
This property is sent by the VMCU to transition Android into a different power state and contains
two integers:
int32Values[0]
: VehicleApPowerStateReq
enum value, which represents
the new state into which to transition.
int32Values[1]
: VehicleApPowerStateShutdownParam
enum value. This
value is sent only for a SHUTDOWN_PREPARE
message and transmits to Android the
options it contains.
The first integer value represents the new state into which Android is to transit. The semantics
are defined in VehicleApPowerStateReq.aidl
and provided below:
Value name
Description
ON
AP should begin full operation.
SHUTDOWN_PREPARE
The AP should prepare to shut down. The second value indicates if the AP is allowed to postpone
shutting down and whether the AP should expect to power off or enter deep sleep.
CANCEL_SHUTDOWN
The AP should stop preparing to shut down and prepare to go ON.
FINISHED
The AP will now be shut down or suspended.
VehicleApPowerStateShutdownParam
is defined in
VehicleApPowerStateShutdownParam.aidl
. This enum has these elements:
Value name
Description
CAN_SLEEP
AP can enter deep sleep instead of shutting down completely. Postponing is allowed.
CAN_HIBERNATE
AP can enter hibernation instead of shutting down completely. Postponing is allowed.
SHUTDOWN_ONLY
AP should shut down. Postponing is allowed. Deep sleep is not allowed.
SLEEP_IMMEDIATELY
AP may enter deep sleep, but must either sleep or shut down immediately. Postponing is
not allowed.
HIBERNATE_IMMEDIATELY
AP may enter suspend-to-disk, but must either hibernate or shut down immediately. Postponing is
not allowed.
SHUTDOWN_IMMEDIATELY
AP must shut down immediately. Postponing is not allowed. Deep sleep is not allowed.
Wake sources
The Integrator must disable the appropriate wake sources when the device is in suspend mode.
Common wake sources include heartbeats, modem, Wi-Fi, and Bluetooth. The only valid wake source must
be an interrupt from the VMCU to wake up the SoC. This assumes that the VMCU can listen to the modem
for remote wakeup events (such as remote engine start). If this functionality is pushed to the AP,
then another wake source to service the modem must be added.
Applications
OEMs must be careful to write applications so that they can be shut down quickly and not postpone
the process indefinitely.
Appendix
Directories in the source code tree
Content
Directory
CarPowerManager-related code.
packages/services/Car/car-lib/src/android/car/hardware/power
CarPowerManagementService and so on.
packages/services/Car/service/src/com/android/car/power
Services dealing with the VHAL, such as VehicleHal
and HAlClient
.
packages/services/Car/service/src/com/android/car/hal
VHAL interface and property definitions.
hardware/interfaces/automotive/vehicle/aidl/android/hardware/automotive/vehicle/
Sample app to provide some idea about the CarPowerManager
packages/services/Car/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink
Class diagram
This class diagram displays the Java classes and interfaces in the power management system:

Figure 5. Power class diagram
Object relationship
The following graph illustrates which objects have references to other objects. An edge
means that the source object holds a reference to the target object. For example, VehicleHAL has a
reference to a PropertyHalService object.

Figure 6. Object reference diagram