dex2oat: Watchdog uses CLOCK_MONOTONIC instead of CLOCK_REALTIME

Keeping up with Watchdog in the system server, which uses CLOCK_MONOTONIC.

Test: mmma dex2oat

Change-Id: If8fadf1c12d6894a4844e394652134616734c382
Signed-off-by: liulvping <liulvping@xiaomi.com>
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index e6b7930..4fa8e5c 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -423,8 +423,12 @@
       : timeout_in_milliseconds_(timeout_in_milliseconds),
         shutting_down_(false) {
     const char* reason = "dex2oat watch dog thread startup";
+    pthread_condattr_t condattr;
     CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_init, (&mutex_, nullptr), reason);
-    CHECK_WATCH_DOG_PTHREAD_CALL(pthread_cond_init, (&cond_, nullptr), reason);
+    CHECK_WATCH_DOG_PTHREAD_CALL(pthread_condattr_init, (&condattr), reason);
+    CHECK_WATCH_DOG_PTHREAD_CALL(pthread_condattr_setclock, (&condattr, CLOCK_MONOTONIC), reason);
+    CHECK_WATCH_DOG_PTHREAD_CALL(pthread_cond_init, (&cond_, &condattr), reason);
+    CHECK_WATCH_DOG_PTHREAD_CALL(pthread_condattr_destroy, (&condattr), reason);
     CHECK_WATCH_DOG_PTHREAD_CALL(pthread_attr_init, (&attr_), reason);
     CHECK_WATCH_DOG_PTHREAD_CALL(pthread_create, (&pthread_, &attr_, &CallBack, this), reason);
     CHECK_WATCH_DOG_PTHREAD_CALL(pthread_attr_destroy, (&attr_), reason);
@@ -482,7 +486,7 @@
 
   void Wait() {
     timespec timeout_ts;
-    InitTimeSpec(true, CLOCK_REALTIME, timeout_in_milliseconds_, 0, &timeout_ts);
+    InitTimeSpec(true, CLOCK_MONOTONIC, timeout_in_milliseconds_, 0, &timeout_ts);
     const char* reason = "dex2oat watch dog thread waiting";
     CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_lock, (&mutex_), reason);
     while (!shutting_down_) {