summaryrefslogtreecommitdiff
path: root/location/lib/java
diff options
context:
space:
mode:
authorSoonil Nagarkar <sooniln@google.com>2020-02-11 14:04:39 -0800
committerSoonil Nagarkar <sooniln@google.com>2020-02-11 14:04:39 -0800
commit77a9227b19cb4afefbf14fb4616d2d917f9bffb5 (patch)
tree710acdb4356fd39366d5878aedb4fd20f213a883 /location/lib/java
parent9a6a6740524be286863c89474c51027f1c27e9f6 (diff)
Fix work profile handling across location
There were a couple problems with work profile state in location. First, we assumed that notifications sent to parent users would also be sent to profiles but this is not true. Second we had assumed location status in profiles was always identical to the parent user, but work profiles may have user restrictions applied which are not present on the parent user. The easiest way to handle these issues seems to be to expand LMS user handling to deal with all users, rather than making various assumptions which may or may not be true. This also means we need to store last locations on a per profile basis. Since we're refactoring how last location works completely, we also removed the special NO_GPS handling for last locations. With the new permission strings we now no longer have to exclude gnss based location from coarsening. This lets us: 1) deprecate and remove various constants and methods use for storing coarse locations tied to fine locations 2) substantially simplify code that calculated coarse location This also exposed numerous bugs in the location service where we were using the current user's state instead of the calling user's state, which could have exposed the current user's location to other users inappropriately. Bug: 148798374 Bug: 146071833 Test: presubmits + manual Change-Id: I2d3216a9fb58b73d0124d563b05de8870b70b716
Diffstat (limited to 'location/lib/java')
-rw-r--r--location/lib/java/com/android/location/provider/LocationProviderBase.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/location/lib/java/com/android/location/provider/LocationProviderBase.java b/location/lib/java/com/android/location/provider/LocationProviderBase.java
index f67d08e045e2..bd29d8ac2a85 100644
--- a/location/lib/java/com/android/location/provider/LocationProviderBase.java
+++ b/location/lib/java/com/android/location/provider/LocationProviderBase.java
@@ -224,6 +224,19 @@ public abstract class LocationProviderBase {
public void reportLocation(Location location) {
ILocationProviderManager manager = mManager;
if (manager != null) {
+ // remove deprecated extras to save on serialization
+ Bundle extras = location.getExtras();
+ if (extras != null && (extras.containsKey("noGPSLocation")
+ || extras.containsKey("coarseLocation"))) {
+ location = new Location(location);
+ extras = location.getExtras();
+ extras.remove("noGPSLocation");
+ extras.remove("coarseLocation");
+ if (extras.isEmpty()) {
+ location.setExtras(null);
+ }
+ }
+
try {
manager.onReportLocation(location);
} catch (RemoteException | RuntimeException e) {