Loading automotive/vehicle/2.0/default/Android.bp +14 −4 Original line number Diff line number Diff line Loading @@ -172,6 +172,8 @@ cc_test { "libbase", "libcutils", ], // Exclude share libraries from default because they might be missing on // some test platforms and we are using static libraries instead. exclude_shared_libs: [ "android.automotive.watchdog-V2-ndk_platform", "android.hardware.automotive.vehicle@2.0", Loading @@ -190,18 +192,26 @@ cc_test { defaults: ["vhal_v2_0_target_defaults"], srcs: [ "impl/vhal_v2_0/tests/ProtoMessageConverter_test.cpp", "impl/vhal_v2_0/tests/DefaultVhalImpl_test.cpp", ], static_libs: [ "android.automotive.watchdog-V2-ndk_platform", "android.hardware.automotive.vehicle@2.0", "android.hardware.automotive.vehicle@2.0-default-impl-lib", "android.hardware.automotive.vehicle@2.0-libproto-native", "libbase", "libcutils", "libjsoncpp", "libprotobuf-cpp-lite", ], // Exclude share libraries from default because they might be missing on // some test platforms and we are using static libraries instead. exclude_shared_libs: [ "android.automotive.watchdog-V2-ndk_platform", "android.hardware.automotive.vehicle@2.0", ], whole_static_libs: [ "android.automotive.watchdog-V2-ndk_platform", "android.hardware.automotive.vehicle@2.0", "android.hardware.automotive.vehicle@2.0-default-impl-lib", "android.hardware.automotive.vehicle@2.0-libproto-native", ], test_suites: ["general-tests"], } Loading automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleConnector.h +16 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <vector> #include <android/hardware/automotive/vehicle/2.0/types.h> #include <utils/Log.h> #include "VehicleClient.h" #include "VehicleServer.h" Loading Loading @@ -72,7 +73,21 @@ class IPassThroughConnector : public VehicleClientType, public VehicleServerType } bool dump(const hidl_handle& handle, const hidl_vec<hidl_string>& options) override { return this->onDump(handle, options); // Calls server's onDump function and print the dumped info to the handle. std::vector<std::string> stdOptions; for (size_t i = 0; i < options.size(); i++) { stdOptions.push_back(options[i]); } IVehicleServer::DumpResult result = this->onDump(stdOptions); int fd = handle->data[0]; if (fd < 0) { ALOGW("Invalid fd from HIDL handle: %d", fd); return false; } if (result.buffer.size() != 0) { dprintf(fd, "[VehicleHalServer] Dumped info: %s\n", result.buffer.c_str()); } return result.callerShouldDumpState; } // To be implemented: Loading automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleServer.h +11 −7 Original line number Diff line number Diff line Loading @@ -28,6 +28,16 @@ namespace android::hardware::automotive::vehicle::V2_0 { */ class IVehicleServer { public: // The return structure for onDump function. struct DumpResult { // If callerShouldDumpState is true, caller would print the information in buffer and // continue to dump its state, otherwise would just dump the buffer and skip its own // dumping logic. bool callerShouldDumpState; // The dumped information for the caller to print. std::string buffer; }; IVehicleServer() = default; IVehicleServer(const IVehicleServer&) = delete; Loading @@ -54,15 +64,9 @@ class IVehicleServer { // generated by car (ECU/fake generator/injected) virtual void onPropertyValueFromCar(const VehiclePropValue& value, bool updateStatus) = 0; // TODO (chenhaosjtuacm): fix this since there are no HIDL in non-Android OS #ifdef __ANDROID__ // Dump method forwarded from HIDL's debug() // If implemented, it must return whether the caller should dump its state. virtual bool onDump(const hidl_handle& /* handle */, const hidl_vec<hidl_string>& /* options */) { return true; } #endif // __ANDROID__ virtual DumpResult onDump(const std::vector<std::string>& options) = 0; }; } // namespace android::hardware::automotive::vehicle::V2_0 automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h +6 −6 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ const ConfigDeclaration kVehicleProperties[]{ .access = VehiclePropertyAccess::READ, .changeMode = VehiclePropertyChangeMode::STATIC, }, .initialValue = {.floatValues = {1776, 4950, 2008, 2140, 2984, 1665, 1667, 11800}}}, .initialValue = {.int32Values = {1776, 4950, 2008, 2140, 2984, 1665, 1667, 11800}}}, {.config = { .prop = toInt(VehicleProperty::PERF_VEHICLE_SPEED), Loading Loading @@ -1072,8 +1072,8 @@ const ConfigDeclaration kVehicleProperties[]{ .access = VehiclePropertyAccess::READ, .changeMode = VehiclePropertyChangeMode::ON_CHANGE, }, .initialValue = {.int32Values = {0 /* Off */, -1, -1, -1, -1 /* Bounds */, -1, -1, -1, -1 /* Insets */}}, .initialValue = {.int32Values = {0 /* Off */, -1, -1, -1, -1 /* Bounds */, -1, -1, -1, -1 /* Insets */}}, }, { .config = Loading Loading @@ -1126,9 +1126,9 @@ const ConfigDeclaration kVehicleProperties[]{ .changeMode = VehiclePropertyChangeMode::ON_CHANGE, .configArray = {0, 0, 0, 11, 0, 0, 0, 0, 16}, }, .initialValue = {.int32Values = {0 /* Off */, -1, -1, -1, -1 /* Bounds */, -1, -1, -1, -1 /* Insets */, 0 /* ClusterHome */, -1 /* ClusterNone */}}, .initialValue = {.int32Values = {0 /* Off */, -1, -1, -1, -1 /* Bounds */, -1, -1, -1, -1 /* Insets */, 0 /* ClusterHome */, -1 /* ClusterNone */}}, }, { .config = Loading automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHalServer.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <fstream> #include <android-base/format.h> #include <android-base/logging.h> #include <utils/SystemClock.h> Loading Loading @@ -329,6 +330,21 @@ StatusCode DefaultVehicleHalServer::onSetProperty(const VehiclePropValue& value, return StatusCode::OK; } IVehicleServer::DumpResult DefaultVehicleHalServer::onDump( const std::vector<std::string>& /* options */) { DumpResult result; result.callerShouldDumpState = true; result.buffer += "Server side properties: \n"; auto values = mServerSidePropStore.readAllValues(); size_t i = 0; for (const auto& value : values) { result.buffer += fmt::format("[{}]: {}\n", i, toString(value)); i++; } return result; } } // namespace impl } // namespace V2_0 Loading Loading
automotive/vehicle/2.0/default/Android.bp +14 −4 Original line number Diff line number Diff line Loading @@ -172,6 +172,8 @@ cc_test { "libbase", "libcutils", ], // Exclude share libraries from default because they might be missing on // some test platforms and we are using static libraries instead. exclude_shared_libs: [ "android.automotive.watchdog-V2-ndk_platform", "android.hardware.automotive.vehicle@2.0", Loading @@ -190,18 +192,26 @@ cc_test { defaults: ["vhal_v2_0_target_defaults"], srcs: [ "impl/vhal_v2_0/tests/ProtoMessageConverter_test.cpp", "impl/vhal_v2_0/tests/DefaultVhalImpl_test.cpp", ], static_libs: [ "android.automotive.watchdog-V2-ndk_platform", "android.hardware.automotive.vehicle@2.0", "android.hardware.automotive.vehicle@2.0-default-impl-lib", "android.hardware.automotive.vehicle@2.0-libproto-native", "libbase", "libcutils", "libjsoncpp", "libprotobuf-cpp-lite", ], // Exclude share libraries from default because they might be missing on // some test platforms and we are using static libraries instead. exclude_shared_libs: [ "android.automotive.watchdog-V2-ndk_platform", "android.hardware.automotive.vehicle@2.0", ], whole_static_libs: [ "android.automotive.watchdog-V2-ndk_platform", "android.hardware.automotive.vehicle@2.0", "android.hardware.automotive.vehicle@2.0-default-impl-lib", "android.hardware.automotive.vehicle@2.0-libproto-native", ], test_suites: ["general-tests"], } Loading
automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleConnector.h +16 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <vector> #include <android/hardware/automotive/vehicle/2.0/types.h> #include <utils/Log.h> #include "VehicleClient.h" #include "VehicleServer.h" Loading Loading @@ -72,7 +73,21 @@ class IPassThroughConnector : public VehicleClientType, public VehicleServerType } bool dump(const hidl_handle& handle, const hidl_vec<hidl_string>& options) override { return this->onDump(handle, options); // Calls server's onDump function and print the dumped info to the handle. std::vector<std::string> stdOptions; for (size_t i = 0; i < options.size(); i++) { stdOptions.push_back(options[i]); } IVehicleServer::DumpResult result = this->onDump(stdOptions); int fd = handle->data[0]; if (fd < 0) { ALOGW("Invalid fd from HIDL handle: %d", fd); return false; } if (result.buffer.size() != 0) { dprintf(fd, "[VehicleHalServer] Dumped info: %s\n", result.buffer.c_str()); } return result.callerShouldDumpState; } // To be implemented: Loading
automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleServer.h +11 −7 Original line number Diff line number Diff line Loading @@ -28,6 +28,16 @@ namespace android::hardware::automotive::vehicle::V2_0 { */ class IVehicleServer { public: // The return structure for onDump function. struct DumpResult { // If callerShouldDumpState is true, caller would print the information in buffer and // continue to dump its state, otherwise would just dump the buffer and skip its own // dumping logic. bool callerShouldDumpState; // The dumped information for the caller to print. std::string buffer; }; IVehicleServer() = default; IVehicleServer(const IVehicleServer&) = delete; Loading @@ -54,15 +64,9 @@ class IVehicleServer { // generated by car (ECU/fake generator/injected) virtual void onPropertyValueFromCar(const VehiclePropValue& value, bool updateStatus) = 0; // TODO (chenhaosjtuacm): fix this since there are no HIDL in non-Android OS #ifdef __ANDROID__ // Dump method forwarded from HIDL's debug() // If implemented, it must return whether the caller should dump its state. virtual bool onDump(const hidl_handle& /* handle */, const hidl_vec<hidl_string>& /* options */) { return true; } #endif // __ANDROID__ virtual DumpResult onDump(const std::vector<std::string>& options) = 0; }; } // namespace android::hardware::automotive::vehicle::V2_0
automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h +6 −6 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ const ConfigDeclaration kVehicleProperties[]{ .access = VehiclePropertyAccess::READ, .changeMode = VehiclePropertyChangeMode::STATIC, }, .initialValue = {.floatValues = {1776, 4950, 2008, 2140, 2984, 1665, 1667, 11800}}}, .initialValue = {.int32Values = {1776, 4950, 2008, 2140, 2984, 1665, 1667, 11800}}}, {.config = { .prop = toInt(VehicleProperty::PERF_VEHICLE_SPEED), Loading Loading @@ -1072,8 +1072,8 @@ const ConfigDeclaration kVehicleProperties[]{ .access = VehiclePropertyAccess::READ, .changeMode = VehiclePropertyChangeMode::ON_CHANGE, }, .initialValue = {.int32Values = {0 /* Off */, -1, -1, -1, -1 /* Bounds */, -1, -1, -1, -1 /* Insets */}}, .initialValue = {.int32Values = {0 /* Off */, -1, -1, -1, -1 /* Bounds */, -1, -1, -1, -1 /* Insets */}}, }, { .config = Loading Loading @@ -1126,9 +1126,9 @@ const ConfigDeclaration kVehicleProperties[]{ .changeMode = VehiclePropertyChangeMode::ON_CHANGE, .configArray = {0, 0, 0, 11, 0, 0, 0, 0, 16}, }, .initialValue = {.int32Values = {0 /* Off */, -1, -1, -1, -1 /* Bounds */, -1, -1, -1, -1 /* Insets */, 0 /* ClusterHome */, -1 /* ClusterNone */}}, .initialValue = {.int32Values = {0 /* Off */, -1, -1, -1, -1 /* Bounds */, -1, -1, -1, -1 /* Insets */, 0 /* ClusterHome */, -1 /* ClusterNone */}}, }, { .config = Loading
automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHalServer.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <fstream> #include <android-base/format.h> #include <android-base/logging.h> #include <utils/SystemClock.h> Loading Loading @@ -329,6 +330,21 @@ StatusCode DefaultVehicleHalServer::onSetProperty(const VehiclePropValue& value, return StatusCode::OK; } IVehicleServer::DumpResult DefaultVehicleHalServer::onDump( const std::vector<std::string>& /* options */) { DumpResult result; result.callerShouldDumpState = true; result.buffer += "Server side properties: \n"; auto values = mServerSidePropStore.readAllValues(); size_t i = 0; for (const auto& value : values) { result.buffer += fmt::format("[{}]: {}\n", i, toString(value)); i++; } return result; } } // namespace impl } // namespace V2_0 Loading