From 6d88bf5b9aed0d3420a82aed26d74e299637afeb Mon Sep 17 00:00:00 2001 From: shrikar Date: Tue, 17 Jan 2023 17:04:21 +0000 Subject: [PATCH] Added HANDS_ON_DETECTION_DRIVER_STATE to HAL layer Bug: 264946425 Test: atest VtsHalAutomotiveVehicle_TargetTest Change-Id: I89ed7c254917eb48b69682b18950c15f60afd2f0 --- .../cpp/AccessForVehicleProperty.h | 1 + .../cpp/ChangeModeForVehicleProperty.h | 1 + .../java/AccessForVehicleProperty.java | 1 + .../java/ChangeModeForVehicleProperty.java | 1 + .../JsonConfigLoader/src/JsonConfigLoader.cpp | 3 ++ .../config/DefaultProperties.json | 18 ++++++++ .../utils/common/include/VehicleHalTypes.h | 1 + .../vehicle/HandsOnDetectionDriverState.aidl | 40 ++++++++++++++++++ .../automotive/vehicle/VehicleProperty.aidl | 1 + .../vehicle/HandsOnDetectionDriverState.aidl | 41 +++++++++++++++++++ .../automotive/vehicle/VehicleProperty.aidl | 24 +++++++++++ .../VtsHalAutomotiveVehicle_TargetTest.cpp | 6 +++ 12 files changed, 138 insertions(+) create mode 100644 automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/HandsOnDetectionDriverState.aidl create mode 100644 automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/HandsOnDetectionDriverState.aidl diff --git a/automotive/vehicle/aidl/generated_lib/cpp/AccessForVehicleProperty.h b/automotive/vehicle/aidl/generated_lib/cpp/AccessForVehicleProperty.h index 1d2d910031..72bff22ec2 100644 --- a/automotive/vehicle/aidl/generated_lib/cpp/AccessForVehicleProperty.h +++ b/automotive/vehicle/aidl/generated_lib/cpp/AccessForVehicleProperty.h @@ -264,6 +264,7 @@ std::unordered_map AccessForVehiclePrope {VehicleProperty::CRUISE_CONTROL_STATE, VehiclePropertyAccess::READ}, {VehicleProperty::CRUISE_CONTROL_COMMAND, VehiclePropertyAccess::WRITE}, {VehicleProperty::HANDS_ON_DETECTION_ENABLED, VehiclePropertyAccess::READ_WRITE}, + {VehicleProperty::HANDS_ON_DETECTION_DRIVER_STATE, VehiclePropertyAccess::READ}, {VehicleProperty::DRIVER_ATTENTION_MONITORING_ENABLED, VehiclePropertyAccess::READ_WRITE}, }; diff --git a/automotive/vehicle/aidl/generated_lib/cpp/ChangeModeForVehicleProperty.h b/automotive/vehicle/aidl/generated_lib/cpp/ChangeModeForVehicleProperty.h index 613636e81c..7122019748 100644 --- a/automotive/vehicle/aidl/generated_lib/cpp/ChangeModeForVehicleProperty.h +++ b/automotive/vehicle/aidl/generated_lib/cpp/ChangeModeForVehicleProperty.h @@ -264,6 +264,7 @@ std::unordered_map ChangeModeForVehi {VehicleProperty::CRUISE_CONTROL_STATE, VehiclePropertyChangeMode::ON_CHANGE}, {VehicleProperty::CRUISE_CONTROL_COMMAND, VehiclePropertyChangeMode::ON_CHANGE}, {VehicleProperty::HANDS_ON_DETECTION_ENABLED, VehiclePropertyChangeMode::ON_CHANGE}, + {VehicleProperty::HANDS_ON_DETECTION_DRIVER_STATE, VehiclePropertyChangeMode::ON_CHANGE}, {VehicleProperty::DRIVER_ATTENTION_MONITORING_ENABLED, VehiclePropertyChangeMode::ON_CHANGE}, }; diff --git a/automotive/vehicle/aidl/generated_lib/java/AccessForVehicleProperty.java b/automotive/vehicle/aidl/generated_lib/java/AccessForVehicleProperty.java index f83f1c260e..2ed889e1a4 100644 --- a/automotive/vehicle/aidl/generated_lib/java/AccessForVehicleProperty.java +++ b/automotive/vehicle/aidl/generated_lib/java/AccessForVehicleProperty.java @@ -256,6 +256,7 @@ public final class AccessForVehicleProperty { Map.entry(VehicleProperty.CRUISE_CONTROL_STATE, VehiclePropertyAccess.READ), Map.entry(VehicleProperty.CRUISE_CONTROL_COMMAND, VehiclePropertyAccess.WRITE), Map.entry(VehicleProperty.HANDS_ON_DETECTION_ENABLED, VehiclePropertyAccess.READ_WRITE), + Map.entry(VehicleProperty.HANDS_ON_DETECTION_DRIVER_STATE, VehiclePropertyAccess.READ), Map.entry(VehicleProperty.DRIVER_ATTENTION_MONITORING_ENABLED, VehiclePropertyAccess.READ_WRITE) ); diff --git a/automotive/vehicle/aidl/generated_lib/java/ChangeModeForVehicleProperty.java b/automotive/vehicle/aidl/generated_lib/java/ChangeModeForVehicleProperty.java index f0642fe379..de3a8ae13c 100644 --- a/automotive/vehicle/aidl/generated_lib/java/ChangeModeForVehicleProperty.java +++ b/automotive/vehicle/aidl/generated_lib/java/ChangeModeForVehicleProperty.java @@ -256,6 +256,7 @@ public final class ChangeModeForVehicleProperty { Map.entry(VehicleProperty.CRUISE_CONTROL_STATE, VehiclePropertyChangeMode.ON_CHANGE), Map.entry(VehicleProperty.CRUISE_CONTROL_COMMAND, VehiclePropertyChangeMode.ON_CHANGE), Map.entry(VehicleProperty.HANDS_ON_DETECTION_ENABLED, VehiclePropertyChangeMode.ON_CHANGE), + Map.entry(VehicleProperty.HANDS_ON_DETECTION_DRIVER_STATE, VehiclePropertyChangeMode.ON_CHANGE), Map.entry(VehicleProperty.DRIVER_ATTENTION_MONITORING_ENABLED, VehiclePropertyChangeMode.ON_CHANGE) ); diff --git a/automotive/vehicle/aidl/impl/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp b/automotive/vehicle/aidl/impl/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp index 7531589311..119d1578fc 100644 --- a/automotive/vehicle/aidl/impl/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp +++ b/automotive/vehicle/aidl/impl/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp @@ -49,6 +49,7 @@ using ::aidl::android::hardware::automotive::vehicle::EvsServiceType; using ::aidl::android::hardware::automotive::vehicle::ForwardCollisionWarningState; using ::aidl::android::hardware::automotive::vehicle::FuelType; using ::aidl::android::hardware::automotive::vehicle::GsrComplianceRequirementType; +using ::aidl::android::hardware::automotive::vehicle::HandsOnDetectionDriverState; using ::aidl::android::hardware::automotive::vehicle::LaneCenteringAssistCommand; using ::aidl::android::hardware::automotive::vehicle::LaneCenteringAssistState; using ::aidl::android::hardware::automotive::vehicle::LaneDepartureWarningState; @@ -230,6 +231,8 @@ JsonValueParser::JsonValueParser() { std::make_unique>(); mConstantParsersByType["CruiseControlCommand"] = std::make_unique>(); + mConstantParsersByType["HandsOnDetectionDriverState"] = + std::make_unique>(); mConstantParsersByType["ErrorState"] = std::make_unique>(); mConstantParsersByType["AutomaticEmergencyBrakingState"] = std::make_unique>(); diff --git a/automotive/vehicle/aidl/impl/default_config/config/DefaultProperties.json b/automotive/vehicle/aidl/impl/default_config/config/DefaultProperties.json index a0e811579a..71af0e834e 100644 --- a/automotive/vehicle/aidl/impl/default_config/config/DefaultProperties.json +++ b/automotive/vehicle/aidl/impl/default_config/config/DefaultProperties.json @@ -3215,6 +3215,24 @@ ] } }, + { + "property": "VehicleProperty::HANDS_ON_DETECTION_DRIVER_STATE", + "defaultValue": { + "int32Values": [ + "HandsOnDetectionDriverState::HANDS_ON" + ] + }, + "areas": [ + { + "areaId": 0, + "supportedEnumValues": [ + "ErrorState::NOT_AVAILABLE_DISABLED", + "HandsOnDetectionDriverState::HANDS_ON", + "HandsOnDetectionDriverState::HANDS_OFF" + ] + } + ] + }, { "property": "VehicleProperty::DRIVER_ATTENTION_MONITORING_ENABLED", "defaultValue": { diff --git a/automotive/vehicle/aidl/impl/utils/common/include/VehicleHalTypes.h b/automotive/vehicle/aidl/impl/utils/common/include/VehicleHalTypes.h index 3b26aa6999..e0b9584331 100644 --- a/automotive/vehicle/aidl/impl/utils/common/include/VehicleHalTypes.h +++ b/automotive/vehicle/aidl/impl/utils/common/include/VehicleHalTypes.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/HandsOnDetectionDriverState.aidl b/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/HandsOnDetectionDriverState.aidl new file mode 100644 index 0000000000..bb390f2224 --- /dev/null +++ b/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/HandsOnDetectionDriverState.aidl @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2023 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 -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 HandsOnDetectionDriverState { + OTHER = 0, + HANDS_ON = 1, + HANDS_OFF = 2, +} diff --git a/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/VehicleProperty.aidl b/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/VehicleProperty.aidl index bbec4bf595..efcfd68c7f 100644 --- a/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/VehicleProperty.aidl +++ b/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/VehicleProperty.aidl @@ -262,5 +262,6 @@ enum VehicleProperty { CRUISE_CONTROL_STATE = (((0x1011 + android.hardware.automotive.vehicle.VehiclePropertyGroup.SYSTEM) + android.hardware.automotive.vehicle.VehicleArea.GLOBAL) + android.hardware.automotive.vehicle.VehiclePropertyType.INT32) /* 289411089 */, CRUISE_CONTROL_COMMAND = (((0x1012 + android.hardware.automotive.vehicle.VehiclePropertyGroup.SYSTEM) + android.hardware.automotive.vehicle.VehicleArea.GLOBAL) + android.hardware.automotive.vehicle.VehiclePropertyType.INT32) /* 289411090 */, HANDS_ON_DETECTION_ENABLED = (((0x1016 + android.hardware.automotive.vehicle.VehiclePropertyGroup.SYSTEM) + android.hardware.automotive.vehicle.VehicleArea.GLOBAL) + android.hardware.automotive.vehicle.VehiclePropertyType.BOOLEAN) /* 287313942 */, + HANDS_ON_DETECTION_DRIVER_STATE = (((0x1017 + android.hardware.automotive.vehicle.VehiclePropertyGroup.SYSTEM) + android.hardware.automotive.vehicle.VehicleArea.GLOBAL) + android.hardware.automotive.vehicle.VehiclePropertyType.INT32) /* 289411095 */, DRIVER_ATTENTION_MONITORING_ENABLED = (((0x1019 + android.hardware.automotive.vehicle.VehiclePropertyGroup.SYSTEM) + android.hardware.automotive.vehicle.VehicleArea.GLOBAL) + android.hardware.automotive.vehicle.VehiclePropertyType.BOOLEAN) /* 287313945 */, } diff --git a/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/HandsOnDetectionDriverState.aidl b/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/HandsOnDetectionDriverState.aidl new file mode 100644 index 0000000000..4a36999ecb --- /dev/null +++ b/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/HandsOnDetectionDriverState.aidl @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2023 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 to enumerate the current driver state of Hands On Detection (HOD). + */ +@VintfStability +@Backing(type="int") +enum HandsOnDetectionDriverState { + /** + * This state is used as an alternative for any HandsOnDetectionDriverState value that is not + * defined in the platform. Ideally, implementations of + * VehicleProperty#HANDS_ON_DETECTION_DRIVER_STATE should not use this state. The framework + * can use this field to remain backwards compatible if HandsOnDetectionDriverState is + * extended to include additional states. + */ + OTHER = 0, + /** + * The system detects that the driver has their hands on the steering wheel. + */ + HANDS_ON = 1, + /** + * The system detects that the driver has their hands off the steering wheel. + */ + HANDS_OFF = 2, +} diff --git a/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl b/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl index 68a1e324ee..9838489e31 100644 --- a/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl +++ b/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl @@ -3946,6 +3946,30 @@ enum VehicleProperty { HANDS_ON_DETECTION_ENABLED = 0x1016 + VehiclePropertyGroup.SYSTEM + VehicleArea.GLOBAL + VehiclePropertyType.BOOLEAN, + /** + * Hands on detection (HOD) driver state. + * + * Returns whether the driver's hands are on the steering wheel. Generally, this property should + * return a valid state defined in the HandsOnDetectionDriverState or ErrorState. For example, + * if the feature is not available due to some temporary state, that information should be + * conveyed through ErrorState. + * + * If the vehicle wants to send a warning to the user because the driver's hands have been off + * the steering wheel for too long, the warning should be surfaced through + * HANDS_ON_DETECTION_WARNING. + * + * For the global area ID (0), the VehicleAreaConfig#supportedEnumValues array must be defined + * unless all states of both HandsOnDetectionDriverState (including OTHER, which is not + * recommended) and ErrorState are supported. + * + * @change_mode VehiclePropertyChangeMode.ON_CHANGE + * @access VehiclePropertyAccess.READ + * @data_enum HandsOnDetectionDriverState + * @data_enum ErrorState + */ + HANDS_ON_DETECTION_DRIVER_STATE = + 0x1017 + VehiclePropertyGroup.SYSTEM + VehicleArea.GLOBAL + VehiclePropertyType.INT32, + /** * Enable or disable driver attention monitoring. * diff --git a/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp b/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp index efbcf47680..8ed79ee777 100644 --- a/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp +++ b/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp @@ -540,6 +540,12 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHandsOnDetectionEnabledConfig) { VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN); } +TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHandsOnDetectionDriverStateConfig) { + verifyProperty(VehicleProperty::HANDS_ON_DETECTION_DRIVER_STATE, VehiclePropertyAccess::READ, + VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, + VehicleArea::GLOBAL, VehiclePropertyType::INT32); +} + TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDriverAttentionMonitoringEnabledConfig) { verifyProperty(VehicleProperty::DRIVER_ATTENTION_MONITORING_ENABLED, VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,