Loading automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp +7 −6 Original line number Diff line number Diff line Loading @@ -1055,10 +1055,11 @@ VhalResult<void> FakeVehicleHardware::setValue(const VehiclePropValue& value) { } auto updatedValue = mValuePool->obtain(value); int64_t timestamp = elapsedRealtimeNano(); updatedValue->timestamp = timestamp; auto writeResult = mServerSidePropStore->writeValue(std::move(updatedValue)); auto writeResult = mServerSidePropStore->writeValue( std::move(updatedValue), /*updateStatus=*/false, /*mode=*/VehiclePropertyStore::EventMode::ON_VALUE_CHANGE, /*useCurrentTimestamp=*/true); if (!writeResult.ok()) { return StatusError(getErrorCode(writeResult)) << StringPrintf("failed to write value into property store, error: %s", Loading Loading @@ -2091,10 +2092,10 @@ StatusCode FakeVehicleHardware::subscribePropIdAreaIdLocked( // Failed to read current value, skip refreshing. return; } result.value()->timestamp = elapsedRealtimeNano(); mServerSidePropStore->writeValue(std::move(result.value()), /*updateStatus=*/true, eventMode); mServerSidePropStore->writeValue(std::move(result.value()), /*updateStatus=*/true, eventMode, /*useCurrentTimestamp=*/true); }); mRecurrentTimer->registerTimerCallback(intervalInNanos, action); mRecurrentActions[propIdAreaId] = action; Loading automotive/vehicle/aidl/impl/utils/common/include/VehiclePropertyStore.h +3 −1 Original line number Diff line number Diff line Loading @@ -100,9 +100,11 @@ class VehiclePropertyStore final { // override an existing value, the status for the existing value would be used for the // overridden value. // 'EventMode' controls whether the 'OnValueChangeCallback' will be called for this operation. // If 'useCurrentTimestamp' is true, the property value will be set to the current timestamp. VhalResult<void> writeValue(VehiclePropValuePool::RecyclableType propValue, bool updateStatus = false, EventMode mode = EventMode::ON_VALUE_CHANGE) EXCLUDES(mLock); EventMode mode = EventMode::ON_VALUE_CHANGE, bool useCurrentTimestamp = false) EXCLUDES(mLock); // Remove a given property value from the property store. The 'propValue' would be used to // generate the key for the value to remove. Loading automotive/vehicle/aidl/impl/utils/common/src/VehiclePropertyStore.cpp +9 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #define LOG_TAG "VehiclePropertyStore" #include <utils/Log.h> #include <utils/SystemClock.h> #include "VehiclePropertyStore.h" Loading Loading @@ -107,13 +108,20 @@ void VehiclePropertyStore::registerProperty(const VehiclePropConfig& config, VhalResult<void> VehiclePropertyStore::writeValue(VehiclePropValuePool::RecyclableType propValue, bool updateStatus, VehiclePropertyStore::EventMode eventMode) { VehiclePropertyStore::EventMode eventMode, bool useCurrentTimestamp) { bool valueUpdated = true; VehiclePropValue updatedValue; OnValueChangeCallback onValueChangeCallback = nullptr; { std::scoped_lock<std::mutex> g(mLock); // Must set timestamp inside the lock to make sure no other writeValue will update the // the timestamp to a newer one while we are writing this value. if (useCurrentTimestamp) { propValue->timestamp = elapsedRealtimeNano(); } int32_t propId = propValue->prop; VehiclePropertyStore::Record* record = getRecordLocked(propId); Loading Loading
automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp +7 −6 Original line number Diff line number Diff line Loading @@ -1055,10 +1055,11 @@ VhalResult<void> FakeVehicleHardware::setValue(const VehiclePropValue& value) { } auto updatedValue = mValuePool->obtain(value); int64_t timestamp = elapsedRealtimeNano(); updatedValue->timestamp = timestamp; auto writeResult = mServerSidePropStore->writeValue(std::move(updatedValue)); auto writeResult = mServerSidePropStore->writeValue( std::move(updatedValue), /*updateStatus=*/false, /*mode=*/VehiclePropertyStore::EventMode::ON_VALUE_CHANGE, /*useCurrentTimestamp=*/true); if (!writeResult.ok()) { return StatusError(getErrorCode(writeResult)) << StringPrintf("failed to write value into property store, error: %s", Loading Loading @@ -2091,10 +2092,10 @@ StatusCode FakeVehicleHardware::subscribePropIdAreaIdLocked( // Failed to read current value, skip refreshing. return; } result.value()->timestamp = elapsedRealtimeNano(); mServerSidePropStore->writeValue(std::move(result.value()), /*updateStatus=*/true, eventMode); mServerSidePropStore->writeValue(std::move(result.value()), /*updateStatus=*/true, eventMode, /*useCurrentTimestamp=*/true); }); mRecurrentTimer->registerTimerCallback(intervalInNanos, action); mRecurrentActions[propIdAreaId] = action; Loading
automotive/vehicle/aidl/impl/utils/common/include/VehiclePropertyStore.h +3 −1 Original line number Diff line number Diff line Loading @@ -100,9 +100,11 @@ class VehiclePropertyStore final { // override an existing value, the status for the existing value would be used for the // overridden value. // 'EventMode' controls whether the 'OnValueChangeCallback' will be called for this operation. // If 'useCurrentTimestamp' is true, the property value will be set to the current timestamp. VhalResult<void> writeValue(VehiclePropValuePool::RecyclableType propValue, bool updateStatus = false, EventMode mode = EventMode::ON_VALUE_CHANGE) EXCLUDES(mLock); EventMode mode = EventMode::ON_VALUE_CHANGE, bool useCurrentTimestamp = false) EXCLUDES(mLock); // Remove a given property value from the property store. The 'propValue' would be used to // generate the key for the value to remove. Loading
automotive/vehicle/aidl/impl/utils/common/src/VehiclePropertyStore.cpp +9 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #define LOG_TAG "VehiclePropertyStore" #include <utils/Log.h> #include <utils/SystemClock.h> #include "VehiclePropertyStore.h" Loading Loading @@ -107,13 +108,20 @@ void VehiclePropertyStore::registerProperty(const VehiclePropConfig& config, VhalResult<void> VehiclePropertyStore::writeValue(VehiclePropValuePool::RecyclableType propValue, bool updateStatus, VehiclePropertyStore::EventMode eventMode) { VehiclePropertyStore::EventMode eventMode, bool useCurrentTimestamp) { bool valueUpdated = true; VehiclePropValue updatedValue; OnValueChangeCallback onValueChangeCallback = nullptr; { std::scoped_lock<std::mutex> g(mLock); // Must set timestamp inside the lock to make sure no other writeValue will update the // the timestamp to a newer one while we are writing this value. if (useCurrentTimestamp) { propValue->timestamp = elapsedRealtimeNano(); } int32_t propId = propValue->prop; VehiclePropertyStore::Record* record = getRecordLocked(propId); Loading