Merge "Add constants for hibernation to VHAL"
diff --git a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleApPowerStateConfigFlag.aidl b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleApPowerStateConfigFlag.aidl
index 472b23b..7e48eba 100644
--- a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleApPowerStateConfigFlag.aidl
+++ b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleApPowerStateConfigFlag.aidl
@@ -36,4 +36,5 @@
 enum VehicleApPowerStateConfigFlag {
   ENABLE_DEEP_SLEEP_FLAG = 1,
   CONFIG_SUPPORT_TIMER_POWER_ON_FLAG = 2,
+  ENABLE_HIBERNATION_FLAG = 3,
 }
diff --git a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleApPowerStateReport.aidl b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleApPowerStateReport.aidl
index 1ca3b50..fc669ec 100644
--- a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleApPowerStateReport.aidl
+++ b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleApPowerStateReport.aidl
@@ -42,4 +42,6 @@
   ON = 6,
   SHUTDOWN_PREPARE = 7,
   SHUTDOWN_CANCELLED = 8,
+  HIBERNATION_ENTRY = 9,
+  HIBERNATION_EXIT = 10,
 }
diff --git a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleApPowerStateShutdownParam.aidl b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleApPowerStateShutdownParam.aidl
index 3e0f4e8..3fde1c7 100644
--- a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleApPowerStateShutdownParam.aidl
+++ b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleApPowerStateShutdownParam.aidl
@@ -38,4 +38,6 @@
   CAN_SLEEP = 2,
   SHUTDOWN_ONLY = 3,
   SLEEP_IMMEDIATELY = 4,
+  HIBERNATE_IMMEDIATELY = 5,
+  CAN_HIBERNATE = 6,
 }
diff --git a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateConfigFlag.aidl b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateConfigFlag.aidl
index 7cb5db3..4d8e2f5 100644
--- a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateConfigFlag.aidl
+++ b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateConfigFlag.aidl
@@ -20,8 +20,10 @@
 @Backing(type="int")
 enum VehicleApPowerStateConfigFlag {
     /**
-     * AP can enter deep sleep state. If not set, AP will always shutdown from
-     * VehicleApPowerState#SHUTDOWN_PREPARE power state.
+     * AP can enter deep sleep state. If not set, AP will shutdown from
+     * VehicleApPowerState#SHUTDOWN_PREPARE power state when deep sleep is requested
+     * (via VehicleApPowerStateShutdownParam#CAN_SLEEP or
+     * VehicleApPowerStateShutdownParam#SLEEP_IMMEDIATELY flags)/
      */
     ENABLE_DEEP_SLEEP_FLAG = 0x1,
     /**
@@ -29,4 +31,11 @@
      * specified in VehicleApPowerSet VEHICLE_AP_POWER_SET_SHUTDOWN_READY message.
      */
     CONFIG_SUPPORT_TIMER_POWER_ON_FLAG = 0x2,
+    /**
+     * AP can enter hibernation state. If not set, AP will shutdown from
+     * VehicleApPowerState#SHUTDOWN_PREPARE when hibernation is requested
+     * (via VehicleApPowerStateShutdownParam#CAN_HIBERNATE or
+     *  VehicleApPowerStateShutdownParam#HIBERNATE_IMMEDIATELY flags)
+     */
+    ENABLE_HIBERNATION_FLAG = 0x3,
 }
diff --git a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateReport.aidl b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateReport.aidl
index f1d741f..e94fc76 100644
--- a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateReport.aidl
+++ b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateReport.aidl
@@ -89,4 +89,22 @@
      * VehicleApPowerStateReq#SHUTDOWN_PREPARE. Other power state requests are ignored.
      */
     SHUTDOWN_CANCELLED = 0x8,
+    /**
+     * AP is ready to hibernate.
+     * The AP will not send any more state reports after this.
+     * After reporting this state, AP will accept VehicleApPowerStateReq#FINISHED.
+     * Other power state requests are ignored.
+     *
+     * int32Values[1]: Time to turn AP back on, in seconds. Power controller should turn on
+     *                 AP after the specified time has elapsed, so AP can run tasks like
+     *                 update. If this value is 0, no wake up is requested. The power
+     *                 controller may not necessarily support timed wake-up.
+     */
+    HIBERNATION_ENTRY = 0x9,
+    /**
+     * AP is exiting from hibernation state.
+     * After reporting this state, AP will accept VehicleApPowerStateReq#ON or
+     * VehicleApPowerStateReq#SHUTDOWN_PREPARE. Other power state requests are ignored.
+     */
+    HIBERNATION_EXIT = 0xA,
 }
diff --git a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateShutdownParam.aidl b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateShutdownParam.aidl
index 7b682b5..a863d14 100644
--- a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateShutdownParam.aidl
+++ b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateShutdownParam.aidl
@@ -36,4 +36,13 @@
      * Postponing is not allowed.
      */
     SLEEP_IMMEDIATELY = 4,
+    /**
+     * AP must hibernate (suspend to disk) immediately. Postponing is not allowed.
+     * Depending on the actual implementation, it may shut down immediately
+     */
+    HIBERNATE_IMMEDIATELY = 5,
+    /**
+     * AP can enter hibernation (suspend to disk) instead of shutting down completely.
+     */
+    CAN_HIBERNATE = 6,
 }