summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/hardware/location/GeofenceHardwareImpl.java11
-rw-r--r--core/java/android/hardware/location/IFusedLocationHardware.aidl5
-rw-r--r--location/lib/java/com/android/location/provider/FusedLocationHardware.java20
-rw-r--r--location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java3
-rw-r--r--services/core/java/com/android/server/location/FlpHardwareProvider.java19
-rw-r--r--services/core/java/com/android/server/location/FusedLocationHardwareSecure.java6
-rw-r--r--services/core/jni/com_android_server_location_FlpHardwareProvider.cpp13
7 files changed, 74 insertions, 3 deletions
diff --git a/core/java/android/hardware/location/GeofenceHardwareImpl.java b/core/java/android/hardware/location/GeofenceHardwareImpl.java
index 5d40e94..b34c9fb 100644
--- a/core/java/android/hardware/location/GeofenceHardwareImpl.java
+++ b/core/java/android/hardware/location/GeofenceHardwareImpl.java
@@ -41,6 +41,7 @@ import java.util.Iterator;
public final class GeofenceHardwareImpl {
private static final String TAG = "GeofenceHardwareImpl";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+ private static final int FIRST_VERSION_WITH_CAPABILITIES = 2;
private final Context mContext;
private static GeofenceHardwareImpl sInstance;
@@ -54,6 +55,7 @@ public final class GeofenceHardwareImpl {
private IFusedGeofenceHardware mFusedService;
private IGpsGeofenceHardware mGpsService;
private int mCapabilities;
+ private int mVersion = 1;
private int[] mSupportedMonitorTypes = new int[GeofenceHardware.NUM_MONITORS];
@@ -145,8 +147,10 @@ public final class GeofenceHardwareImpl {
private void updateFusedHardwareAvailability() {
boolean fusedSupported;
try {
+ final boolean hasGnnsCapabilities = (mVersion < FIRST_VERSION_WITH_CAPABILITIES)
+ || (mCapabilities & CAPABILITY_GNSS) != 0;
fusedSupported = (mFusedService != null
- ? mFusedService.isSupported() && (mCapabilities & CAPABILITY_GNSS) != 0
+ ? mFusedService.isSupported() && hasGnnsCapabilities
: false);
} catch (RemoteException e) {
Log.e(TAG, "RemoteException calling LocationManagerService");
@@ -177,6 +181,11 @@ public final class GeofenceHardwareImpl {
updateFusedHardwareAvailability();
}
+ public void setVersion(int version) {
+ mVersion = version;
+ updateFusedHardwareAvailability();
+ }
+
public void setFusedGeofenceHardware(IFusedGeofenceHardware service) {
if(mFusedService == null) {
mFusedService = service;
diff --git a/core/java/android/hardware/location/IFusedLocationHardware.aidl b/core/java/android/hardware/location/IFusedLocationHardware.aidl
index 3de766a..2ea4d23 100644
--- a/core/java/android/hardware/location/IFusedLocationHardware.aidl
+++ b/core/java/android/hardware/location/IFusedLocationHardware.aidl
@@ -121,4 +121,9 @@ interface IFusedLocationHardware {
* of the locations returned in this call.
*/
void flushBatchedLocations() = 11;
+
+ /**
+ * Returns the version of this FLP HAL implementation.
+ */
+ int getVersion() = 12;
}
diff --git a/location/lib/java/com/android/location/provider/FusedLocationHardware.java b/location/lib/java/com/android/location/provider/FusedLocationHardware.java
index 480a18c..eb3b2f4 100644
--- a/location/lib/java/com/android/location/provider/FusedLocationHardware.java
+++ b/location/lib/java/com/android/location/provider/FusedLocationHardware.java
@@ -216,6 +216,26 @@ public final class FusedLocationHardware {
}
}
+
+ /**
+ * Returns the version of the FLP HAL.
+ *
+ * <p>Version 1 is the initial release.
+ * <p>Version 2 adds the ability to use {@link #flushBatchedLocations},
+ * {@link FusedLocationHardwareSink#onCapabilities}, and
+ * {@link FusedLocationHardwareSink#onStatusChanged}.
+ *
+ * <p>This method is only available on API 23 or later. Older APIs have version 1.
+ */
+ public int getVersion() {
+ try {
+ return mLocationHardware.getVersion();
+ } catch(RemoteException e) {
+ Log.e(TAG, "RemoteException at getVersion");
+ }
+ return 1;
+ }
+
/*
* Helper methods and classes
*/
diff --git a/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java b/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java
index 618d5d6..01d37ac 100644
--- a/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java
+++ b/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java
@@ -54,7 +54,8 @@ public class FusedLocationHardwareSink {
/**
* Called when the status changes in the underlying FLP HAL
* implementation (the ability to compute location). This
- * callback will only be made on API 23 or later.
+ * callback will only be made on version 2 or later
+ * (see {@link FusedLocationHardware#getVersion()}).
*
* @param status One of FLP_STATUS_LOCATION_AVAILABLE or
* FLP_STATUS_LOCATION_UNAVAILABLE as defined in
diff --git a/services/core/java/com/android/server/location/FlpHardwareProvider.java b/services/core/java/com/android/server/location/FlpHardwareProvider.java
index 834dff2..1fb22be 100644
--- a/services/core/java/com/android/server/location/FlpHardwareProvider.java
+++ b/services/core/java/com/android/server/location/FlpHardwareProvider.java
@@ -42,11 +42,13 @@ import android.util.Log;
* {@hide}
*/
public class FlpHardwareProvider {
+ private static final int FIRST_VERSION_WITH_FLUSH_LOCATIONS = 2;
private GeofenceHardwareImpl mGeofenceHardwareSink = null;
private IFusedLocationHardwareSink mLocationSink = null;
// Capabilities provided by FlpCallbacks
private boolean mHaveBatchingCapabilities;
private int mBatchingCapabilities;
+ private int mVersion;
private static FlpHardwareProvider sSingletonInstance = null;
@@ -150,6 +152,11 @@ public class FlpHardwareProvider {
}
}
+ private void setVersion(int version) {
+ mVersion = version;
+ getGeofenceHardwareSink().setVersion(version);
+ }
+
private void maybeSendCapabilities() {
IFusedLocationHardwareSink sink;
boolean haveBatchingCapabilities;
@@ -366,7 +373,12 @@ public class FlpHardwareProvider {
@Override
public void flushBatchedLocations() {
- nativeFlushBatchedLocations();
+ if (mVersion >= FIRST_VERSION_WITH_FLUSH_LOCATIONS) {
+ nativeFlushBatchedLocations();
+ } else {
+ Log.wtf(TAG,
+ "Tried to call flushBatchedLocations on an unsupported implementation");
+ }
}
@Override
@@ -388,6 +400,11 @@ public class FlpHardwareProvider {
public void injectDeviceContext(int deviceEnabledContext) {
nativeInjectDeviceContext(deviceEnabledContext);
}
+
+ @Override
+ public int getVersion() {
+ return mVersion;
+ }
};
private final IFusedGeofenceHardware mGeofenceHardwareService =
diff --git a/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java b/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java
index e49c411..a08d326 100644
--- a/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java
+++ b/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java
@@ -122,4 +122,10 @@ public class FusedLocationHardwareSecure extends IFusedLocationHardware.Stub {
checkPermissions();
mLocationHardware.flushBatchedLocations();
}
+
+ @Override
+ public int getVersion() throws RemoteException {
+ checkPermissions();
+ return mLocationHardware.getVersion();
+ }
}
diff --git a/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp b/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp
index 852b5e9..2ca5f5a 100644
--- a/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp
+++ b/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp
@@ -31,6 +31,7 @@ static jobject sCallbacksObj = NULL;
static JNIEnv *sCallbackEnv = NULL;
static hw_device_t* sHardwareDevice = NULL;
+static jmethodID sSetVersion = NULL;
static jmethodID sOnLocationReport = NULL;
static jmethodID sOnDataReport = NULL;
static jmethodID sOnBatchingCapabilities = NULL;
@@ -141,6 +142,14 @@ static int SetThreadEvent(ThreadEvent event) {
}
ALOGV("Callback thread attached: %p", sCallbackEnv);
+
+ // Send the version to the upper layer.
+ sCallbackEnv->CallVoidMethod(
+ sCallbacksObj,
+ sSetVersion,
+ sFlpInterface->size == sizeof(FlpLocationInterface) ? 2 : 1
+ );
+ CheckExceptions(sCallbackEnv, __FUNCTION__);
break;
}
case DISASSOCIATE_JVM:
@@ -176,6 +185,10 @@ static void ClassInit(JNIEnv* env, jclass clazz) {
sFlpInterface = NULL;
// get references to the Java provider methods
+ sSetVersion = env->GetMethodID(
+ clazz,
+ "setVersion",
+ "(I)V");
sOnLocationReport = env->GetMethodID(
clazz,
"onLocationReport",