diff options
5 files changed, 49 insertions, 11 deletions
diff --git a/core/java/android/hardware/location/IFusedLocationHardware.aidl b/core/java/android/hardware/location/IFusedLocationHardware.aidl index 382c12c..3de766a 100644 --- a/core/java/android/hardware/location/IFusedLocationHardware.aidl +++ b/core/java/android/hardware/location/IFusedLocationHardware.aidl @@ -32,21 +32,21 @@ interface IFusedLocationHardware { * * @param eventSink The sink to register. */ - void registerSink(in IFusedLocationHardwareSink eventSink); + void registerSink(in IFusedLocationHardwareSink eventSink) = 0; /** * Unregisters a sink with the Location Hardware object. * * @param eventSink The sink to unregister. */ - void unregisterSink(in IFusedLocationHardwareSink eventSink); + void unregisterSink(in IFusedLocationHardwareSink eventSink) = 1; /** * Provides access to the batch size available in Hardware. * * @return The batch size the hardware supports. */ - int getSupportedBatchSize(); + int getSupportedBatchSize() = 2; /** * Requests the Hardware to start batching locations. @@ -56,7 +56,7 @@ interface IFusedLocationHardware { * * @throws RuntimeException if the request Id exists. */ - void startBatching(in int id, in FusedBatchOptions batchOptions); + void startBatching(in int id, in FusedBatchOptions batchOptions) = 3; /** * Requests the Hardware to stop batching for the given Id. @@ -64,7 +64,7 @@ interface IFusedLocationHardware { * @param id The request that needs to be stopped. * @throws RuntimeException if the request Id is unknown. */ - void stopBatching(in int id); + void stopBatching(in int id) = 4; /** * Updates a batching operation in progress. @@ -74,7 +74,7 @@ interface IFusedLocationHardware { * * @throws RuntimeException if the Id of the request is unknown. */ - void updateBatchingOptions(in int id, in FusedBatchOptions batchOptions); + void updateBatchingOptions(in int id, in FusedBatchOptions batchOptions) = 5; /** * Requests the most recent locations available in Hardware. @@ -83,14 +83,14 @@ interface IFusedLocationHardware { * * @param batchSizeRequested The number of locations requested. */ - void requestBatchOfLocations(in int batchSizeRequested); + void requestBatchOfLocations(in int batchSizeRequested) = 6; /** * Flags if the Hardware supports injection of diagnostic data. * * @return True if data injection is supported, false otherwise. */ - boolean supportsDiagnosticDataInjection(); + boolean supportsDiagnosticDataInjection() = 7; /** * Injects diagnostic data into the Hardware subsystem. @@ -98,14 +98,14 @@ interface IFusedLocationHardware { * @param data The data to inject. * @throws RuntimeException if injection is not supported. */ - void injectDiagnosticData(in String data); + void injectDiagnosticData(in String data) = 8; /** * Flags if the Hardware supports injection of device context information. * * @return True if device context injection is supported, false otherwise. */ - boolean supportsDeviceContextInjection(); + boolean supportsDeviceContextInjection() = 9; /** * Injects device context information into the Hardware subsystem. @@ -113,5 +113,12 @@ interface IFusedLocationHardware { * @param deviceEnabledContext The context to inject. * @throws RuntimeException if injection is not supported. */ - void injectDeviceContext(in int deviceEnabledContext); + void injectDeviceContext(in int deviceEnabledContext) = 10; + + /** + * Requests all batched locations currently available in Hardware + * and clears the buffer. Any subsequent calls will not return any + * of the locations returned in this call. + */ + void flushBatchedLocations() = 11; } diff --git a/location/lib/java/com/android/location/provider/FusedLocationHardware.java b/location/lib/java/com/android/location/provider/FusedLocationHardware.java index cbe404b7..480a18c 100644 --- a/location/lib/java/com/android/location/provider/FusedLocationHardware.java +++ b/location/lib/java/com/android/location/provider/FusedLocationHardware.java @@ -174,6 +174,14 @@ public final class FusedLocationHardware { } } + public void flushBatchedLocations() { + try { + mLocationHardware.flushBatchedLocations(); + } catch(RemoteException e) { + Log.e(TAG, "RemoteException at flushBatchedLocations"); + } + } + public boolean supportsDiagnosticDataInjection() { try { return mLocationHardware.supportsDiagnosticDataInjection(); diff --git a/services/core/java/com/android/server/location/FlpHardwareProvider.java b/services/core/java/com/android/server/location/FlpHardwareProvider.java index f41d930..834dff2 100644 --- a/services/core/java/com/android/server/location/FlpHardwareProvider.java +++ b/services/core/java/com/android/server/location/FlpHardwareProvider.java @@ -273,6 +273,7 @@ public class FlpHardwareProvider { private native void nativeUpdateBatchingOptions(int requestId, FusedBatchOptions optionsObject); private native void nativeStopBatching(int id); private native void nativeRequestBatchedLocation(int lastNLocations); + private native void nativeFlushBatchedLocations(); private native void nativeInjectLocation(Location location); // TODO [Fix] sort out the lifetime of the instance private native void nativeCleanup(); @@ -364,6 +365,11 @@ public class FlpHardwareProvider { } @Override + public void flushBatchedLocations() { + nativeFlushBatchedLocations(); + } + + @Override public boolean supportsDiagnosticDataInjection() { return nativeIsDiagnosticSupported(); } diff --git a/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java b/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java index 389bd24..e49c411 100644 --- a/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java +++ b/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java @@ -116,4 +116,10 @@ public class FusedLocationHardwareSecure extends IFusedLocationHardware.Stub { checkPermissions(); mLocationHardware.injectDeviceContext(deviceEnabledContext); } + + @Override + public void flushBatchedLocations() throws RemoteException { + checkPermissions(); + mLocationHardware.flushBatchedLocations(); + } } diff --git a/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp b/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp index 81cdcb0..852b5e9 100644 --- a/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp +++ b/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp @@ -847,6 +847,14 @@ static void GetBatchedLocation(JNIEnv* env, jobject /* object */, jint lastNLoca sFlpInterface->get_batched_location(lastNLocations); } +static void FlushBatchedLocations(JNIEnv* env, jobject /* object */) { + if(sFlpInterface == NULL) { + ThrowOnError(env, FLP_RESULT_ERROR, __FUNCTION__); + } + + sFlpInterface->flush_batched_locations(); +} + static void InjectLocation(JNIEnv* env, jobject /* object */, jobject locationObject) { if(locationObject == NULL) { ALOGE("Invalid location for injection: %p", locationObject); @@ -1029,6 +1037,9 @@ static JNINativeMethod sMethods[] = { {"nativeRequestBatchedLocation", "(I)V", reinterpret_cast<void*>(GetBatchedLocation)}, + {"nativeFlushBatchedLocations", + "()V", + reinterpret_cast<void*>(FlushBatchedLocations)}, {"nativeInjectLocation", "(Landroid/location/Location;)V", reinterpret_cast<void*>(InjectLocation)}, |