Loading automotive/vehicle/2.0/default/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -137,7 +137,6 @@ cc_library_static { local_include_dirs: ["common/include/vhal_v2_0"], export_include_dirs: ["impl"], srcs: [ "impl/vhal_v2_0/EmulatedUserHal.cpp", "impl/vhal_v2_0/GeneratorHub.cpp", "impl/vhal_v2_0/JsonFakeValueGenerator.cpp", "impl/vhal_v2_0/LinearFakeValueGenerator.cpp", Loading automotive/vehicle/2.0/default/VehicleService.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ using namespace android::hardware::automotive::vehicle::V2_0; int main(int /* argc */, char* /* argv */ []) { auto store = std::make_unique<VehiclePropertyStore>(); auto connector = impl::makeEmulatedPassthroughConnector(); auto connector = std::make_unique<impl::EmulatedVehicleConnector>(); auto userHal = connector->getEmulatedUserHal(); auto hal = std::make_unique<impl::EmulatedVehicleHal>(store.get(), connector.get(), userHal); auto emulator = std::make_unique<impl::VehicleEmulator>(hal.get()); Loading automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleConnector.cpp +26 −10 Original line number Diff line number Diff line Loading @@ -35,12 +35,32 @@ namespace V2_0 { namespace impl { class EmulatedPassthroughConnector : public PassthroughConnector { public: bool onDump(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; }; EmulatedUserHal* EmulatedVehicleConnector::getEmulatedUserHal() { return &mEmulatedUserHal; } StatusCode EmulatedVehicleConnector::onSetProperty(const VehiclePropValue& value, bool updateStatus) { if (mEmulatedUserHal.isSupported(value.prop)) { LOG(INFO) << "onSetProperty(): property " << value.prop << " will be handled by UserHal"; bool EmulatedPassthroughConnector::onDump(const hidl_handle& handle, const auto& ret = mEmulatedUserHal.onSetProperty(value); if (!ret.ok()) { LOG(ERROR) << "onSetProperty(): HAL returned error: " << ret.error().message(); return StatusCode(ret.error().code()); } auto updatedValue = ret.value().get(); if (updatedValue != nullptr) { LOG(INFO) << "onSetProperty(): updating property returned by HAL: " << toString(*updatedValue); onPropertyValueFromCar(*updatedValue, updateStatus); } return StatusCode::OK; } return this->VehicleHalServer::onSetProperty(value, updateStatus); } bool EmulatedVehicleConnector::onDump(const hidl_handle& handle, const hidl_vec<hidl_string>& options) { int fd = handle->data[0]; Loading Loading @@ -68,10 +88,6 @@ bool EmulatedPassthroughConnector::onDump(const hidl_handle& handle, return true; } PassthroughConnectorPtr makeEmulatedPassthroughConnector() { return std::make_unique<EmulatedPassthroughConnector>(); } } // namespace impl } // namespace V2_0 Loading automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleConnector.h +14 −3 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <vhal_v2_0/VehicleConnector.h> #include "EmulatedUserHal.h" #include "VehicleHalClient.h" #include "VehicleHalServer.h" Loading @@ -30,10 +31,20 @@ namespace V2_0 { namespace impl { using PassthroughConnector = IPassThroughConnector<VehicleHalClient, VehicleHalServer>; using PassthroughConnectorPtr = std::unique_ptr<PassthroughConnector>; class EmulatedVehicleConnector : public IPassThroughConnector<VehicleHalClient, VehicleHalServer> { public: EmulatedVehicleConnector() {} PassthroughConnectorPtr makeEmulatedPassthroughConnector(); EmulatedUserHal* getEmulatedUserHal(); // Methods from VehicleHalServer StatusCode onSetProperty(const VehiclePropValue& value, bool updateStatus) override; bool onDump(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; private: EmulatedUserHal mEmulatedUserHal; }; } // namespace impl Loading automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleHalServer.cpp +0 −20 Original line number Diff line number Diff line Loading @@ -41,10 +41,6 @@ VehiclePropValuePool* VehicleHalServer::getValuePool() const { return mValuePool; } EmulatedUserHal* VehicleHalServer::getEmulatedUserHal() { return &mEmulatedUserHal; } void VehicleHalServer::setValuePool(VehiclePropValuePool* valuePool) { if (!valuePool) { LOG(WARNING) << __func__ << ": Setting value pool to nullptr!"; Loading Loading @@ -185,22 +181,6 @@ VehicleHalServer::VehiclePropValuePtr VehicleHalServer::createHwInputKeyProp( } StatusCode VehicleHalServer::onSetProperty(const VehiclePropValue& value, bool updateStatus) { if (mEmulatedUserHal.isSupported(value.prop)) { LOG(INFO) << "onSetProperty(): property " << value.prop << " will be handled by UserHal"; const auto& ret = mEmulatedUserHal.onSetProperty(value); if (!ret.ok()) { LOG(ERROR) << "onSetProperty(): HAL returned error: " << ret.error().message(); return StatusCode(ret.error().code()); } auto updatedValue = ret.value().get(); if (updatedValue != nullptr) { LOG(INFO) << "onSetProperty(): updating property returned by HAL: " << toString(*updatedValue); onPropertyValueFromCar(*updatedValue, updateStatus); } return StatusCode::OK; } LOG(DEBUG) << "onSetProperty(" << value.prop << ")"; // Some properties need to be treated non-trivially Loading Loading
automotive/vehicle/2.0/default/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -137,7 +137,6 @@ cc_library_static { local_include_dirs: ["common/include/vhal_v2_0"], export_include_dirs: ["impl"], srcs: [ "impl/vhal_v2_0/EmulatedUserHal.cpp", "impl/vhal_v2_0/GeneratorHub.cpp", "impl/vhal_v2_0/JsonFakeValueGenerator.cpp", "impl/vhal_v2_0/LinearFakeValueGenerator.cpp", Loading
automotive/vehicle/2.0/default/VehicleService.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ using namespace android::hardware::automotive::vehicle::V2_0; int main(int /* argc */, char* /* argv */ []) { auto store = std::make_unique<VehiclePropertyStore>(); auto connector = impl::makeEmulatedPassthroughConnector(); auto connector = std::make_unique<impl::EmulatedVehicleConnector>(); auto userHal = connector->getEmulatedUserHal(); auto hal = std::make_unique<impl::EmulatedVehicleHal>(store.get(), connector.get(), userHal); auto emulator = std::make_unique<impl::VehicleEmulator>(hal.get()); Loading
automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleConnector.cpp +26 −10 Original line number Diff line number Diff line Loading @@ -35,12 +35,32 @@ namespace V2_0 { namespace impl { class EmulatedPassthroughConnector : public PassthroughConnector { public: bool onDump(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; }; EmulatedUserHal* EmulatedVehicleConnector::getEmulatedUserHal() { return &mEmulatedUserHal; } StatusCode EmulatedVehicleConnector::onSetProperty(const VehiclePropValue& value, bool updateStatus) { if (mEmulatedUserHal.isSupported(value.prop)) { LOG(INFO) << "onSetProperty(): property " << value.prop << " will be handled by UserHal"; bool EmulatedPassthroughConnector::onDump(const hidl_handle& handle, const auto& ret = mEmulatedUserHal.onSetProperty(value); if (!ret.ok()) { LOG(ERROR) << "onSetProperty(): HAL returned error: " << ret.error().message(); return StatusCode(ret.error().code()); } auto updatedValue = ret.value().get(); if (updatedValue != nullptr) { LOG(INFO) << "onSetProperty(): updating property returned by HAL: " << toString(*updatedValue); onPropertyValueFromCar(*updatedValue, updateStatus); } return StatusCode::OK; } return this->VehicleHalServer::onSetProperty(value, updateStatus); } bool EmulatedVehicleConnector::onDump(const hidl_handle& handle, const hidl_vec<hidl_string>& options) { int fd = handle->data[0]; Loading Loading @@ -68,10 +88,6 @@ bool EmulatedPassthroughConnector::onDump(const hidl_handle& handle, return true; } PassthroughConnectorPtr makeEmulatedPassthroughConnector() { return std::make_unique<EmulatedPassthroughConnector>(); } } // namespace impl } // namespace V2_0 Loading
automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleConnector.h +14 −3 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <vhal_v2_0/VehicleConnector.h> #include "EmulatedUserHal.h" #include "VehicleHalClient.h" #include "VehicleHalServer.h" Loading @@ -30,10 +31,20 @@ namespace V2_0 { namespace impl { using PassthroughConnector = IPassThroughConnector<VehicleHalClient, VehicleHalServer>; using PassthroughConnectorPtr = std::unique_ptr<PassthroughConnector>; class EmulatedVehicleConnector : public IPassThroughConnector<VehicleHalClient, VehicleHalServer> { public: EmulatedVehicleConnector() {} PassthroughConnectorPtr makeEmulatedPassthroughConnector(); EmulatedUserHal* getEmulatedUserHal(); // Methods from VehicleHalServer StatusCode onSetProperty(const VehiclePropValue& value, bool updateStatus) override; bool onDump(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; private: EmulatedUserHal mEmulatedUserHal; }; } // namespace impl Loading
automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleHalServer.cpp +0 −20 Original line number Diff line number Diff line Loading @@ -41,10 +41,6 @@ VehiclePropValuePool* VehicleHalServer::getValuePool() const { return mValuePool; } EmulatedUserHal* VehicleHalServer::getEmulatedUserHal() { return &mEmulatedUserHal; } void VehicleHalServer::setValuePool(VehiclePropValuePool* valuePool) { if (!valuePool) { LOG(WARNING) << __func__ << ": Setting value pool to nullptr!"; Loading Loading @@ -185,22 +181,6 @@ VehicleHalServer::VehiclePropValuePtr VehicleHalServer::createHwInputKeyProp( } StatusCode VehicleHalServer::onSetProperty(const VehiclePropValue& value, bool updateStatus) { if (mEmulatedUserHal.isSupported(value.prop)) { LOG(INFO) << "onSetProperty(): property " << value.prop << " will be handled by UserHal"; const auto& ret = mEmulatedUserHal.onSetProperty(value); if (!ret.ok()) { LOG(ERROR) << "onSetProperty(): HAL returned error: " << ret.error().message(); return StatusCode(ret.error().code()); } auto updatedValue = ret.value().get(); if (updatedValue != nullptr) { LOG(INFO) << "onSetProperty(): updating property returned by HAL: " << toString(*updatedValue); onPropertyValueFromCar(*updatedValue, updateStatus); } return StatusCode::OK; } LOG(DEBUG) << "onSetProperty(" << value.prop << ")"; // Some properties need to be treated non-trivially Loading