diff --git a/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp b/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp
index 91b4fa5..6ff393d 100644
--- a/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp
+++ b/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp
@@ -38,6 +38,10 @@
 using ::android::hardware::sensors::V1_0::SensorStatus;
 using ::android::hardware::sensors::V1_0::SharedMemType;
 using ::android::hardware::sensors::V1_0::Vec3;
+using std::chrono::duration_cast;
+using std::chrono::microseconds;
+using std::chrono::milliseconds;
+using std::chrono::nanoseconds;
 
 constexpr size_t kEventSize = static_cast<size_t>(SensorsEventFormatOffset::TOTAL_LENGTH);
 
@@ -67,9 +71,9 @@
     }
 
     void waitForFlushEvents(const std::vector<SensorInfo>& sensorsToWaitFor,
-                            int32_t numCallsToFlush, int64_t timeoutMs) {
+                            int32_t numCallsToFlush, milliseconds timeout) {
         std::unique_lock<std::recursive_mutex> lock(mFlushMutex);
-        mFlushCV.wait_for(lock, std::chrono::milliseconds(timeoutMs),
+        mFlushCV.wait_for(lock, timeout,
                           [&] { return flushesReceived(sensorsToWaitFor, numCallsToFlush); });
     }
 
@@ -78,10 +82,9 @@
         return mEventMap[sensorHandle];
     }
 
-    void waitForEvents(const std::vector<SensorInfo>& sensorsToWaitFor, int32_t timeoutMs) {
+    void waitForEvents(const std::vector<SensorInfo>& sensorsToWaitFor, milliseconds timeout) {
         std::unique_lock<std::recursive_mutex> lock(mEventMutex);
-        mEventCV.wait_for(lock, std::chrono::milliseconds(timeoutMs),
-                          [&] { return eventsReceived(sensorsToWaitFor); });
+        mEventCV.wait_for(lock, timeout, [&] { return eventsReceived(sensorsToWaitFor); });
     }
 
    protected:
@@ -372,7 +375,7 @@
     }
 
     // Wait for events to be written back to the Event FMQ
-    callback.waitForEvents(sensors, 1000 /* timeoutMs */);
+    callback.waitForEvents(sensors, milliseconds(1000) /* timeout */);
 
     for (const auto& s : sensors) {
         auto events = callback.getEvents(s.sensorHandle);
@@ -699,7 +702,7 @@
     }
 
     // Wait up to one second for the flush events
-    callback.waitForFlushEvents(sensors, flushCalls, 1000 /* timeoutMs */);
+    callback.waitForFlushEvents(sensors, flushCalls, milliseconds(1000) /* timeout */);
 
     // Deactivate all sensors after waiting for flush events so pending flush events are not
     // abandoned by the HAL.
@@ -820,17 +823,18 @@
 }
 
 TEST_F(SensorsHidlTest, NoStaleEvents) {
-    constexpr int64_t kFiveHundredMilliseconds = 500 * 1000;
-    constexpr int64_t kOneSecond = 1000 * 1000;
+    constexpr milliseconds kFiveHundredMs(500);
+    constexpr milliseconds kOneSecond(1000);
 
     // Register the callback to receive sensor events
     EventCallback callback;
     getEnvironment()->registerCallback(&callback);
 
     const std::vector<SensorInfo> sensors = getSensorsList();
-    int32_t maxMinDelay = 0;
+    milliseconds maxMinDelay(0);
     for (const SensorInfo& sensor : getSensorsList()) {
-        maxMinDelay = std::max(maxMinDelay, sensor.minDelay);
+        milliseconds minDelay = duration_cast<milliseconds>(microseconds(sensor.minDelay));
+        maxMinDelay = milliseconds(std::max(maxMinDelay.count(), minDelay.count()));
     }
 
     // Activate the sensors so that they start generating events
@@ -839,7 +843,7 @@
     // According to the CDD, the first sample must be generated within 400ms + 2 * sample_time
     // and the maximum reporting latency is 100ms + 2 * sample_time. Wait a sufficient amount
     // of time to guarantee that a sample has arrived.
-    callback.waitForEvents(sensors, kFiveHundredMilliseconds + (5 * maxMinDelay));
+    callback.waitForEvents(sensors, kFiveHundredMs + (5 * maxMinDelay));
     activateAllSensors(false);
 
     // Save the last received event for each sensor
@@ -851,21 +855,21 @@
     }
 
     // Allow some time to pass, reset the callback, then reactivate the sensors
-    usleep(kOneSecond + (5 * maxMinDelay));
+    usleep(duration_cast<microseconds>(kOneSecond + (5 * maxMinDelay)).count());
     callback.reset();
     activateAllSensors(true);
-    callback.waitForEvents(sensors, kFiveHundredMilliseconds + (5 * maxMinDelay));
+    callback.waitForEvents(sensors, kFiveHundredMs + (5 * maxMinDelay));
     activateAllSensors(false);
 
     for (const SensorInfo& sensor : sensors) {
         // Ensure that the first event received is not stale by ensuring that its timestamp is
         // sufficiently different from the previous event
         const Event newEvent = callback.getEvents(sensor.sensorHandle).front();
-        int64_t delta = newEvent.timestamp - lastEventTimestampMap[sensor.sensorHandle];
-        ASSERT_GE(delta, kFiveHundredMilliseconds + (3 * sensor.minDelay));
+        milliseconds delta = duration_cast<milliseconds>(
+                nanoseconds(newEvent.timestamp - lastEventTimestampMap[sensor.sensorHandle]));
+        milliseconds sensorMinDelay = duration_cast<milliseconds>(microseconds(sensor.minDelay));
+        ASSERT_GE(delta, kFiveHundredMs + (3 * sensorMinDelay));
     }
-
-    getEnvironment()->unregisterCallback();
 }
 
 void SensorsHidlTest::checkRateLevel(const SensorInfo& sensor, int32_t directChannelHandle,
