diff options
author | Yuncheol Heo <ycheo@google.com> | 2021-04-09 17:15:11 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-04-09 17:15:11 +0000 |
commit | ed48cd23bc971f62185aa6f34ff5cd04159686bd (patch) | |
tree | aa2b5d4cd67d3ab03643c744c92aab205f5bb9ba | |
parent | 016d01a998d25aefc1c78d4f39eda317ba54c446 (diff) | |
parent | e3eea4f93280d5cfd4042f04f0412d0691c29314 (diff) |
Merge "Redirect the Cluster VHAL messages to vendor ones, or vice versa." into sc-dev
3 files changed, 89 insertions, 0 deletions
diff --git a/automotive/vehicle/2.0/default/Android.bp b/automotive/vehicle/2.0/default/Android.bp index b2f8bf630a..d6f3120221 100644 --- a/automotive/vehicle/2.0/default/Android.bp +++ b/automotive/vehicle/2.0/default/Android.bp @@ -210,6 +210,7 @@ cc_binary { vendor: true, relative_install_path: "hw", srcs: ["VehicleService.cpp"], + cflags: ["-DENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING"], shared_libs: [ "libbase", "libjsoncpp", 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 f5b53d3f1b..2cc956de52 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 @@ -115,6 +115,28 @@ const int32_t kSetBooleanPropertyFromVehicleForTest = */ const int32_t kMixedTypePropertyForTest = 0x1111 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::MIXED; + +#ifdef ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING +/** + * Converts the system property to the vendor property. + * WARNING: This is only for the end-to-end testing, Should NOT include in the + * user build */ +inline constexpr int32_t toVendor(VehicleProperty prop) { + return (toInt(prop) & ~toInt(VehiclePropertyGroup::MASK)) | VehiclePropertyGroup::VENDOR; +} + +/** + * These properties are used for the end-to-end testing of ClusterHomeService. + */ +constexpr int32_t VENDOR_CLUSTER_SWITCH_UI = toVendor(VehicleProperty::CLUSTER_SWITCH_UI); +constexpr int32_t VENDOR_CLUSTER_DISPLAY_STATE = toVendor(VehicleProperty::CLUSTER_DISPLAY_STATE); +constexpr int32_t VENDOR_CLUSTER_REPORT_STATE = toVendor(VehicleProperty::CLUSTER_REPORT_STATE); +constexpr int32_t VENDOR_CLUSTER_REQUEST_DISPLAY = + toVendor(VehicleProperty::CLUSTER_REQUEST_DISPLAY); +constexpr int32_t VENDOR_CLUSTER_NAVIGATION_STATE = + toVendor(VehicleProperty::CLUSTER_NAVIGATION_STATE); +#endif // ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING + /** * FakeDataCommand enum defines the supported command type for kGenerateFakeDataControllingProperty. * All those commands can be send independently with each other. And each will override the one sent @@ -1237,6 +1259,50 @@ const ConfigDeclaration kVehicleProperties[]{ .changeMode = VehiclePropertyChangeMode::ON_CHANGE, }, }, +#ifdef ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING + // Vendor propetry for E2E ClusterHomeService testing. + { + .config = + { + .prop = VENDOR_CLUSTER_SWITCH_UI, + .access = VehiclePropertyAccess::WRITE, + .changeMode = VehiclePropertyChangeMode::ON_CHANGE, + }, + }, + { + .config = + { + .prop = VENDOR_CLUSTER_DISPLAY_STATE, + .access = VehiclePropertyAccess::WRITE, + .changeMode = VehiclePropertyChangeMode::ON_CHANGE, + }, + }, + { + .config = + { + .prop = VENDOR_CLUSTER_REPORT_STATE, + .access = VehiclePropertyAccess::READ, + .changeMode = VehiclePropertyChangeMode::ON_CHANGE, + .configArray = {0, 0, 0, 9, 0, 0, 0, 0, 16}, + }, + }, + { + .config = + { + .prop = VENDOR_CLUSTER_REQUEST_DISPLAY, + .access = VehiclePropertyAccess::READ, + .changeMode = VehiclePropertyChangeMode::ON_CHANGE, + }, + }, + { + .config = + { + .prop = VENDOR_CLUSTER_NAVIGATION_STATE, + .access = VehiclePropertyAccess::READ, + .changeMode = VehiclePropertyChangeMode::ON_CHANGE, + }, + }, +#endif // ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING }; } // impl diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleHalServer.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleHalServer.cpp index 0ee183596a..6b870527c3 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleHalServer.cpp +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleHalServer.cpp @@ -247,6 +247,28 @@ StatusCode VehicleHalServer::onSetProperty(const VehiclePropValue& value, bool u break; } break; + +#ifdef ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING + case toInt(VehicleProperty::CLUSTER_REPORT_STATE): + case toInt(VehicleProperty::CLUSTER_REQUEST_DISPLAY): + case toInt(VehicleProperty::CLUSTER_NAVIGATION_STATE): + case VENDOR_CLUSTER_SWITCH_UI: + case VENDOR_CLUSTER_DISPLAY_STATE: { + auto updatedPropValue = createVehiclePropValue(getPropType(value.prop), 0); + updatedPropValue->prop = value.prop & ~toInt(VehiclePropertyGroup::MASK); + if (isSystemProperty(value.prop)) { + updatedPropValue->prop |= toInt(VehiclePropertyGroup::VENDOR); + } else { + updatedPropValue->prop |= toInt(VehiclePropertyGroup::SYSTEM); + } + updatedPropValue->value = value.value; + updatedPropValue->timestamp = elapsedRealtimeNano(); + updatedPropValue->areaId = value.areaId; + onPropertyValueFromCar(*updatedPropValue, updateStatus); + return StatusCode::OK; + } +#endif // ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING + default: break; } |