summaryrefslogtreecommitdiff
path: root/location/lib/java
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2018-03-08 16:43:07 +0900
committerJiyong Park <jiyong@google.com>2018-03-21 10:36:44 +0900
commit4cc3a1c056f69ac4da1dc5055c36b7357e9f673c (patch)
tree106fdc43e6561b8a14543eb34ef4fd94932993b2 /location/lib/java
parenteee99986c8021d6825f99a25434725fccf7b2b12 (diff)
Remove FlpHardwareProvider
After Treble's FLP merge into GNSS HAL, the FlpHardwareProvider is just an empty shell. Removing FusedLocation and/or Flp + Hardware classes altogether. Bug: 35726697 Test: m -j Test: Open Google Map and then walk around. The dot moves as I walk. Change-Id: I7f413e38b57424e8ebb9d7d14d94f145a48d10f8
Diffstat (limited to 'location/lib/java')
-rw-r--r--location/lib/java/com/android/location/provider/FusedLocationHardware.java371
-rw-r--r--location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java67
-rw-r--r--location/lib/java/com/android/location/provider/FusedProvider.java24
-rw-r--r--location/lib/java/com/android/location/provider/GmsFusedBatchOptions.java114
4 files changed, 5 insertions, 571 deletions
diff --git a/location/lib/java/com/android/location/provider/FusedLocationHardware.java b/location/lib/java/com/android/location/provider/FusedLocationHardware.java
deleted file mode 100644
index eb3b2f4609e7..000000000000
--- a/location/lib/java/com/android/location/provider/FusedLocationHardware.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.location.provider;
-
-import android.hardware.location.IFusedLocationHardware;
-import android.hardware.location.IFusedLocationHardwareSink;
-
-import android.location.Location;
-
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.os.RemoteException;
-import android.util.Log;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Class that exposes IFusedLocationHardware functionality to unbundled services.
- */
-public final class FusedLocationHardware {
- private static final String TAG = "FusedLocationHardware";
-
- private IFusedLocationHardware mLocationHardware;
-
- // the list uses a copy-on-write pattern to update its contents
- HashMap<FusedLocationHardwareSink, DispatcherHandler> mSinkList =
- new HashMap<FusedLocationHardwareSink, DispatcherHandler>();
-
- private IFusedLocationHardwareSink mInternalSink = new IFusedLocationHardwareSink.Stub() {
- @Override
- public void onLocationAvailable(Location[] locations) {
- dispatchLocations(locations);
- }
-
- @Override
- public void onDiagnosticDataAvailable(String data) {
- dispatchDiagnosticData(data);
- }
-
- @Override
- public void onCapabilities(int capabilities) {
- dispatchCapabilities(capabilities);
- }
-
- @Override
- public void onStatusChanged(int status) {
- dispatchStatus(status);
- }
- };
-
- /**
- * @hide
- */
- public FusedLocationHardware(IFusedLocationHardware locationHardware) {
- mLocationHardware = locationHardware;
- }
-
- /*
- * Methods to provide a Facade for IFusedLocationHardware
- */
- public void registerSink(FusedLocationHardwareSink sink, Looper looper) {
- if(sink == null || looper == null) {
- throw new IllegalArgumentException("Parameter sink and looper cannot be null.");
- }
-
- boolean registerSink;
- synchronized (mSinkList) {
- // register only on first insertion
- registerSink = mSinkList.size() == 0;
- // guarantee uniqueness
- if(mSinkList.containsKey(sink)) {
- return;
- }
-
- HashMap<FusedLocationHardwareSink, DispatcherHandler> newSinkList =
- new HashMap<FusedLocationHardwareSink, DispatcherHandler>(mSinkList);
- newSinkList.put(sink, new DispatcherHandler(looper));
- mSinkList = newSinkList;
- }
-
- if(registerSink) {
- try {
- mLocationHardware.registerSink(mInternalSink);
- } catch(RemoteException e) {
- Log.e(TAG, "RemoteException at registerSink");
- }
- }
- }
-
- public void unregisterSink(FusedLocationHardwareSink sink) {
- if(sink == null) {
- throw new IllegalArgumentException("Parameter sink cannot be null.");
- }
-
- boolean unregisterSink;
- synchronized(mSinkList) {
- if(!mSinkList.containsKey(sink)) {
- //done
- return;
- }
-
- HashMap<FusedLocationHardwareSink, DispatcherHandler> newSinkList =
- new HashMap<FusedLocationHardwareSink, DispatcherHandler>(mSinkList);
- newSinkList.remove(sink);
- //unregister after the last sink
- unregisterSink = newSinkList.size() == 0;
-
- mSinkList = newSinkList;
- }
-
- if(unregisterSink) {
- try {
- mLocationHardware.unregisterSink(mInternalSink);
- } catch(RemoteException e) {
- Log.e(TAG, "RemoteException at unregisterSink");
- }
- }
- }
-
- public int getSupportedBatchSize() {
- try {
- return mLocationHardware.getSupportedBatchSize();
- } catch(RemoteException e) {
- Log.e(TAG, "RemoteException at getSupportedBatchSize");
- return 0;
- }
- }
-
- public void startBatching(int id, GmsFusedBatchOptions batchOptions) {
- try {
- mLocationHardware.startBatching(id, batchOptions.getParcelableOptions());
- } catch(RemoteException e) {
- Log.e(TAG, "RemoteException at startBatching");
- }
- }
-
- public void stopBatching(int id) {
- try {
- mLocationHardware.stopBatching(id);
- } catch(RemoteException e) {
- Log.e(TAG, "RemoteException at stopBatching");
- }
- }
-
- public void updateBatchingOptions(int id, GmsFusedBatchOptions batchOptions) {
- try {
- mLocationHardware.updateBatchingOptions(id, batchOptions.getParcelableOptions());
- } catch(RemoteException e) {
- Log.e(TAG, "RemoteException at updateBatchingOptions");
- }
- }
-
- public void requestBatchOfLocations(int batchSizeRequest) {
- try {
- mLocationHardware.requestBatchOfLocations(batchSizeRequest);
- } catch(RemoteException e) {
- Log.e(TAG, "RemoteException at requestBatchOfLocations");
- }
- }
-
- public void flushBatchedLocations() {
- try {
- mLocationHardware.flushBatchedLocations();
- } catch(RemoteException e) {
- Log.e(TAG, "RemoteException at flushBatchedLocations");
- }
- }
-
- public boolean supportsDiagnosticDataInjection() {
- try {
- return mLocationHardware.supportsDiagnosticDataInjection();
- } catch(RemoteException e) {
- Log.e(TAG, "RemoteException at supportsDiagnisticDataInjection");
- return false;
- }
- }
-
- public void injectDiagnosticData(String data) {
- try {
- mLocationHardware.injectDiagnosticData(data);
- } catch(RemoteException e) {
- Log.e(TAG, "RemoteException at injectDiagnosticData");
- }
- }
-
- public boolean supportsDeviceContextInjection() {
- try {
- return mLocationHardware.supportsDeviceContextInjection();
- } catch(RemoteException e) {
- Log.e(TAG, "RemoteException at supportsDeviceContextInjection");
- return false;
- }
- }
-
- public void injectDeviceContext(int deviceEnabledContext) {
- try {
- mLocationHardware.injectDeviceContext(deviceEnabledContext);
- } catch(RemoteException e) {
- Log.e(TAG, "RemoteException at injectDeviceContext");
- }
- }
-
-
- /**
- * 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
- */
- private class DispatcherHandler extends Handler {
- public static final int DISPATCH_LOCATION = 1;
- public static final int DISPATCH_DIAGNOSTIC_DATA = 2;
- public static final int DISPATCH_CAPABILITIES = 3;
- public static final int DISPATCH_STATUS = 4;
-
- public DispatcherHandler(Looper looper) {
- super(looper, null /*callback*/ , true /*async*/);
- }
-
- @Override
- public void handleMessage(Message message) {
- MessageCommand command = (MessageCommand) message.obj;
- switch(message.what) {
- case DISPATCH_LOCATION:
- command.dispatchLocation();
- break;
- case DISPATCH_DIAGNOSTIC_DATA:
- command.dispatchDiagnosticData();
- break;
- case DISPATCH_CAPABILITIES:
- command.dispatchCapabilities();
- break;
- case DISPATCH_STATUS:
- command.dispatchStatus();
- break;
- default:
- Log.e(TAG, "Invalid dispatch message");
- break;
- }
- }
- }
-
- private class MessageCommand {
- private final FusedLocationHardwareSink mSink;
- private final Location[] mLocations;
- private final String mData;
- private final int mCapabilities;
- private final int mStatus;
-
- public MessageCommand(
- FusedLocationHardwareSink sink,
- Location[] locations,
- String data,
- int capabilities,
- int status) {
- mSink = sink;
- mLocations = locations;
- mData = data;
- mCapabilities = capabilities;
- mStatus = status;
- }
-
- public void dispatchLocation() {
- mSink.onLocationAvailable(mLocations);
- }
-
- public void dispatchDiagnosticData() {
- mSink.onDiagnosticDataAvailable(mData);
- }
-
- public void dispatchCapabilities() {
- mSink.onCapabilities(mCapabilities);
- }
-
- public void dispatchStatus() {
- mSink.onStatusChanged(mStatus);
- }
- }
-
- private void dispatchLocations(Location[] locations) {
- HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks;
- synchronized (mSinkList) {
- sinks = mSinkList;
- }
-
- for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) {
- Message message = Message.obtain(
- entry.getValue(),
- DispatcherHandler.DISPATCH_LOCATION,
- new MessageCommand(entry.getKey(), locations, null /*data*/, 0, 0));
- message.sendToTarget();
- }
- }
-
- private void dispatchDiagnosticData(String data) {
- HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks;
- synchronized(mSinkList) {
- sinks = mSinkList;
- }
-
- for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) {
- Message message = Message.obtain(
- entry.getValue(),
- DispatcherHandler.DISPATCH_DIAGNOSTIC_DATA,
- new MessageCommand(entry.getKey(), null /*locations*/, data, 0, 0));
- message.sendToTarget();
- }
- }
-
- private void dispatchCapabilities(int capabilities) {
- HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks;
- synchronized(mSinkList) {
- sinks = mSinkList;
- }
-
- for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) {
- Message message = Message.obtain(
- entry.getValue(),
- DispatcherHandler.DISPATCH_CAPABILITIES,
- new MessageCommand(entry.getKey(), null /*locations*/, null, capabilities, 0));
- message.sendToTarget();
- }
- }
-
- private void dispatchStatus(int status) {
- HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks;
- synchronized(mSinkList) {
- sinks = mSinkList;
- }
-
- for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) {
- Message message = Message.obtain(
- entry.getValue(),
- DispatcherHandler.DISPATCH_STATUS,
- new MessageCommand(entry.getKey(), null /*locations*/, null, 0, status));
- message.sendToTarget();
- }
- }
-}
diff --git a/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java b/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java
deleted file mode 100644
index 01d37acde7b8..000000000000
--- a/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.location.provider;
-
-import android.location.Location;
-
-/**
- * Base class for sinks to interact with FusedLocationHardware.
- *
- * <p>Default implementations allow new methods to be added without crashing
- * clients compiled against an old library version.
- */
-public class FusedLocationHardwareSink {
- /**
- * Called when one or more locations are available from the FLP
- * HAL.
- */
- public void onLocationAvailable(Location[] locations) {
- // default do nothing
- }
-
- /**
- * Called when diagnostic data is available from the FLP HAL.
- */
- public void onDiagnosticDataAvailable(String data) {
- // default do nothing
- }
-
- /**
- * Called when capabilities are available from the FLP HAL.
- * Should be called once right after initialization.
- *
- * @param capabilities A bitmask of capabilities defined in
- * fused_location.h.
- */
- public void onCapabilities(int capabilities) {
- // default do nothing
- }
-
- /**
- * Called when the status changes in the underlying FLP HAL
- * implementation (the ability to compute location). This
- * 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
- * fused_location.h.
- */
- public void onStatusChanged(int status) {
- // default do nothing
- }
-} \ No newline at end of file
diff --git a/location/lib/java/com/android/location/provider/FusedProvider.java b/location/lib/java/com/android/location/provider/FusedProvider.java
index c966adeadc6f..78a593b6670b 100644
--- a/location/lib/java/com/android/location/provider/FusedProvider.java
+++ b/location/lib/java/com/android/location/provider/FusedProvider.java
@@ -16,8 +16,6 @@
package com.android.location.provider;
-import android.hardware.location.IFusedLocationHardware;
-import android.location.IFusedProvider;
import android.os.IBinder;
/**
@@ -26,17 +24,12 @@ import android.os.IBinder;
* <p>Fused providers can be implemented as services and return the result of
* {@link com.android.location.provider.FusedProvider#getBinder()} in its getBinder() method.
*
- * <p>IMPORTANT: This class is effectively a public API for unbundled applications, and must remain
- * API stable. See README.txt in the root of this package for more information.
+ * @deprecated This class should no longer be used. The location service does not uses this.
+ * This class exist here just to prevent existing apps having reference to this class from
+ * breaking.
*/
+@Deprecated
public abstract class FusedProvider {
- private IFusedProvider.Stub mProvider = new IFusedProvider.Stub() {
- @Override
- public void onFusedLocationHardwareChange(IFusedLocationHardware instance) {
- setFusedLocationHardware(new FusedLocationHardware(instance));
- }
- };
-
/**
* Gets the Binder associated with the provider.
* This is intended to be used for the onBind() method of a service that implements a fused
@@ -45,13 +38,6 @@ public abstract class FusedProvider {
* @return The IBinder instance associated with the provider.
*/
public IBinder getBinder() {
- return mProvider;
+ return null;
}
-
- /**
- * Sets the FusedLocationHardware instance in the provider..
- * @param value The instance to set. This can be null in cases where the service connection
- * is disconnected.
- */
- public abstract void setFusedLocationHardware(FusedLocationHardware value);
}
diff --git a/location/lib/java/com/android/location/provider/GmsFusedBatchOptions.java b/location/lib/java/com/android/location/provider/GmsFusedBatchOptions.java
deleted file mode 100644
index 13278e7afc1f..000000000000
--- a/location/lib/java/com/android/location/provider/GmsFusedBatchOptions.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.location.provider;
-
-import android.location.FusedBatchOptions;
-
-/**
- * Class that exposes FusedBatchOptions to the GmsCore .
- */
-public class GmsFusedBatchOptions {
- private FusedBatchOptions mOptions = new FusedBatchOptions();
-
- /*
- * Methods that provide a facade for properties in FusedBatchOptions.
- */
- public void setMaxPowerAllocationInMW(double value) {
- mOptions.setMaxPowerAllocationInMW(value);
- }
-
- public double getMaxPowerAllocationInMW() {
- return mOptions.getMaxPowerAllocationInMW();
- }
-
- public void setPeriodInNS(long value) {
- mOptions.setPeriodInNS(value);
- }
-
- public long getPeriodInNS() {
- return mOptions.getPeriodInNS();
- }
-
- public void setSmallestDisplacementMeters(float value) {
- mOptions.setSmallestDisplacementMeters(value);
- }
-
- public float getSmallestDisplacementMeters() {
- return mOptions.getSmallestDisplacementMeters();
- }
-
- public void setSourceToUse(int source) {
- mOptions.setSourceToUse(source);
- }
-
- public void resetSourceToUse(int source) {
- mOptions.resetSourceToUse(source);
- }
-
- public boolean isSourceToUseSet(int source) {
- return mOptions.isSourceToUseSet(source);
- }
-
- public int getSourcesToUse() {
- return mOptions.getSourcesToUse();
- }
-
- public void setFlag(int flag) {
- mOptions.setFlag(flag);
- }
-
- public void resetFlag(int flag) {
- mOptions.resetFlag(flag);
- }
-
- public boolean isFlagSet(int flag) {
- return mOptions.isFlagSet(flag);
- }
-
- public int getFlags() {
- return mOptions.getFlags();
- }
-
- /**
- * Definition of enum flag sets needed by this class.
- * Such values need to be kept in sync with the ones in fused_location.h
- */
-
- public static final class SourceTechnologies {
- public static int GNSS = 1<<0;
- public static int WIFI = 1<<1;
- public static int SENSORS = 1<<2;
- public static int CELL = 1<<3;
- public static int BLUETOOTH = 1<<4;
- }
-
- public static final class BatchFlags {
- public static int WAKEUP_ON_FIFO_FULL = 1<<0;
- public static int CALLBACK_ON_LOCATION_FIX = 1<<1;
- }
-
- /*
- * Method definitions for internal use.
- */
-
- /**
- * @hide
- */
- public FusedBatchOptions getParcelableOptions() {
- return mOptions;
- }
-}