location: Use ILocationProvider Binder interface for all location providers.
This change eliminates the LocationProviderImpl class which had been used
for location providers running in the system process.
Now the LocationProvider base class is only used to implement the
LocationManager.createProvider() method for retrieving provider information.
Added a new IGpsStatusProvider interface for providers that serve GPS status.
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/test-runner/android/test/TestLocationProvider.java b/test-runner/android/test/TestLocationProvider.java
index 0fc3d16..500786d 100644
--- a/test-runner/android/test/TestLocationProvider.java
+++ b/test-runner/android/test/TestLocationProvider.java
@@ -19,17 +19,19 @@
import android.location.Criteria;
import android.location.ILocationManager;
+import android.location.ILocationProvider;
import android.location.Location;
+import android.location.LocationProvider;
import android.os.Bundle;
+import android.os.RemoteException;
import android.os.SystemClock;
-
-import com.android.internal.location.LocationProviderImpl;
+import android.util.Log;
/**
* @hide - This is part of a framework that is under development and should not be used for
* active development.
*/
-public class TestLocationProvider extends LocationProviderImpl {
+public class TestLocationProvider extends ILocationProvider.Stub {
public static final String PROVIDER_NAME = "test";
public static final double LAT = 0;
@@ -37,9 +39,12 @@
public static final double ALTITUDE = 10000;
public static final float SPEED = 10;
public static final float BEARING = 1;
- public static final int STATUS = AVAILABLE;
+ public static final int STATUS = LocationProvider.AVAILABLE;
private static final long LOCATION_INTERVAL = 1000;
+ private static final String TAG = "TestLocationProvider";
+
+ private final ILocationManager mLocationManager;
private Location mLocation;
private boolean mEnabled;
private TestLocationProviderThread mThread;
@@ -75,59 +80,46 @@
}
public TestLocationProvider(ILocationManager locationManager) {
- super(PROVIDER_NAME, locationManager);
+ mLocationManager = locationManager;
mLocation = new Location(PROVIDER_NAME);
}
- //LocationProvider methods
-
- @Override
public int getAccuracy() {
return Criteria.ACCURACY_COARSE;
}
- @Override
public int getPowerRequirement() {
return Criteria.NO_REQUIREMENT;
}
- @Override
public boolean hasMonetaryCost() {
return false;
}
- @Override
public boolean requiresCell() {
return false;
}
- @Override
public boolean requiresNetwork() {
return false;
}
- @Override
public boolean requiresSatellite() {
return false;
}
- @Override
public boolean supportsAltitude() {
return true;
}
- @Override
public boolean supportsBearing() {
return true;
}
- @Override
public boolean supportsSpeed() {
return true;
}
- //LocationProviderImpl methods
- @Override
public synchronized void disable() {
mEnabled = false;
if (mThread != null) {
@@ -140,23 +132,49 @@
}
}
- @Override
public synchronized void enable() {
mEnabled = true;
mThread = new TestLocationProviderThread();
mThread.start();
}
- @Override
public boolean isEnabled() {
return mEnabled;
}
- @Override
public int getStatus(Bundle extras) {
return STATUS;
}
+ public long getStatusUpdateTime() {
+ return 0;
+ }
+
+ public void enableLocationTracking(boolean enable) {
+ }
+
+ public void setMinTime(long minTime) {
+ }
+
+ public void updateNetworkState(int state) {
+ }
+
+ public boolean sendExtraCommand(String command, Bundle extras) {
+ return false;
+ }
+
+ public void addListener(int uid) {
+ }
+
+ public void removeListener(int uid) {
+ }
+
+ public void wakeLockAcquired() {
+ }
+
+ public void wakeLockReleased() {
+ }
+
private void updateLocation() {
long time = SystemClock.uptimeMillis();
long multiplier = (time/5000)%500000;
@@ -170,7 +188,11 @@
extras.putInt("extraTest", 24);
mLocation.setExtras(extras);
mLocation.setTime(time);
- reportLocationChanged(mLocation);
+ try {
+ mLocationManager.setLocation(mLocation);
+ } catch (RemoteException e) {
+ Log.e(TAG, "RemoteException calling updateLocation");
+ }
}
}