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/LocationVerifier.java b/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationVerifier.java
index 56a3b44..be0ef01 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationVerifier.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationVerifier.java
@@ -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 {
         @Override
         public void onLocationChanged(Location location) {
             if (!mRunning) return;
 
+            mActiveLocationArrive = true;
             mNumActiveUpdates++;
             scheduleTimeout();
 
@@ -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;
+            }
+
             mNumPassiveUpdates++;
             long timestamp = location.getTime();
             long delta = timestamp - mLastPassiveTimestamp;