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

b/14118906

Change-Id: I4723a3b9cad99aacc70bd3b7b5b5e034aa6c033d
This commit is contained in:
destradaa
2014-04-25 11:37:52 -07:00
parent 250bb6e3e0
commit cc972725af
3 changed files with 26 additions and 5 deletions

View File

@@ -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;

View File

@@ -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;
}
/*

View File

@@ -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);
}