CHQTS: Convert nanoapps to use shared time_util.h constants

No functional change.

Bug: 111444635
Test: Compile only
Change-Id: I509f56cbd4a58b23b18de9268c15417f1ade646a
diff --git a/apps/chqts/src/general_test/basic_audio_test.cc b/apps/chqts/src/general_test/basic_audio_test.cc
index 01aabb1..7452c49 100644
--- a/apps/chqts/src/general_test/basic_audio_test.cc
+++ b/apps/chqts/src/general_test/basic_audio_test.cc
@@ -17,16 +17,15 @@
 #include <general_test/basic_audio_test.h>
 
 #include <shared/send_message.h>
+#include <shared/time_util.h>
 
+using nanoapp_testing::kOneSecondInNanoseconds;
 using nanoapp_testing::sendFatalFailureToHost;
 using nanoapp_testing::sendSuccessToHost;
 
 namespace general_test {
 namespace {
 
-//! Unit conversion nanoseconds per second.
-constexpr uint64_t kNanosecondsPerSecond = 1000000000;
-
 //! This is a reasonably high limit on the number of audio sources that a system
 //! would expose. Use this to verify that there are no gaps in the source
 //! handles.
@@ -50,12 +49,12 @@
 //! sample rate possible, a minimum number of samples will be delivered in
 //! a batch.
 constexpr uint64_t kMinBufferDuration =
-    (kNanosecondsPerSecond / kMaxAudioSampleRate) * 10;
+    (kOneSecondInNanoseconds / kMaxAudioSampleRate) * 10;
 
 //! Provide a ceiling for the maximum buffer duration. This is to catch buggy
 //! descriptors of audio sources who expose very long buffers of data which are
 //! not practical for always-on, low-power use-cases.
-constexpr uint64_t kMaxBufferDuration = kNanosecondsPerSecond * 120;
+constexpr uint64_t kMaxBufferDuration = kOneSecondInNanoseconds * 120;
 
 /**
  * @return true if the character is ASCII printable.
@@ -126,7 +125,7 @@
 bool validateMinimumAudioSource(const struct chreAudioSource& source) {
   // CHQTS requires a 16kHz, PCM-format, 2 second buffer.
   constexpr uint32_t kRequiredSampleRate = 16000;
-  constexpr uint64_t kRequiredBufferDuration = 2 * kNanosecondsPerSecond;
+  constexpr uint64_t kRequiredBufferDuration = 2 * kOneSecondInNanoseconds;
 
   // Ensure that the minimum buffer size is less than or equal to the required
   // size.
diff --git a/apps/chqts/src/general_test/basic_sensor_test_base.cc b/apps/chqts/src/general_test/basic_sensor_test_base.cc
index ec3aac0..f177433 100644
--- a/apps/chqts/src/general_test/basic_sensor_test_base.cc
+++ b/apps/chqts/src/general_test/basic_sensor_test_base.cc
@@ -20,10 +20,13 @@
 #include <cstddef>
 
 #include <shared/send_message.h>
+#include <shared/time_util.h>
 
 #include <chre.h>
 
 using nanoapp_testing::MessageType;
+using nanoapp_testing::kOneMillisecondInNanoseconds;
+using nanoapp_testing::kOneSecondInNanoseconds;
 using nanoapp_testing::sendFatalFailureToHost;
 using nanoapp_testing::sendInternalFailureToHost;
 using nanoapp_testing::sendStringToHost;
@@ -53,8 +56,7 @@
 namespace {
 constexpr uint16_t kStartEvent = CHRE_EVENT_FIRST_USER_VALUE;
 constexpr uint16_t kPassiveCompleteEvent = CHRE_EVENT_FIRST_USER_VALUE + 1;
-constexpr uint64_t kNanosecondsPerSecond = 1000000000;
-constexpr uint64_t kEventLoopSlack = 100000000;  // 100 msec
+constexpr uint64_t kEventLoopSlack = 100 * kOneMillisecondInNanoseconds;
 
 uint64_t getEventDuration(const chreSensorThreeAxisData *event) {
   uint64_t duration = 0;
@@ -121,19 +123,19 @@
   } else {
     if (!chreSensorConfigure(mSensorHandle, mode,
                              CHRE_SENSOR_INTERVAL_DEFAULT,
-                             kNanosecondsPerSecond)) {
+                             kOneSecondInNanoseconds)) {
       sendFatalFailureToHost("chreSensorConfigure() failed passive with "
                              "default interval and non-default latency");
     }
     if (!isOneShotSensor() && !chreSensorConfigure(
-        mSensorHandle, mode, kNanosecondsPerSecond,
+        mSensorHandle, mode, kOneSecondInNanoseconds,
         CHRE_SENSOR_LATENCY_DEFAULT)) {
       sendFatalFailureToHost("chreSensorConfigure() failed passive with "
                              "non-default interval and default latency");
     }
     if (!isOneShotSensor() && !chreSensorConfigure(
-        mSensorHandle, mode, kNanosecondsPerSecond,
-        kNanosecondsPerSecond)) {
+        mSensorHandle, mode, kOneSecondInNanoseconds,
+        kOneSecondInNanoseconds)) {
       sendFatalFailureToHost("chreSensorConfigure() failed passive with "
                              "non-default interval and latency");
     }
@@ -211,7 +213,7 @@
     //     from what it currently is for the sensor, and confirm it
     //     changes back when we're DONE.  But that's beyond the current
     //     scope of this 'basic' test.
-    kNanosecondsPerSecond, /* interval */
+    kOneSecondInNanoseconds, /* interval */
     // We want the test to run as quickly as possible.
     // TODO: Similar to the interval, we could try to test changes in
     //     this value, but it's beyond our 'basic' scope for now.
diff --git a/apps/chqts/src/general_test/heap_exhaustion_stability_test.cc b/apps/chqts/src/general_test/heap_exhaustion_stability_test.cc
index 9828a3a..0aae364 100644
--- a/apps/chqts/src/general_test/heap_exhaustion_stability_test.cc
+++ b/apps/chqts/src/general_test/heap_exhaustion_stability_test.cc
@@ -20,9 +20,12 @@
 #include <cstddef>
 
 #include <shared/send_message.h>
+#include <shared/time_util.h>
 
 #include <chre.h>
 
+using nanoapp_testing::kOneMillisecondInNanoseconds;
+using nanoapp_testing::kOneSecondInNanoseconds;
 using nanoapp_testing::sendFailureToHost;
 using nanoapp_testing::sendFatalFailureToHost;
 using nanoapp_testing::sendSuccessToHost;
@@ -49,10 +52,8 @@
 // Thus we make this "static const" instead of "constexpr", as we expect
 // them to have backing memory.
 
-// 5 seconds
-static const uint64_t kExhaustionDuration = UINT64_C(5000000000);
-// 10 milliseconds
-static const uint64_t kShortDuration = UINT64_C(10000000);
+static const uint64_t kExhaustionDuration = 5 * kOneSecondInNanoseconds;
+static const uint64_t kShortDuration = 10 * kOneMillisecondInNanoseconds;
 
 constexpr uint16_t kEventType = CHRE_EVENT_FIRST_USER_VALUE;
 
diff --git a/apps/chqts/src/general_test/timer_cancel_test.cc b/apps/chqts/src/general_test/timer_cancel_test.cc
index 689d868..6a2fa6c 100644
--- a/apps/chqts/src/general_test/timer_cancel_test.cc
+++ b/apps/chqts/src/general_test/timer_cancel_test.cc
@@ -20,9 +20,11 @@
 #include <cstddef>
 
 #include <shared/send_message.h>
+#include <shared/time_util.h>
 
 #include <chre.h>
 
+using nanoapp_testing::kOneMillisecondInNanoseconds;
 using nanoapp_testing::sendFatalFailureToHost;
 using nanoapp_testing::sendInternalFailureToHost;
 using nanoapp_testing::sendSuccessToHost;
@@ -36,8 +38,7 @@
  * When all of our stages have succeeded, then we send success to the host.
  */
 
-// 10 milliseconds
-static uint64_t kDuration = UINT64_C(10000000);
+static uint64_t kDuration = 10 * kOneMillisecondInNanoseconds;
 
 namespace general_test {
 
diff --git a/apps/chqts/src/general_test/timer_set_test.cc b/apps/chqts/src/general_test/timer_set_test.cc
index fb7165b..2a04e9a 100644
--- a/apps/chqts/src/general_test/timer_set_test.cc
+++ b/apps/chqts/src/general_test/timer_set_test.cc
@@ -21,9 +21,12 @@
 #include <new>
 
 #include <shared/send_message.h>
+#include <shared/time_util.h>
 
 #include <chre.h>
 
+using nanoapp_testing::kOneMillisecondInNanoseconds;
+using nanoapp_testing::kOneSecondInNanoseconds;
 using nanoapp_testing::sendFatalFailureToHost;
 using nanoapp_testing::sendInternalFailureToHost;
 using nanoapp_testing::sendSuccessToHost;
@@ -44,11 +47,8 @@
  * us more time to notice them (incorrectly) firing multiple times.
  */
 
-// 10 milliseconds
-static uint64_t kShortDuration = UINT64_C(10000000);
-// 1 second
-static uint64_t kOneSecond = UINT64_C(1000000000);
-static uint64_t kLongDuration = kOneSecond;
+static uint64_t kShortDuration = 10 * kOneMillisecondInNanoseconds;
+static uint64_t kLongDuration = kOneSecondInNanoseconds;
 
 namespace general_test {
 
@@ -79,7 +79,7 @@
     sendFatalFailureToHost("Timer triggered too soon ", &mStage);
   }
   // TODO(b/32179037): Make this check much stricter.
-  if (timestamp > (expectedTime + kOneSecond)) {
+  if (timestamp > (expectedTime + kOneSecondInNanoseconds)) {
     sendFatalFailureToHost("Timer triggered over a second late ", &mStage);
   }