summaryrefslogtreecommitdiffstats
path: root/location/java
diff options
context:
space:
mode:
Diffstat (limited to 'location/java')
-rw-r--r--location/java/android/location/GpsClock.java3
-rw-r--r--location/java/android/location/GpsMeasurement.java2
-rw-r--r--location/java/android/location/GpsMeasurementListenerTransport.java17
-rw-r--r--location/java/android/location/GpsMeasurementsEvent.java34
-rw-r--r--location/java/android/location/GpsNavigationMessage.java2
-rw-r--r--location/java/android/location/GpsNavigationMessageEvent.java33
-rw-r--r--location/java/android/location/GpsNavigationMessageListenerTransport.java18
-rw-r--r--location/java/android/location/IGpsMeasurementsListener.aidl1
-rw-r--r--location/java/android/location/IGpsNavigationMessageListener.aidl1
-rw-r--r--location/java/android/location/ILocationManager.aidl4
-rw-r--r--location/java/android/location/LocalListenerHelper.java25
-rw-r--r--location/java/android/location/LocationManager.java8
12 files changed, 121 insertions, 27 deletions
diff --git a/location/java/android/location/GpsClock.java b/location/java/android/location/GpsClock.java
index 963b604..22ac1a9 100644
--- a/location/java/android/location/GpsClock.java
+++ b/location/java/android/location/GpsClock.java
@@ -16,6 +16,7 @@
package android.location;
+import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
@@ -26,6 +27,7 @@ import android.util.Log;
*
* @hide
*/
+@SystemApi
public class GpsClock implements Parcelable {
private static final String TAG = "GpsClock";
@@ -492,6 +494,7 @@ public class GpsClock implements Parcelable {
setType(TYPE_UNKNOWN);
setTimeInNs(Long.MIN_VALUE);
resetTimeUncertaintyInNs();
+ resetFullBiasInNs();
resetBiasInNs();
resetBiasUncertaintyInNs();
resetDriftInNsPerSec();
diff --git a/location/java/android/location/GpsMeasurement.java b/location/java/android/location/GpsMeasurement.java
index 1550dc2..1c50181 100644
--- a/location/java/android/location/GpsMeasurement.java
+++ b/location/java/android/location/GpsMeasurement.java
@@ -16,6 +16,7 @@
package android.location;
+import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
@@ -25,6 +26,7 @@ import android.util.Log;
*
* @hide
*/
+@SystemApi
public class GpsMeasurement implements Parcelable {
private static final String TAG = "GpsMeasurement";
diff --git a/location/java/android/location/GpsMeasurementListenerTransport.java b/location/java/android/location/GpsMeasurementListenerTransport.java
index 2d9a372..610da96 100644
--- a/location/java/android/location/GpsMeasurementListenerTransport.java
+++ b/location/java/android/location/GpsMeasurementListenerTransport.java
@@ -26,14 +26,12 @@ import android.os.RemoteException;
*/
class GpsMeasurementListenerTransport
extends LocalListenerHelper<GpsMeasurementsEvent.Listener> {
- private final Context mContext;
private final ILocationManager mLocationManager;
private final IGpsMeasurementsListener mListenerTransport = new ListenerTransport();
public GpsMeasurementListenerTransport(Context context, ILocationManager locationManager) {
- super("GpsMeasurementListenerTransport");
- mContext = context;
+ super(context, "GpsMeasurementListenerTransport");
mLocationManager = locationManager;
}
@@ -41,7 +39,7 @@ class GpsMeasurementListenerTransport
protected boolean registerWithServer() throws RemoteException {
return mLocationManager.addGpsMeasurementsListener(
mListenerTransport,
- mContext.getPackageName());
+ getContext().getPackageName());
}
@Override
@@ -59,7 +57,18 @@ class GpsMeasurementListenerTransport
listener.onGpsMeasurementsReceived(event);
}
};
+ foreach(operation);
+ }
+ @Override
+ public void onStatusChanged(final int status) {
+ ListenerOperation<GpsMeasurementsEvent.Listener> operation =
+ new ListenerOperation<GpsMeasurementsEvent.Listener>() {
+ @Override
+ public void execute(GpsMeasurementsEvent.Listener listener) throws RemoteException {
+ listener.onStatusChanged(status);
+ }
+ };
foreach(operation);
}
}
diff --git a/location/java/android/location/GpsMeasurementsEvent.java b/location/java/android/location/GpsMeasurementsEvent.java
index e04ed81..1366873 100644
--- a/location/java/android/location/GpsMeasurementsEvent.java
+++ b/location/java/android/location/GpsMeasurementsEvent.java
@@ -17,6 +17,7 @@
package android.location;
import android.annotation.NonNull;
+import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
@@ -31,7 +32,26 @@ import java.util.Collections;
*
* @hide
*/
+@SystemApi
public class GpsMeasurementsEvent implements Parcelable {
+
+ /**
+ * The system does not support tracking of GPS Measurements. This status will not change in the
+ * future.
+ */
+ public static final int STATUS_NOT_SUPPORTED = 0;
+
+ /**
+ * GPS Measurements are successfully being tracked, it will receive updates once they are
+ * available.
+ */
+ public static final int STATUS_READY = 1;
+
+ /**
+ * GPS provider or Location is disabled, updates will not be received until they are enabled.
+ */
+ public static final int STATUS_GPS_LOCATION_DISABLED = 2;
+
private final GpsClock mClock;
private final Collection<GpsMeasurement> mReadOnlyMeasurements;
@@ -42,8 +62,18 @@ public class GpsMeasurementsEvent implements Parcelable {
*
* @hide
*/
+ @SystemApi
public interface Listener {
+
+ /**
+ * Returns the latest collected GPS Measurements.
+ */
void onGpsMeasurementsReceived(GpsMeasurementsEvent eventArgs);
+
+ /**
+ * Returns the latest status of the GPS Measurements sub-system.
+ */
+ void onStatusChanged(int status);
}
public GpsMeasurementsEvent(GpsClock clock, GpsMeasurement[] measurements) {
@@ -103,7 +133,9 @@ public class GpsMeasurementsEvent implements Parcelable {
public void writeToParcel(Parcel parcel, int flags) {
parcel.writeParcelable(mClock, flags);
- GpsMeasurement[] measurementsArray = mReadOnlyMeasurements.toArray(new GpsMeasurement[0]);
+ int measurementsCount = mReadOnlyMeasurements.size();
+ GpsMeasurement[] measurementsArray =
+ mReadOnlyMeasurements.toArray(new GpsMeasurement[measurementsCount]);
parcel.writeInt(measurementsArray.length);
parcel.writeTypedArray(measurementsArray, flags);
}
diff --git a/location/java/android/location/GpsNavigationMessage.java b/location/java/android/location/GpsNavigationMessage.java
index 2eb4708..42f8ee4 100644
--- a/location/java/android/location/GpsNavigationMessage.java
+++ b/location/java/android/location/GpsNavigationMessage.java
@@ -17,6 +17,7 @@
package android.location;
import android.annotation.NonNull;
+import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
@@ -28,6 +29,7 @@ import java.security.InvalidParameterException;
*
* @hide
*/
+@SystemApi
public class GpsNavigationMessage implements Parcelable {
private static final String TAG = "GpsNavigationMessage";
private static final byte[] EMPTY_ARRAY = new byte[0];
diff --git a/location/java/android/location/GpsNavigationMessageEvent.java b/location/java/android/location/GpsNavigationMessageEvent.java
index 50ffa75..bd6921c 100644
--- a/location/java/android/location/GpsNavigationMessageEvent.java
+++ b/location/java/android/location/GpsNavigationMessageEvent.java
@@ -17,13 +17,11 @@
package android.location;
import android.annotation.NonNull;
+import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import java.security.InvalidParameterException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
/**
* A class implementing a container for data associated with a navigation message event.
@@ -31,7 +29,26 @@ import java.util.Collections;
*
* @hide
*/
+@SystemApi
public class GpsNavigationMessageEvent implements Parcelable {
+
+ /**
+ * The system does not support tracking of GPS Navigation Messages. This status will not change
+ * in the future.
+ */
+ public static int STATUS_NOT_SUPPORTED = 0;
+
+ /**
+ * GPS Navigation Messages are successfully being tracked, it will receive updates once they are
+ * available.
+ */
+ public static int STATUS_READY = 1;
+
+ /**
+ * GPS provider or Location is disabled, updated will not be received until they are enabled.
+ */
+ public static int STATUS_GPS_LOCATION_DISABLED = 2;
+
private final GpsNavigationMessage mNavigationMessage;
/**
@@ -41,8 +58,18 @@ public class GpsNavigationMessageEvent implements Parcelable {
*
* @hide
*/
+ @SystemApi
public interface Listener {
+
+ /**
+ * Returns the latest collected GPS Navigation Message.
+ */
void onGpsNavigationMessageReceived(GpsNavigationMessageEvent event);
+
+ /**
+ * Returns the latest status of the GPS Navigation Messages sub-system.
+ */
+ void onStatusChanged(int status);
}
public GpsNavigationMessageEvent(GpsNavigationMessage message) {
diff --git a/location/java/android/location/GpsNavigationMessageListenerTransport.java b/location/java/android/location/GpsNavigationMessageListenerTransport.java
index ec4812b..f6ba407 100644
--- a/location/java/android/location/GpsNavigationMessageListenerTransport.java
+++ b/location/java/android/location/GpsNavigationMessageListenerTransport.java
@@ -26,7 +26,6 @@ import android.os.RemoteException;
*/
class GpsNavigationMessageListenerTransport
extends LocalListenerHelper<GpsNavigationMessageEvent.Listener> {
- private final Context mContext;
private final ILocationManager mLocationManager;
private final IGpsNavigationMessageListener mListenerTransport = new ListenerTransport();
@@ -34,8 +33,7 @@ class GpsNavigationMessageListenerTransport
public GpsNavigationMessageListenerTransport(
Context context,
ILocationManager locationManager) {
- super("GpsNavigationMessageListenerTransport");
- mContext = context;
+ super(context, "GpsNavigationMessageListenerTransport");
mLocationManager = locationManager;
}
@@ -43,7 +41,7 @@ class GpsNavigationMessageListenerTransport
protected boolean registerWithServer() throws RemoteException {
return mLocationManager.addGpsNavigationMessageListener(
mListenerTransport,
- mContext.getPackageName());
+ getContext().getPackageName());
}
@Override
@@ -62,7 +60,19 @@ class GpsNavigationMessageListenerTransport
listener.onGpsNavigationMessageReceived(event);
}
};
+ foreach(operation);
+ }
+ @Override
+ public void onStatusChanged(final int status) {
+ ListenerOperation<GpsNavigationMessageEvent.Listener> operation =
+ new ListenerOperation<GpsNavigationMessageEvent.Listener>() {
+ @Override
+ public void execute(GpsNavigationMessageEvent.Listener listener)
+ throws RemoteException {
+ listener.onStatusChanged(status);
+ }
+ };
foreach(operation);
}
}
diff --git a/location/java/android/location/IGpsMeasurementsListener.aidl b/location/java/android/location/IGpsMeasurementsListener.aidl
index b34bb6c..cbd3100 100644
--- a/location/java/android/location/IGpsMeasurementsListener.aidl
+++ b/location/java/android/location/IGpsMeasurementsListener.aidl
@@ -23,4 +23,5 @@ import android.location.GpsMeasurementsEvent;
*/
oneway interface IGpsMeasurementsListener {
void onGpsMeasurementsReceived(in GpsMeasurementsEvent event);
+ void onStatusChanged(in int status);
}
diff --git a/location/java/android/location/IGpsNavigationMessageListener.aidl b/location/java/android/location/IGpsNavigationMessageListener.aidl
index 18603fe..a708ea6 100644
--- a/location/java/android/location/IGpsNavigationMessageListener.aidl
+++ b/location/java/android/location/IGpsNavigationMessageListener.aidl
@@ -23,4 +23,5 @@ import android.location.GpsNavigationMessageEvent;
*/
oneway interface IGpsNavigationMessageListener {
void onGpsNavigationMessageReceived(in GpsNavigationMessageEvent event);
+ void onStatusChanged(in int status);
}
diff --git a/location/java/android/location/ILocationManager.aidl b/location/java/android/location/ILocationManager.aidl
index 1501710..af76175 100644
--- a/location/java/android/location/ILocationManager.aidl
+++ b/location/java/android/location/ILocationManager.aidl
@@ -62,12 +62,12 @@ interface ILocationManager
boolean sendNiResponse(int notifId, int userResponse);
boolean addGpsMeasurementsListener(in IGpsMeasurementsListener listener, in String packageName);
- boolean removeGpsMeasurementsListener(in IGpsMeasurementsListener listener);
+ void removeGpsMeasurementsListener(in IGpsMeasurementsListener listener);
boolean addGpsNavigationMessageListener(
in IGpsNavigationMessageListener listener,
in String packageName);
- boolean removeGpsNavigationMessageListener(in IGpsNavigationMessageListener listener);
+ void removeGpsNavigationMessageListener(in IGpsNavigationMessageListener listener);
// --- deprecated ---
List<String> getAllProviders();
diff --git a/location/java/android/location/LocalListenerHelper.java b/location/java/android/location/LocalListenerHelper.java
index 1f3bf67..458c451 100644
--- a/location/java/android/location/LocalListenerHelper.java
+++ b/location/java/android/location/LocalListenerHelper.java
@@ -19,6 +19,7 @@ package android.location;
import com.android.internal.util.Preconditions;
import android.annotation.NonNull;
+import android.content.Context;
import android.os.RemoteException;
import android.util.Log;
@@ -32,17 +33,19 @@ import java.util.HashSet;
* @hide
*/
abstract class LocalListenerHelper<TListener> {
- private final HashSet<TListener> mListeners = new HashSet<TListener>();
+ private final HashSet<TListener> mListeners = new HashSet<>();
+
private final String mTag;
+ private final Context mContext;
- protected LocalListenerHelper(String name) {
+ protected LocalListenerHelper(Context context, String name) {
Preconditions.checkNotNull(name);
+ mContext = context;
mTag = name;
}
public boolean add(@NonNull TListener listener) {
Preconditions.checkNotNull(listener);
-
synchronized (mListeners) {
// we need to register with the service first, because we need to find out if the
// service will actually support the request before we attempt anything
@@ -59,18 +62,15 @@ abstract class LocalListenerHelper<TListener> {
return false;
}
}
-
if (mListeners.contains(listener)) {
return true;
}
- mListeners.add(listener);
+ return mListeners.add(listener);
}
- return true;
}
public void remove(@NonNull TListener listener) {
Preconditions.checkNotNull(listener);
-
synchronized (mListeners) {
boolean removed = mListeners.remove(listener);
boolean isLastRemoved = removed && mListeners.isEmpty();
@@ -78,7 +78,7 @@ abstract class LocalListenerHelper<TListener> {
try {
unregisterFromServer();
} catch (RemoteException e) {
-
+ Log.v(mTag, "Error handling last listener removal", e);
}
}
}
@@ -91,12 +91,15 @@ abstract class LocalListenerHelper<TListener> {
void execute(TListener listener) throws RemoteException;
}
- protected void foreach(ListenerOperation operation) {
+ protected Context getContext() {
+ return mContext;
+ }
+
+ protected void foreach(ListenerOperation<TListener> operation) {
Collection<TListener> listeners;
synchronized (mListeners) {
- listeners = new ArrayList<TListener>(mListeners);
+ listeners = new ArrayList<>(mListeners);
}
-
for (TListener listener : listeners) {
try {
operation.execute(listener);
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java
index ed408e0..0eb4fdc 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -1579,10 +1579,11 @@ public class LocationManager {
* Adds a GPS Measurement listener.
*
* @param listener a {@link GpsMeasurementsEvent.Listener} object to register.
- * @return {@code true} if the listener was successfully registered, {@code false} otherwise.
+ * @return {@code true} if the listener was added successfully, {@code false} otherwise.
*
* @hide
*/
+ @SystemApi
public boolean addGpsMeasurementListener(GpsMeasurementsEvent.Listener listener) {
return mGpsMeasurementListenerTransport.add(listener);
}
@@ -1594,6 +1595,7 @@ public class LocationManager {
*
* @hide
*/
+ @SystemApi
public void removeGpsMeasurementListener(GpsMeasurementsEvent.Listener listener) {
mGpsMeasurementListenerTransport.remove(listener);
}
@@ -1602,10 +1604,11 @@ public class LocationManager {
* Adds a GPS Navigation Message listener.
*
* @param listener a {@link GpsNavigationMessageEvent.Listener} object to register.
- * @return {@code true} if the listener was successfully registered, {@code false} otherwise.
+ * @return {@code true} if the listener was added successfully, {@code false} otherwise.
*
* @hide
*/
+ @SystemApi
public boolean addGpsNavigationMessageListener(GpsNavigationMessageEvent.Listener listener) {
return mGpsNavigationMessageListenerTransport.add(listener);
}
@@ -1617,6 +1620,7 @@ public class LocationManager {
*
* @hide
*/
+ @SystemApi
public void removeGpsNavigationMessageListener(
GpsNavigationMessageEvent.Listener listener) {
mGpsNavigationMessageListenerTransport.remove(listener);