Fix a type conversion bug.

Convert int64_t to long on x86 platform loses info.

Test: atest FakeVehicleHardwareTest on cf_gwear_x86.
Bug: 288376096
Change-Id: I8826e2c0ba6c3e26af858a1d8f1388b75d537082
This commit is contained in:
Yu Shan
2023-06-29 18:33:04 -07:00
parent 19af89541f
commit 76aaef448f
2 changed files with 2 additions and 2 deletions

View File

@@ -57,7 +57,7 @@ class LinearFakeValueGenerator : public FakeValueGenerator {
float dispersion; // Defines minimum and maximum value based on initial value.
float increment; // Value that we will be added to currentValue with each timer tick.
int64_t interval;
long lastEventTimestamp;
int64_t lastEventTimestamp;
};
GeneratorCfg mGenCfg;

View File

@@ -86,7 +86,7 @@ std::optional<VehiclePropValue> LinearFakeValueGenerator::nextEvent() {
if (mGenCfg.lastEventTimestamp == 0) {
mGenCfg.lastEventTimestamp = elapsedRealtimeNano();
} else {
long nextEventTime = mGenCfg.lastEventTimestamp + mGenCfg.interval;
int64_t nextEventTime = mGenCfg.lastEventTimestamp + mGenCfg.interval;
// Prevent overflow.
assert(nextEventTime > mGenCfg.lastEventTimestamp);
mGenCfg.lastEventTimestamp = nextEventTime;