summaryrefslogtreecommitdiffstats
path: root/location
diff options
context:
space:
mode:
authorDavid Christie <dnchrist@google.com>2015-04-12 20:57:57 -0700
committerDavid Christie <dnchrist@google.com>2015-04-13 17:25:27 -0700
commit15003f19e5e5a443222569401f167a3ac0e1de3a (patch)
tree74259f8732f9e5aa7cc8bb96b1d44d7d8ebdb59c /location
parentffca45a2cdd778e6edd5c3959bf53c6192b7e035 (diff)
downloadframeworks_base-15003f19e5e5a443222569401f167a3ac0e1de3a.zip
frameworks_base-15003f19e5e5a443222569401f167a3ac0e1de3a.tar.gz
frameworks_base-15003f19e5e5a443222569401f167a3ac0e1de3a.tar.bz2
Add a status callback for location batching in FLP HAL
-Allows GmsCore to know when location is unsuccessful so it can switch to a SW solution. Change-Id: I3d1df7b828f7fb189446881eea87d9a952310614
Diffstat (limited to 'location')
-rw-r--r--location/lib/java/com/android/location/provider/FusedLocationHardware.java39
-rw-r--r--location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java13
2 files changed, 48 insertions, 4 deletions
diff --git a/location/lib/java/com/android/location/provider/FusedLocationHardware.java b/location/lib/java/com/android/location/provider/FusedLocationHardware.java
index 44cb199..cbe404b7 100644
--- a/location/lib/java/com/android/location/provider/FusedLocationHardware.java
+++ b/location/lib/java/com/android/location/provider/FusedLocationHardware.java
@@ -57,6 +57,11 @@ public final class FusedLocationHardware {
public void onCapabilities(int capabilities) {
dispatchCapabilities(capabilities);
}
+
+ @Override
+ public void onStatusChanged(int status) {
+ dispatchStatus(status);
+ }
};
/**
@@ -210,6 +215,7 @@ public final class FusedLocationHardware {
public static final int DISPATCH_LOCATION = 1;
public static final int DISPATCH_DIAGNOSTIC_DATA = 2;
public static final int DISPATCH_CAPABILITIES = 3;
+ public static final int DISPATCH_STATUS = 4;
public DispatcherHandler(Looper looper) {
super(looper, null /*callback*/ , true /*async*/);
@@ -228,6 +234,9 @@ public final class FusedLocationHardware {
case DISPATCH_CAPABILITIES:
command.dispatchCapabilities();
break;
+ case DISPATCH_STATUS:
+ command.dispatchStatus();
+ break;
default:
Log.e(TAG, "Invalid dispatch message");
break;
@@ -240,16 +249,19 @@ public final class FusedLocationHardware {
private final Location[] mLocations;
private final String mData;
private final int mCapabilities;
+ private final int mStatus;
public MessageCommand(
FusedLocationHardwareSink sink,
Location[] locations,
String data,
- int capabilities) {
+ int capabilities,
+ int status) {
mSink = sink;
mLocations = locations;
mData = data;
mCapabilities = capabilities;
+ mStatus = status;
}
public void dispatchLocation() {
@@ -263,6 +275,10 @@ public final class FusedLocationHardware {
public void dispatchCapabilities() {
mSink.onCapabilities(mCapabilities);
}
+
+ public void dispatchStatus() {
+ mSink.onStatusChanged(mStatus);
+ }
}
private void dispatchLocations(Location[] locations) {
@@ -275,7 +291,7 @@ public final class FusedLocationHardware {
Message message = Message.obtain(
entry.getValue(),
DispatcherHandler.DISPATCH_LOCATION,
- new MessageCommand(entry.getKey(), locations, null /*data*/, 0));
+ new MessageCommand(entry.getKey(), locations, null /*data*/, 0, 0));
message.sendToTarget();
}
}
@@ -290,7 +306,7 @@ public final class FusedLocationHardware {
Message message = Message.obtain(
entry.getValue(),
DispatcherHandler.DISPATCH_DIAGNOSTIC_DATA,
- new MessageCommand(entry.getKey(), null /*locations*/, data, 0));
+ new MessageCommand(entry.getKey(), null /*locations*/, data, 0, 0));
message.sendToTarget();
}
}
@@ -305,7 +321,22 @@ public final class FusedLocationHardware {
Message message = Message.obtain(
entry.getValue(),
DispatcherHandler.DISPATCH_CAPABILITIES,
- new MessageCommand(entry.getKey(), null /*locations*/, null, capabilities));
+ new MessageCommand(entry.getKey(), null /*locations*/, null, capabilities, 0));
+ message.sendToTarget();
+ }
+ }
+
+ private void dispatchStatus(int status) {
+ HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks;
+ synchronized(mSinkList) {
+ sinks = mSinkList;
+ }
+
+ for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) {
+ Message message = Message.obtain(
+ entry.getValue(),
+ DispatcherHandler.DISPATCH_STATUS,
+ new MessageCommand(entry.getKey(), null /*locations*/, null, 0, status));
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 aaef773..618d5d6 100644
--- a/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java
+++ b/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java
@@ -50,4 +50,17 @@ public class FusedLocationHardwareSink {
public void onCapabilities(int capabilities) {
// default do nothing
}
+
+ /**
+ * Called when the status changes in the underlying FLP HAL
+ * implementation (the ability to compute location). This
+ * callback will only be made on API 23 or later.
+ *
+ * @param status One of FLP_STATUS_LOCATION_AVAILABLE or
+ * FLP_STATUS_LOCATION_UNAVAILABLE as defined in
+ * fused_location.h.
+ */
+ public void onStatusChanged(int status) {
+ // default do nothing
+ }
} \ No newline at end of file