Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc972725 authored by destradaa's avatar destradaa
Browse files

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

b/14118906

Change-Id: I4723a3b9cad99aacc70bd3b7b5b5e034aa6c033d
parent 250bb6e3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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;

+3 −2
Original line number Diff line number Diff line
@@ -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;
    }

    /*
+21 −1
Original line number Diff line number Diff line
@@ -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);
    }