Merge "Calculate next update time in nanosecond" into qt-dev am: 29051a0302
am: 30a6ef599b
Change-Id: I2fb3c809b73855479e9fd64b63552be89a5f0f43
diff --git a/car-lib/src/com/android/car/internal/CarRatedFloatListeners.java b/car-lib/src/com/android/car/internal/CarRatedFloatListeners.java
index 60b6a62..93519d6 100644
--- a/car-lib/src/com/android/car/internal/CarRatedFloatListeners.java
+++ b/car-lib/src/com/android/car/internal/CarRatedFloatListeners.java
@@ -29,6 +29,7 @@
* @hide
*/
public class CarRatedFloatListeners<T> {
+ private static final float NANOSECOND_PER_SECOND = 1000 * 1000 * 1000;
private final Map<T, Float> mListenersToRate = new HashMap<>(4);
private final Map<T, Long> mListenersUpdateTime = new HashMap<>(4);
@@ -112,7 +113,7 @@
return true;
}
if (nextUpdateTime <= eventTimeStamp) {
- Float cycle = 1000 / updateRate;
+ Float cycle = NANOSECOND_PER_SECOND / updateRate;
nextUpdateTime = eventTimeStamp + cycle.longValue();
mListenersUpdateTime.put(listener, nextUpdateTime);
return true;