為了確保硬體和軟體組件(例如顯示、音訊和語音互動)根據需要選擇性地開啟和關閉,AAOS 提供了電源策略,其中包括一組硬體和軟體組件的預期電源開啟和關閉狀態。當 Android 電源狀態轉換或滿足其等待的條件時,VHAL(或系統特權供應商服務)可以應用新的電源策略。
在“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
電源策略組
在電源策略組中指定電源狀態轉換時,會自動套用預設電源策略。供應商可以定義等待 VHAL、開啟和等待 VHAL 完成(深度睡眠進入或關機啟動)的預設電源策略。
系統電源策略
AAOS 僅支援一種系統電源策略,即「無使用者互動」。當設備進入車庫模式時,將套用系統電源策略。
下表列出了系統電源策略中每個組件的行為。實施者可以覆蓋系統電源策略中的藍牙、NFC 和可信任設備檢測。覆蓋應用於/vendor/etc/power_policy.xml
。
成分 | 電源狀態 | 可配置 |
---|---|---|
聲音的 | 離開 | 不 |
媒體 | 離開 | 不 |
顯示主 | 離開 | 不 |
顯示集群 | 離開 | 不 |
顯示前乘客 | 離開 | 不 |
顯示後排乘客 | 離開 | 不 |
藍牙 | 離開 | 是的 |
無線上網 | 在 | 不 |
蜂窩網路 | 在 | 不 |
乙太網路 | 在 | 不 |
投影 | 離開 | 不 |
近場通訊 | 離開 | 是的 |
輸入 | 離開 | 不 |
語音交互 | 離開 | 不 |
視覺交互 | 離開 | 不 |
可信任設備檢測 | 在 | 是的 |
地點 | 離開 | 不 |
麥克風 | 離開 | 不 |
中央處理器 | 在 | 不 |
與 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
註冊電源策略變更偵聽器。