From cc972725af35284c0b571aaa0dc6873e69b15119 Mon Sep 17 00:00:00 2001 From: destradaa Date: Fri, 25 Apr 2014 11:37:52 -0700 Subject: [PATCH] Make sure FLP HAL statuses currently used are translated (if needed) correctly into the framework. b/14118906 Change-Id: I4723a3b9cad99aacc70bd3b7b5b5e034aa6c033d --- .../hardware/location/GeofenceHardware.java | 4 ++-- .../android/location/FusedBatchOptions.java | 5 +++-- .../server/location/FlpHardwareProvider.java | 22 ++++++++++++++++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/core/java/android/hardware/location/GeofenceHardware.java b/core/java/android/hardware/location/GeofenceHardware.java index 21de9f5df91f6..4c074e9929195 100644 --- a/core/java/android/hardware/location/GeofenceHardware.java +++ b/core/java/android/hardware/location/GeofenceHardware.java @@ -79,7 +79,7 @@ public final class GeofenceHardware { */ public static final int MONITOR_UNSUPPORTED = 2; - // The following constants need to match geofence flags in gps.h + // The following constants need to match geofence flags in gps.h and fused_location.h /** * The constant to indicate that the user has entered the geofence. */ @@ -92,7 +92,7 @@ public final class GeofenceHardware { /** * The constant to indicate that the user is uncertain with respect to a - * geofence. nn + * geofence. */ public static final int GEOFENCE_UNCERTAIN = 1<<2L; diff --git a/location/java/android/location/FusedBatchOptions.java b/location/java/android/location/FusedBatchOptions.java index 623d707610dcd..5600aeb9abad4 100644 --- a/location/java/android/location/FusedBatchOptions.java +++ b/location/java/android/location/FusedBatchOptions.java @@ -95,8 +95,9 @@ public class FusedBatchOptions implements Parcelable { } public static final class BatchFlags { - public static int WAKEUP_ON_FIFO_FULL = 1<<0; - public static int CALLBACK_ON_LOCATION_FIX = 1<<1; + // follow the definitions to the letter in fused_location.h + public static int WAKEUP_ON_FIFO_FULL = 0x0000001; + public static int CALLBACK_ON_LOCATION_FIX =0x0000002; } /* diff --git a/services/core/java/com/android/server/location/FlpHardwareProvider.java b/services/core/java/com/android/server/location/FlpHardwareProvider.java index fab84a85ae0c2..79f192d8c9398 100644 --- a/services/core/java/com/android/server/location/FlpHardwareProvider.java +++ b/services/core/java/com/android/server/location/FlpHardwareProvider.java @@ -60,6 +60,10 @@ public class FlpHardwareProvider { private static final int FLP_RESULT_ID_UNKNOWN = -5; private static final int FLP_RESULT_INVALID_GEOFENCE_TRANSITION = -6; + // FlpHal monitor status codes, they must be equal to the ones in fused_location.h + private static final int FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE = 1<<0; + private static final int FLP_GEOFENCE_MONITOR_STATUS_AVAILABLE = 1<<1; + public static FlpHardwareProvider getInstance(Context context) { if (sSingletonInstance == null) { sSingletonInstance = new FlpHardwareProvider(context); @@ -141,6 +145,8 @@ public class FlpHardwareProvider { int transition, long timestamp, int sourcesUsed) { + // the transition Id does not require translation because the values in fused_location.h + // and GeofenceHardware are in sync getGeofenceHardwareSink().reportGeofenceTransition( geofenceId, updateLocationInformation(location), @@ -157,9 +163,23 @@ public class FlpHardwareProvider { updatedLocation = updateLocationInformation(location); } + int monitorStatus; + switch (status) { + case FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE: + monitorStatus = GeofenceHardware.MONITOR_CURRENTLY_UNAVAILABLE; + break; + case FLP_GEOFENCE_MONITOR_STATUS_AVAILABLE: + monitorStatus = GeofenceHardware.MONITOR_CURRENTLY_AVAILABLE; + break; + default: + Log.e(TAG, "Invalid FlpHal Geofence monitor status: " + status); + monitorStatus = GeofenceHardware.MONITOR_CURRENTLY_UNAVAILABLE; + break; + } + getGeofenceHardwareSink().reportGeofenceMonitorStatus( GeofenceHardware.MONITORING_TYPE_FUSED_HARDWARE, - status, + monitorStatus, updatedLocation, source); }