summaryrefslogtreecommitdiff
path: root/android/GnssDebug.cpp
diff options
context:
space:
mode:
authorBaili Feng <bailif@codeaurora.org>2018-01-08 16:21:29 +0800
committerBaili Feng <bailif@codeaurora.org>2018-04-10 08:24:34 +0800
commitd856a9414d745634c9dff7650a4d3dc48b8563f0 (patch)
tree5a596bcff98c58d78025c40170f6bddb7888c0f7 /android/GnssDebug.cpp
parentab95d2dc2e128793d6616f65916e40d25a82cedd (diff)
downloadgps-d856a9414d745634c9dff7650a4d3dc48b8563f0.tar.gz
hidl gnss hal 1.1 implementation
Implement new apis for IGnss 1.1 Change-Id: I2c98c32355f6d9681d51b709697e49ec735fe1cf CRs-fixed: 2133458
Diffstat (limited to 'android/GnssDebug.cpp')
-rw-r--r--android/GnssDebug.cpp55
1 files changed, 44 insertions, 11 deletions
diff --git a/android/GnssDebug.cpp b/android/GnssDebug.cpp
index 3d2b8bd..45cde6b 100644
--- a/android/GnssDebug.cpp
+++ b/android/GnssDebug.cpp
@@ -25,13 +25,19 @@
namespace android {
namespace hardware {
namespace gnss {
-namespace V1_0 {
+namespace V1_1 {
namespace implementation {
using ::android::hardware::hidl_vec;
-#define GNSS_DEBUG_UNKNOWN_UTC_TIME (1483228800000ULL) // 1/1/2017 00:00 GMT
-#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC (1.57783680E17) // 5 years in ns
+#define GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS (20000000)
+#define GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS (20000)
+#define GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC (500)
+#define GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG (180)
+
+#define GNSS_DEBUG_UNKNOWN_UTC_TIME (1483228800000LL) // 1/1/2017 00:00 GMT
+#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC (1.57783680E17) // 5 years in ns
+#define GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC (2.0e5) // ppm
GnssDebug::GnssDebug(Gnss* gnss) : mGnss(gnss)
{
@@ -79,16 +85,35 @@ Return<void> GnssDebug::getDebugData(getDebugData_cb _hidl_cb)
data.position.bearingAccuracyDegrees =
reports.mLocation.bearingAccuracyDegrees;
- struct timespec tv_now;
- clock_gettime(CLOCK_MONOTONIC, &tv_now);
+ 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);
data.position.ageSeconds =
- (tv_now.tv_sec - reports.mLocation.mUtcReported.tv_sec) +
- (float)((tv_now.tv_nsec - reports.mLocation.mUtcReported.tv_nsec)) / 1000000000LL;
+ (tv_now.tv_sec - tv_report.tv_sec) +
+ (float)((tv_now.tv_usec - tv_report.tv_usec)) / 1000000;
}
else {
data.position.valid = false;
}
+ if (data.position.horizontalAccuracyMeters <= 0 ||
+ data.position.horizontalAccuracyMeters > GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS) {
+ data.position.horizontalAccuracyMeters = GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS;
+ }
+ if (data.position.verticalAccuracyMeters <= 0 ||
+ data.position.verticalAccuracyMeters > GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS) {
+ data.position.verticalAccuracyMeters = GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS;
+ }
+ if (data.position.speedAccuracyMetersPerSecond <= 0 ||
+ data.position.speedAccuracyMetersPerSecond > GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC) {
+ data.position.speedAccuracyMetersPerSecond = GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC;
+ }
+ if (data.position.bearingAccuracyDegrees <= 0 ||
+ data.position.bearingAccuracyDegrees > GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG) {
+ data.position.bearingAccuracyDegrees = GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG;
+ }
+
// time block
if (reports.mTime.mValid) {
data.time.timeEstimate = reports.mTime.timeEstimate;
@@ -96,10 +121,18 @@ Return<void> GnssDebug::getDebugData(getDebugData_cb _hidl_cb)
data.time.frequencyUncertaintyNsPerSec =
reports.mTime.frequencyUncertaintyNsPerSec;
}
- else {
+
+ if (data.time.timeEstimate <= 0 ||
+ data.time.timeEstimate > GNSS_DEBUG_UNKNOWN_UTC_TIME) {
data.time.timeEstimate = GNSS_DEBUG_UNKNOWN_UTC_TIME;
- data.time.timeUncertaintyNs = (float)(GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC);
- data.time.frequencyUncertaintyNsPerSec = 0;
+ }
+ if (data.time.timeUncertaintyNs <= 0 ||
+ data.time.timeUncertaintyNs > (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC) {
+ data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC;
+ }
+ if (data.time.frequencyUncertaintyNsPerSec <= 0 ||
+ data.time.frequencyUncertaintyNsPerSec > (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC) {
+ data.time.frequencyUncertaintyNsPerSec = (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC;
}
// satellite data block
@@ -135,7 +168,7 @@ Return<void> GnssDebug::getDebugData(getDebugData_cb _hidl_cb)
}
} // namespace implementation
-} // namespace V1_0
+} // namespace V1_1
} // namespace gnss
} // namespace hardware
} // namespace android