summaryrefslogtreecommitdiffstats
path: root/location
diff options
context:
space:
mode:
Diffstat (limited to 'location')
-rw-r--r--location/lib/java/com/android/location/provider/FusedLocationHardware.java40
-rw-r--r--location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java33
2 files changed, 64 insertions, 9 deletions
diff --git a/location/lib/java/com/android/location/provider/FusedLocationHardware.java b/location/lib/java/com/android/location/provider/FusedLocationHardware.java
index bc5a8a1..44cb199 100644
--- a/location/lib/java/com/android/location/provider/FusedLocationHardware.java
+++ b/location/lib/java/com/android/location/provider/FusedLocationHardware.java
@@ -34,7 +34,7 @@ import java.util.Map;
* Class that exposes IFusedLocationHardware functionality to unbundled services.
*/
public final class FusedLocationHardware {
- private final String TAG = "FusedLocationHardware";
+ private static final String TAG = "FusedLocationHardware";
private IFusedLocationHardware mLocationHardware;
@@ -52,6 +52,11 @@ public final class FusedLocationHardware {
public void onDiagnosticDataAvailable(String data) {
dispatchDiagnosticData(data);
}
+
+ @Override
+ public void onCapabilities(int capabilities) {
+ dispatchCapabilities(capabilities);
+ }
};
/**
@@ -204,6 +209,7 @@ public final class FusedLocationHardware {
private class DispatcherHandler extends Handler {
public static final int DISPATCH_LOCATION = 1;
public static final int DISPATCH_DIAGNOSTIC_DATA = 2;
+ public static final int DISPATCH_CAPABILITIES = 3;
public DispatcherHandler(Looper looper) {
super(looper, null /*callback*/ , true /*async*/);
@@ -218,6 +224,10 @@ public final class FusedLocationHardware {
break;
case DISPATCH_DIAGNOSTIC_DATA:
command.dispatchDiagnosticData();
+ break;
+ case DISPATCH_CAPABILITIES:
+ command.dispatchCapabilities();
+ break;
default:
Log.e(TAG, "Invalid dispatch message");
break;
@@ -229,14 +239,17 @@ public final class FusedLocationHardware {
private final FusedLocationHardwareSink mSink;
private final Location[] mLocations;
private final String mData;
+ private final int mCapabilities;
public MessageCommand(
FusedLocationHardwareSink sink,
Location[] locations,
- String data) {
+ String data,
+ int capabilities) {
mSink = sink;
mLocations = locations;
mData = data;
+ mCapabilities = capabilities;
}
public void dispatchLocation() {
@@ -246,6 +259,10 @@ public final class FusedLocationHardware {
public void dispatchDiagnosticData() {
mSink.onDiagnosticDataAvailable(mData);
}
+
+ public void dispatchCapabilities() {
+ mSink.onCapabilities(mCapabilities);
+ }
}
private void dispatchLocations(Location[] locations) {
@@ -258,7 +275,7 @@ public final class FusedLocationHardware {
Message message = Message.obtain(
entry.getValue(),
DispatcherHandler.DISPATCH_LOCATION,
- new MessageCommand(entry.getKey(), locations, null /*data*/));
+ new MessageCommand(entry.getKey(), locations, null /*data*/, 0));
message.sendToTarget();
}
}
@@ -273,7 +290,22 @@ public final class FusedLocationHardware {
Message message = Message.obtain(
entry.getValue(),
DispatcherHandler.DISPATCH_DIAGNOSTIC_DATA,
- new MessageCommand(entry.getKey(), null /*locations*/, data));
+ new MessageCommand(entry.getKey(), null /*locations*/, data, 0));
+ message.sendToTarget();
+ }
+ }
+
+ private void dispatchCapabilities(int capabilities) {
+ HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks;
+ synchronized(mSinkList) {
+ sinks = mSinkList;
+ }
+
+ for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) {
+ Message message = Message.obtain(
+ entry.getValue(),
+ DispatcherHandler.DISPATCH_CAPABILITIES,
+ new MessageCommand(entry.getKey(), null /*locations*/, null, capabilities));
message.sendToTarget();
}
}
diff --git a/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java b/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java
index 2c39fa8..aaef773 100644
--- a/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java
+++ b/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java
@@ -20,11 +20,34 @@ import android.location.Location;
/**
* Base class for sinks to interact with FusedLocationHardware.
+ *
+ * <p>Default implementations allow new methods to be added without crashing
+ * clients compiled against an old library version.
*/
-public abstract class FusedLocationHardwareSink {
- /*
- * Methods to provide a facade for IFusedLocationHardware
+public class FusedLocationHardwareSink {
+ /**
+ * Called when one or more locations are available from the FLP
+ * HAL.
+ */
+ public void onLocationAvailable(Location[] locations) {
+ // default do nothing
+ }
+
+ /**
+ * Called when diagnostic data is available from the FLP HAL.
+ */
+ public void onDiagnosticDataAvailable(String data) {
+ // default do nothing
+ }
+
+ /**
+ * Called when capabilities are available from the FLP HAL.
+ * Should be called once right after initialization.
+ *
+ * @param capabilities A bitmask of capabilities defined in
+ * fused_location.h.
*/
- public abstract void onLocationAvailable(Location[] locations);
- public abstract void onDiagnosticDataAvailable(String data);
+ public void onCapabilities(int capabilities) {
+ // default do nothing
+ }
} \ No newline at end of file