From e9c3f04f8628883091ca0912dd50b80fb9560316 Mon Sep 17 00:00:00 2001 From: Baili Feng Date: Mon, 21 May 2018 19:55:18 +0800 Subject: [PATCH] Replace MONOTONIC clock with BOOTTIME clock MONOTONIC clock doesn't tick when device is in suspend mode. BOOTTIME clock handles suspend mode while. Change-Id: I14ce943ddfd409fcc5cb70acde0cd4f5c94d1058 CRs-Fixed: 2241735 --- core/SystemStatus.h | 6 +++--- gnss/GnssAdapter.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/SystemStatus.h b/core/SystemStatus.h index 1c3adc84..ff5e7548 100644 --- a/core/SystemStatus.h +++ b/core/SystemStatus.h @@ -71,10 +71,10 @@ public: static const uint32_t maxItem = 5; SystemStatusItemBase() { - struct timespec tv; - clock_gettime(CLOCK_MONOTONIC, &tv); + timeval tv; + gettimeofday(&tv, NULL); mUtcTime.tv_sec = tv.tv_sec; - mUtcTime.tv_nsec = tv.tv_nsec; + mUtcTime.tv_nsec = tv.tv_usec *1000ULL; mUtcReported = mUtcTime; }; virtual ~SystemStatusItemBase() {}; diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index d08bd447..9ab1fd6a 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -86,7 +86,7 @@ GnssAdapter::GnssAdapter() : pthread_condattr_t condAttr; pthread_condattr_init(&condAttr); - pthread_condattr_setclock(&condAttr, CLOCK_MONOTONIC); + pthread_condattr_setclock(&condAttr, CLOCK_BOOTTIME); pthread_cond_init(&mNiData.session.tCond, &condAttr); pthread_cond_init(&mNiData.sessionEs.tCond, &condAttr); pthread_condattr_destroy(&condAttr); @@ -2343,7 +2343,7 @@ static void* niThreadProc(void *args) pthread_mutex_lock(&pSession->tLock); /* Calculate absolute expire time */ - clock_gettime(CLOCK_MONOTONIC, &present_time); + clock_gettime(CLOCK_BOOTTIME, &present_time); expire_time.tv_sec = present_time.tv_sec + pSession->respTimeLeft; expire_time.tv_nsec = present_time.tv_nsec; LOC_LOGD("%s]: time out set for abs time %ld with delay %d sec",