summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictoria Lease <violets@google.com>2012-10-31 15:54:05 -0700
committerVictoria Lease <violets@google.com>2012-11-01 13:55:36 -0700
commit779b77455fc51382ecafa210b8a805d2a616da55 (patch)
treec8dbdaf9a7dc45be92fbef534f2ead9cd4b13039
parent03f7ebfeaadb3f03c9a9a6405276fb702ad11fe1 (diff)
downloadframeworks_base-779b77455fc51382ecafa210b8a805d2a616da55.zip
frameworks_base-779b77455fc51382ecafa210b8a805d2a616da55.tar.gz
frameworks_base-779b77455fc51382ecafa210b8a805d2a616da55.tar.bz2
fix NLP for COARSE applications, build FLP with SDK
In this commit, we provide a means for unbundled location providers to attach an EXTRA_NO_GPS_LOCATION to the Locations that they report. We also build FusedLocation against the SDK rather than the internal tree. Used in conjunction with I394ded497b8de40d1f85618bff282553cdf378cb to fix NLP for applications with only ACCESS_COARSE_LOCATION permission. Bug: 7453355 Change-Id: Ie696f7abff9ef5237740ab87fe9f537a1c812c54
-rw-r--r--location/java/android/location/Location.java8
-rw-r--r--location/lib/java/com/android/location/provider/LocationProviderBase.java17
-rw-r--r--packages/FusedLocation/Android.mk1
-rw-r--r--packages/FusedLocation/src/com/android/location/fused/FusionEngine.java22
4 files changed, 46 insertions, 2 deletions
diff --git a/location/java/android/location/Location.java b/location/java/android/location/Location.java
index f057ebc..4025a7b 100644
--- a/location/java/android/location/Location.java
+++ b/location/java/android/location/Location.java
@@ -60,11 +60,19 @@ public class Location implements Parcelable {
public static final int FORMAT_SECONDS = 2;
/**
+ * Bundle key for a version of the location that has been fed through
+ * LocationFudger. Allows location providers to flag locations as being
+ * safe for use with ACCESS_COARSE_LOCATION permission.
+ *
* @hide
*/
public static final String EXTRA_COARSE_LOCATION = "coarseLocation";
/**
+ * Bundle key for a version of the location containing no GPS data.
+ * Allows location providers to flag locations as being safe to
+ * feed to LocationFudger.
+ *
* @hide
*/
public static final String EXTRA_NO_GPS_LOCATION = "noGPSLocation";
diff --git a/location/lib/java/com/android/location/provider/LocationProviderBase.java b/location/lib/java/com/android/location/provider/LocationProviderBase.java
index b0e5d2c..8a5a739 100644
--- a/location/lib/java/com/android/location/provider/LocationProviderBase.java
+++ b/location/lib/java/com/android/location/provider/LocationProviderBase.java
@@ -23,6 +23,8 @@ import java.io.PrintWriter;
import android.content.Context;
import android.location.ILocationManager;
import android.location.Location;
+import android.location.LocationManager;
+import android.location.LocationRequest;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
@@ -58,6 +60,21 @@ public abstract class LocationProviderBase {
private final ProviderProperties mProperties;
private final IBinder mBinder;
+ /**
+ * Bundle key for a version of the location containing no GPS data.
+ * Allows location providers to flag locations as being safe to
+ * feed to LocationFudger.
+ */
+ public static final String EXTRA_NO_GPS_LOCATION = Location.EXTRA_NO_GPS_LOCATION;
+
+ /**
+ * Name of the Fused location provider.
+ *
+ * <p>This provider combines inputs for all possible location sources
+ * to provide the best possible Location fix.
+ */
+ public static final String FUSED_PROVIDER = LocationManager.FUSED_PROVIDER;
+
private final class Service extends ILocationProvider.Stub {
@Override
public void enable() {
diff --git a/packages/FusedLocation/Android.mk b/packages/FusedLocation/Android.mk
index 318782f..a81b9f1 100644
--- a/packages/FusedLocation/Android.mk
+++ b/packages/FusedLocation/Android.mk
@@ -23,5 +23,6 @@ LOCAL_JAVA_LIBRARIES := com.android.location.provider
LOCAL_PACKAGE_NAME := FusedLocation
LOCAL_CERTIFICATE := platform
+LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)
diff --git a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java
index 87d56fd..60de79c 100644
--- a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java
+++ b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java
@@ -20,6 +20,7 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.HashMap;
+import com.android.location.provider.LocationProviderBase;
import com.android.location.provider.ProviderRequestUnbundled;
import android.content.Context;
@@ -29,6 +30,7 @@ import android.location.LocationManager;
import android.location.LocationRequest;
import android.os.Bundle;
import android.os.Looper;
+import android.os.Parcelable;
import android.os.SystemClock;
import android.os.WorkSource;
import android.util.Log;
@@ -41,6 +43,7 @@ public class FusionEngine implements LocationListener {
private static final String TAG = "FusedLocation";
private static final String NETWORK = LocationManager.NETWORK_PROVIDER;
private static final String GPS = LocationManager.GPS_PROVIDER;
+ private static final String FUSED = LocationProviderBase.FUSED_PROVIDER;
public static final long SWITCH_ON_FRESHNESS_CLIFF_NS = 11 * 1000000000; // 11 seconds
@@ -72,6 +75,7 @@ public class FusionEngine implements LocationListener {
mStats.get(GPS).available = mLocationManager.isProviderEnabled(GPS);
mStats.put(NETWORK, new ProviderStats());
mStats.get(NETWORK).available = mLocationManager.isProviderEnabled(NETWORK);
+
}
public void init(Callback callback) {
@@ -226,10 +230,24 @@ public class FusionEngine implements LocationListener {
} else {
mFusedLocation = new Location(mNetworkLocation);
}
+ mFusedLocation.setProvider(FUSED);
if (mNetworkLocation != null) {
- mFusedLocation.setExtraLocation(Location.EXTRA_NO_GPS_LOCATION, mNetworkLocation);
+ // copy NO_GPS_LOCATION extra from mNetworkLocation into mFusedLocation
+ Bundle srcExtras = mNetworkLocation.getExtras();
+ if (srcExtras != null) {
+ Parcelable srcParcelable =
+ srcExtras.getParcelable(LocationProviderBase.EXTRA_NO_GPS_LOCATION);
+ if (srcParcelable instanceof Location) {
+ Bundle dstExtras = mFusedLocation.getExtras();
+ if (dstExtras == null) {
+ dstExtras = new Bundle();
+ mFusedLocation.setExtras(dstExtras);
+ }
+ dstExtras.putParcelable(LocationProviderBase.EXTRA_NO_GPS_LOCATION,
+ (Location) srcParcelable);
+ }
+ }
}
- mFusedLocation.setProvider(LocationManager.FUSED_PROVIDER);
mCallback.reportLocation(mFusedLocation);
}