Преглед изворни кода

sm8450-common: gps: GNSS adapter: need to check validity of elapsed real time

1: Need to check the validity of elapased real time before
   marking it as valid
2: Increase the allowed time between two get boot time call
   from 10 micro seconds to 2 milli-seconds

Change-Id: If2f7ddb23ce72cb52f294ff44353f5c9a9421a9c
CRs-fixed: 3281559
Vrutti Patel пре 2 година
родитељ
комит
341ddf5768
2 измењених фајлова са 8 додато и 4 уклоњено
  1. 1 1
      gps/core/LocApiBase.cpp
  2. 7 3
      gps/gnss/GnssAdapter.cpp

+ 1 - 1
gps/core/LocApiBase.cpp

@@ -1171,7 +1171,7 @@ bool ElapsedRealtimeEstimator::getCurrentTime(
     struct timespec sinceBootTime = {};
     struct timespec sinceBootTimeTest = {};
     bool clockGetTimeSuccess = false;
-    const uint32_t MAX_TIME_DELTA_VALUE_NANOS = 10000;
+    const uint32_t MAX_TIME_DELTA_VALUE_NANOS = 2000000; // 2 milli-seconds
     const uint32_t MAX_GET_TIME_COUNT = 20;
     /* Attempt to get CLOCK_REALTIME and CLOCK_BOOTIME in succession without an interruption
     or context switch (for up to MAX_GET_TIME_COUNT times) to avoid errors in the calculation */

+ 7 - 3
gps/gnss/GnssAdapter.cpp

@@ -428,11 +428,15 @@ void GnssAdapter::fillElapsedRealTime(const GpsLocationExtended& locationExtende
         else if (out.timestamp > 0) {
             int64_t locationTimeNanos = (int64_t)out.timestamp * 1000000;
             bool isCurDataTimeTrustable = (out.timestamp % mLocPositionMode.min_interval == 0);
-            out.flags |= LOCATION_HAS_ELAPSED_REAL_TIME_BIT;
-            out.elapsedRealTime = mPositionElapsedRealTimeCal.getElapsedRealtimeEstimateNanos(
+            int64_t elapsedRealTime = mPositionElapsedRealTimeCal.getElapsedRealtimeEstimateNanos(
                     locationTimeNanos, isCurDataTimeTrustable,
                     (int64_t)mLocPositionMode.min_interval * 1000000);
-            out.elapsedRealTimeUnc = mPositionElapsedRealTimeCal.getElapsedRealtimeUncNanos();
+
+            if (elapsedRealTime != -1) {
+                out.flags |= LOCATION_HAS_ELAPSED_REAL_TIME_BIT;
+                out.elapsedRealTime = elapsedRealTime;
+                out.elapsedRealTimeUnc = mPositionElapsedRealTimeCal.getElapsedRealtimeUncNanos();
+            }
         }
 #endif //FEATURE_AUTOMOTIVE
     }