diff options
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 21de9f5..4c074e9 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 623d707..5600aeb 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 fab84a8..79f192d 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); } |