Add host_supported to VHAL libs.
We need to build a FakeVehicleHardware impl on host, thus we need to add the host_supported option. Test: Local build on host. Bug: 328316981 Change-Id: Ia21d26640c465846423cab1a0ff8a283c798b92a
This commit is contained in:
parent
6c4bc494ee
commit
9d3513882a
16 changed files with 48 additions and 26 deletions
|
@ -60,5 +60,5 @@ aidl_interface {
|
||||||
},
|
},
|
||||||
|
|
||||||
],
|
],
|
||||||
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,4 +24,5 @@ cc_library_headers {
|
||||||
local_include_dirs: ["."],
|
local_include_dirs: ["."],
|
||||||
export_include_dirs: ["."],
|
export_include_dirs: ["."],
|
||||||
defaults: ["VehicleHalInterfaceDefaults"],
|
defaults: ["VehicleHalInterfaceDefaults"],
|
||||||
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ cc_library_headers {
|
||||||
local_include_dirs: ["."],
|
local_include_dirs: ["."],
|
||||||
export_include_dirs: ["."],
|
export_include_dirs: ["."],
|
||||||
defaults: ["VehicleHalInterfaceDefaults"],
|
defaults: ["VehicleHalInterfaceDefaults"],
|
||||||
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_library_headers {
|
cc_library_headers {
|
||||||
|
@ -32,4 +33,5 @@ cc_library_headers {
|
||||||
local_include_dirs: ["."],
|
local_include_dirs: ["."],
|
||||||
export_include_dirs: ["."],
|
export_include_dirs: ["."],
|
||||||
defaults: ["VehicleHalInterfaceDefaults"],
|
defaults: ["VehicleHalInterfaceDefaults"],
|
||||||
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ cc_library {
|
||||||
],
|
],
|
||||||
cflags: ["-DENABLE_VEHICLE_HAL_TEST_PROPERTIES"],
|
cflags: ["-DENABLE_VEHICLE_HAL_TEST_PROPERTIES"],
|
||||||
shared_libs: ["libjsoncpp"],
|
shared_libs: ["libjsoncpp"],
|
||||||
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_library_headers {
|
cc_library_headers {
|
||||||
|
|
|
@ -32,4 +32,5 @@ cc_library {
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
"libjsoncpp",
|
"libjsoncpp",
|
||||||
],
|
],
|
||||||
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ cc_library {
|
||||||
whole_static_libs: [
|
whole_static_libs: [
|
||||||
"wakeup_client_protos",
|
"wakeup_client_protos",
|
||||||
],
|
],
|
||||||
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_defaults {
|
cc_defaults {
|
||||||
|
|
|
@ -206,7 +206,7 @@ class FakeVehicleHardware : public IVehicleHardware {
|
||||||
EXCLUDES(mLock);
|
EXCLUDES(mLock);
|
||||||
// Load the config files in format '*.json' from the directory and parse the config files
|
// Load the config files in format '*.json' from the directory and parse the config files
|
||||||
// into a map from property ID to ConfigDeclarations.
|
// into a map from property ID to ConfigDeclarations.
|
||||||
void loadPropConfigsFromDir(const std::string& dirPath,
|
bool loadPropConfigsFromDir(const std::string& dirPath,
|
||||||
std::unordered_map<int32_t, ConfigDeclaration>* configs);
|
std::unordered_map<int32_t, ConfigDeclaration>* configs);
|
||||||
// Function to be called when a value change event comes from vehicle bus. In our fake
|
// Function to be called when a value change event comes from vehicle bus. In our fake
|
||||||
// implementation, this function is only called during "--inject-event" dump command.
|
// implementation, this function is only called during "--inject-event" dump command.
|
||||||
|
|
|
@ -363,7 +363,12 @@ bool FakeVehicleHardware::UseOverrideConfigDir() {
|
||||||
|
|
||||||
std::unordered_map<int32_t, ConfigDeclaration> FakeVehicleHardware::loadConfigDeclarations() {
|
std::unordered_map<int32_t, ConfigDeclaration> FakeVehicleHardware::loadConfigDeclarations() {
|
||||||
std::unordered_map<int32_t, ConfigDeclaration> configsByPropId;
|
std::unordered_map<int32_t, ConfigDeclaration> configsByPropId;
|
||||||
loadPropConfigsFromDir(mDefaultConfigDir, &configsByPropId);
|
bool defaultConfigLoaded = loadPropConfigsFromDir(mDefaultConfigDir, &configsByPropId);
|
||||||
|
if (!defaultConfigLoaded) {
|
||||||
|
// This cannot work without a valid default config.
|
||||||
|
ALOGE("Failed to load default config, exiting");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
if (UseOverrideConfigDir()) {
|
if (UseOverrideConfigDir()) {
|
||||||
loadPropConfigsFromDir(mOverrideConfigDir, &configsByPropId);
|
loadPropConfigsFromDir(mOverrideConfigDir, &configsByPropId);
|
||||||
}
|
}
|
||||||
|
@ -2378,30 +2383,35 @@ void FakeVehicleHardware::onValuesChangeCallback(std::vector<VehiclePropValue> v
|
||||||
(*mOnPropertyChangeCallback)(std::move(subscribedUpdatedValues));
|
(*mOnPropertyChangeCallback)(std::move(subscribedUpdatedValues));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVehicleHardware::loadPropConfigsFromDir(
|
bool FakeVehicleHardware::loadPropConfigsFromDir(
|
||||||
const std::string& dirPath,
|
const std::string& dirPath,
|
||||||
std::unordered_map<int32_t, ConfigDeclaration>* configsByPropId) {
|
std::unordered_map<int32_t, ConfigDeclaration>* configsByPropId) {
|
||||||
ALOGI("loading properties from %s", dirPath.c_str());
|
ALOGI("loading properties from %s", dirPath.c_str());
|
||||||
if (auto dir = opendir(dirPath.c_str()); dir != NULL) {
|
auto dir = opendir(dirPath.c_str());
|
||||||
std::regex regJson(".*[.]json", std::regex::icase);
|
if (dir == nullptr) {
|
||||||
while (auto f = readdir(dir)) {
|
ALOGE("Failed to open config directory: %s", dirPath.c_str());
|
||||||
if (!std::regex_match(f->d_name, regJson)) {
|
return false;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
std::string filePath = dirPath + "/" + std::string(f->d_name);
|
|
||||||
ALOGI("loading properties from %s", filePath.c_str());
|
|
||||||
auto result = mLoader.loadPropConfig(filePath);
|
|
||||||
if (!result.ok()) {
|
|
||||||
ALOGE("failed to load config file: %s, error: %s", filePath.c_str(),
|
|
||||||
result.error().message().c_str());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (auto& [propId, configDeclaration] : result.value()) {
|
|
||||||
(*configsByPropId)[propId] = std::move(configDeclaration);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
closedir(dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::regex regJson(".*[.]json", std::regex::icase);
|
||||||
|
while (auto f = readdir(dir)) {
|
||||||
|
if (!std::regex_match(f->d_name, regJson)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
std::string filePath = dirPath + "/" + std::string(f->d_name);
|
||||||
|
ALOGI("loading properties from %s", filePath.c_str());
|
||||||
|
auto result = mLoader.loadPropConfig(filePath);
|
||||||
|
if (!result.ok()) {
|
||||||
|
ALOGE("failed to load config file: %s, error: %s", filePath.c_str(),
|
||||||
|
result.error().message().c_str());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (auto& [propId, configDeclaration] : result.value()) {
|
||||||
|
(*configsByPropId)[propId] = std::move(configDeclaration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<float> FakeVehicleHardware::safelyParseFloat(int index, const std::string& s) {
|
Result<float> FakeVehicleHardware::safelyParseFloat(int index, const std::string& s) {
|
||||||
|
|
|
@ -29,4 +29,5 @@ cc_library {
|
||||||
"VehicleHalUtils",
|
"VehicleHalUtils",
|
||||||
],
|
],
|
||||||
export_static_lib_headers: ["VehicleHalUtils"],
|
export_static_lib_headers: ["VehicleHalUtils"],
|
||||||
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,4 +29,5 @@ cc_library {
|
||||||
"VehicleHalUtils",
|
"VehicleHalUtils",
|
||||||
],
|
],
|
||||||
export_static_lib_headers: ["VehicleHalUtils"],
|
export_static_lib_headers: ["VehicleHalUtils"],
|
||||||
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,4 +127,5 @@ cc_library_static {
|
||||||
cflags: [
|
cflags: [
|
||||||
"-Wno-unused-parameter",
|
"-Wno-unused-parameter",
|
||||||
],
|
],
|
||||||
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ cc_library {
|
||||||
],
|
],
|
||||||
defaults: ["VehicleHalDefaults"],
|
defaults: ["VehicleHalDefaults"],
|
||||||
export_static_lib_headers: ["VehicleHalUtils"],
|
export_static_lib_headers: ["VehicleHalUtils"],
|
||||||
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_test {
|
cc_test {
|
||||||
|
|
|
@ -30,4 +30,5 @@ cc_library_headers {
|
||||||
export_header_lib_headers: [
|
export_header_lib_headers: [
|
||||||
"VehicleHalUtilHeaders",
|
"VehicleHalUtilHeaders",
|
||||||
],
|
],
|
||||||
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,12 @@ cc_library {
|
||||||
local_include_dirs: ["include"],
|
local_include_dirs: ["include"],
|
||||||
export_include_dirs: ["include"],
|
export_include_dirs: ["include"],
|
||||||
defaults: ["VehicleHalDefaults"],
|
defaults: ["VehicleHalDefaults"],
|
||||||
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_library_headers {
|
cc_library_headers {
|
||||||
name: "VehicleHalUtilHeaders",
|
name: "VehicleHalUtilHeaders",
|
||||||
export_include_dirs: ["include"],
|
export_include_dirs: ["include"],
|
||||||
vendor: true,
|
vendor: true,
|
||||||
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,9 +172,7 @@ VhalResult<void> VehiclePropertyStore::writeValue(VehiclePropValuePool::Recyclab
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onValuesChangeCallback == nullptr && onValueChangeCallback == nullptr) {
|
if (onValuesChangeCallback == nullptr && onValueChangeCallback == nullptr) {
|
||||||
ALOGW("No callback registered, ignoring property update for propId: %" PRId32
|
// No callback registered.
|
||||||
", area ID: %" PRId32,
|
|
||||||
propId, areaId);
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ aidl_interface {
|
||||||
},
|
},
|
||||||
|
|
||||||
],
|
],
|
||||||
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
filegroup {
|
filegroup {
|
||||||
|
|
Loading…
Reference in a new issue