summaryrefslogtreecommitdiffstats
path: root/location
diff options
context:
space:
mode:
Diffstat (limited to 'location')
-rw-r--r--location/java/android/location/Geocoder.java17
-rw-r--r--location/java/android/location/GeocoderParams.aidl19
-rw-r--r--location/java/android/location/GeocoderParams.java92
-rw-r--r--location/java/android/location/IGeocodeProvider.aidl5
-rw-r--r--location/java/android/location/ILocationManager.aidl5
-rw-r--r--location/java/android/location/LocationManager.java76
-rw-r--r--location/java/android/location/LocationProviderImpl.java235
-rwxr-xr-xlocation/java/com/android/internal/location/GpsLocationProvider.java49
-rw-r--r--location/java/com/android/internal/location/GpsXtraDownloader.java5
9 files changed, 446 insertions, 57 deletions
diff --git a/location/java/android/location/Geocoder.java b/location/java/android/location/Geocoder.java
index 2ce1273..c325b1b 100644
--- a/location/java/android/location/Geocoder.java
+++ b/location/java/android/location/Geocoder.java
@@ -45,10 +45,7 @@ import java.util.List;
public final class Geocoder {
private static final String TAG = "Geocoder";
- private String mLanguage;
- private String mCountry;
- private String mVariant;
- private String mAppName;
+ private GeocoderParams mParams;
private ILocationManager mService;
/**
@@ -64,11 +61,7 @@ public final class Geocoder {
if (locale == null) {
throw new NullPointerException("locale == null");
}
- mLanguage = locale.getLanguage();
- mCountry = locale.getCountry();
- mVariant = locale.getVariant();
- mAppName = context.getPackageName();
-
+ mParams = new GeocoderParams(context, locale);
IBinder b = ServiceManager.getService(Context.LOCATION_SERVICE);
mService = ILocationManager.Stub.asInterface(b);
}
@@ -119,7 +112,7 @@ public final class Geocoder {
try {
List<Address> results = new ArrayList<Address>();
String ex = mService.getFromLocation(latitude, longitude, maxResults,
- mLanguage, mCountry, mVariant, mAppName, results);
+ mParams, results);
if (ex != null) {
throw new IOException(ex);
} else {
@@ -161,7 +154,7 @@ public final class Geocoder {
try {
List<Address> results = new ArrayList<Address>();
String ex = mService.getFromLocationName(locationName,
- 0, 0, 0, 0, maxResults, mLanguage, mCountry, mVariant, mAppName, results);
+ 0, 0, 0, 0, maxResults, mParams, results);
if (ex != null) {
throw new IOException(ex);
} else {
@@ -234,7 +227,7 @@ public final class Geocoder {
ArrayList<Address> result = new ArrayList<Address>();
String ex = mService.getFromLocationName(locationName,
lowerLeftLatitude, lowerLeftLongitude, upperRightLatitude, upperRightLongitude,
- maxResults, mLanguage, mCountry, mVariant, mAppName, result);
+ maxResults, mParams, result);
if (ex != null) {
throw new IOException(ex);
} else {
diff --git a/location/java/android/location/GeocoderParams.aidl b/location/java/android/location/GeocoderParams.aidl
new file mode 100644
index 0000000..2484e20
--- /dev/null
+++ b/location/java/android/location/GeocoderParams.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2010, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.location;
+
+parcelable GeocoderParams;
diff --git a/location/java/android/location/GeocoderParams.java b/location/java/android/location/GeocoderParams.java
new file mode 100644
index 0000000..8b8e63b
--- /dev/null
+++ b/location/java/android/location/GeocoderParams.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.location;
+
+import android.content.Context;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Locale;
+
+/**
+ * This class contains extra parameters to pass to an IGeocodeProvider
+ * implementation from the Geocoder class. Currently this contains the
+ * language, country and variant information from the Geocoder's locale
+ * as well as the Geocoder client's package name for geocoder server
+ * logging. This information is kept in a separate class to allow for
+ * future expansion of the IGeocodeProvider interface.
+ */
+public class GeocoderParams implements Parcelable {
+ private Locale mLocale;
+ private String mPackageName;
+
+ // used only for parcelling
+ private GeocoderParams() {
+ }
+
+ /**
+ * This object is only constructed by the Geocoder class
+ *
+ * @hide
+ */
+ public GeocoderParams(Context context, Locale locale) {
+ mLocale = locale;
+ mPackageName = context.getPackageName();
+ }
+
+ /**
+ * returns the Geocoder's locale
+ */
+ public Locale getLocale() {
+ return mLocale;
+ }
+
+ /**
+ * returns the package name of the Geocoder's client
+ */
+ public String getClientPackage() {
+ return mPackageName;
+ }
+
+ public static final Parcelable.Creator<GeocoderParams> CREATOR =
+ new Parcelable.Creator<GeocoderParams>() {
+ public GeocoderParams createFromParcel(Parcel in) {
+ GeocoderParams gp = new GeocoderParams();
+ String language = in.readString();
+ String country = in.readString();
+ String variant = in.readString();
+ gp.mLocale = new Locale(language, country, variant);
+ gp.mPackageName = in.readString();
+ return gp;
+ }
+
+ public GeocoderParams[] newArray(int size) {
+ return new GeocoderParams[size];
+ }
+ };
+
+ public int describeContents() {
+ return 0;
+ }
+
+ public void writeToParcel(Parcel parcel, int flags) {
+ parcel.writeString(mLocale.getLanguage());
+ parcel.writeString(mLocale.getCountry());
+ parcel.writeString(mLocale.getVariant());
+ parcel.writeString(mPackageName);
+ }
+}
diff --git a/location/java/android/location/IGeocodeProvider.aidl b/location/java/android/location/IGeocodeProvider.aidl
index e79e8d2..aaa70c7 100644
--- a/location/java/android/location/IGeocodeProvider.aidl
+++ b/location/java/android/location/IGeocodeProvider.aidl
@@ -17,6 +17,7 @@
package android.location;
import android.location.Address;
+import android.location.GeocoderParams;
/**
* An interface for location providers implementing the Geocoder services.
@@ -26,10 +27,10 @@ import android.location.Address;
interface IGeocodeProvider {
String getFromLocation(double latitude, double longitude, int maxResults,
- String language, String country, String variant, String appName, out List<Address> addrs);
+ in GeocoderParams params, out List<Address> addrs);
String getFromLocationName(String locationName,
double lowerLeftLatitude, double lowerLeftLongitude,
double upperRightLatitude, double upperRightLongitude, int maxResults,
- String language, String country, String variant, String appName, out List<Address> addrs);
+ in GeocoderParams params, out List<Address> addrs);
}
diff --git a/location/java/android/location/ILocationManager.aidl b/location/java/android/location/ILocationManager.aidl
index b6c59d6..1fac07c 100644
--- a/location/java/android/location/ILocationManager.aidl
+++ b/location/java/android/location/ILocationManager.aidl
@@ -18,6 +18,7 @@ package android.location;
import android.app.PendingIntent;
import android.location.Address;
+import android.location.GeocoderParams;
import android.location.IGeocodeProvider;
import android.location.IGpsStatusListener;
import android.location.ILocationListener;
@@ -63,11 +64,11 @@ interface ILocationManager
void reportLocation(in Location location);
String getFromLocation(double latitude, double longitude, int maxResults,
- String language, String country, String variant, String appName, out List<Address> addrs);
+ in GeocoderParams params, out List<Address> addrs);
String getFromLocationName(String locationName,
double lowerLeftLatitude, double lowerLeftLongitude,
double upperRightLatitude, double upperRightLongitude, int maxResults,
- String language, String country, String variant, String appName, out List<Address> addrs);
+ in GeocoderParams params, out List<Address> addrs);
void addTestProvider(String name, boolean requiresNetwork, boolean requiresSatellite,
boolean requiresCell, boolean hasMonetaryCost, boolean supportsAltitude,
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java
index 94ced22..6d7a23d 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -23,7 +23,6 @@ import android.os.Looper;
import android.os.RemoteException;
import android.os.Handler;
import android.os.Message;
-import android.util.Config;
import android.util.Log;
import com.android.internal.location.DummyLocationProvider;
@@ -105,6 +104,48 @@ public class LocationManager {
*/
public static final String KEY_LOCATION_CHANGED = "location";
+ public interface GeocodeProvider {
+ String getFromLocation(double latitude, double longitude, int maxResults,
+ GeocoderParams params, List<Address> addrs);
+
+ String getFromLocationName(String locationName,
+ double lowerLeftLatitude, double lowerLeftLongitude,
+ double upperRightLatitude, double upperRightLongitude, int maxResults,
+ GeocoderParams params, List<Address> addrs);
+ }
+
+ private static final class GeocodeProviderProxy extends IGeocodeProvider.Stub {
+ private GeocodeProvider mProvider;
+
+ GeocodeProviderProxy(GeocodeProvider provider) {
+ mProvider = provider;
+ }
+
+ /**
+ * This method is overridden to implement the
+ * {@link Geocoder#getFromLocation(double, double, int)} method.
+ * Classes implementing this method should not hold a reference to the params parameter.
+ */
+ public String getFromLocation(double latitude, double longitude, int maxResults,
+ GeocoderParams params, List<Address> addrs) {
+ return mProvider.getFromLocation(latitude, longitude, maxResults, params, addrs);
+ }
+
+ /**
+ * This method is overridden to implement the
+ * {@link Geocoder#getFromLocationName(String, int, double, double, double, double)} method.
+ * Classes implementing this method should not hold a reference to the params parameter.
+ */
+ public String getFromLocationName(String locationName,
+ double lowerLeftLatitude, double lowerLeftLongitude,
+ double upperRightLatitude, double upperRightLongitude, int maxResults,
+ GeocoderParams params, List<Address> addrs) {
+ return mProvider.getFromLocationName(locationName, lowerLeftLatitude,
+ lowerLeftLongitude, upperRightLatitude, upperRightLongitude,
+ maxResults, params, addrs);
+ }
+ }
+
// Map from LocationListeners to their associated ListenerTransport objects
private HashMap<LocationListener,ListenerTransport> mListeners =
new HashMap<LocationListener,ListenerTransport>();
@@ -206,7 +247,7 @@ public class LocationManager {
* factory Context.getSystemService.
*/
public LocationManager(ILocationManager service) {
- if (Config.LOGD) {
+ if (false) {
Log.d(TAG, "Constructor: service = " + service);
}
mService = service;
@@ -235,7 +276,7 @@ public class LocationManager {
* @return list of Strings containing names of the providers
*/
public List<String> getAllProviders() {
- if (Config.LOGD) {
+ if (false) {
Log.d(TAG, "getAllProviders");
}
try {
@@ -787,7 +828,7 @@ public class LocationManager {
if (listener == null) {
throw new IllegalArgumentException("listener==null");
}
- if (Config.LOGD) {
+ if (false) {
Log.d(TAG, "removeUpdates: listener = " + listener);
}
try {
@@ -812,7 +853,7 @@ public class LocationManager {
if (intent == null) {
throw new IllegalArgumentException("intent==null");
}
- if (Config.LOGD) {
+ if (false) {
Log.d(TAG, "removeUpdates: intent = " + intent);
}
try {
@@ -867,7 +908,7 @@ public class LocationManager {
*/
public void addProximityAlert(double latitude, double longitude,
float radius, long expiration, PendingIntent intent) {
- if (Config.LOGD) {
+ if (false) {
Log.d(TAG, "addProximityAlert: latitude = " + latitude +
", longitude = " + longitude + ", radius = " + radius +
", expiration = " + expiration +
@@ -888,7 +929,7 @@ public class LocationManager {
* proximity alerts
*/
public void removeProximityAlert(PendingIntent intent) {
- if (Config.LOGD) {
+ if (false) {
Log.d(TAG, "removeProximityAlert: intent = " + intent);
}
try {
@@ -1378,6 +1419,19 @@ public class LocationManager {
}
/**
+ * Installs a location provider.
+ *
+ * @param provider implementation of the location provider
+ *
+ * @return true if the command succeeds.
+ *
+ * Requires the android.permission.INSTALL_LOCATION_PROVIDER permission.
+ */
+ public boolean installLocationProvider(LocationProviderImpl provider) {
+ return installLocationProvider(provider.getName(), provider.getInterface());
+ }
+
+ /**
* Installs a geocoder server.
*
* @param provider Binder interface for the geocoder provider
@@ -1385,12 +1439,10 @@ public class LocationManager {
* @return true if the command succeeds.
*
* Requires the android.permission.INSTALL_LOCATION_PROVIDER permission.
- *
- * {@hide}
*/
- public boolean installGeocodeProvider(IGeocodeProvider provider) {
+ public boolean installGeocodeProvider(GeocodeProvider provider) {
try {
- mService.installGeocodeProvider(provider);
+ mService.installGeocodeProvider(new GeocodeProviderProxy(provider));
return true;
} catch (RemoteException e) {
Log.e(TAG, "RemoteException in setGeocodeProvider: ", e);
@@ -1404,8 +1456,6 @@ public class LocationManager {
* @param location new Location to report
*
* Requires the android.permission.INSTALL_LOCATION_PROVIDER permission.
- *
- * {@hide}
*/
public void reportLocation(Location location) {
try {
diff --git a/location/java/android/location/LocationProviderImpl.java b/location/java/android/location/LocationProviderImpl.java
new file mode 100644
index 0000000..9a3624e
--- /dev/null
+++ b/location/java/android/location/LocationProviderImpl.java
@@ -0,0 +1,235 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.location;
+
+import android.net.NetworkInfo;
+import android.os.Bundle;
+
+/**
+ * An abstract superclass for location providers that are implemented
+ * outside of the core android platform.
+ * A LocationProviderImpl can be installed using the
+ * {@link LocationManager#installLocationProvider(LocationProviderImpl)} method.
+ * Installing a location provider requires the
+ * android.permission.INSTALL_LOCATION_PROVIDER permission.
+ */
+public abstract class LocationProviderImpl extends LocationProvider {
+
+ private ILocationProvider.Stub mProvider = new ILocationProvider.Stub() {
+
+ public boolean requiresNetwork() {
+ return LocationProviderImpl.this.requiresNetwork();
+ }
+
+ public boolean requiresSatellite() {
+ return LocationProviderImpl.this.requiresSatellite();
+ }
+
+ public boolean requiresCell() {
+ return LocationProviderImpl.this.requiresCell();
+ }
+
+ public boolean hasMonetaryCost() {
+ return LocationProviderImpl.this.hasMonetaryCost();
+ }
+
+ public boolean supportsAltitude() {
+ return LocationProviderImpl.this.supportsAltitude();
+ }
+
+ public boolean supportsSpeed() {
+ return LocationProviderImpl.this.supportsSpeed();
+ }
+
+ public boolean supportsBearing() {
+ return LocationProviderImpl.this.supportsBearing();
+ }
+
+ public int getPowerRequirement() {
+ return LocationProviderImpl.this.getPowerRequirement();
+ }
+
+ public int getAccuracy() {
+ return LocationProviderImpl.this.getAccuracy();
+ }
+
+ public void enable() {
+ LocationProviderImpl.this.enable();
+ }
+
+ public void disable() {
+ LocationProviderImpl.this.disable();
+ }
+
+ public boolean isEnabled() {
+ return LocationProviderImpl.this.isEnabled();
+ }
+
+ public int getStatus(Bundle extras) {
+ return LocationProviderImpl.this.getStatus(extras);
+ }
+
+ public long getStatusUpdateTime() {
+ return LocationProviderImpl.this.getStatusUpdateTime();
+ }
+
+ public void enableLocationTracking(boolean enable) {
+ LocationProviderImpl.this.enableLocationTracking(enable);
+ }
+
+ public void setMinTime(long minTime) {
+ LocationProviderImpl.this.setMinTime(minTime);
+ }
+
+ public void updateNetworkState(int state, NetworkInfo info) {
+ LocationProviderImpl.this.updateNetworkState(state, info);
+ }
+
+ public void updateLocation(Location location) {
+ LocationProviderImpl.this.updateLocation(location);
+ }
+
+ public boolean sendExtraCommand(String command, Bundle extras) {
+ return LocationProviderImpl.this.sendExtraCommand(command, extras);
+ }
+
+ public void addListener(int uid) {
+ LocationProviderImpl.this.addListener(uid);
+ }
+
+ public void removeListener(int uid) {
+ LocationProviderImpl.this.removeListener(uid);
+ }
+ };
+
+ public LocationProviderImpl(String name) {
+ super(name);
+ }
+
+ /**
+ * {@hide}
+ */
+ /* package */ ILocationProvider getInterface() {
+ return mProvider;
+ }
+
+ /**
+ * Enables the location provider
+ */
+ public abstract void enable();
+
+ /**
+ * Disables the location provider
+ */
+ public abstract void disable();
+
+ /**
+ * Returns true if the provider is currently enabled
+ */
+ public abstract boolean isEnabled();
+
+ /**
+ * Returns a information on the status of this provider.
+ * {@link #OUT_OF_SERVICE} is returned if the provider is
+ * out of service, and this is not expected to change in the near
+ * future; {@link #TEMPORARILY_UNAVAILABLE} is returned if
+ * the provider is temporarily unavailable but is expected to be
+ * available shortly; and {@link #AVAILABLE} is returned
+ * if the provider is currently available.
+ *
+ * <p> If extras is non-null, additional status information may be
+ * added to it in the form of provider-specific key/value pairs.
+ */
+ public abstract int getStatus(Bundle extras);
+
+ /**
+ * Returns the time at which the status was last updated. It is the
+ * responsibility of the provider to appropriately set this value using
+ * {@link android.os.SystemClock#elapsedRealtime SystemClock.elapsedRealtime()}.
+ * there is a status update that it wishes to broadcast to all its
+ * listeners. The provider should be careful not to broadcast
+ * the same status again.
+ *
+ * @return time of last status update in millis since last reboot
+ */
+ public abstract long getStatusUpdateTime();
+
+ /**
+ * Notifies the location provider that clients are listening for locations.
+ * Called with enable set to true when the first client is added and
+ * called with enable set to false when the last client is removed.
+ * This allows the provider to prepare for receiving locations,
+ * and to shut down when no clients are remaining.
+ *
+ * @param enable true if location tracking should be enabled.
+ */
+ public abstract void enableLocationTracking(boolean enable);
+
+ /**
+ * Notifies the location provider of the smallest minimum time between updates amongst
+ * all clients that are listening for locations. This allows the provider to reduce
+ * the frequency of updates to match the requested frequency.
+ *
+ * @param minTime the smallest minTime value over all listeners for this provider.
+ */
+ public abstract void setMinTime(long minTime);
+
+ /**
+ * Updates the network state for the given provider. This function must
+ * be overwritten if {@link #requiresNetwork} returns true. The state is
+ * {@link #TEMPORARILY_UNAVAILABLE} (disconnected), OR {@link #AVAILABLE}
+ * (connected or connecting).
+ *
+ * @param state data state
+ */
+ public abstract void updateNetworkState(int state, NetworkInfo info);
+
+ /**
+ * Informs the provider when a new location has been computed by a different
+ * location provider. This is intended to be used as aiding data for the
+ * receiving provider.
+ *
+ * @param location new location from other location provider
+ */
+ public abstract void updateLocation(Location location);
+
+ /**
+ * Implements addditional location provider specific additional commands.
+ *
+ * @param command name of the command to send to the provider.
+ * @param extras optional arguments for the command (or null).
+ * The provider may optionally fill the extras Bundle with results from the command.
+ *
+ * @return true if the command succeeds.
+ */
+ public abstract boolean sendExtraCommand(String command, Bundle extras);
+
+ /**
+ * Notifies the location provider when a new client is listening for locations.
+ *
+ * @param uid user ID of the new client.
+ */
+ public abstract void addListener(int uid);
+
+ /**
+ * Notifies the location provider when a client is no longer listening for locations.
+ *
+ * @param uid user ID of the client no longer listening.
+ */
+ public abstract void removeListener(int uid);
+}
+
diff --git a/location/java/com/android/internal/location/GpsLocationProvider.java b/location/java/com/android/internal/location/GpsLocationProvider.java
index 134756e..9d67882 100755
--- a/location/java/com/android/internal/location/GpsLocationProvider.java
+++ b/location/java/com/android/internal/location/GpsLocationProvider.java
@@ -41,7 +41,6 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.provider.Settings;
-import android.util.Config;
import android.util.Log;
import android.util.SparseIntArray;
@@ -69,7 +68,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
private static final String TAG = "GpsLocationProvider";
- private static final boolean DEBUG = true;
+ private static final boolean DEBUG = false;
private static final boolean VERBOSE = false;
/**
@@ -380,7 +379,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
public void updateNetworkState(int state, NetworkInfo info) {
mNetworkAvailable = (state == LocationProvider.AVAILABLE);
- if (Config.LOGD) {
+ if (DEBUG) {
Log.d(TAG, "updateNetworkState " + (mNetworkAvailable ? "available" : "unavailable")
+ " info: " + info);
}
@@ -501,7 +500,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
* when the provider is enabled.
*/
public synchronized void enable() {
- if (Config.LOGD) Log.d(TAG, "enable");
+ if (DEBUG) Log.d(TAG, "enable");
if (mEnabled) return;
mEnabled = native_init();
@@ -537,7 +536,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
* down while the provider is disabled.
*/
public synchronized void disable() {
- if (Config.LOGD) Log.d(TAG, "disable");
+ if (DEBUG) Log.d(TAG, "disable");
if (!mEnabled) return;
mEnabled = false;
@@ -609,7 +608,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
}
public void setMinTime(long minTime) {
- if (Config.LOGD) Log.d(TAG, "setMinTime " + minTime);
+ if (DEBUG) Log.d(TAG, "setMinTime " + minTime);
if (minTime >= 0) {
int interval = (int)(minTime/1000);
@@ -630,7 +629,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
}
public void binderDied() {
- if (Config.LOGD) Log.d(TAG, "GPS status listener died");
+ if (DEBUG) Log.d(TAG, "GPS status listener died");
synchronized(mListeners) {
mListeners.remove(this);
@@ -728,7 +727,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
}
private boolean forceTimeInjection() {
- if (Config.LOGD) Log.d(TAG, "forceTimeInjection");
+ if (DEBUG) Log.d(TAG, "forceTimeInjection");
if (mNetworkThread != null) {
mNetworkThread.timeInjectRequest();
return true;
@@ -804,7 +803,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
// report time to first fix
if (mTTFF == 0 && (flags & LOCATION_HAS_LAT_LONG) == LOCATION_HAS_LAT_LONG) {
mTTFF = (int)(mLastFixTime - mFixRequestTime);
- if (Config.LOGD) Log.d(TAG, "TTFF: " + mTTFF);
+ if (DEBUG) Log.d(TAG, "TTFF: " + mTTFF);
// notify status listeners
synchronized(mListeners) {
@@ -1069,7 +1068,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
}
private void xtraDownloadRequest() {
- if (Config.LOGD) Log.d(TAG, "xtraDownloadRequest");
+ if (DEBUG) Log.d(TAG, "xtraDownloadRequest");
if (mNetworkThread != null) {
mNetworkThread.xtraDownloadRequest();
}
@@ -1086,7 +1085,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
StringBuilder extrasBuf = new StringBuilder();
- if (Config.LOGD) Log.d(TAG, "sendNiResponse, notifId: " + notificationId +
+ if (DEBUG) Log.d(TAG, "sendNiResponse, notifId: " + notificationId +
", response: " + userResponse);
native_send_ni_response(notificationId, userResponse);
@@ -1172,14 +1171,14 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
}
public void run() {
- if (Config.LOGD) Log.d(TAG, "GpsEventThread starting");
+ if (DEBUG) Log.d(TAG, "GpsEventThread starting");
// Exit as soon as disable() is called instead of waiting for the GPS to stop.
while (mEnabled) {
// this will wait for an event from the GPS,
// which will be reported via reportLocation or reportStatus
native_wait_for_event();
}
- if (Config.LOGD) Log.d(TAG, "GpsEventThread exiting");
+ if (DEBUG) Log.d(TAG, "GpsEventThread exiting");
}
}
@@ -1204,7 +1203,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
}
public void runLocked() {
- if (Config.LOGD) Log.d(TAG, "NetworkThread starting");
+ if (DEBUG) Log.d(TAG, "NetworkThread starting");
SntpClient client = new SntpClient();
GpsXtraDownloader xtraDownloader = null;
@@ -1220,18 +1219,17 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
synchronized (this) {
try {
if (!mNetworkAvailable) {
- if (Config.LOGD) Log.d(TAG,
- "NetworkThread wait for network");
+ if (DEBUG) Log.d(TAG, "NetworkThread wait for network");
wait();
} else if (waitTime > 0) {
- if (Config.LOGD) {
+ if (DEBUG) {
Log.d(TAG, "NetworkThread wait for " +
waitTime + "ms");
}
wait(waitTime);
}
} catch (InterruptedException e) {
- if (Config.LOGD) {
+ if (DEBUG) {
Log.d(TAG, "InterruptedException in GpsNetworkThread");
}
}
@@ -1240,12 +1238,11 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
} while (!mDone && ((!mXtraDownloadRequested &&
!mTimeInjectRequested && waitTime > 0)
|| !mNetworkAvailable));
- if (Config.LOGD) Log.d(TAG, "NetworkThread out of wake loop");
-
+ if (DEBUG) Log.d(TAG, "NetworkThread out of wake loop");
if (!mDone) {
if (mNtpServer != null &&
(mTimeInjectRequested || mNextNtpTime <= System.currentTimeMillis())) {
- if (Config.LOGD) {
+ if (DEBUG) {
Log.d(TAG, "Requesting time from NTP server " + mNtpServer);
}
mTimeInjectRequested = false;
@@ -1254,14 +1251,14 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
long timeReference = client.getNtpTimeReference();
int certainty = (int)(client.getRoundTripTime()/2);
- if (Config.LOGD) Log.d(TAG, "calling native_inject_time: " +
+ if (DEBUG) Log.d(TAG, "calling native_inject_time: " +
time + " reference: " + timeReference
+ " certainty: " + certainty);
native_inject_time(time, timeReference, certainty);
mNextNtpTime = System.currentTimeMillis() + NTP_INTERVAL;
} else {
- if (Config.LOGD) Log.d(TAG, "requestTime failed");
+ if (DEBUG) Log.d(TAG, "requestTime failed");
mNextNtpTime = System.currentTimeMillis() + RETRY_INTERVAL;
}
}
@@ -1272,7 +1269,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
mXtraDownloadRequested = false;
byte[] data = xtraDownloader.downloadXtraData();
if (data != null) {
- if (Config.LOGD) {
+ if (DEBUG) {
Log.d(TAG, "calling native_inject_xtra_data");
}
native_inject_xtra_data(data, data.length);
@@ -1283,7 +1280,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
}
}
}
- if (Config.LOGD) Log.d(TAG, "NetworkThread exiting");
+ if (DEBUG) Log.d(TAG, "NetworkThread exiting");
}
synchronized void xtraDownloadRequest() {
@@ -1301,7 +1298,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
}
synchronized void setDone() {
- if (Config.LOGD) Log.d(TAG, "stopping NetworkThread");
+ if (DEBUG) Log.d(TAG, "stopping NetworkThread");
mDone = true;
notify();
}
diff --git a/location/java/com/android/internal/location/GpsXtraDownloader.java b/location/java/com/android/internal/location/GpsXtraDownloader.java
index 33ebce7..02a9f48 100644
--- a/location/java/com/android/internal/location/GpsXtraDownloader.java
+++ b/location/java/com/android/internal/location/GpsXtraDownloader.java
@@ -32,10 +32,12 @@ import java.util.Random;
import android.content.Context;
import android.net.Proxy;
-import android.net.http.AndroidHttpClient;
import android.util.Config;
import android.util.Log;
+import com.android.common.AndroidHttpClient;
+
+
/**
* A class for downloading GPS XTRA data.
*
@@ -169,4 +171,3 @@ public class GpsXtraDownloader {
}
}
-