Loading location/java/android/location/ILocationManager.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,9 @@ interface ILocationManager Location getLastKnownLocation(String provider); /* used by location providers to tell the location manager when it has a new location */ void setLocation(in Location location); String getFromLocation(double latitude, double longitude, int maxResults, String language, String country, String variant, String appName, out List<Address> addrs); String getFromLocationName(String locationName, Loading location/java/android/location/LocationProviderImpl.java +14 −12 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import java.util.HashMap; import java.util.List; import android.os.Bundle; import android.os.RemoteException; import android.util.Config; import android.util.Log; Loading @@ -46,11 +47,13 @@ public abstract class LocationProviderImpl extends LocationProvider { private static HashMap<String, LocationProviderImpl> sProvidersByName = new HashMap<String, LocationProviderImpl>(); private final ILocationManager mLocationManager; private boolean mLocationTracking = false; private long mMinTime = 0; protected LocationProviderImpl(String name) { protected LocationProviderImpl(String name, ILocationManager locationManager) { super(name); mLocationManager = locationManager; } public static void addProvider(LocationProviderImpl provider) { Loading Loading @@ -114,16 +117,24 @@ public abstract class LocationProviderImpl extends LocationProvider { return null; } public void reportLocationChanged(Location location) { try { mLocationManager.setLocation(location); } catch (RemoteException e) { Log.e(TAG, "RemoteException calling ILocationManager.onLocationChanged"); } } /** * Enables this provider. When enabled, calls to {@link #getStatus()} * and {@link #getLocation} must be handled. Hardware may be started up * must be handled. Hardware may be started up * when the provider is enabled. */ public abstract void enable(); /** * Disables this provider. When disabled, calls to {@link #getStatus()} * and {@link #getLocation} need not be handled. Hardware may be shut * need not be handled. Hardware may be shut * down while the provider is disabled. */ public abstract void disable(); Loading Loading @@ -174,15 +185,6 @@ public abstract class LocationProviderImpl extends LocationProvider { return 0; } /** * Sets a Location object with the information gathered * during the most recent fix. * * @param l location object to set * @return true if a location fix is available */ public abstract boolean getLocation(Location l); /** * Notifies the location provider that clients are listening for locations. * Called with enable set to true when the first client is added and Loading location/java/com/android/internal/location/GpsLocationProvider.java +7 −17 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.location.Criteria; import android.location.IGpsStatusListener; import android.location.ILocationManager; import android.location.Location; import android.location.LocationManager; import android.location.LocationProvider; Loading Loading @@ -209,8 +210,8 @@ public class GpsLocationProvider extends LocationProviderImpl { return native_is_supported(); } public GpsLocationProvider(Context context) { super(LocationManager.GPS_PROVIDER); public GpsLocationProvider(Context context, ILocationManager locationManager) { super(LocationManager.GPS_PROVIDER, locationManager); mContext = context; TelephonyBroadcastReceiver receiver = new TelephonyBroadcastReceiver(); Loading Loading @@ -355,7 +356,7 @@ public class GpsLocationProvider extends LocationProviderImpl { /** * Enables this provider. When enabled, calls to getStatus() * and getLocation() must be handled. Hardware may be started up * must be handled. Hardware may be started up * when the provider is enabled. */ @Override Loading Loading @@ -385,7 +386,7 @@ public class GpsLocationProvider extends LocationProviderImpl { /** * Disables this provider. When disabled, calls to getStatus() * and getLocation() need not be handled. Hardware may be shut * need not be handled. Hardware may be shut * down while the provider is disabled. */ @Override Loading Loading @@ -448,19 +449,6 @@ public class GpsLocationProvider extends LocationProviderImpl { return mStatusUpdateTime; } @Override public boolean getLocation(Location l) { synchronized (mLocation) { // don't report locations without latitude and longitude if ((mLocationFlags & LOCATION_HAS_LAT_LONG) == 0) { return false; } l.set(mLocation); l.setExtras(mLocationExtras); return true; } } @Override public void enableLocationTracking(boolean enable) { if (mLocationTracking == enable) { Loading Loading @@ -685,6 +673,8 @@ public class GpsLocationProvider extends LocationProviderImpl { mLocation.removeAccuracy(); } reportLocationChanged(mLocation); // Send to collector if ((flags & LOCATION_HAS_LAT_LONG) == LOCATION_HAS_LAT_LONG && mCollector != null) { Loading location/java/com/android/internal/location/INetworkLocationProvider.java +0 −5 Original line number Diff line number Diff line Loading @@ -20,12 +20,7 @@ import android.location.Address; import android.location.Location; import android.net.wifi.ScanResult; import com.google.common.io.protocol.ProtoBuf; import java.io.IOException; import java.util.Collection; import java.util.List; import java.util.Locale; /** * Interface for network location provider Loading location/java/com/android/internal/location/MockProvider.java +11 −34 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.location; import android.location.ILocationManager; import android.location.Location; import android.location.LocationProviderImpl; import android.os.Bundle; Loading Loading @@ -46,10 +47,11 @@ public class MockProvider extends LocationProviderImpl { private boolean mHasStatus; private boolean mEnabled; public MockProvider(String name, boolean requiresNetwork, boolean requiresSatellite, public MockProvider(String name, ILocationManager locationManager, boolean requiresNetwork, boolean requiresSatellite, boolean requiresCell, boolean hasMonetaryCost, boolean supportsAltitude, boolean supportsSpeed, boolean supportsBearing, int powerRequirement, int accuracy) { super(name); super(name, locationManager); mRequiresNetwork = requiresNetwork; mRequiresSatellite = requiresSatellite; Loading @@ -73,15 +75,6 @@ public class MockProvider extends LocationProviderImpl { mEnabled = true; } @Override public boolean getLocation(Location l) { if (mHasLocation) { l.set(mLocation); return true; } return false; } @Override public int getStatus(Bundle extras) { if (mHasStatus) { Loading @@ -93,6 +86,11 @@ public class MockProvider extends LocationProviderImpl { } } @Override public long getStatusUpdateTime() { return mStatusUpdateTime; } @Override public boolean isEnabled() { return mEnabled; Loading Loading @@ -146,6 +144,7 @@ public class MockProvider extends LocationProviderImpl { public void setLocation(Location l) { mLocation.set(l); mHasLocation = true; reportLocationChanged(mLocation); } public void clearLocation() { Loading @@ -164,29 +163,7 @@ public class MockProvider extends LocationProviderImpl { public void clearStatus() { mHasStatus = false; } public int overrideStatus(int status) { if (mHasStatus) { return mStatus; } else { return status; } } public long overrideStatusUpdateTime(long statusUpdateTime) { if (mHasStatus) { return mStatusUpdateTime; } else { return statusUpdateTime; } } public void overrideExtras(Bundle extras) { if (mHasStatus) { extras.clear(); extras.putAll(mExtras); } mStatusUpdateTime = 0; } public void dump(PrintWriter pw, String prefix) { Loading Loading
location/java/android/location/ILocationManager.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,9 @@ interface ILocationManager Location getLastKnownLocation(String provider); /* used by location providers to tell the location manager when it has a new location */ void setLocation(in Location location); String getFromLocation(double latitude, double longitude, int maxResults, String language, String country, String variant, String appName, out List<Address> addrs); String getFromLocationName(String locationName, Loading
location/java/android/location/LocationProviderImpl.java +14 −12 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import java.util.HashMap; import java.util.List; import android.os.Bundle; import android.os.RemoteException; import android.util.Config; import android.util.Log; Loading @@ -46,11 +47,13 @@ public abstract class LocationProviderImpl extends LocationProvider { private static HashMap<String, LocationProviderImpl> sProvidersByName = new HashMap<String, LocationProviderImpl>(); private final ILocationManager mLocationManager; private boolean mLocationTracking = false; private long mMinTime = 0; protected LocationProviderImpl(String name) { protected LocationProviderImpl(String name, ILocationManager locationManager) { super(name); mLocationManager = locationManager; } public static void addProvider(LocationProviderImpl provider) { Loading Loading @@ -114,16 +117,24 @@ public abstract class LocationProviderImpl extends LocationProvider { return null; } public void reportLocationChanged(Location location) { try { mLocationManager.setLocation(location); } catch (RemoteException e) { Log.e(TAG, "RemoteException calling ILocationManager.onLocationChanged"); } } /** * Enables this provider. When enabled, calls to {@link #getStatus()} * and {@link #getLocation} must be handled. Hardware may be started up * must be handled. Hardware may be started up * when the provider is enabled. */ public abstract void enable(); /** * Disables this provider. When disabled, calls to {@link #getStatus()} * and {@link #getLocation} need not be handled. Hardware may be shut * need not be handled. Hardware may be shut * down while the provider is disabled. */ public abstract void disable(); Loading Loading @@ -174,15 +185,6 @@ public abstract class LocationProviderImpl extends LocationProvider { return 0; } /** * Sets a Location object with the information gathered * during the most recent fix. * * @param l location object to set * @return true if a location fix is available */ public abstract boolean getLocation(Location l); /** * Notifies the location provider that clients are listening for locations. * Called with enable set to true when the first client is added and Loading
location/java/com/android/internal/location/GpsLocationProvider.java +7 −17 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.location.Criteria; import android.location.IGpsStatusListener; import android.location.ILocationManager; import android.location.Location; import android.location.LocationManager; import android.location.LocationProvider; Loading Loading @@ -209,8 +210,8 @@ public class GpsLocationProvider extends LocationProviderImpl { return native_is_supported(); } public GpsLocationProvider(Context context) { super(LocationManager.GPS_PROVIDER); public GpsLocationProvider(Context context, ILocationManager locationManager) { super(LocationManager.GPS_PROVIDER, locationManager); mContext = context; TelephonyBroadcastReceiver receiver = new TelephonyBroadcastReceiver(); Loading Loading @@ -355,7 +356,7 @@ public class GpsLocationProvider extends LocationProviderImpl { /** * Enables this provider. When enabled, calls to getStatus() * and getLocation() must be handled. Hardware may be started up * must be handled. Hardware may be started up * when the provider is enabled. */ @Override Loading Loading @@ -385,7 +386,7 @@ public class GpsLocationProvider extends LocationProviderImpl { /** * Disables this provider. When disabled, calls to getStatus() * and getLocation() need not be handled. Hardware may be shut * need not be handled. Hardware may be shut * down while the provider is disabled. */ @Override Loading Loading @@ -448,19 +449,6 @@ public class GpsLocationProvider extends LocationProviderImpl { return mStatusUpdateTime; } @Override public boolean getLocation(Location l) { synchronized (mLocation) { // don't report locations without latitude and longitude if ((mLocationFlags & LOCATION_HAS_LAT_LONG) == 0) { return false; } l.set(mLocation); l.setExtras(mLocationExtras); return true; } } @Override public void enableLocationTracking(boolean enable) { if (mLocationTracking == enable) { Loading Loading @@ -685,6 +673,8 @@ public class GpsLocationProvider extends LocationProviderImpl { mLocation.removeAccuracy(); } reportLocationChanged(mLocation); // Send to collector if ((flags & LOCATION_HAS_LAT_LONG) == LOCATION_HAS_LAT_LONG && mCollector != null) { Loading
location/java/com/android/internal/location/INetworkLocationProvider.java +0 −5 Original line number Diff line number Diff line Loading @@ -20,12 +20,7 @@ import android.location.Address; import android.location.Location; import android.net.wifi.ScanResult; import com.google.common.io.protocol.ProtoBuf; import java.io.IOException; import java.util.Collection; import java.util.List; import java.util.Locale; /** * Interface for network location provider Loading
location/java/com/android/internal/location/MockProvider.java +11 −34 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.location; import android.location.ILocationManager; import android.location.Location; import android.location.LocationProviderImpl; import android.os.Bundle; Loading Loading @@ -46,10 +47,11 @@ public class MockProvider extends LocationProviderImpl { private boolean mHasStatus; private boolean mEnabled; public MockProvider(String name, boolean requiresNetwork, boolean requiresSatellite, public MockProvider(String name, ILocationManager locationManager, boolean requiresNetwork, boolean requiresSatellite, boolean requiresCell, boolean hasMonetaryCost, boolean supportsAltitude, boolean supportsSpeed, boolean supportsBearing, int powerRequirement, int accuracy) { super(name); super(name, locationManager); mRequiresNetwork = requiresNetwork; mRequiresSatellite = requiresSatellite; Loading @@ -73,15 +75,6 @@ public class MockProvider extends LocationProviderImpl { mEnabled = true; } @Override public boolean getLocation(Location l) { if (mHasLocation) { l.set(mLocation); return true; } return false; } @Override public int getStatus(Bundle extras) { if (mHasStatus) { Loading @@ -93,6 +86,11 @@ public class MockProvider extends LocationProviderImpl { } } @Override public long getStatusUpdateTime() { return mStatusUpdateTime; } @Override public boolean isEnabled() { return mEnabled; Loading Loading @@ -146,6 +144,7 @@ public class MockProvider extends LocationProviderImpl { public void setLocation(Location l) { mLocation.set(l); mHasLocation = true; reportLocationChanged(mLocation); } public void clearLocation() { Loading @@ -164,29 +163,7 @@ public class MockProvider extends LocationProviderImpl { public void clearStatus() { mHasStatus = false; } public int overrideStatus(int status) { if (mHasStatus) { return mStatus; } else { return status; } } public long overrideStatusUpdateTime(long statusUpdateTime) { if (mHasStatus) { return mStatusUpdateTime; } else { return statusUpdateTime; } } public void overrideExtras(Bundle extras) { if (mHasStatus) { extras.clear(); extras.putAll(mExtras); } mStatusUpdateTime = 0; } public void dump(PrintWriter pw, String prefix) { Loading