summaryrefslogtreecommitdiffstats
path: root/location/java/com
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-02-09 08:46:14 -0500
committerMike Lockwood <lockwood@android.com>2010-02-10 09:41:25 -0500
commitd03ff94fe58045b5bd1dd783fb98026778a4265d (patch)
treec35d201ab498f23f075f1c48ce4ce3ce55e9f2e4 /location/java/com
parentca35953c9064114cb09181e8bffddb2f7c2d8d53 (diff)
downloadframeworks_base-d03ff94fe58045b5bd1dd783fb98026778a4265d.zip
frameworks_base-d03ff94fe58045b5bd1dd783fb98026778a4265d.tar.gz
frameworks_base-d03ff94fe58045b5bd1dd783fb98026778a4265d.tar.bz2
Clean up interface between LocationManagerService and the location providers:
LocationManagerService now uses new Java interface LocationProviderInterface rather than LocationProviderProxy to refer to location providers internally. LocationProviderProxy and the ILocationProvider binder interface are only used for location providers implemented as services (NetworkLocationProvider) Built-in location providers (GpsLocationProvider and mock providers) now just implement LocationProviderInterface rather than using a Binder interface and proxy object. Delete obsolete and unused TestLocationProvider class. Change-Id: Id800e7c1864f7c666f8e37125c05896493b9c8c4 Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'location/java/com')
-rwxr-xr-xlocation/java/com/android/internal/location/GpsLocationProvider.java15
-rw-r--r--location/java/com/android/internal/location/LocationProviderProxy.java16
-rw-r--r--location/java/com/android/internal/location/MockProvider.java12
3 files changed, 27 insertions, 16 deletions
diff --git a/location/java/com/android/internal/location/GpsLocationProvider.java b/location/java/com/android/internal/location/GpsLocationProvider.java
index 8b5f702..dce3b27 100755
--- a/location/java/com/android/internal/location/GpsLocationProvider.java
+++ b/location/java/com/android/internal/location/GpsLocationProvider.java
@@ -26,11 +26,11 @@ import android.location.Criteria;
import android.location.IGpsStatusListener;
import android.location.IGpsStatusProvider;
import android.location.ILocationManager;
-import android.location.ILocationProvider;
import android.location.INetInitiatedListener;
import android.location.Location;
import android.location.LocationManager;
import android.location.LocationProvider;
+import android.location.LocationProviderInterface;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.SntpClient;
@@ -65,7 +65,7 @@ import java.util.Map.Entry;
*
* {@hide}
*/
-public class GpsLocationProvider extends ILocationProvider.Stub {
+public class GpsLocationProvider implements LocationProviderInterface {
private static final String TAG = "GpsLocationProvider";
@@ -374,6 +374,13 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
}
/**
+ * Returns the name of this provider.
+ */
+ public String getName() {
+ return LocationManager.GPS_PROVIDER;
+ }
+
+ /**
* Returns true if the provider requires access to a
* data network (e.g., the Internet), false otherwise.
*/
@@ -576,6 +583,10 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
}
}
+ public boolean isEnabled() {
+ return mEnabled;
+ }
+
public int getStatus(Bundle extras) {
if (extras != null) {
extras.putInt("satellites", mSvCount);
diff --git a/location/java/com/android/internal/location/LocationProviderProxy.java b/location/java/com/android/internal/location/LocationProviderProxy.java
index 361104f..abb90b7 100644
--- a/location/java/com/android/internal/location/LocationProviderProxy.java
+++ b/location/java/com/android/internal/location/LocationProviderProxy.java
@@ -22,6 +22,7 @@ import android.content.Intent;
import android.content.ServiceConnection;
import android.location.ILocationProvider;
import android.location.Location;
+import android.location.LocationProviderInterface;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.Handler;
@@ -31,18 +32,17 @@ import android.os.SystemClock;
import android.util.Log;
/**
- * A class for proxying ILocationProvider implementations.
+ * A class for proxying location providers implemented as services.
*
* {@hide}
*/
-public class LocationProviderProxy {
+public class LocationProviderProxy implements LocationProviderInterface {
private static final String TAG = "LocationProviderProxy";
private final Context mContext;
private final String mName;
private ILocationProvider mProvider;
- private Intent mIntent;
private Handler mHandler;
private final Connection mServiceConnection = new Connection();
@@ -56,21 +56,13 @@ public class LocationProviderProxy {
// for caching requiresNetwork, requiresSatellite, etc.
private DummyLocationProvider mCachedAttributes;
- // constructor for proxying built-in location providers
- public LocationProviderProxy(Context context, String name, ILocationProvider provider) {
- mContext = context;
- mName = name;
- mProvider = provider;
- }
-
// constructor for proxying location providers implemented in a separate service
public LocationProviderProxy(Context context, String name, String serviceName,
Handler handler) {
mContext = context;
mName = name;
- mIntent = new Intent(serviceName);
mHandler = handler;
- mContext.bindService(mIntent, mServiceConnection, Context.BIND_AUTO_CREATE);
+ mContext.bindService(new Intent(serviceName), mServiceConnection, Context.BIND_AUTO_CREATE);
}
private class Connection implements ServiceConnection {
diff --git a/location/java/com/android/internal/location/MockProvider.java b/location/java/com/android/internal/location/MockProvider.java
index 7d9e86c..2f6fdee 100644
--- a/location/java/com/android/internal/location/MockProvider.java
+++ b/location/java/com/android/internal/location/MockProvider.java
@@ -17,9 +17,9 @@
package com.android.internal.location;
import android.location.ILocationManager;
-import android.location.ILocationProvider;
import android.location.Location;
import android.location.LocationProvider;
+import android.location.LocationProviderInterface;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.RemoteException;
@@ -33,7 +33,7 @@ import java.io.PrintWriter;
*
* {@hide}
*/
-public class MockProvider extends ILocationProvider.Stub {
+public class MockProvider implements LocationProviderInterface {
private final String mName;
private final ILocationManager mLocationManager;
private final boolean mRequiresNetwork;
@@ -73,6 +73,10 @@ public class MockProvider extends ILocationProvider.Stub {
mLocation = new Location(name);
}
+ public String getName() {
+ return mName;
+ }
+
public void disable() {
mEnabled = false;
}
@@ -81,6 +85,10 @@ public class MockProvider extends ILocationProvider.Stub {
mEnabled = true;
}
+ public boolean isEnabled() {
+ return mEnabled;
+ }
+
public int getStatus(Bundle extras) {
if (mHasStatus) {
extras.clear();