Merge "DO NOT MERGE Filter out the overdue location cases in GPS test" into jb-dev
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 fd226a6..6226cf6 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();
@@ -95,6 +97,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;
@@ -186,4 +197,4 @@
mProvider + " location change");
return true;
}
-}
\ No newline at end of file
+}