Loading automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleConnector.h +17 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,12 @@ class IVehicleClient { // updateStatus is true if and only if the value is // generated by car (ECU/fake generator/injected) virtual void onPropertyValue(const VehiclePropValue& value, bool updateStatus) = 0; // Dump method forwarded from HIDL's debug() // If implemented, it must return whether the caller should dump its state. virtual bool dump(const hidl_handle& /* handle */, const hidl_vec<hidl_string>& /* options */) { return true; } }; /** Loading Loading @@ -97,6 +103,13 @@ class IVehicleServer { // updateStatus is true if and only if the value is // generated by car (ECU/fake generator/injected) virtual void onPropertyValueFromCar(const VehiclePropValue& value, bool updateStatus) = 0; // 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; } }; /** Loading Loading @@ -134,6 +147,10 @@ class IPassThroughConnector : public VehicleClientType, public VehicleServerType return this->onPropertyValue(value, updateStatus); } bool dump(const hidl_handle& handle, const hidl_vec<hidl_string>& options) override { return this->onDump(handle, options); } // To be implemented: // virtual std::vector<VehiclePropConfig> onGetAllPropertyConfig() = 0; // virtual void onPropertyValue(const VehiclePropValue& value) = 0; Loading automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHal.h +20 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,26 @@ public: */ virtual void onCreate() {} /** * Dump method forwarded from HIDL's debug(). * * By default it doesn't dump anything and let caller dump its properties, but it could be * override to change the behavior. For example: * * - To augment caller's dump, it should dump its state and return true. * - To not dump anything at all, it should just return false. * - To provide custom dump (like dumping just specific state or executing a custom command), * it should check if options is not empty, handle the options accordingly, then return false. * * @param handle handle used to dump the contents. * @param options options passed to dump. * * @return whether the caller should dump its state. */ virtual bool dump(const hidl_handle& /* handle */, const hidl_vec<hidl_string>& /* options */) { return true; } void init( VehiclePropValuePool* valueObjectPool, const HalEventFunction& onHalEvent, Loading automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp +11 −3 Original line number Diff line number Diff line Loading @@ -186,11 +186,19 @@ Return<void> VehicleHalManager::debugDump(IVehicle::debugDump_cb _hidl_cb) { } Return<void> VehicleHalManager::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) { if (fd.getNativeHandle() != nullptr && fd->numFds > 0) { cmdDump(fd->data[0], options); } else { if (fd.getNativeHandle() == nullptr || fd->numFds == 0) { ALOGE("Invalid parameters passed to debug()"); return Void(); } bool shouldContinue = mHal->dump(fd, options); if (!shouldContinue) { ALOGI("Dumped HAL only"); return Void(); } // Do our dump cmdDump(fd->data[0], options); return Void(); } Loading automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleConnector.cpp +39 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ #define LOG_TAG "automotive.vehicle@2.0-connector" #include <fstream> #include <android-base/logging.h> #include <utils/SystemClock.h> Loading Loading @@ -370,6 +372,43 @@ StatusCode EmulatedVehicleServer::onSetInitialUserInfo(const VehiclePropValue& v return StatusCode::OK; } bool EmulatedVehicleServer::onDump(const hidl_handle& handle, const hidl_vec<hidl_string>& options) { int fd = handle->data[0]; if (options.size() > 0) { if (options[0] == "--help") { dprintf(fd, "Emulator-specific usage:\n"); dprintf(fd, "--user-hal: dumps state used for user management \n"); dprintf(fd, "\n"); // Include caller's help options return true; } else if (options[0] == "--user-hal") { dumpUserHal(fd, ""); return false; } else { // Let caller handle the options... return true; } } dprintf(fd, "Emulator-specific state:\n"); dumpUserHal(fd, " "); dprintf(fd, "\n"); return true; } void EmulatedVehicleServer::dumpUserHal(int fd, std::string indent) { if (mInitialUserResponseFromCmd != nullptr) { dprintf(fd, "%sInitial User Info: %s\n", indent.c_str(), toString(*mInitialUserResponseFromCmd).c_str()); } else { dprintf(fd, "%sNo Initial User Info\n", indent.c_str()); } } EmulatedPassthroughConnectorPtr makeEmulatedPassthroughConnector() { return std::make_unique<EmulatedPassthroughConnector>(); } Loading automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleConnector.h +3 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ class EmulatedVehicleServer : public IVehicleServer { StatusCode onSetProperty(const VehiclePropValue& value, bool updateStatus) override; bool onDump(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; // Set the Property Value Pool used in this server void setValuePool(VehiclePropValuePool* valuePool); Loading Loading @@ -81,6 +83,7 @@ class EmulatedVehicleServer : public IVehicleServer { // TODO(b/146207078): it might be clearer to move members below to an EmulatedUserHal class std::unique_ptr<VehiclePropValue> mInitialUserResponseFromCmd; StatusCode onSetInitialUserInfo(const VehiclePropValue& value, bool updateStatus); void dumpUserHal(int fd, std::string indent); }; // Helper functions Loading Loading
automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleConnector.h +17 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,12 @@ class IVehicleClient { // updateStatus is true if and only if the value is // generated by car (ECU/fake generator/injected) virtual void onPropertyValue(const VehiclePropValue& value, bool updateStatus) = 0; // Dump method forwarded from HIDL's debug() // If implemented, it must return whether the caller should dump its state. virtual bool dump(const hidl_handle& /* handle */, const hidl_vec<hidl_string>& /* options */) { return true; } }; /** Loading Loading @@ -97,6 +103,13 @@ class IVehicleServer { // updateStatus is true if and only if the value is // generated by car (ECU/fake generator/injected) virtual void onPropertyValueFromCar(const VehiclePropValue& value, bool updateStatus) = 0; // 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; } }; /** Loading Loading @@ -134,6 +147,10 @@ class IPassThroughConnector : public VehicleClientType, public VehicleServerType return this->onPropertyValue(value, updateStatus); } bool dump(const hidl_handle& handle, const hidl_vec<hidl_string>& options) override { return this->onDump(handle, options); } // To be implemented: // virtual std::vector<VehiclePropConfig> onGetAllPropertyConfig() = 0; // virtual void onPropertyValue(const VehiclePropValue& value) = 0; Loading
automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHal.h +20 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,26 @@ public: */ virtual void onCreate() {} /** * Dump method forwarded from HIDL's debug(). * * By default it doesn't dump anything and let caller dump its properties, but it could be * override to change the behavior. For example: * * - To augment caller's dump, it should dump its state and return true. * - To not dump anything at all, it should just return false. * - To provide custom dump (like dumping just specific state or executing a custom command), * it should check if options is not empty, handle the options accordingly, then return false. * * @param handle handle used to dump the contents. * @param options options passed to dump. * * @return whether the caller should dump its state. */ virtual bool dump(const hidl_handle& /* handle */, const hidl_vec<hidl_string>& /* options */) { return true; } void init( VehiclePropValuePool* valueObjectPool, const HalEventFunction& onHalEvent, Loading
automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp +11 −3 Original line number Diff line number Diff line Loading @@ -186,11 +186,19 @@ Return<void> VehicleHalManager::debugDump(IVehicle::debugDump_cb _hidl_cb) { } Return<void> VehicleHalManager::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) { if (fd.getNativeHandle() != nullptr && fd->numFds > 0) { cmdDump(fd->data[0], options); } else { if (fd.getNativeHandle() == nullptr || fd->numFds == 0) { ALOGE("Invalid parameters passed to debug()"); return Void(); } bool shouldContinue = mHal->dump(fd, options); if (!shouldContinue) { ALOGI("Dumped HAL only"); return Void(); } // Do our dump cmdDump(fd->data[0], options); return Void(); } Loading
automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleConnector.cpp +39 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ #define LOG_TAG "automotive.vehicle@2.0-connector" #include <fstream> #include <android-base/logging.h> #include <utils/SystemClock.h> Loading Loading @@ -370,6 +372,43 @@ StatusCode EmulatedVehicleServer::onSetInitialUserInfo(const VehiclePropValue& v return StatusCode::OK; } bool EmulatedVehicleServer::onDump(const hidl_handle& handle, const hidl_vec<hidl_string>& options) { int fd = handle->data[0]; if (options.size() > 0) { if (options[0] == "--help") { dprintf(fd, "Emulator-specific usage:\n"); dprintf(fd, "--user-hal: dumps state used for user management \n"); dprintf(fd, "\n"); // Include caller's help options return true; } else if (options[0] == "--user-hal") { dumpUserHal(fd, ""); return false; } else { // Let caller handle the options... return true; } } dprintf(fd, "Emulator-specific state:\n"); dumpUserHal(fd, " "); dprintf(fd, "\n"); return true; } void EmulatedVehicleServer::dumpUserHal(int fd, std::string indent) { if (mInitialUserResponseFromCmd != nullptr) { dprintf(fd, "%sInitial User Info: %s\n", indent.c_str(), toString(*mInitialUserResponseFromCmd).c_str()); } else { dprintf(fd, "%sNo Initial User Info\n", indent.c_str()); } } EmulatedPassthroughConnectorPtr makeEmulatedPassthroughConnector() { return std::make_unique<EmulatedPassthroughConnector>(); } Loading
automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleConnector.h +3 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ class EmulatedVehicleServer : public IVehicleServer { StatusCode onSetProperty(const VehiclePropValue& value, bool updateStatus) override; bool onDump(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; // Set the Property Value Pool used in this server void setValuePool(VehiclePropValuePool* valuePool); Loading Loading @@ -81,6 +83,7 @@ class EmulatedVehicleServer : public IVehicleServer { // TODO(b/146207078): it might be clearer to move members below to an EmulatedUserHal class std::unique_ptr<VehiclePropValue> mInitialUserResponseFromCmd; StatusCode onSetInitialUserInfo(const VehiclePropValue& value, bool updateStatus); void dumpUserHal(int fd, std::string indent); }; // Helper functions Loading