summaryrefslogtreecommitdiff
path: root/location/java
diff options
context:
space:
mode:
authorSoonil Nagarkar <sooniln@google.com>2021-06-09 14:27:38 -0700
committerSoonil Nagarkar <sooniln@google.com>2021-06-15 08:45:44 -0700
commit4aa42bdb17a64203fdca94e2458b4152191e15a2 (patch)
tree2c1ebf9858e5eb26b3ee9aba0f3922f872ef02b9 /location/java
parent3f1e0c9d5a6779971616c9d9139cd2234de79334 (diff)
Fix bugs in LocationManagerService and AppOpsPolicy
LocationManagerService was overwriting location source appops tag information whenever a location provider changed state. Since multiple location providers can correspond to the same uid/app id, this could lead to loss of tags. This is fixed by recalculating the set of tag for an entire app id any time a uid changes. AppOpsPolicy had a bug where tag lists coming from different uids under the same appid would inappropriately overwrite each other. This is fixed by modifying the internal/external APIs to work in terms of appid rather than uid, so that it is someone else's responsibility to ensure the result is valid for the app id as a whole. Also fixes a bug where LMS assumes tag listeners are added prior to any providers. If listeners are added after some providers they will miss updates. Fixed by always updating the listener on registration. Bug: 190073375 Test: manual Change-Id: Ib52d752d857b6ac3b6683186a8d1bbcb814fb798
Diffstat (limited to 'location/java')
-rw-r--r--location/java/android/location/LocationManagerInternal.java73
1 files changed, 8 insertions, 65 deletions
diff --git a/location/java/android/location/LocationManagerInternal.java b/location/java/android/location/LocationManagerInternal.java
index 763835c9cbe2..d59756d02348 100644
--- a/location/java/android/location/LocationManagerInternal.java
+++ b/location/java/android/location/LocationManagerInternal.java
@@ -16,14 +16,10 @@
package android.location;
-
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.location.util.identity.CallerIdentity;
-
-import com.android.internal.annotations.Immutable;
-
-import java.util.Set;
+import android.os.PackageTagsList;
/**
* Location manager local system service interface.
@@ -43,18 +39,14 @@ public abstract class LocationManagerInternal {
}
/**
- * Interface for getting callbacks when a location provider's location tags change.
- *
- * @see LocationTagInfo
+ * Interface for getting callbacks when an app id's location provider package tags change.
*/
- public interface OnProviderLocationTagsChangeListener {
+ public interface LocationPackageTagsListener {
/**
- * Called when the location tags for a provider change.
- *
- * @param providerLocationTagInfo The tag info for a provider.
+ * Called when the package tags for a location provider change for a uid.
*/
- void onLocationTagsChanged(@NonNull LocationTagInfo providerLocationTagInfo);
+ void onLocationPackageTagsChanged(int uid, @NonNull PackageTagsList packageTagsList);
}
/**
@@ -109,58 +101,9 @@ public abstract class LocationManagerInternal {
public abstract @Nullable LocationTime getGnssTimeMillis();
/**
- * Sets a listener for changes in the location providers' tags. Passing
+ * Sets a listener for changes in an app id's location provider package tags. Passing
* {@code null} clears the current listener.
- *
- * @param listener The listener.
*/
- public abstract void setOnProviderLocationTagsChangeListener(
- @Nullable OnProviderLocationTagsChangeListener listener);
-
- /**
- * This class represents the location permission tags used by the location provider
- * packages in a given UID. These tags are strictly used for accessing state guarded
- * by the location permission(s) by a location provider which are required for the
- * provider to fulfill its function as being a location provider.
- */
- @Immutable
- public static class LocationTagInfo {
- private final int mUid;
-
- @NonNull
- private final String mPackageName;
-
- @Nullable
- private final Set<String> mLocationTags;
-
- public LocationTagInfo(int uid, @NonNull String packageName,
- @Nullable Set<String> locationTags) {
- mUid = uid;
- mPackageName = packageName;
- mLocationTags = locationTags;
- }
-
- /**
- * @return The UID for which tags are related.
- */
- public int getUid() {
- return mUid;
- }
-
- /**
- * @return The package for which tags are related.
- */
- @NonNull
- public String getPackageName() {
- return mPackageName;
- }
-
- /**
- * @return The tags for the package used for location related accesses.
- */
- @Nullable
- public Set<String> getTags() {
- return mLocationTags;
- }
- }
+ public abstract void setLocationPackageTagsListener(
+ @Nullable LocationPackageTagsListener listener);
}