diff options
author | Baili Feng <bailif@codeaurora.org> | 2017-12-05 16:59:41 +0800 |
---|---|---|
committer | Baili Feng <bailif@codeaurora.org> | 2017-12-05 16:59:41 +0800 |
commit | edcf00043593e125ccc798a70fb6ce2c9318444b (patch) | |
tree | 44558b815a31d53c55d02f006b8877f8a3b074c1 /android | |
parent | 6ccaa83f60d0014b1c6414ef380a7d3a456a678b (diff) | |
download | gps-edcf00043593e125ccc798a70fb6ce2c9318444b.tar.gz |
Replace wall time
Replace gettimeofday with clock_gettime
CRs-fixed: 2144315
Change-Id: Ie8472d2aedcd0e63b86cc5ff100ce9bb28fd670c
Diffstat (limited to 'android')
-rw-r--r-- | android/GnssDebug.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/android/GnssDebug.cpp b/android/GnssDebug.cpp index ff467d3..3d2b8bd 100644 --- a/android/GnssDebug.cpp +++ b/android/GnssDebug.cpp @@ -79,13 +79,11 @@ Return<void> GnssDebug::getDebugData(getDebugData_cb _hidl_cb) data.position.bearingAccuracyDegrees = reports.mLocation.bearingAccuracyDegrees; - timeval tv_now, tv_report; - tv_report.tv_sec = reports.mLocation.mUtcReported.tv_sec; - tv_report.tv_usec = reports.mLocation.mUtcReported.tv_nsec / 1000ULL; - gettimeofday(&tv_now, NULL); + struct timespec tv_now; + clock_gettime(CLOCK_MONOTONIC, &tv_now); data.position.ageSeconds = - (tv_now.tv_sec - tv_report.tv_sec) + - (float)((tv_now.tv_usec - tv_report.tv_usec)) / 1000000; + (tv_now.tv_sec - reports.mLocation.mUtcReported.tv_sec) + + (float)((tv_now.tv_nsec - reports.mLocation.mUtcReported.tv_nsec)) / 1000000000LL; } else { data.position.valid = false; |