summaryrefslogtreecommitdiffstats
path: root/automotive
diff options
context:
space:
mode:
authorEnrico Granata <egranata@google.com>2018-03-30 18:07:22 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-03-30 18:07:22 +0000
commite0bce7913b9fadbc7b4c30d6b6530aac4f7b45e3 (patch)
treec8d2d8421a5fb0657f29abded866a77c1cb18d07 /automotive
parent1f8a14fce5056ec78f316df42adc8806cdc54741 (diff)
parent8acfc2246ad4a0d5e76d47c029ee37900f9cc97f (diff)
downloadplatform_hardware_interfaces-e0bce7913b9fadbc7b4c30d6b6530aac4f7b45e3.tar.gz
platform_hardware_interfaces-e0bce7913b9fadbc7b4c30d6b6530aac4f7b45e3.tar.bz2
platform_hardware_interfaces-e0bce7913b9fadbc7b4c30d6b6530aac4f7b45e3.zip
Merge "Teach VehiclePropertyStore to not propagate the status value when a set() operation comes from Android" into pi-dev
Diffstat (limited to 'automotive')
-rw-r--r--automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehiclePropertyStore.h2
-rw-r--r--automotive/vehicle/2.0/default/common/src/VehiclePropertyStore.cpp7
-rw-r--r--automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp24
3 files changed, 24 insertions, 9 deletions
diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehiclePropertyStore.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehiclePropertyStore.h
index eda94b77dc..0a243fe352 100644
--- a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehiclePropertyStore.h
+++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehiclePropertyStore.h
@@ -67,7 +67,7 @@ public:
/* Stores provided value. Returns true if value was written returns false if config for
* example wasn't registered. */
- bool writeValue(const VehiclePropValue& propValue);
+ bool writeValue(const VehiclePropValue& propValue, bool updateStatus);
void removeValue(const VehiclePropValue& propValue);
void removeValuesForProperty(int32_t propId);
diff --git a/automotive/vehicle/2.0/default/common/src/VehiclePropertyStore.cpp b/automotive/vehicle/2.0/default/common/src/VehiclePropertyStore.cpp
index f2aa4210a2..94ace455cc 100644
--- a/automotive/vehicle/2.0/default/common/src/VehiclePropertyStore.cpp
+++ b/automotive/vehicle/2.0/default/common/src/VehiclePropertyStore.cpp
@@ -41,7 +41,8 @@ void VehiclePropertyStore::registerProperty(const VehiclePropConfig& config,
mConfigs.insert({ config.prop, RecordConfig { config, tokenFunc } });
}
-bool VehiclePropertyStore::writeValue(const VehiclePropValue& propValue) {
+bool VehiclePropertyStore::writeValue(const VehiclePropValue& propValue,
+ bool updateStatus) {
MuxGuard g(mLock);
if (!mConfigs.count(propValue.prop)) return false;
@@ -52,7 +53,9 @@ bool VehiclePropertyStore::writeValue(const VehiclePropValue& propValue) {
} else {
valueToUpdate->timestamp = propValue.timestamp;
valueToUpdate->value = propValue.value;
- valueToUpdate->status = propValue.status;
+ if (updateStatus) {
+ valueToUpdate->status = propValue.status;
+ }
}
return true;
}
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp
index d51576eb44..3979ac2113 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp
@@ -127,6 +127,8 @@ VehicleHal::VehiclePropValuePtr EmulatedVehicleHal::get(
}
StatusCode EmulatedVehicleHal::set(const VehiclePropValue& propValue) {
+ static constexpr bool shouldUpdateStatus = false;
+
if (propValue.prop == kGenerateFakeDataControllingProperty) {
StatusCode status = handleGenerateFakeDataRequest(propValue);
if (status != StatusCode::OK) {
@@ -177,7 +179,7 @@ StatusCode EmulatedVehicleHal::set(const VehiclePropValue& propValue) {
return StatusCode::NOT_AVAILABLE;
}
- if (!mPropStore->writeValue(propValue)) {
+ if (!mPropStore->writeValue(propValue, shouldUpdateStatus)) {
return StatusCode::INVALID_ARG;
}
@@ -199,6 +201,8 @@ static bool isDiagnosticProperty(VehiclePropConfig propConfig) {
// Parse supported properties list and generate vector of property values to hold current values.
void EmulatedVehicleHal::onCreate() {
+ static constexpr bool shouldUpdateStatus = true;
+
for (auto& it : kVehicleProperties) {
VehiclePropConfig cfg = it.config;
int32_t numAreas = cfg.areaConfigs.size();
@@ -240,7 +244,7 @@ void EmulatedVehicleHal::onCreate() {
} else {
prop.value = it.initialValue;
}
- mPropStore->writeValue(prop);
+ mPropStore->writeValue(prop, shouldUpdateStatus);
}
}
initObd2LiveFrame(*mPropStore->getConfigOrDie(OBD2_LIVE_FRAME));
@@ -300,6 +304,8 @@ bool EmulatedVehicleHal::isContinuousProperty(int32_t propId) const {
}
bool EmulatedVehicleHal::setPropertyFromVehicle(const VehiclePropValue& propValue) {
+ static constexpr bool shouldUpdateStatus = true;
+
if (propValue.prop == kGenerateFakeDataControllingProperty) {
StatusCode status = handleGenerateFakeDataRequest(propValue);
if (status != StatusCode::OK) {
@@ -307,7 +313,7 @@ bool EmulatedVehicleHal::setPropertyFromVehicle(const VehiclePropValue& propValu
}
}
- if (mPropStore->writeValue(propValue)) {
+ if (mPropStore->writeValue(propValue, shouldUpdateStatus)) {
doHalEvent(getValuePool()->obtain(propValue));
return true;
} else {
@@ -391,6 +397,8 @@ VehicleHal::VehiclePropValuePtr EmulatedVehicleHal::createHwInputKeyProp(
}
void EmulatedVehicleHal::onFakeValueGenerated(int32_t propId, float value) {
+ static constexpr bool shouldUpdateStatus = false;
+
VehiclePropValuePtr updatedPropValue {};
switch (getPropType(propId)) {
case VehiclePropertyType::FLOAT:
@@ -410,7 +418,7 @@ void EmulatedVehicleHal::onFakeValueGenerated(int32_t propId, float value) {
updatedPropValue->areaId = 0; // Add area support if necessary.
updatedPropValue->timestamp = elapsedRealtimeNano();
updatedPropValue->status = VehiclePropertyStatus::AVAILABLE;
- mPropStore->writeValue(*updatedPropValue);
+ mPropStore->writeValue(*updatedPropValue, shouldUpdateStatus);
auto changeMode = mPropStore->getConfigOrDie(propId)->changeMode;
if (VehiclePropertyChangeMode::ON_CHANGE == changeMode) {
doHalEvent(move(updatedPropValue));
@@ -439,16 +447,20 @@ void EmulatedVehicleHal::initStaticConfig() {
}
void EmulatedVehicleHal::initObd2LiveFrame(const VehiclePropConfig& propConfig) {
+ static constexpr bool shouldUpdateStatus = true;
+
auto liveObd2Frame = createVehiclePropValue(VehiclePropertyType::MIXED, 0);
auto sensorStore = fillDefaultObd2Frame(static_cast<size_t>(propConfig.configArray[0]),
static_cast<size_t>(propConfig.configArray[1]));
sensorStore->fillPropValue("", liveObd2Frame.get());
liveObd2Frame->prop = OBD2_LIVE_FRAME;
- mPropStore->writeValue(*liveObd2Frame);
+ mPropStore->writeValue(*liveObd2Frame, shouldUpdateStatus);
}
void EmulatedVehicleHal::initObd2FreezeFrame(const VehiclePropConfig& propConfig) {
+ static constexpr bool shouldUpdateStatus = true;
+
auto sensorStore = fillDefaultObd2Frame(static_cast<size_t>(propConfig.configArray[0]),
static_cast<size_t>(propConfig.configArray[1]));
@@ -460,7 +472,7 @@ void EmulatedVehicleHal::initObd2FreezeFrame(const VehiclePropConfig& propConfig
sensorStore->fillPropValue(dtc, freezeFrame.get());
freezeFrame->prop = OBD2_FREEZE_FRAME;
- mPropStore->writeValue(*freezeFrame);
+ mPropStore->writeValue(*freezeFrame, shouldUpdateStatus);
}
}