summaryrefslogtreecommitdiffstats
path: root/core/java/android/hardware/location
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/hardware/location')
-rw-r--r--core/java/android/hardware/location/GeofenceHardwareImpl.java27
-rw-r--r--core/java/android/hardware/location/GeofenceHardwareService.java11
-rw-r--r--core/java/android/hardware/location/IFusedLocationHardwareSink.aidl10
3 files changed, 45 insertions, 3 deletions
diff --git a/core/java/android/hardware/location/GeofenceHardwareImpl.java b/core/java/android/hardware/location/GeofenceHardwareImpl.java
index 4696b2a..5d40e94 100644
--- a/core/java/android/hardware/location/GeofenceHardwareImpl.java
+++ b/core/java/android/hardware/location/GeofenceHardwareImpl.java
@@ -53,6 +53,7 @@ public final class GeofenceHardwareImpl {
private IFusedGeofenceHardware mFusedService;
private IGpsGeofenceHardware mGpsService;
+ private int mCapabilities;
private int[] mSupportedMonitorTypes = new int[GeofenceHardware.NUM_MONITORS];
@@ -89,6 +90,9 @@ public final class GeofenceHardwareImpl {
private static final int RESOLUTION_LEVEL_COARSE = 2;
private static final int RESOLUTION_LEVEL_FINE = 3;
+ // Capability constant corresponding to fused_location.h entry when geofencing supports GNNS.
+ private static final int CAPABILITY_GNSS = 1;
+
public synchronized static GeofenceHardwareImpl getInstance(Context context) {
if (sInstance == null) {
sInstance = new GeofenceHardwareImpl(context);
@@ -141,7 +145,9 @@ public final class GeofenceHardwareImpl {
private void updateFusedHardwareAvailability() {
boolean fusedSupported;
try {
- fusedSupported = (mFusedService != null ? mFusedService.isSupported() : false);
+ fusedSupported = (mFusedService != null
+ ? mFusedService.isSupported() && (mCapabilities & CAPABILITY_GNSS) != 0
+ : false);
} catch (RemoteException e) {
Log.e(TAG, "RemoteException calling LocationManagerService");
fusedSupported = false;
@@ -166,6 +172,11 @@ public final class GeofenceHardwareImpl {
}
}
+ public void onCapabilities(int capabilities) {
+ mCapabilities = capabilities;
+ updateFusedHardwareAvailability();
+ }
+
public void setFusedGeofenceHardware(IFusedGeofenceHardware service) {
if(mFusedService == null) {
mFusedService = service;
@@ -212,6 +223,20 @@ public final class GeofenceHardwareImpl {
}
}
+ public int getCapabilitiesForMonitoringType(int monitoringType) {
+ switch (mSupportedMonitorTypes[monitoringType]) {
+ case GeofenceHardware.MONITOR_CURRENTLY_AVAILABLE:
+ switch (monitoringType) {
+ case GeofenceHardware.MONITORING_TYPE_GPS_HARDWARE:
+ return CAPABILITY_GNSS;
+ case GeofenceHardware.MONITORING_TYPE_FUSED_HARDWARE:
+ return mCapabilities;
+ }
+ break;
+ }
+ return 0;
+ }
+
public boolean addCircularFence(
int monitoringType,
GeofenceHardwareRequestParcelable request,
diff --git a/core/java/android/hardware/location/GeofenceHardwareService.java b/core/java/android/hardware/location/GeofenceHardwareService.java
index 4816c5f..c0bcb27 100644
--- a/core/java/android/hardware/location/GeofenceHardwareService.java
+++ b/core/java/android/hardware/location/GeofenceHardwareService.java
@@ -65,14 +65,17 @@ public class GeofenceHardwareService extends Service {
}
private IBinder mBinder = new IGeofenceHardware.Stub() {
+ @Override
public void setGpsGeofenceHardware(IGpsGeofenceHardware service) {
mGeofenceHardwareImpl.setGpsHardwareGeofence(service);
}
+ @Override
public void setFusedGeofenceHardware(IFusedGeofenceHardware service) {
mGeofenceHardwareImpl.setFusedGeofenceHardware(service);
}
+ @Override
public int[] getMonitoringTypes() {
mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE,
"Location Hardware permission not granted to access hardware geofence");
@@ -80,12 +83,15 @@ public class GeofenceHardwareService extends Service {
return mGeofenceHardwareImpl.getMonitoringTypes();
}
+ @Override
public int getStatusOfMonitoringType(int monitoringType) {
mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE,
"Location Hardware permission not granted to access hardware geofence");
return mGeofenceHardwareImpl.getStatusOfMonitoringType(monitoringType);
}
+
+ @Override
public boolean addCircularFence(
int monitoringType,
GeofenceHardwareRequestParcelable request,
@@ -96,6 +102,7 @@ public class GeofenceHardwareService extends Service {
return mGeofenceHardwareImpl.addCircularFence(monitoringType, request, callback);
}
+ @Override
public boolean removeGeofence(int id, int monitoringType) {
mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE,
"Location Hardware permission not granted to access hardware geofence");
@@ -104,6 +111,7 @@ public class GeofenceHardwareService extends Service {
return mGeofenceHardwareImpl.removeGeofence(id, monitoringType);
}
+ @Override
public boolean pauseGeofence(int id, int monitoringType) {
mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE,
"Location Hardware permission not granted to access hardware geofence");
@@ -112,6 +120,7 @@ public class GeofenceHardwareService extends Service {
return mGeofenceHardwareImpl.pauseGeofence(id, monitoringType);
}
+ @Override
public boolean resumeGeofence(int id, int monitoringType, int monitorTransitions) {
mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE,
"Location Hardware permission not granted to access hardware geofence");
@@ -120,6 +129,7 @@ public class GeofenceHardwareService extends Service {
return mGeofenceHardwareImpl.resumeGeofence(id, monitoringType, monitorTransitions);
}
+ @Override
public boolean registerForMonitorStateChangeCallback(int monitoringType,
IGeofenceHardwareMonitorCallback callback) {
mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE,
@@ -130,6 +140,7 @@ public class GeofenceHardwareService extends Service {
callback);
}
+ @Override
public boolean unregisterForMonitorStateChangeCallback(int monitoringType,
IGeofenceHardwareMonitorCallback callback) {
mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE,
diff --git a/core/java/android/hardware/location/IFusedLocationHardwareSink.aidl b/core/java/android/hardware/location/IFusedLocationHardwareSink.aidl
index a11d8ab..2107ae8 100644
--- a/core/java/android/hardware/location/IFusedLocationHardwareSink.aidl
+++ b/core/java/android/hardware/location/IFusedLocationHardwareSink.aidl
@@ -30,12 +30,18 @@ interface IFusedLocationHardwareSink {
*
* @param locations The batch of location information available.
*/
- void onLocationAvailable(in Location[] locations);
+ void onLocationAvailable(in Location[] locations) = 0;
/**
* Event generated from FLP HAL to provide diagnostic data to the platform.
*
* @param data The diagnostic data provided by FLP HAL.
*/
- void onDiagnosticDataAvailable(in String data);
+ void onDiagnosticDataAvailable(in String data) = 1;
+
+ /**
+ * Event generated from FLP HAL to provide a mask of supported
+ * capabilities. Should be called immediatly after init.
+ */
+ void onCapabilities(int capabilities) = 2;
} \ No newline at end of file