Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c279fe1 authored by Kai Wang's avatar Kai Wang Committed by Android (Google) Code Review
Browse files

Merge "Check timestamp before updating the value"

parents 160cf8e7 244e794f
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -50,13 +50,19 @@ bool VehiclePropertyStore::writeValue(const VehiclePropValue& propValue,
    VehiclePropValue* valueToUpdate = const_cast<VehiclePropValue*>(getValueOrNullLocked(recId));
    if (valueToUpdate == nullptr) {
        mPropertyValues.insert({ recId, propValue });
    } else {
        return true;
    }

    // propValue is outdated and drops it.
    if (valueToUpdate->timestamp > propValue.timestamp) {
        return false;
    }
    // update the propertyValue.
    valueToUpdate->timestamp = propValue.timestamp;
    valueToUpdate->value = propValue.value;
    if (updateStatus) {
        valueToUpdate->status = propValue.status;
    }
    }
    return true;
}

+1 −1
Original line number Diff line number Diff line
@@ -455,7 +455,7 @@ void EmulatedVehicleHal::onFakeValueGenerated(const VehiclePropValue& value) {

    VehiclePropValuePtr updatedPropValue = getValuePool()->obtain(value);
    if (updatedPropValue) {
        updatedPropValue->timestamp = elapsedRealtimeNano();
        updatedPropValue->timestamp = value.timestamp;
        updatedPropValue->status = VehiclePropertyStatus::AVAILABLE;
        mPropStore->writeValue(*updatedPropValue, shouldUpdateStatus);
        auto changeMode = mPropStore->getConfigOrDie(value.prop)->changeMode;