From 4d1fe81bee2a1ef01b1a14638484a2d7528afcc3 Mon Sep 17 00:00:00 2001 From: Kai Date: Thu, 5 Aug 2021 14:02:33 -0700 Subject: [PATCH] Add placeholder properties for emulator Add some placeholder properties in google VHAL. Developers who use the aae emulator can use them in developing new features without implementing a real property. Bug: 193460353 Test: build aae emulator, use adb lshal to change property values Change-Id: I6131a4892495c4c1e1c73e078572a666a33f984e --- .../default/impl/vhal_v2_0/DefaultConfig.h | 36 +++++++++++++++++++ .../default/impl/vhal_v2_0/PropertyUtils.h | 13 +++++++ .../vhal_v2_0/tests/DefaultVhalImpl_test.cpp | 2 +- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h index 11dc6eb11b..e76a91aab4 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h @@ -1061,6 +1061,42 @@ const ConfigDeclaration kVehicleProperties[]{ .changeMode = VehiclePropertyChangeMode::ON_CHANGE, }, }, + { + .config = + { + .prop = PLACEHOLDER_PROPERTY_INT, + .access = VehiclePropertyAccess::READ_WRITE, + .changeMode = VehiclePropertyChangeMode::ON_CHANGE, + }, + .initialValue = {.int32Values = {0}}, + }, + { + .config = + { + .prop = PLACEHOLDER_PROPERTY_FLOAT, + .access = VehiclePropertyAccess::READ_WRITE, + .changeMode = VehiclePropertyChangeMode::ON_CHANGE, + }, + .initialValue = {.floatValues = {0.0f}}, + }, + { + .config = + { + .prop = PLACEHOLDER_PROPERTY_BOOLEAN, + .access = VehiclePropertyAccess::READ_WRITE, + .changeMode = VehiclePropertyChangeMode::ON_CHANGE, + }, + .initialValue = {.int32Values = {0 /* false */}}, + }, + { + .config = + { + .prop = PLACEHOLDER_PROPERTY_STRING, + .access = VehiclePropertyAccess::READ_WRITE, + .changeMode = VehiclePropertyChangeMode::ON_CHANGE, + }, + .initialValue = {.stringValue = {"Test"}}, + }, #ifdef ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING // Vendor propetry for E2E ClusterHomeService testing. { diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/PropertyUtils.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/PropertyUtils.h index ec43e8db5d..f58e09a67d 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/PropertyUtils.h +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/PropertyUtils.h @@ -100,6 +100,19 @@ constexpr int32_t VENDOR_CLUSTER_NAVIGATION_STATE = toVendor(VehicleProperty::CLUSTER_NAVIGATION_STATE); #endif // ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING +/** + * These properties are placeholder properties for developers to test new features without + * implementing a real property. + */ +constexpr int32_t PLACEHOLDER_PROPERTY_INT = + 0x2a11 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::INT32; +constexpr int32_t PLACEHOLDER_PROPERTY_FLOAT = + 0x2a11 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::FLOAT; +constexpr int32_t PLACEHOLDER_PROPERTY_BOOLEAN = + 0x2a11 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::BOOLEAN; +constexpr int32_t PLACEHOLDER_PROPERTY_STRING = + 0x2a11 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::STRING; + const int32_t kHvacPowerProperties[] = { toInt(VehicleProperty::HVAC_FAN_SPEED), toInt(VehicleProperty::HVAC_FAN_DIRECTION), diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/tests/DefaultVhalImpl_test.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/tests/DefaultVhalImpl_test.cpp index 0233bddb88..e3c8dd6c79 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/tests/DefaultVhalImpl_test.cpp +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/tests/DefaultVhalImpl_test.cpp @@ -141,7 +141,7 @@ class DefaultVhalImplTest : public ::testing::Test { TEST_F(DefaultVhalImplTest, testListProperties) { std::vector configs = mHal->listProperties(); - EXPECT_EQ((size_t)117, configs.size()); + EXPECT_EQ((size_t)121, configs.size()); } TEST_F(DefaultVhalImplTest, testGetDefaultPropertyFloat) {