Make sure FLP HAL statuses currently used are translated (if needed) correctly into the framework.
b/14118906

Change-Id: I4723a3b9cad99aacc70bd3b7b5b5e034aa6c033d
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 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 @@
 
     /**
      * 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 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 @@
     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 @@
             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 @@
             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);
     }