為確保硬件和軟件組件(如顯示、音頻和語音交互)根據需要選擇性地打開和關閉,AAOS 提供了一個電源策略,該策略由一組硬件和軟件組件的預期電源打開和關閉狀態組成. VHAL 或系統特權供應商服務可以在 Android 電源狀態轉換或滿足它們等待的條件時應用新的電源策略。
在 Wait for VHAL 和 On 狀態下允許應用電源策略。在關機準備中,車庫模式正在運行,不應受到電源狀態更改的干擾。雖然無法應用常規電源策略,但在關機準備中應用了一個特殊的電源策略,即名為“無用戶交互”的系統電源策略。
AAOS 電源狀態
AAOS 設備遵循此電源狀態圖:

圖 1. AAOS 電源狀態圖
每種電源狀態描述如下:
| 價值 | 描述 |
|---|---|
| 離開 | 沒有為應用處理器 (AP)、內存和外圍設備提供物理電源。 |
| 等待 VHAL |
|
| 上 |
|
| 關機準備 |
|
| 等待 VHAL 完成 |
|
| 掛起到 RAM (STR) | 車輛和 AP 已關閉,沒有執行任何代碼,並且 AP RAM 保持供電。 |
軟件架構
電源策略架構如下圖所示,並在以下部分中定義:

圖 2.電源策略架構
電源策略是如何定義的?
實施者在/vendor/etc/automotive/power_policy.xml中定義電源策略,其中:
- 定義電源策略。
- 定義電源策略組,其中包括默認電源策略並在發生電源狀態轉換時自動應用。
- 覆蓋系統電源策略。
電源政策
電源策略是硬件和軟件組件的一組預期電源狀態。 AAOS 在電源策略中支持以下組件:
-
AUDIO -
MEDIA -
DISPLAY_MAIN -
DISPLAY_CLUSTER -
DISPLAY_FRONT_PASSENGER -
DISPLAY_REAR_PASSENGER -
BLUETOOTH -
WIFI -
CELLULAR -
ETHERNET -
PROJECTION -
NFC -
INPUT -
VOICE_INTERACTION -
VISUAL_INTERACTION -
TRUSTED_DEVICE_DETECTION -
LOCATION -
MICROPHONE -
CPU
電源策略組
在電源策略組中指定電源狀態轉換時會自動應用默認電源策略。供應商可以為 Wait For VHAL、On 和 Wait for VHAL Finish(深度睡眠進入或關機啟動)定義默認電源策略。
系統電源策略
AAOS 僅支持一種系統電源策略,即“無用戶交互”。當設備進入靜音模式或車庫模式時應用系統電源策略。
下表列出了系統電源策略中每個組件的行為。實施者可以覆蓋系統電源策略中的藍牙、NFC 和可信設備檢測。覆蓋應用在/vendor/etc/power_policy.xml中。
| 成分 | 電源狀態 | 可配置 |
|---|---|---|
| 聲音的 | 離開 | 不 |
| 媒體 | 離開 | 不 |
| 顯示主要 | 離開 | 不 |
| 顯示集群 | 離開 | 不 |
| 顯示前排乘客 | 離開 | 不 |
| 顯示後排乘客 | 離開 | 不 |
| 藍牙 | 離開 | 是的 |
| 無線上網 | 上 | 不 |
| 蜂窩 | 上 | 不 |
| 以太網 | 上 | 不 |
| 投影 | 離開 | 不 |
| NFC | 離開 | 是的 |
| 輸入 | 離開 | 不 |
| 語音交互 | 離開 | 不 |
| 視覺交互 | 離開 | 不 |
| 可信設備檢測 | 上 | 是的 |
| 地點 | 離開 | 不 |
| 麥克風 | 離開 | 不 |
| 中央處理器 | 上 | 不 |
與 VHAL 的交互
在系統層運行的汽車電源策略守護進程訂閱兩個屬性來監聽來自 VHAL 的請求:
-
POWER_POLICY_REQ,VHAL 將電源策略 ID 寫入此屬性。 -
POWER_POLICY_GROUP_REQ,VHAL 將電源策略組 ID 寫入此屬性。
系統中當前的電源策略可以通過 VHAL 以外的模塊進行更改。在這種情況下,汽車電源策略守護程序會更新CURRENT_POWER_POLICY屬性以將更改通知給 VHAL。
與本機進程的交互
如上所述,汽車電源策略守護進程運行在系統層,在電源策略管理方面,提供與運行在框架層的 CPMS 幾乎相同的功能。此外,假設汽車電源策略守護程序和 CPMS 完全同步。
汽車電源策略守護程序導出 AIDL 接口以供 HAL 和其他本機進程使用。當新的電源策略更改時,可以通知他們。換句話說,當每個都必須改變它的電源狀態時。
ICarPowerPolicyServer.aidl
package android.frameworks.automotive.powerpolicy;
import android.frameworks.automotive.powerpolicy.CarPowerPolicy;
import android.frameworks.automotive.powerpolicy.CarPowerPolicyFilter;
import android.frameworks.automotive.powerpolicy.ICarPowerPolicyChangeCallback;
import android.frameworks.automotive.powerpolicy.PowerComponent;
/**
* ICarPowerPolicyServer is an interface implemented by the power policy daemon.
* VHAL changes the power policy and the power policy daemon notifies the change to registered
* subscribers. When subscribing to policy changes, a filter can be specified so that the registered
* callbacks can listen only to a specific power component's change.
*/
@VintfStability
interface ICarPowerPolicyServer {
/**
* Gets the current power policy.
*/
CarPowerPolicy getCurrentPowerPolicy();
/**
* Gets whether the power component is turned on or off.
*
* @param componentId Power component ID defined in PowerComponent.aidl to check power state.
* @return True if the component's power state is on.
*/
boolean getPowerComponentState(in PowerComponent componentId);
/**
* Subscribes to power policy change.
* Notification is sent to the registered callback when the power policy changes and the power
* state of the components which the callback is interested in changes.
*
* @param callback Callback that is invoked when the power policy changes.
* @param filter The list of components which the callback is interested in.
*/
void registerPowerPolicyChangeCallback(in ICarPowerPolicyChangeCallback callback,
in CarPowerPolicyFilter filter);
/**
* Unsubscribes from power policy change.
*
* @param callback Callback that doesn't want to receive power policy change.
*/
void unregisterPowerPolicyChangeCallback(in ICarPowerPolicyChangeCallback callback);
}
ICarPowerPolicyChangeCallback.aidl
package android.frameworks.automotive.powerpolicy;
import android.frameworks.automotive.powerpolicy.CarPowerPolicy;
/**
* ICarPowerPolicyChangeCallback is notified when a power policy changes.
*/
@VintfStability
oneway interface ICarPowerPolicyChangeCallback {
/**
* Called when a power policy is fully changed.
*
* @param policy The current policy.
*/
void onPolicyChanged(in CarPowerPolicy policy);
}
與 Java 模塊的交互
CarPowerManager提供了啟用電源策略管理的方法:
- 獲取當前的電源策略。
- 獲取當前電源策略組
- 應用新的電源策略
- 設置新的電源策略組
只有系統特權模塊可以使用這些方法。希望在應用電源策略時得到通知的模塊可以向CarPowerManager註冊電源策略更改偵聽器。