電源政策

為了確保硬體和軟體組件(例如顯示、音訊和語音互動)根據需要選擇性地開啟和關閉,AAOS 提供了電源策略,其中包括一組硬體和軟體組件的預期電源開啟和關閉狀態。當 Android 電源狀態轉換或滿足其等待的條件時,VHAL(或系統特權供應商服務)可以應用新的電源策略。

在“Wait for VHAL”和“On”狀態下允許應用電源策略。在關機準備中,車庫模式正在運行,並且不應受到電源狀態變化的干擾。雖然不能應用常規的電源策略,但在關機準備中應用了一種特殊的電源策略,即名為「無用戶互動」的系統電源策略。

AAOS 電源狀態

AAOS 設備遵循以下電源狀態圖:

AAOS電源狀態圖

圖 1. AAOS 電源狀態圖

每種電源狀態說明如下:

價值描述
離開實體上不向應用處理器 (AP)、記憶體和周邊裝置提供電源。
等待VHAL
  • 當駕駛員與車輛互動時(例如,打開車門),VMCU 向 AP、記憶體供電。和周邊設備。
  • AAOS 從三種狀態之一轉換(關閉、掛起至 RAM(STR、等待 VHAL 完成)),然後進入等待 VHAL,等待與 VHAL 協調。
  • VHAL 指示 AAOS 進入 On 狀態。在此狀態下,AAOS 完全運行並與驅動程式互動。
  • 顯示由電源策略控制,而不是由其他外形規格的 Android 顯示開/關呼叫控制。
關機準備
  • 當駕駛者停止駕駛時,VHAL 指示 AAOS 進入關機準備狀態。在此狀態下,顯示和音訊關閉,且 AAOS 不與駕駛員互動。 Android系統仍在運行,可以更新應用程式和Android系統。當更新(如果有)完成時,Android 系統進入等待 VHAL Finish。
等待 VHAL 完成
  • AAOS 通知 VHAL 它可以關閉。車輛微控制器單元 (VMCU) 預計將系統單晶片 (SoC) 置於深度睡眠狀態並切斷 AP 的電源。然後 AAOS 處於 STR 狀態,但沒有執行任何程式碼。
  • 如果 VHAL 未完成且驅動程式傳回,則主機 (HU) 應直接轉換為等待 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註冊電源策略變更偵聽器。