Merge "Add properties for EV charging"
diff --git a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/EvChargeState.aidl b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/EvChargeState.aidl
new file mode 100644
index 0000000..fe1c240
--- /dev/null
+++ b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/EvChargeState.aidl
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.automotive.vehicle;
+@Backing(type="int") @VintfStability
+enum EvChargeState {
+  UNKNOWN = 0,
+  CHARGING = 1,
+  FULLY_CHARGED = 2,
+  NOT_CHARGING = 3,
+  ERROR = 4,
+}
diff --git a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/EvRegenerativeBrakingState.aidl b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/EvRegenerativeBrakingState.aidl
new file mode 100644
index 0000000..b869562
--- /dev/null
+++ b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/EvRegenerativeBrakingState.aidl
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.automotive.vehicle;
+@Backing(type="int") @VintfStability
+enum EvRegenerativeBrakingState {
+  UNKNOWN = 0,
+  DISABLED = 1,
+  PARTIALLY_ENABLED = 2,
+  FULLY_ENABLED = 3,
+}
diff --git a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleProperty.aidl b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleProperty.aidl
index bcb63b6..2505dbd 100644
--- a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleProperty.aidl
+++ b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleProperty.aidl
@@ -198,4 +198,10 @@
   FRONT_FOG_LIGHTS_SWITCH = 289410876,
   REAR_FOG_LIGHTS_STATE = 289410877,
   REAR_FOG_LIGHTS_SWITCH = 289410878,
+  EV_CHARGE_CURRENT_DRAW_LIMIT = 291508031,
+  EV_CHARGE_PERCENT_LIMIT = 291508032,
+  EV_CHARGE_STATE = 289410881,
+  EV_CHARGE_SWITCH = 287313730,
+  EV_CHARGE_TIME_REMAINING = 289410883,
+  EV_REGENERATIVE_BRAKING_STATE = 289410884,
 }
diff --git a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleUnit.aidl b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleUnit.aidl
index 034dec5..c80fdbb 100644
--- a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleUnit.aidl
+++ b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleUnit.aidl
@@ -60,6 +60,7 @@
   MILLIWATTS = 99,
   AMPERE_HOURS = 100,
   KILOWATT_HOUR = 101,
+  AMPERE = 102,
   KILOPASCAL = 112,
   PSI = 113,
   BAR = 114,
diff --git a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/EvChargeState.aidl b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/EvChargeState.aidl
new file mode 100644
index 0000000..e095fc4
--- /dev/null
+++ b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/EvChargeState.aidl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.automotive.vehicle;
+
+/**
+ * Used by EV charging properties to enumerate the current state of the battery charging.
+ */
+@VintfStability
+@Backing(type="int")
+enum EvChargeState {
+    UNKNOWN = 0,
+    CHARGING = 1,
+    FULLY_CHARGED = 2,
+    NOT_CHARGING = 3,
+    /**
+     * Vehicle not charging due to an error
+     */
+    ERROR = 4,
+}
diff --git a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/EvRegenerativeBrakingState.aidl b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/EvRegenerativeBrakingState.aidl
new file mode 100644
index 0000000..4382287
--- /dev/null
+++ b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/EvRegenerativeBrakingState.aidl
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.automotive.vehicle;
+
+/**
+ * Used by the regenerative braking property to enumerate the current state
+ * of the regenerative braking.
+ */
+@VintfStability
+@Backing(type="int")
+enum EvRegenerativeBrakingState {
+    UNKNOWN = 0,
+    DISABLED = 1,
+    PARTIALLY_ENABLED = 2,
+    FULLY_ENABLED = 3,
+}
diff --git a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleProperty.aidl b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleProperty.aidl
index 533c7a2..87b4802 100644
--- a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleProperty.aidl
+++ b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleProperty.aidl
@@ -2724,4 +2724,83 @@
      */
     REAR_FOG_LIGHTS_SWITCH = 0x0F3E + 0x10000000 + 0x01000000
             + 0x00400000, // VehiclePropertyGroup:SYSTEM,VehicleArea:GLOBAL,VehiclePropertyType:INT32
