From 47a9378d4decf802a1715653f1aef8b8a97d5aa5 Mon Sep 17 00:00:00 2001 From: Kai Date: Wed, 26 Feb 2020 13:00:16 -0800 Subject: [PATCH] Add timestamp for continuously property. Bug: 148960132 Test: 1. apply google vhal to device 2. atest CtsCarTestCases:CarPropertyManagerTest Change-Id: Ib6690b5e242287958017c87632f56a546d418674 --- .../vehicle/2.0/default/common/src/VehiclePropertyStore.cpp | 2 ++ .../2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/automotive/vehicle/2.0/default/common/src/VehiclePropertyStore.cpp b/automotive/vehicle/2.0/default/common/src/VehiclePropertyStore.cpp index 24b777c75f..6087bfa526 100644 --- a/automotive/vehicle/2.0/default/common/src/VehiclePropertyStore.cpp +++ b/automotive/vehicle/2.0/default/common/src/VehiclePropertyStore.cpp @@ -58,6 +58,8 @@ bool VehiclePropertyStore::writeValue(const VehiclePropValue& propValue, return false; } // update the propertyValue. + // The timestamp in propertyStore should only be updated by the server side. It indicates + // the time when the event is generated by the server. valueToUpdate->timestamp = propValue.timestamp; valueToUpdate->value = propValue.value; if (updateStatus) { 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 692c7f791f..7ffa8bad08 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,7 +127,9 @@ VehicleHal::VehiclePropValuePtr EmulatedVehicleHal::get( *outStatus = v != nullptr ? StatusCode::OK : StatusCode::INVALID_ARG; break; } - + if (v.get()) { + v->timestamp = elapsedRealtimeNano(); + } return v; } @@ -284,6 +286,7 @@ void EmulatedVehicleHal::onContinuousPropertyTimer(const std::vector& p } if (v.get()) { + v->timestamp = elapsedRealtimeNano(); doHalEvent(std::move(v)); } }