summaryrefslogtreecommitdiffstats
path: root/packages/FusedLocation
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 /packages/FusedLocation
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
Diffstat (limited to 'packages/FusedLocation')
-rw-r--r--packages/FusedLocation/Android.mk1
-rw-r--r--packages/FusedLocation/src/com/android/location/fused/FusionEngine.java22
2 files changed, 21 insertions, 2 deletions
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);
}