From eee99986c8021d6825f99a25434725fccf7b2b12 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 27 Feb 2018 22:00:23 +0900 Subject: [PATCH 1/2] Create the stubs lib for com.android.location.provider com.android.location.provider.stubs is the stubs library for the shared library com.android.location.provider. The stubs library is intended to provide the stable set of APIs to the apps implementing location provider. Without the stubs library, apps had to directly link to the shared library which is built without Android SDK and exposes private APIs that are not intended to be used by apps. This also has been causing the lin-type check warnings when the shared lib is used by apps built with SDK; apps built with SDK is not allowed to link to lib built without SDK. This has been reported as warnings but will soon be errors. Now such apps are required to link to the stubs lib, which is built with SDK. While building the stubs library, following APIs are made hidden because they are exposing private APIs from the Android platform. 1) Activity* classes are removed from the API, as they are not intended to be used by apps since O. 2) GeocodeProvider and GeofenceProvider are removed from the API. 3) LocationProvider.mLocationManager is removed as it is exposing the private symbol ILocationProvider 4) ProviderPropertiesUnbundle.getProviderProperties are removed from the API as it is exposing the private symbol ProviderProperties. 5) The constructor of ProviderRequestUnbundled is removed since the class is intended to be instantiated by the service. Bug: 71420593 Test: m -j com.android.location.provider.stubs Change-Id: I20aba7e9ca9c3adc75db241f37a55f0d657f3ced --- location/lib/Android.mk | 22 +++++++++++++++++++ .../provider/ActivityChangedEvent.java | 1 + .../provider/ActivityRecognitionEvent.java | 1 + .../provider/ActivityRecognitionProvider.java | 1 + .../ActivityRecognitionProviderClient.java | 1 + .../ActivityRecognitionProviderWatcher.java | 1 + .../location/provider/GeocodeProvider.java | 1 + .../location/provider/GeofenceProvider.java | 1 + .../provider/GmsFusedBatchOptions.java | 2 +- .../provider/LocationProviderBase.java | 1 + .../provider/ProviderPropertiesUnbundled.java | 1 + .../provider/ProviderRequestUnbundled.java | 1 + 12 files changed, 33 insertions(+), 1 deletion(-) diff --git a/location/lib/Android.mk b/location/lib/Android.mk index 8424601a57ef5..6642134ec32b8 100644 --- a/location/lib/Android.mk +++ b/location/lib/Android.mk @@ -42,3 +42,25 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions LOCAL_SRC_FILES := $(LOCAL_MODULE) include $(BUILD_PREBUILT) + +# ==== Stub library =========================================== +include $(CLEAR_VARS) +LOCAL_MODULE := com.android.location.provider-stubs-gen +LOCAL_MODULE_CLASS := JAVA_LIBRARIES +LOCAL_SRC_FILES := $(call all-java-files-under,java) +LOCAL_DROIDDOC_STUB_OUT_DIR := $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/com.android.location.provider.stubs_intermediates/src +LOCAL_DROIDDOC_OPTIONS:= \ + -hide 111 -hide 113 -hide 125 -hide 126 -hide 127 -hide 128 \ + -stubpackages com.android.location.provider \ + -nodocs +LOCAL_UNINSTALLABLE_MODULE := true +include $(BUILD_DROIDDOC) +com_android_nfc_extras_gen_stamp := $(full_target) + +include $(CLEAR_VARS) +LOCAL_MODULE := com.android.location.provider.stubs +LOCAL_SOURCE_FILES_ALL_GENERATED := true +LOCAL_SDK_VERSION := current +LOCAL_ADDITIONAL_DEPENDENCIES := $(com_android_nfc_extras_gen_stamp) +com_android_nfc_extras_gen_stamp := +include $(BUILD_STATIC_JAVA_LIBRARY) diff --git a/location/lib/java/com/android/location/provider/ActivityChangedEvent.java b/location/lib/java/com/android/location/provider/ActivityChangedEvent.java index c7dfc887bbbb1..843dd670315a0 100644 --- a/location/lib/java/com/android/location/provider/ActivityChangedEvent.java +++ b/location/lib/java/com/android/location/provider/ActivityChangedEvent.java @@ -23,6 +23,7 @@ import java.util.List; /** * A class representing an event for Activity changes. + * @hide */ public class ActivityChangedEvent { private final List mActivityRecognitionEvents; diff --git a/location/lib/java/com/android/location/provider/ActivityRecognitionEvent.java b/location/lib/java/com/android/location/provider/ActivityRecognitionEvent.java index a39cff2285671..e54dea40d6903 100644 --- a/location/lib/java/com/android/location/provider/ActivityRecognitionEvent.java +++ b/location/lib/java/com/android/location/provider/ActivityRecognitionEvent.java @@ -18,6 +18,7 @@ package com.android.location.provider; /** * A class that represents an Activity Recognition Event. + * @hide */ public class ActivityRecognitionEvent { private final String mActivity; diff --git a/location/lib/java/com/android/location/provider/ActivityRecognitionProvider.java b/location/lib/java/com/android/location/provider/ActivityRecognitionProvider.java index bc2dae14be384..0eff7d3f2014c 100644 --- a/location/lib/java/com/android/location/provider/ActivityRecognitionProvider.java +++ b/location/lib/java/com/android/location/provider/ActivityRecognitionProvider.java @@ -28,6 +28,7 @@ import java.util.HashSet; /** * A class that exposes {@link IActivityRecognitionHardware} functionality to unbundled services. + * @hide */ public final class ActivityRecognitionProvider { private final IActivityRecognitionHardware mService; diff --git a/location/lib/java/com/android/location/provider/ActivityRecognitionProviderClient.java b/location/lib/java/com/android/location/provider/ActivityRecognitionProviderClient.java index 0b878d7c1f2b8..326d901b9daa7 100644 --- a/location/lib/java/com/android/location/provider/ActivityRecognitionProviderClient.java +++ b/location/lib/java/com/android/location/provider/ActivityRecognitionProviderClient.java @@ -27,6 +27,7 @@ import android.util.Log; /** * A client class for interaction with an Activity-Recognition provider. + * @hide */ public abstract class ActivityRecognitionProviderClient { private static final String TAG = "ArProviderClient"; diff --git a/location/lib/java/com/android/location/provider/ActivityRecognitionProviderWatcher.java b/location/lib/java/com/android/location/provider/ActivityRecognitionProviderWatcher.java index 7139025d2722d..42f77b42766ff 100644 --- a/location/lib/java/com/android/location/provider/ActivityRecognitionProviderWatcher.java +++ b/location/lib/java/com/android/location/provider/ActivityRecognitionProviderWatcher.java @@ -30,6 +30,7 @@ import android.util.Log; * A watcher class for Activity-Recognition instances. * * @deprecated use {@link ActivityRecognitionProviderClient} instead. + * @hide */ @Deprecated public class ActivityRecognitionProviderWatcher { diff --git a/location/lib/java/com/android/location/provider/GeocodeProvider.java b/location/lib/java/com/android/location/provider/GeocodeProvider.java index d7a34af332ca7..f7f3d82169a76 100644 --- a/location/lib/java/com/android/location/provider/GeocodeProvider.java +++ b/location/lib/java/com/android/location/provider/GeocodeProvider.java @@ -33,6 +33,7 @@ import java.util.List; *

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. + * @hide */ public abstract class GeocodeProvider { diff --git a/location/lib/java/com/android/location/provider/GeofenceProvider.java b/location/lib/java/com/android/location/provider/GeofenceProvider.java index fafaa8462dd91..43690ab87cf26 100644 --- a/location/lib/java/com/android/location/provider/GeofenceProvider.java +++ b/location/lib/java/com/android/location/provider/GeofenceProvider.java @@ -31,6 +31,7 @@ import android.location.IGeofenceProvider; *

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. + * @hide */ public abstract class GeofenceProvider { diff --git a/location/lib/java/com/android/location/provider/GmsFusedBatchOptions.java b/location/lib/java/com/android/location/provider/GmsFusedBatchOptions.java index 29818ecb85cba..13278e7afc1ff 100644 --- a/location/lib/java/com/android/location/provider/GmsFusedBatchOptions.java +++ b/location/lib/java/com/android/location/provider/GmsFusedBatchOptions.java @@ -105,7 +105,7 @@ public class GmsFusedBatchOptions { * Method definitions for internal use. */ - /* + /** * @hide */ public FusedBatchOptions getParcelableOptions() { diff --git a/location/lib/java/com/android/location/provider/LocationProviderBase.java b/location/lib/java/com/android/location/provider/LocationProviderBase.java index d717f40cab597..30655f5bbf10f 100644 --- a/location/lib/java/com/android/location/provider/LocationProviderBase.java +++ b/location/lib/java/com/android/location/provider/LocationProviderBase.java @@ -56,6 +56,7 @@ import com.android.internal.util.FastPrintWriter; public abstract class LocationProviderBase { private final String TAG; + /** @hide */ protected final ILocationManager mLocationManager; private final ProviderProperties mProperties; private final IBinder mBinder; diff --git a/location/lib/java/com/android/location/provider/ProviderPropertiesUnbundled.java b/location/lib/java/com/android/location/provider/ProviderPropertiesUnbundled.java index 9ee4df21c8941..b1a1bda45f395 100644 --- a/location/lib/java/com/android/location/provider/ProviderPropertiesUnbundled.java +++ b/location/lib/java/com/android/location/provider/ProviderPropertiesUnbundled.java @@ -41,6 +41,7 @@ public final class ProviderPropertiesUnbundled { mProperties = properties; } + /** @hide */ public ProviderProperties getProviderProperties() { return mProperties; } diff --git a/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java b/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java index ad3d1df355485..6a8e61877e46f 100644 --- a/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java +++ b/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java @@ -33,6 +33,7 @@ import com.android.internal.location.ProviderRequest; public final class ProviderRequestUnbundled { private final ProviderRequest mRequest; + /** @hide */ public ProviderRequestUnbundled(ProviderRequest request) { mRequest = request; } From 4cc3a1c056f69ac4da1dc5055c36b7357e9f673c Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Thu, 8 Mar 2018 16:43:07 +0900 Subject: [PATCH 2/2] 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 --- Android.bp | 3 - config/boot-image-profile.txt | 2 - config/hiddenapi-light-greylist.txt | 1 - config/hiddenapi-vendor-list.txt | 1 - .../location/IFusedLocationHardware.aidl | 129 ------ .../location/IFusedLocationHardwareSink.aidl | 53 --- .../java/android/location/IFusedProvider.aidl | 32 -- .../provider/FusedLocationHardware.java | 371 ------------------ .../provider/FusedLocationHardwareSink.java | 67 ---- .../location/provider/FusedProvider.java | 24 +- .../provider/GmsFusedBatchOptions.java | 114 ------ services/art-profile | 1 - .../server/LocationManagerService.java | 32 +- .../server/location/FlpHardwareProvider.java | 74 ---- .../location/FusedLocationHardwareSecure.java | 131 ------- .../android/server/location/FusedProxy.java | 130 ------ 16 files changed, 6 insertions(+), 1159 deletions(-) delete mode 100644 core/java/android/hardware/location/IFusedLocationHardware.aidl delete mode 100644 core/java/android/hardware/location/IFusedLocationHardwareSink.aidl delete mode 100644 location/java/android/location/IFusedProvider.aidl delete mode 100644 location/lib/java/com/android/location/provider/FusedLocationHardware.java delete mode 100644 location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java delete mode 100644 location/lib/java/com/android/location/provider/GmsFusedBatchOptions.java delete mode 100644 services/core/java/com/android/server/location/FlpHardwareProvider.java delete mode 100644 services/core/java/com/android/server/location/FusedLocationHardwareSecure.java delete mode 100644 services/core/java/com/android/server/location/FusedProxy.java diff --git a/Android.bp b/Android.bp index 1caa4977a1685..33f374328b33d 100644 --- a/Android.bp +++ b/Android.bp @@ -169,8 +169,6 @@ java_library { "core/java/android/hardware/location/IActivityRecognitionHardwareClient.aidl", "core/java/android/hardware/location/IActivityRecognitionHardwareSink.aidl", "core/java/android/hardware/location/IActivityRecognitionHardwareWatcher.aidl", - "core/java/android/hardware/location/IFusedLocationHardware.aidl", - "core/java/android/hardware/location/IFusedLocationHardwareSink.aidl", "core/java/android/hardware/location/IGeofenceHardware.aidl", "core/java/android/hardware/location/IGeofenceHardwareCallback.aidl", "core/java/android/hardware/location/IGeofenceHardwareMonitorCallback.aidl", @@ -409,7 +407,6 @@ java_library { "location/java/android/location/IBatchedLocationCallback.aidl", "location/java/android/location/ICountryDetector.aidl", "location/java/android/location/ICountryListener.aidl", - "location/java/android/location/IFusedProvider.aidl", "location/java/android/location/IGeocodeProvider.aidl", "location/java/android/location/IGeofenceProvider.aidl", "location/java/android/location/IGnssStatusListener.aidl", diff --git a/config/boot-image-profile.txt b/config/boot-image-profile.txt index 40b266fe29d7e..87fb99807ebc7 100644 --- a/config/boot-image-profile.txt +++ b/config/boot-image-profile.txt @@ -3375,8 +3375,6 @@ HPLandroid/location/ICountryListener$Stub;->()V HPLandroid/location/ICountryListener$Stub;->asBinder()Landroid/os/IBinder; HPLandroid/location/ICountryListener$Stub;->asInterface(Landroid/os/IBinder;)Landroid/location/ICountryListener; HPLandroid/location/ICountryListener;->onCountryDetected(Landroid/location/Country;)V -HPLandroid/location/IFusedProvider$Stub;->()V -HPLandroid/location/IFusedProvider;->onFusedLocationHardwareChange(Landroid/hardware/location/IFusedLocationHardware;)V HPLandroid/location/IGeocodeProvider$Stub$Proxy;->(Landroid/os/IBinder;)V HPLandroid/location/IGeocodeProvider$Stub$Proxy;->getFromLocation(DDILandroid/location/GeocoderParams;Ljava/util/List;)Ljava/lang/String; HPLandroid/location/IGeocodeProvider$Stub;->()V diff --git a/config/hiddenapi-light-greylist.txt b/config/hiddenapi-light-greylist.txt index 99d871e0f6f52..b3e515522fcc4 100644 --- a/config/hiddenapi-light-greylist.txt +++ b/config/hiddenapi-light-greylist.txt @@ -781,7 +781,6 @@ Landroid/location/Country;->getCountryIso()Ljava/lang/String; Landroid/location/Country;->getSource()I Landroid/location/GeocoderParams;->getClientPackage()Ljava/lang/String; Landroid/location/GeocoderParams;->getLocale()Ljava/util/Locale; -Landroid/location/IFusedProvider$Stub;->()V Landroid/location/IGeocodeProvider$Stub;->()V Landroid/location/IGeofenceProvider$Stub;->()V Landroid/location/ILocationManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/location/ILocationManager; diff --git a/config/hiddenapi-vendor-list.txt b/config/hiddenapi-vendor-list.txt index 952b28b8b820f..aacfba439c612 100644 --- a/config/hiddenapi-vendor-list.txt +++ b/config/hiddenapi-vendor-list.txt @@ -76,7 +76,6 @@ Landroid/graphics/drawable/Drawable;->updateTintFilter(Landroid/graphics/PorterD Landroid/hardware/camera2/CaptureRequest$Key;->(Ljava/lang/String;Ljava/lang/Class;)V Landroid/hardware/location/GeofenceHardware;->(Landroid/hardware/location/IGeofenceHardware;)V Landroid/hardware/location/IActivityRecognitionHardwareClient;->onAvailabilityChanged(ZLandroid/hardware/location/IActivityRecognitionHardware;)V -Landroid/location/IFusedProvider;->onFusedLocationHardwareChange(Landroid/hardware/location/IFusedLocationHardware;)V Landroid/location/IGeocodeProvider;->getFromLocation(DDILandroid/location/GeocoderParams;Ljava/util/List;)Ljava/lang/String; Landroid/location/IGeocodeProvider;->getFromLocationName(Ljava/lang/String;DDDDILandroid/location/GeocoderParams;Ljava/util/List;)Ljava/lang/String; Landroid/location/IGeofenceProvider;->setGeofenceHardware(Landroid/hardware/location/IGeofenceHardware;)V diff --git a/core/java/android/hardware/location/IFusedLocationHardware.aidl b/core/java/android/hardware/location/IFusedLocationHardware.aidl deleted file mode 100644 index 2ea4d23749584..0000000000000 --- a/core/java/android/hardware/location/IFusedLocationHardware.aidl +++ /dev/null @@ -1,129 +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/license/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 android.hardware.location; - -import android.hardware.location.IFusedLocationHardwareSink; -import android.location.FusedBatchOptions; - -/** - * Fused Location hardware interface. - * This interface is the basic set of supported functionality by Fused Hardware - * modules that offer Location batching capabilities. - * - * @hide - */ -interface IFusedLocationHardware { - /** - * Registers a sink with the Location Hardware object. - * - * @param eventSink The sink to register. - */ - 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) = 1; - - /** - * Provides access to the batch size available in Hardware. - * - * @return The batch size the hardware supports. - */ - int getSupportedBatchSize() = 2; - - /** - * Requests the Hardware to start batching locations. - * - * @param id An Id associated with the request. - * @param batchOptions The options required for batching. - * - * @throws RuntimeException if the request Id exists. - */ - void startBatching(in int id, in FusedBatchOptions batchOptions) = 3; - - /** - * Requests the Hardware to stop batching for the given Id. - * - * @param id The request that needs to be stopped. - * @throws RuntimeException if the request Id is unknown. - */ - void stopBatching(in int id) = 4; - - /** - * Updates a batching operation in progress. - * - * @param id The Id of the operation to update. - * @param batchOptions The options to apply to the given operation. - * - * @throws RuntimeException if the Id of the request is unknown. - */ - void updateBatchingOptions(in int id, in FusedBatchOptions batchOptions) = 5; - - /** - * Requests the most recent locations available in Hardware. - * This operation does not dequeue the locations, so still other batching - * events will continue working. - * - * @param batchSizeRequested The number of locations requested. - */ - 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() = 7; - - /** - * Injects diagnostic data into the Hardware subsystem. - * - * @param data The data to inject. - * @throws RuntimeException if injection is not supported. - */ - 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() = 9; - - /** - * Injects device context information into the Hardware subsystem. - * - * @param deviceEnabledContext The context to inject. - * @throws RuntimeException if injection is not supported. - */ - 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; - - /** - * Returns the version of this FLP HAL implementation. - */ - int getVersion() = 12; -} diff --git a/core/java/android/hardware/location/IFusedLocationHardwareSink.aidl b/core/java/android/hardware/location/IFusedLocationHardwareSink.aidl deleted file mode 100644 index a7dd0351010d5..0000000000000 --- a/core/java/android/hardware/location/IFusedLocationHardwareSink.aidl +++ /dev/null @@ -1,53 +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/license/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 android.hardware.location; - -import android.location.Location; - -/** - * Fused Location hardware event sink interface. - * This interface defines the set of events that the FusedLocationHardware provides. - * - * @hide - */ -oneway interface IFusedLocationHardwareSink { - /** - * Event generated when a batch of location information is available. - * - * @param locations The batch of location information available. - */ - 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) = 1; - - /** - * Event generated from FLP HAL to provide a mask of supported - * capabilities. Should be called immediatly after init. - */ - void onCapabilities(int capabilities) = 2; - - /** - * Event generated from FLP HAL when the status of location batching - * changes (location is successful/unsuccessful). - */ - void onStatusChanged(int status) = 3; -} diff --git a/location/java/android/location/IFusedProvider.aidl b/location/java/android/location/IFusedProvider.aidl deleted file mode 100644 index e86ad1ac5147a..0000000000000 --- a/location/java/android/location/IFusedProvider.aidl +++ /dev/null @@ -1,32 +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 android.location; - -import android.hardware.location.IFusedLocationHardware; - -/** - * Interface definition for Location providers that require FLP services. - * @hide - */ -oneway interface IFusedProvider { - /** - * Provides access to a FusedLocationHardware instance needed for the provider to work. - * - * @param instance The FusedLocationHardware available for the provider to use. - */ - void onFusedLocationHardwareChange(in IFusedLocationHardware instance); -} 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 eb3b2f4609e79..0000000000000 --- 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 mSinkList = - new HashMap(); - - 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 newSinkList = - new HashMap(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 newSinkList = - new HashMap(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. - * - *

Version 1 is the initial release. - *

Version 2 adds the ability to use {@link #flushBatchedLocations}, - * {@link FusedLocationHardwareSink#onCapabilities}, and - * {@link FusedLocationHardwareSink#onStatusChanged}. - * - *

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 sinks; - synchronized (mSinkList) { - sinks = mSinkList; - } - - for(Map.Entry 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 sinks; - synchronized(mSinkList) { - sinks = mSinkList; - } - - for(Map.Entry 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 sinks; - synchronized(mSinkList) { - sinks = mSinkList; - } - - for(Map.Entry 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 sinks; - synchronized(mSinkList) { - sinks = mSinkList; - } - - for(Map.Entry 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 01d37acde7b8f..0000000000000 --- 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. - * - *

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 c966adeadc6fe..78a593b6670bc 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; *

Fused providers can be implemented as services and return the result of * {@link com.android.location.provider.FusedProvider#getBinder()} in its getBinder() method. * - *

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 13278e7afc1ff..0000000000000 --- 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; - } -} diff --git a/services/art-profile b/services/art-profile index d2cde029b4901..93e580af759a9 100644 --- a/services/art-profile +++ b/services/art-profile @@ -10677,7 +10677,6 @@ PLcom/android/server/location/ContextHubService;->sendMessage(IILandroid/hardwar PLcom/android/server/location/CountryDetectorBase;->(Landroid/content/Context;)V PLcom/android/server/location/CountryDetectorBase;->notifyListener(Landroid/location/Country;)V PLcom/android/server/location/CountryDetectorBase;->setCountryListener(Landroid/location/CountryListener;)V -PLcom/android/server/location/FlpHardwareProvider;->isSupported()Z PLcom/android/server/location/GeocoderProxy;->(Landroid/content/Context;IIILandroid/os/Handler;)V PLcom/android/server/location/GeocoderProxy;->bind()Z PLcom/android/server/location/GeocoderProxy;->createAndBind(Landroid/content/Context;IIILandroid/os/Handler;)Lcom/android/server/location/GeocoderProxy; diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java index 65e90bad41a72..d5cbfd4a70cb5 100644 --- a/services/core/java/com/android/server/LocationManagerService.java +++ b/services/core/java/com/android/server/LocationManagerService.java @@ -82,8 +82,6 @@ import com.android.internal.os.BackgroundThread; import com.android.internal.util.ArrayUtils; import com.android.internal.util.DumpUtils; import com.android.server.location.ActivityRecognitionProxy; -import com.android.server.location.FlpHardwareProvider; -import com.android.server.location.FusedProxy; import com.android.server.location.GeocoderProxy; import com.android.server.location.GeofenceManager; import com.android.server.location.GeofenceProxy; @@ -491,13 +489,6 @@ public class LocationManagerService extends ILocationManager.Stub { if (gpsProvider != null && gpsProvider.isEnabled()) { gpsProvider.disable(); } - - // it is needed to check if FLP HW provider is supported before accessing the instance, this - // avoids an exception to be thrown by the singleton factory method - if (FlpHardwareProvider.isSupported()) { - FlpHardwareProvider flpHardwareProvider = FlpHardwareProvider.getInstance(mContext); - flpHardwareProvider.cleanup(); - } } /** @@ -686,27 +677,6 @@ public class LocationManagerService extends ILocationManager.Stub { Slog.e(TAG, "no geocoder provider found"); } - // bind to fused hardware provider if supported - // in devices without support, requesting an instance of FlpHardwareProvider will raise an - // exception, so make sure we only do that when supported - FlpHardwareProvider flpHardwareProvider; - if (FlpHardwareProvider.isSupported()) { - flpHardwareProvider = FlpHardwareProvider.getInstance(mContext); - FusedProxy fusedProxy = FusedProxy.createAndBind( - mContext, - mLocationHandler, - flpHardwareProvider.getLocationHardware(), - com.android.internal.R.bool.config_enableHardwareFlpOverlay, - com.android.internal.R.string.config_hardwareFlpPackageName, - com.android.internal.R.array.config_locationProviderPackageNames); - if (fusedProxy == null) { - Slog.d(TAG, "Unable to bind FusedProxy."); - } - } else { - flpHardwareProvider = null; - Slog.d(TAG, "FLP HAL not supported"); - } - // bind to geofence provider GeofenceProxy provider = GeofenceProxy.createAndBind( mContext, com.android.internal.R.bool.config_enableGeofenceOverlay, @@ -714,7 +684,7 @@ public class LocationManagerService extends ILocationManager.Stub { com.android.internal.R.array.config_locationProviderPackageNames, mLocationHandler, mGpsGeofenceProxy, - flpHardwareProvider != null ? flpHardwareProvider.getGeofenceHardware() : null); + null); if (provider == null) { Slog.d(TAG, "Unable to bind FLP Geofence proxy."); } diff --git a/services/core/java/com/android/server/location/FlpHardwareProvider.java b/services/core/java/com/android/server/location/FlpHardwareProvider.java deleted file mode 100644 index 5c9b0eaa29ccf..0000000000000 --- a/services/core/java/com/android/server/location/FlpHardwareProvider.java +++ /dev/null @@ -1,74 +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.server.location; - -import android.content.Context; -import android.hardware.location.IFusedLocationHardware; -import android.location.IFusedGeofenceHardware; -import android.util.Log; - -/** - * This class was an interop layer for JVM types and the JNI code that interacted - * with the FLP HAL implementation. - * - * Now, after Treble FLP & GNSS HAL simplification, it is a thin shell that acts like the - * pre-existing cases where there was no FLP Hardware support, to keep legacy users of this - * class operating. - * - * {@hide} - * {@Deprecated} - */ -public class FlpHardwareProvider { - private static FlpHardwareProvider sSingletonInstance = null; - - private final static String TAG = "FlpHardwareProvider"; - - private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); - - public static FlpHardwareProvider getInstance(Context context) { - if (sSingletonInstance == null) { - sSingletonInstance = new FlpHardwareProvider(); - if (DEBUG) Log.d(TAG, "getInstance() created empty provider"); - } - return sSingletonInstance; - } - - private FlpHardwareProvider() { - } - - public static boolean isSupported() { - if (DEBUG) Log.d(TAG, "isSupported() returning false"); - return false; - } - - /** - * Interface implementations for services built on top of this functionality. - */ - public static final String LOCATION = "Location"; - - public IFusedLocationHardware getLocationHardware() { - return null; - } - - public IFusedGeofenceHardware getGeofenceHardware() { - return null; - } - - public void cleanup() { - if (DEBUG) Log.d(TAG, "empty cleanup()"); - } -} diff --git a/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java b/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java deleted file mode 100644 index a08d3263be6c8..0000000000000 --- a/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java +++ /dev/null @@ -1,131 +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.server.location; - -import android.content.Context; -import android.hardware.location.IFusedLocationHardware; -import android.hardware.location.IFusedLocationHardwareSink; -import android.location.FusedBatchOptions; -import android.os.RemoteException; - -/** - * FusedLocationHardware decorator that adds permission checking. - * @hide - */ -public class FusedLocationHardwareSecure extends IFusedLocationHardware.Stub { - private final IFusedLocationHardware mLocationHardware; - private final Context mContext; - private final String mPermissionId; - - public FusedLocationHardwareSecure( - IFusedLocationHardware locationHardware, - Context context, - String permissionId) { - mLocationHardware = locationHardware; - mContext = context; - mPermissionId = permissionId; - } - - private void checkPermissions() { - mContext.enforceCallingPermission( - mPermissionId, - String.format( - "Permission '%s' not granted to access FusedLocationHardware", - mPermissionId)); - } - - @Override - public void registerSink(IFusedLocationHardwareSink eventSink) throws RemoteException { - checkPermissions(); - mLocationHardware.registerSink(eventSink); - } - - @Override - public void unregisterSink(IFusedLocationHardwareSink eventSink) throws RemoteException { - checkPermissions(); - mLocationHardware.unregisterSink(eventSink); - } - - @Override - public int getSupportedBatchSize() throws RemoteException { - checkPermissions(); - return mLocationHardware.getSupportedBatchSize(); - } - - @Override - public void startBatching(int id, FusedBatchOptions batchOptions) throws RemoteException { - checkPermissions(); - mLocationHardware.startBatching(id, batchOptions); - } - - @Override - public void stopBatching(int id) throws RemoteException { - checkPermissions(); - mLocationHardware.stopBatching(id); - } - - @Override - public void updateBatchingOptions( - int id, - FusedBatchOptions batchoOptions - ) throws RemoteException { - checkPermissions(); - mLocationHardware.updateBatchingOptions(id, batchoOptions); - } - - @Override - public void requestBatchOfLocations(int batchSizeRequested) throws RemoteException { - checkPermissions(); - mLocationHardware.requestBatchOfLocations(batchSizeRequested); - } - - @Override - public boolean supportsDiagnosticDataInjection() throws RemoteException { - checkPermissions(); - return mLocationHardware.supportsDiagnosticDataInjection(); - } - - @Override - public void injectDiagnosticData(String data) throws RemoteException { - checkPermissions(); - mLocationHardware.injectDiagnosticData(data); - } - - @Override - public boolean supportsDeviceContextInjection() throws RemoteException { - checkPermissions(); - return mLocationHardware.supportsDeviceContextInjection(); - } - - @Override - public void injectDeviceContext(int deviceEnabledContext) throws RemoteException { - checkPermissions(); - mLocationHardware.injectDeviceContext(deviceEnabledContext); - } - - @Override - public void flushBatchedLocations() throws RemoteException { - checkPermissions(); - mLocationHardware.flushBatchedLocations(); - } - - @Override - public int getVersion() throws RemoteException { - checkPermissions(); - return mLocationHardware.getVersion(); - } -} diff --git a/services/core/java/com/android/server/location/FusedProxy.java b/services/core/java/com/android/server/location/FusedProxy.java deleted file mode 100644 index b90f037a50460..0000000000000 --- a/services/core/java/com/android/server/location/FusedProxy.java +++ /dev/null @@ -1,130 +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 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.server.location; - -import com.android.server.ServiceWatcher; - -import android.Manifest; -import android.content.Context; -import android.hardware.location.IFusedLocationHardware; -import android.location.IFusedProvider; -import android.os.Handler; -import android.os.IBinder; -import android.os.RemoteException; -import android.util.Log; - -/** - * Proxy that helps bind GCore FusedProvider implementations to the Fused Hardware instances. - * - * @hide - */ -public final class FusedProxy { - private final String TAG = "FusedProxy"; - private final ServiceWatcher mServiceWatcher; - private final FusedLocationHardwareSecure mLocationHardware; - - /** - * Constructor of the class. - * This is private as the class follows a factory pattern for construction. - * - * @param context The context needed for construction. - * @param handler The handler needed for construction. - * @param locationHardware The instance of the Fused location hardware assigned to the proxy. - */ - private FusedProxy( - Context context, - Handler handler, - IFusedLocationHardware locationHardware, - int overlaySwitchResId, - int defaultServicePackageNameResId, - int initialPackageNameResId) { - mLocationHardware = new FusedLocationHardwareSecure( - locationHardware, - context, - Manifest.permission.LOCATION_HARDWARE); - Runnable newServiceWork = new Runnable() { - @Override - public void run() { - bindProvider(mLocationHardware); - } - }; - - // prepare the connection to the provider - mServiceWatcher = new ServiceWatcher( - context, - TAG, - "com.android.location.service.FusedProvider", - overlaySwitchResId, - defaultServicePackageNameResId, - initialPackageNameResId, - newServiceWork, - handler); - } - - /** - * Creates an instance of the proxy and binds it to the appropriate FusedProvider. - * - * @param context The context needed for construction. - * @param handler The handler needed for construction. - * @param locationHardware The instance of the Fused location hardware assigned to the proxy. - * - * @return An instance of the proxy if it could be bound, null otherwise. - */ - public static FusedProxy createAndBind( - Context context, - Handler handler, - IFusedLocationHardware locationHardware, - int overlaySwitchResId, - int defaultServicePackageNameResId, - int initialPackageNameResId) { - FusedProxy fusedProxy = new FusedProxy( - context, - handler, - locationHardware, - overlaySwitchResId, - defaultServicePackageNameResId, - initialPackageNameResId); - - // try to bind the Fused provider - if (!fusedProxy.mServiceWatcher.start()) { - return null; - } - - return fusedProxy; - } - - /** - * Helper function to bind the FusedLocationHardware to the appropriate FusedProvider instance. - * - * @param locationHardware The FusedLocationHardware instance to use for the binding operation. - */ - private void bindProvider(IFusedLocationHardware locationHardware) { - if (!mServiceWatcher.runOnBinder(new ServiceWatcher.BinderRunner() { - @Override - public void run(IBinder binder) { - IFusedProvider provider = IFusedProvider.Stub.asInterface(binder); - try { - provider.onFusedLocationHardwareChange(locationHardware); - } catch (RemoteException e) { - Log.e(TAG, e.toString()); - } - } - })) { - Log.e(TAG, "No instance of FusedProvider found on FusedLocationHardware connected."); - } - } -}