Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d77ea68 authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Change provider packages API to test all providers

This will replace the LocationManager.getNetworkProviderPackage() API
with LocationManager.isProviderPackage(). The network provider should
not be considered special.

In addition, providers now have the ability to specify additional
packages that may make location requests on their behalf, so that those
packages can be considered location providers as well.

Bug: 117177078
Test: manually
Change-Id: I204b56e7bb40874ac3347988474fb8afa787feb8
parent affa55b4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3322,6 +3322,7 @@ package android.location {
    method public boolean isLocationControllerExtraPackageEnabled();
    method public boolean isLocationEnabledForUser(android.os.UserHandle);
    method public boolean isProviderEnabledForUser(String, android.os.UserHandle);
    method public boolean isProviderPackage(String);
    method @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE) public boolean registerGnssBatchedLocationCallback(long, boolean, android.location.BatchedLocationCallback, android.os.Handler);
    method @Deprecated public void removeGpsMeasurementListener(android.location.GpsMeasurementsEvent.Listener);
    method @Deprecated public void removeGpsNavigationMessageListener(android.location.GpsNavigationMessageEvent.Listener);
+2 −1
Original line number Diff line number Diff line
@@ -85,12 +85,13 @@ interface ILocationManager
    boolean stopGnssBatch();
    boolean injectLocation(in Location location);

    // --- deprecated ---
    List<String> getAllProviders();
    List<String> getProviders(in Criteria criteria, boolean enabledOnly);
    String getBestProvider(in Criteria criteria, boolean enabledOnly);
    ProviderProperties getProviderProperties(String provider);
    String getNetworkProviderPackage();
    boolean isProviderPackage(String packageName);

    void setLocationControllerExtraPackage(String packageName);
    String getLocationControllerExtraPackage();
    void setLocationControllerExtraPackageEnabled(boolean enabled);
+16 −0
Original line number Diff line number Diff line
@@ -2424,6 +2424,22 @@ public class LocationManager {
        }
    }

    /**
     * Returns true if the given package name matches a location provider package, and false
     * otherwise.
     *
     * @hide
     */
    @SystemApi
    public boolean isProviderPackage(String packageName) {
        try {
            return mService.isProviderPackage(packageName);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
            return false;
        }
    }

    /**
     * Set the extra location controller package for location services on the device.
     *
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import com.android.internal.location.ProviderProperties;
 */
interface ILocationProviderManager {

    void onSetAdditionalProviderPackages(in List<String> packageNames);

    void onSetEnabled(boolean enabled);

    void onSetProperties(in ProviderProperties properties);
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.location.provider {
    method protected boolean onSendExtraCommand(@Nullable String, @Nullable android.os.Bundle);
    method protected abstract void onSetRequest(com.android.location.provider.ProviderRequestUnbundled, android.os.WorkSource);
    method public void reportLocation(android.location.Location);
    method public void setAdditionalProviderPackages(java.util.List<java.lang.String>);
    method public void setEnabled(boolean);
    method public void setProperties(com.android.location.provider.ProviderPropertiesUnbundled);
    field public static final String EXTRA_NO_GPS_LOCATION = "noGPSLocation";
Loading