mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 06:22:53 +00:00
Merge "Added VehicleHal.dump()"
This commit is contained in:
committed by
Android (Google) Code Review
commit
ca7f21dc4e
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
#define LOG_TAG "automotive.vehicle@2.0-connector"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <utils/SystemClock.h>
|
||||
|
||||
@@ -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>();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -131,6 +131,10 @@ VehicleHal::VehiclePropValuePtr EmulatedVehicleHal::get(
|
||||
return v;
|
||||
}
|
||||
|
||||
bool EmulatedVehicleHal::dump(const hidl_handle& fd, const hidl_vec<hidl_string>& options) {
|
||||
return mVehicleClient->dump(fd, options);
|
||||
}
|
||||
|
||||
StatusCode EmulatedVehicleHal::set(const VehiclePropValue& propValue) {
|
||||
constexpr bool updateStatus = false;
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
StatusCode set(const VehiclePropValue& propValue) override;
|
||||
StatusCode subscribe(int32_t property, float sampleRate) override;
|
||||
StatusCode unsubscribe(int32_t property) override;
|
||||
bool dump(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
|
||||
|
||||
// Methods from EmulatedVehicleHalIface
|
||||
bool setPropertyFromVehicle(const VehiclePropValue& propValue) override;
|
||||
|
||||
Reference in New Issue
Block a user