Loading location/java/android/location/Location.java +8 −0 Original line number Diff line number Diff line Loading @@ -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"; Loading location/lib/java/com/android/location/provider/LocationProviderBase.java +17 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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() { Loading packages/FusedLocation/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -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) packages/FusedLocation/src/com/android/location/fused/FusionEngine.java +20 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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 Loading Loading @@ -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) { Loading Loading @@ -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); } Loading Loading
location/java/android/location/Location.java +8 −0 Original line number Diff line number Diff line Loading @@ -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"; Loading
location/lib/java/com/android/location/provider/LocationProviderBase.java +17 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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() { Loading
packages/FusedLocation/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -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)
packages/FusedLocation/src/com/android/location/fused/FusionEngine.java +20 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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 Loading Loading @@ -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) { Loading Loading @@ -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); } Loading