diff options
author | Yu Shan <shanyu@google.com> | 2021-07-13 19:24:30 -0700 |
---|---|---|
committer | Yu Shan <shanyu@google.com> | 2021-07-20 18:36:33 -0700 |
commit | 7e2fcaebf24db8656acdb7631cdbb1e6cb436b26 (patch) | |
tree | ed9eead4e750fdbe356b39c6fabcc3c4992075a2 /emulator/vhal_v2_0 | |
parent | 93eb4511f5c24fad6236cc1f9b5d05cee135c12c (diff) | |
download | car-7e2fcaebf24db8656acdb7631cdbb1e6cb436b26.tar.gz |
Support debug commands in emulated VHAL.
Call default VHAL's debug handler in emulated VHAL when ondump is
called. Also handles the debug message sent from emulator.
Test: Update VehicleHalTest and run atest.
Bug: 193565753
Change-Id: I57ea9467f021e83c8808a852f4ac34654281b050
Diffstat (limited to 'emulator/vhal_v2_0')
-rw-r--r-- | emulator/vhal_v2_0/EmulatedVehicleHalServer.cpp | 4 | ||||
-rw-r--r-- | emulator/vhal_v2_0/EmulatedVehicleHalServer.h | 2 | ||||
-rw-r--r-- | emulator/vhal_v2_0/VehicleEmulator.cpp | 14 | ||||
-rw-r--r-- | emulator/vhal_v2_0/VehicleEmulator.h | 3 |
4 files changed, 23 insertions, 0 deletions
diff --git a/emulator/vhal_v2_0/EmulatedVehicleHalServer.cpp b/emulator/vhal_v2_0/EmulatedVehicleHalServer.cpp index 548fa3c..8bc5175 100644 --- a/emulator/vhal_v2_0/EmulatedVehicleHalServer.cpp +++ b/emulator/vhal_v2_0/EmulatedVehicleHalServer.cpp @@ -85,6 +85,10 @@ EmulatedVehicleHalServer::VehiclePropValuePtr EmulatedVehicleHalServer::get( return v; } +IVehicleServer::DumpResult EmulatedVehicleHalServer::debug(const std::vector<std::string>& options){ + return DefaultVehicleHalServer::onDump(options); +} + } // namespace impl } // namespace V2_0 diff --git a/emulator/vhal_v2_0/EmulatedVehicleHalServer.h b/emulator/vhal_v2_0/EmulatedVehicleHalServer.h index efcb324..dca838a 100644 --- a/emulator/vhal_v2_0/EmulatedVehicleHalServer.h +++ b/emulator/vhal_v2_0/EmulatedVehicleHalServer.h @@ -44,6 +44,8 @@ class EmulatedVehicleHalServer : public DefaultVehicleHalServer, public Emulated VehiclePropValuePtr get(const VehiclePropValue& requestedPropValue, StatusCode* outStatus); + IVehicleServer::DumpResult debug(const std::vector<std::string>& options); + private: bool mInQEMU; }; diff --git a/emulator/vhal_v2_0/VehicleEmulator.cpp b/emulator/vhal_v2_0/VehicleEmulator.cpp index aae6a65..616973a 100644 --- a/emulator/vhal_v2_0/VehicleEmulator.cpp +++ b/emulator/vhal_v2_0/VehicleEmulator.cpp @@ -192,6 +192,17 @@ void VehicleEmulator::doSetProperty(VehicleEmulator::EmulatorMessage const& rxMs respMsg.set_status(halRes ? vhal_proto::RESULT_OK : vhal_proto::ERROR_INVALID_PROPERTY); } +void VehicleEmulator::doDebug(vhal_proto::EmulatorMessage const& rxMsg, + vhal_proto::EmulatorMessage& respMsg) { + auto protoCommands = rxMsg.debug_commands(); + std::vector<std::string> commands = std::vector<std::string>( + protoCommands.begin(), protoCommands.end()); + IVehicleServer::DumpResult result = mHal->debug(commands); + respMsg.set_status(vhal_proto::RESULT_OK); + respMsg.set_msg_type(vhal_proto::DEBUG_RESP); + respMsg.set_debug_result(result.buffer); +} + void VehicleEmulator::processMessage(vhal_proto::EmulatorMessage const& rxMsg, vhal_proto::EmulatorMessage& respMsg) { switch (rxMsg.msg_type()) { @@ -210,6 +221,9 @@ void VehicleEmulator::processMessage(vhal_proto::EmulatorMessage const& rxMsg, case vhal_proto::SET_PROPERTY_CMD: doSetProperty(rxMsg, respMsg); break; + case vhal_proto::DEBUG_CMD: + doDebug(rxMsg, respMsg); + break; default: ALOGW("%s: Unknown message received, type = %d", __func__, rxMsg.msg_type()); respMsg.set_status(vhal_proto::ERROR_UNIMPLEMENTED_CMD); diff --git a/emulator/vhal_v2_0/VehicleEmulator.h b/emulator/vhal_v2_0/VehicleEmulator.h index 3090dbe..651df7d 100644 --- a/emulator/vhal_v2_0/VehicleEmulator.h +++ b/emulator/vhal_v2_0/VehicleEmulator.h @@ -23,6 +23,7 @@ #include <vector> #include <vhal_v2_0/VehicleHal.h> +#include <vhal_v2_0/VehicleServer.h> #include "CommConn.h" #include "PipeComm.h" @@ -49,6 +50,7 @@ class EmulatedServerIface { virtual std::vector<VehiclePropConfig> listProperties() = 0; virtual VehiclePropValuePtr get(const VehiclePropValue& requestedPropValue, StatusCode* outStatus) = 0; + virtual IVehicleServer::DumpResult debug(const std::vector<std::string>& options) = 0; void registerEmulator(VehicleEmulator* emulator) { ALOGI("%s, emulator: %p", __func__, emulator); @@ -89,6 +91,7 @@ class VehicleEmulator : public MessageProcessor { void doGetProperty(EmulatorMessage const& rxMsg, EmulatorMessage& respMsg); void doGetPropertyAll(EmulatorMessage const& rxMsg, EmulatorMessage& respMsg); void doSetProperty(EmulatorMessage const& rxMsg, EmulatorMessage& respMsg); + void doDebug(EmulatorMessage const& rxMsg, EmulatorMessage& respMsg); void populateProtoVehicleConfig(vhal_proto::VehiclePropConfig* protoCfg, const VehiclePropConfig& cfg); void populateProtoVehiclePropValue(vhal_proto::VehiclePropValue* protoVal, |