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
diff --git a/services/art-profile b/services/art-profile
index d2cde02..93e580a 100644
--- a/services/art-profile
+++ b/services/art-profile
@@ -10677,7 +10677,6 @@
 PLcom/android/server/location/CountryDetectorBase;-><init>(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;-><init>(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 65e90bad..d5cbfd4 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.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 @@
         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 @@
             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 @@
                 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 5c9b0ea..0000000
--- 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 a08d326..0000000
--- 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 b90f037..0000000
--- 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.");
-        }
-    }
-}