summaryrefslogtreecommitdiff
path: root/emulator/vhal_v2_0
diff options
context:
space:
mode:
authorYu Shan <shanyu@google.com>2021-06-29 15:08:26 -0700
committerYu Shan <shanyu@google.com>2021-07-01 18:54:50 -0700
commitd6d97c266b17c5deb0d60af03bafc5aaaa12d525 (patch)
tree2d6bff18840c68f6e9c2eeb1c8023eef47ddfef4 /emulator/vhal_v2_0
parent565589139f8cee5480c0340a2ca4a6843956c198 (diff)
downloadcar-d6d97c266b17c5deb0d60af03bafc5aaaa12d525.tar.gz
Update the onDump interface.
Update the onDump interface to return a dumpResult structure to avoid using hidl handle at the server side. Test: Presubmit Change-Id: I0fafe776bb05e3aaf2eeb47d969fc0eea7591a17
Diffstat (limited to 'emulator/vhal_v2_0')
-rw-r--r--emulator/vhal_v2_0/EmulatedUserHal.cpp24
-rw-r--r--emulator/vhal_v2_0/EmulatedUserHal.h5
-rw-r--r--emulator/vhal_v2_0/EmulatedVehicleConnector.cpp34
-rw-r--r--emulator/vhal_v2_0/EmulatedVehicleConnector.h2
4 files changed, 35 insertions, 30 deletions
diff --git a/emulator/vhal_v2_0/EmulatedUserHal.cpp b/emulator/vhal_v2_0/EmulatedUserHal.cpp
index f5664f3..aed7026 100644
--- a/emulator/vhal_v2_0/EmulatedUserHal.cpp
+++ b/emulator/vhal_v2_0/EmulatedUserHal.cpp
@@ -311,35 +311,37 @@ Result<std::unique_ptr<VehiclePropValue>> EmulatedUserHal::sendUserHalResponse(
return response;
}
-void EmulatedUserHal::showDumpHelp(int fd) {
- dprintf(fd, "%s: dumps state used for user management\n", kUserHalDumpOption);
+std::string EmulatedUserHal::showDumpHelp() {
+ return fmt::format("{}: dumps state used for user management\n", kUserHalDumpOption);
}
-void EmulatedUserHal::dump(int fd, std::string indent) {
+std::string EmulatedUserHal::dump(std::string indent) {
+ std::string info;
if (mInitialUserResponseFromCmd != nullptr) {
- dprintf(fd, "%sInitialUserInfo response: %s\n", indent.c_str(),
+ info += fmt::format("{}InitialUserInfo response: {}\n", indent.c_str(),
toString(*mInitialUserResponseFromCmd).c_str());
} else {
- dprintf(fd, "%sNo InitialUserInfo response\n", indent.c_str());
+ info += fmt::format("{}No InitialUserInfo response\n", indent.c_str());
}
if (mSwitchUserResponseFromCmd != nullptr) {
- dprintf(fd, "%sSwitchUser response: %s\n", indent.c_str(),
+ info += fmt::format("{}SwitchUser response: {}\n", indent.c_str(),
toString(*mSwitchUserResponseFromCmd).c_str());
} else {
- dprintf(fd, "%sNo SwitchUser response\n", indent.c_str());
+ info += fmt::format("{}No SwitchUser response\n", indent.c_str());
}
if (mCreateUserResponseFromCmd != nullptr) {
- dprintf(fd, "%sCreateUser response: %s\n", indent.c_str(),
+ info += fmt::format("{}CreateUser response: {}\n", indent.c_str(),
toString(*mCreateUserResponseFromCmd).c_str());
} else {
- dprintf(fd, "%sNo CreateUser response\n", indent.c_str());
+ info += fmt::format("{}No CreateUser response\n", indent.c_str());
}
if (mSetUserIdentificationAssociationResponseFromCmd != nullptr) {
- dprintf(fd, "%sSetUserIdentificationAssociation response: %s\n", indent.c_str(),
+ info += fmt::format("{}SetUserIdentificationAssociation response: {}\n", indent.c_str(),
toString(*mSetUserIdentificationAssociationResponseFromCmd).c_str());
} else {
- dprintf(fd, "%sNo SetUserIdentificationAssociation response\n", indent.c_str());
+ info += fmt::format("{}No SetUserIdentificationAssociation response\n", indent.c_str());
}
+ return info;
}
} // namespace impl
diff --git a/emulator/vhal_v2_0/EmulatedUserHal.h b/emulator/vhal_v2_0/EmulatedUserHal.h
index db2f117..bc7e4c5 100644
--- a/emulator/vhal_v2_0/EmulatedUserHal.h
+++ b/emulator/vhal_v2_0/EmulatedUserHal.h
@@ -17,6 +17,7 @@
#ifndef android_hardware_automotive_vehicle_V2_0_impl_EmulatedUserHal_H_
#define android_hardware_automotive_vehicle_V2_0_impl_EmulatedUserHal_H_
+#include <android-base/format.h>
#include <android-base/result.h>
#include <android/hardware/automotive/vehicle/2.0/types.h>
@@ -64,12 +65,12 @@ class EmulatedUserHal {
/**
* Shows the User HAL emulation help.
*/
- void showDumpHelp(int fd);
+ std::string showDumpHelp();
/**
* Dump its contents.
*/
- void dump(int fd, std::string indent);
+ std::string dump(std::string indent);
private:
/**
diff --git a/emulator/vhal_v2_0/EmulatedVehicleConnector.cpp b/emulator/vhal_v2_0/EmulatedVehicleConnector.cpp
index f3383ce..946747d 100644
--- a/emulator/vhal_v2_0/EmulatedVehicleConnector.cpp
+++ b/emulator/vhal_v2_0/EmulatedVehicleConnector.cpp
@@ -61,32 +61,34 @@ StatusCode EmulatedVehicleConnector::onSetProperty(const VehiclePropValue& value
return this->EmulatedVehicleHalServer::onSetProperty(value, updateStatus);
}
-bool EmulatedVehicleConnector::onDump(const hidl_handle& handle,
- const hidl_vec<hidl_string>& options) {
- int fd = handle->data[0];
-
+IVehicleServer::DumpResult EmulatedVehicleConnector::onDump(
+ const std::vector<std::string>& options) {
+ DumpResult result;
if (options.size() > 0) {
if (options[0] == "--help") {
- dprintf(fd, "Emulator-specific usage:\n");
- mEmulatedUserHal.showDumpHelp(fd);
- dprintf(fd, "\n");
+ result.buffer += "Emulator-specific usage:\n";
+ result.buffer += mEmulatedUserHal.showDumpHelp();
+ result.buffer += "\n";
// Include caller's help options
- return true;
+ result.callerShouldDumpState = true;
+ return result;
} else if (options[0] == kUserHalDumpOption) {
- mEmulatedUserHal.dump(fd, "");
- return false;
+ result.buffer += mEmulatedUserHal.dump("");
+ result.callerShouldDumpState = false;
+ return result;
} else {
// Let caller handle the options...
- return true;
+ result.callerShouldDumpState = true;
+ return result;
}
}
- dprintf(fd, "Emulator-specific state:\n");
- mEmulatedUserHal.dump(fd, " ");
- dprintf(fd, "\n");
-
- return true;
+ result.buffer += "Emulator-specific state:\n";
+ result.buffer += mEmulatedUserHal.dump(" ");
+ result.buffer += "\n";
+ result.callerShouldDumpState = true;
+ return result;
}
} // namespace impl
diff --git a/emulator/vhal_v2_0/EmulatedVehicleConnector.h b/emulator/vhal_v2_0/EmulatedVehicleConnector.h
index dc6ccfa..cc02164 100644
--- a/emulator/vhal_v2_0/EmulatedVehicleConnector.h
+++ b/emulator/vhal_v2_0/EmulatedVehicleConnector.h
@@ -44,7 +44,7 @@ class EmulatedVehicleConnector
// Methods from EmulatedVehicleHalServer
StatusCode onSetProperty(const VehiclePropValue& value, bool updateStatus) override;
- bool onDump(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
+ DumpResult onDump(const std::vector<std::string>& options) override;
void triggerSendAllValues() { this->sendAllValuesToClient(); }