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

Commit 1575a04e authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Refactor how location providers are managed

Put enabled/disabled state under location provider control, and use it
to represent whether a location provider may be used, not whether the
user has enabled or disabled a location provider.

Bug: 118885128
Test: manually
Change-Id: I1209c49c13ca8995b223f383ad332322fffc7a96
parent 4c479018
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -451,6 +451,7 @@ java_defaults {
        "location/java/android/location/IGpsGeofenceHardware.aidl",
        "location/java/android/location/INetInitiatedListener.aidl",
        "location/java/com/android/internal/location/ILocationProvider.aidl",
        "location/java/com/android/internal/location/ILocationProviderManager.aidl",
        "media/java/android/media/IAudioFocusDispatcher.aidl",
        "media/java/android/media/IAudioRoutesObserver.aidl",
        "media/java/android/media/IAudioService.aidl",
+2 −2
Original line number Diff line number Diff line
@@ -22732,8 +22732,8 @@ package android.location {
    method public boolean addNmeaListener(android.location.OnNmeaMessageListener, android.os.Handler);
    method public void addProximityAlert(double, double, float, long, android.app.PendingIntent);
    method public void addTestProvider(java.lang.String, boolean, boolean, boolean, boolean, boolean, boolean, boolean, int, int);
    method public void clearTestProviderEnabled(java.lang.String);
    method public void clearTestProviderLocation(java.lang.String);
    method public deprecated void clearTestProviderEnabled(java.lang.String);
    method public deprecated void clearTestProviderLocation(java.lang.String);
    method public deprecated void clearTestProviderStatus(java.lang.String);
    method public java.util.List<java.lang.String> getAllProviders();
    method public java.lang.String getBestProvider(android.location.Criteria, boolean);
+7 −4
Original line number Diff line number Diff line
@@ -1849,13 +1849,16 @@ Lcom/android/internal/location/GpsNetInitiatedHandler;->handleNiNotification(Lco
Lcom/android/internal/location/GpsNetInitiatedHandler;->mIsHexInput:Z
Lcom/android/internal/location/ILocationProvider$Stub;-><init>()V
Lcom/android/internal/location/ILocationProvider$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/location/ILocationProvider;
Lcom/android/internal/location/ILocationProvider;->disable()V
Lcom/android/internal/location/ILocationProvider;->enable()V
Lcom/android/internal/location/ILocationProvider;->getProperties()Lcom/android/internal/location/ProviderProperties;
Lcom/android/internal/location/ILocationProvider;->getStatus(Landroid/os/Bundle;)I
Lcom/android/internal/location/ILocationProvider;->getStatusUpdateTime()J
Lcom/android/internal/location/ILocationProvider;->sendExtraCommand(Ljava/lang/String;Landroid/os/Bundle;)Z
Lcom/android/internal/location/ILocationProvider;->sendExtraCommand(Ljava/lang/String;Landroid/os/Bundle;)V
Lcom/android/internal/location/ILocationProvider;->setLocationProviderManager(Lcom/android/internal/location/ILocationProviderManager;)V
Lcom/android/internal/location/ILocationProvider;->setRequest(Lcom/android/internal/location/ProviderRequest;Landroid/os/WorkSource;)V
Lcom/android/internal/location/ILocationProviderManager$Stub;-><init>()V
Lcom/android/internal/location/ILocationProviderManager$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/location/ILocationProviderManager;
Lcom/android/internal/location/ILocationProviderManager;->onReportLocation(Landroid/location/Location;)V
Lcom/android/internal/location/ILocationProviderManager;->onSetEnabled(Z)V
Lcom/android/internal/location/ILocationProviderManager;->onSetProperties(Lcom/android/internal/location/ProviderProperties;)V
Lcom/android/internal/logging/MetricsLogger;-><init>()V
Lcom/android/internal/net/LegacyVpnInfo;-><init>()V
Lcom/android/internal/net/VpnConfig;-><init>()V
+1 −7
Original line number Diff line number Diff line
@@ -96,9 +96,7 @@ interface ILocationManager
    void addTestProvider(String name, in ProviderProperties properties, String opPackageName);
    void removeTestProvider(String provider, String opPackageName);
    void setTestProviderLocation(String provider, in Location loc, String opPackageName);
    void clearTestProviderLocation(String provider, String opPackageName);
    void setTestProviderEnabled(String provider, boolean enabled, String opPackageName);
    void clearTestProviderEnabled(String provider, String opPackageName);

    // --- deprecated ---
    void setTestProviderStatus(String provider, int status, in Bundle extras, long updateTime,
@@ -108,12 +106,8 @@ interface ILocationManager

    // --- internal ---

    // Used by location providers to tell the location manager when it has a new location.
    // Passive is true if the location is coming from the passive provider, in which case
    // it need not be shared with other providers.
    // --- deprecated ---
    void reportLocation(in Location location, boolean passive);

    // Used when a (initially Gnss) Location batch arrives
    void reportLocationBatch(in List<Location> locations);

    // for reporting callback completion
+8 −12
Original line number Diff line number Diff line
@@ -1537,14 +1537,11 @@ public class LocationManager {
     * mock location app op} is not set to {@link android.app.AppOpsManager#MODE_ALLOWED
     * allowed} for your app.
     * @throws IllegalArgumentException if no provider with the given name exists
     *
     * @deprecated This function has always been a no-op, and may be removed in the future.
     */
    public void clearTestProviderLocation(String provider) {
        try {
            mService.clearTestProviderLocation(provider, mContext.getOpPackageName());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
    @Deprecated
    public void clearTestProviderLocation(String provider) {}

    /**
     * Sets a mock enabled value for the given provider.  This value will be used in place
@@ -1575,13 +1572,12 @@ public class LocationManager {
     * mock location app op} is not set to {@link android.app.AppOpsManager#MODE_ALLOWED
     * allowed} for your app.
     * @throws IllegalArgumentException if no provider with the given name exists
     *
     * @deprecated Use {@link #setTestProviderEnabled(String, boolean)} instead.
     */
    @Deprecated
    public void clearTestProviderEnabled(String provider) {
        try {
            mService.clearTestProviderEnabled(provider, mContext.getOpPackageName());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        setTestProviderEnabled(provider, true);
    }

    /**
Loading