summaryrefslogtreecommitdiffstats
path: root/test-runner
diff options
context:
space:
mode:
authorMike Lockwood <>2009-04-03 08:24:43 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-04-03 08:24:43 -0700
commit4e50b78bda9cd58be61581d2886c88ff6348a1c1 (patch)
treee94551d77542bc0a06844d536e1eface70005dde /test-runner
parente84de8d702bd26fb1e5b55f3cfdd953d8a31ec22 (diff)
downloadframeworks_base-4e50b78bda9cd58be61581d2886c88ff6348a1c1.zip
frameworks_base-4e50b78bda9cd58be61581d2886c88ff6348a1c1.tar.gz
frameworks_base-4e50b78bda9cd58be61581d2886c88ff6348a1c1.tar.bz2
AI 144452: More Location Manager cleanup:
Remove 1 Hz "heartbeat" polling of location providers from LocationManagerService. Now location providers report their location to LocationManagerService via LocationManager.setLocation() rather than waiting to be polled. This reduces GPS fix latency by up to one second. Remove LocationProvderImpl.getLocation(). Since we are no longer polling, this method is no longer necessary. BUG=1729031 Automated import of CL 144452
Diffstat (limited to 'test-runner')
-rw-r--r--test-runner/android/test/TestLocationProvider.java64
1 files changed, 50 insertions, 14 deletions
diff --git a/test-runner/android/test/TestLocationProvider.java b/test-runner/android/test/TestLocationProvider.java
index 00c1ce8..69747d2 100644
--- a/test-runner/android/test/TestLocationProvider.java
+++ b/test-runner/android/test/TestLocationProvider.java
@@ -18,6 +18,7 @@ package android.test;
import android.location.Criteria;
+import android.location.ILocationManager;
import android.location.Location;
import android.location.LocationProviderImpl;
import android.os.Bundle;
@@ -36,14 +37,45 @@ public class TestLocationProvider extends LocationProviderImpl {
public static final float SPEED = 10;
public static final float BEARING = 1;
public static final int STATUS = AVAILABLE;
+ private static final long LOCATION_INTERVAL = 1000;
private Location mLocation;
private boolean mEnabled;
-
- public TestLocationProvider() {
- super(PROVIDER_NAME);
+ private TestLocationProviderThread mThread;
+
+ private class TestLocationProviderThread extends Thread {
+
+ private boolean mDone = false;
+
+ public TestLocationProviderThread() {
+ super("TestLocationProviderThread");
+ }
+
+ public void run() {
+ // thread exits after disable() is called
+ synchronized (this) {
+ while (!mDone) {
+ try {
+ wait(LOCATION_INTERVAL);
+ } catch (InterruptedException e) {
+ }
+
+ if (!mDone) {
+ TestLocationProvider.this.updateLocation();
+ }
+ }
+ }
+ }
+
+ synchronized void setDone() {
+ mDone = true;
+ notify();
+ }
+ }
+
+ public TestLocationProvider(ILocationManager locationManager) {
+ super(PROVIDER_NAME, locationManager);
mLocation = new Location(PROVIDER_NAME);
- updateLocation();
}
//LocationProvider methods
@@ -95,13 +127,23 @@ public class TestLocationProvider extends LocationProviderImpl {
//LocationProviderImpl methods
@Override
- public void disable() {
+ public synchronized void disable() {
mEnabled = false;
+ if (mThread != null) {
+ mThread.setDone();
+ try {
+ mThread.join();
+ } catch (InterruptedException e) {
+ }
+ mThread = null;
+ }
}
@Override
- public void enable() {
- mEnabled = true;
+ public synchronized void enable() {
+ mEnabled = true;
+ mThread = new TestLocationProviderThread();
+ mThread.start();
}
@Override
@@ -110,13 +152,6 @@ public class TestLocationProvider extends LocationProviderImpl {
}
@Override
- public boolean getLocation(Location l) {
- updateLocation();
- l.set(mLocation);
- return true;
- }
-
- @Override
public int getStatus(Bundle extras) {
return STATUS;
}
@@ -134,6 +169,7 @@ public class TestLocationProvider extends LocationProviderImpl {
extras.putInt("extraTest", 24);
mLocation.setExtras(extras);
mLocation.setTime(time);
+ reportLocationChanged(mLocation);
}
}