Filter out the overdue location cases in GPS test

Bug 7109051

Occasionally, passive listeners receive a overdue location.
The overdue location comes from previous test round, and it will
confuse calculation of time interval. Finally, the confused interval
is mistaken for a FAIL even though GPS works normally. For this reason,
we have to filter out the overdue location at beginning of test round.
We log that the overdue location was ignored.

Change-Id: I72bfc08b458e99805f60e8caac3c2594c77ad93f
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/location/ b/apps/CtsVerifier/src/com/android/cts/verifier/location/
index 56a3b44..be0ef01 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/location/
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/location/
@@ -45,12 +45,14 @@
     private int mNumActiveUpdates = 0;
     private int mNumPassiveUpdates = 0;
     private boolean mRunning = false;
+    private boolean mActiveLocationArrive = false;
     private class ActiveListener implements LocationListener {
         public void onLocationChanged(Location location) {
             if (!mRunning) return;
+            mActiveLocationArrive = true;
@@ -103,6 +105,15 @@
             if (!mRunning) return;
             if (!location.getProvider().equals(mProvider)) return;
+            // When a test round start, passive listener shouldn't recevice location before active listener.
+            // If this situation occurs, we treat this location as overdue location.
+            // (The overdue location comes from previous test round, it occurs occasionally)
+            // We have to skip it to prevent wrong calculation of time interval.
+            if (!mActiveLocationArrive) {
+                mCb.log("ignoring passive " + mProvider + " update");
+                return;
+            }
             long timestamp = location.getTime();
             long delta = timestamp - mLastPassiveTimestamp;