+
+    /**
+     * Indicates the maximum current draw threshold for charging set by the user
+     *
+     * configArray[0] is used to specify the max current draw allowed by
+     * the vehicle in Amperes.
+     *
+     * @change_mode VehiclePropertyChangeMode:ON_CHANGE
+     * @access VehiclePropertyAccess:READ_WRITE
+     * @unit VehicleUnit:AMPERE
+     */
+    EV_CHARGE_CURRENT_DRAW_LIMIT = 0x0F3F + 0x10000000 + 0x01000000
+            + 0x00600000, // VehiclePropertyGroup:SYSTEM,VehicleArea:GLOBAL,VehiclePropertyType:FLOAT
+
+    /**
+     * Indicates the maximum charge percent threshold set by the user
+     *
+     * Returns a float value from 0 to 100.
+     *
+     * configArray is used to specify the valid values.
+     *   For example, if the vehicle supports the following charge percent limit values:
+     *     [20, 40, 60, 80, 100]
+     *   then the configArray should be {20, 40, 60, 80, 100}
+     * If the configArray is empty then all values from 0 to 100 must be valid.
+     *
+     * @change_mode VehiclePropertyChangeMode:ON_CHANGE
+     * @access VehiclePropertyAccess:READ_WRITE
+     */
+    EV_CHARGE_PERCENT_LIMIT = 0x0F40 + 0x10000000 + 0x01000000
+            + 0x00600000, // VehiclePropertyGroup:SYSTEM,VehicleArea:GLOBAL,VehiclePropertyType:FLOAT
+
+    /**
+     * Charging state of the car
+     *
+     * Returns the current charging state of the car.
+     *
+     * @change_mode VehiclePropertyChangeMode:ON_CHANGE
+     * @access VehiclePropertyAccess:READ
+     * @data_enum EvChargeState
+     */
+    EV_CHARGE_STATE = 0x0F41 + 0x10000000 + 0x01000000
+            + 0x00400000, // VehiclePropertyGroup:SYSTEM,VehicleArea:GLOBAL,VehiclePropertyType:INT32
+
+    /**
+     * Start or stop charging the EV battery
+     *
+     * The setting that the user wants. Setting this property to true starts the battery charging
+     * and setting to false stops charging.
+     *
+     * @change_mode VehiclePropertyChangeMode:ON_CHANGE
+     * @access VehiclePropertyAccess:READ_WRITE
+     */
+    EV_CHARGE_SWITCH = 0x0F42 + 0x10000000 + 0x01000000
+            + 0x00200000, // VehiclePropertyGroup:SYSTEM,VehicleArea:GLOBAL,VehiclePropertyType:BOOLEAN
+
+    /**
+     * Estimated charge time remaining in seconds
+     *
+     * Returns 0 if the vehicle is not charging.
+     *
+     * @change_mode VehiclePropertyChangeMode:CONTINUOUS
+     * @access VehiclePropertyAccess:READ
+     * @unit VehicleUnit:SECS
+     */
+    EV_CHARGE_TIME_REMAINING = 0x0F43 + 0x10000000 + 0x01000000
+            + 0x00400000, // VehiclePropertyGroup:SYSTEM,VehicleArea:GLOBAL,VehiclePropertyType:INT32
+
+    /**
+     * Regenerative braking or one-pedal drive state of the car
+     *
+     * Returns the current state associated with the regenerative braking
+     * setting in the car
+     *
+     * @change_mode VehiclePropertyChangeMode:ON_CHANGE
+     * @access VehiclePropertyAccess:READ
+     * @data_enum EvRegenerativeBrakingState
+     */
+    EV_REGENERATIVE_BRAKING_STATE = 0x0F44 + 0x10000000 + 0x01000000
+            + 0x00400000, // VehiclePropertyGroup:SYSTEM,VehicleArea:GLOBAL,VehiclePropertyType:INT32
 }
diff --git a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleUnit.aidl b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleUnit.aidl
index 9c3f8f9..3817b74 100644
--- a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleUnit.aidl
+++ b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleUnit.aidl
@@ -51,6 +51,7 @@
     MILLIWATTS = 0x63,
     AMPERE_HOURS = 0x64,
     KILOWATT_HOUR = 0x65,
+    AMPERE = 0x66,
     KILOPASCAL = 0x70,
     PSI = 0x71,
     BAR = 0x72,