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

Commit 77a9227b authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

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
parent 9a6a6740
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4136,7 +4136,7 @@ package android.location {
    method public boolean isComplete();
    method public void makeComplete();
    method public void setIsFromMockProvider(boolean);
    field public static final String EXTRA_NO_GPS_LOCATION = "noGPSLocation";
    field @Deprecated public static final String EXTRA_NO_GPS_LOCATION = "noGPSLocation";
  }
  public class LocationManager {
+1 −1
Original line number Diff line number Diff line
@@ -1338,7 +1338,7 @@ package android.location {

  public class Location implements android.os.Parcelable {
    method public void makeComplete();
    field public static final String EXTRA_NO_GPS_LOCATION = "noGPSLocation";
    field @Deprecated public static final String EXTRA_NO_GPS_LOCATION = "noGPSLocation";
  }

  public class LocationManager {
+11 −0
Original line number Diff line number Diff line
@@ -6257,16 +6257,19 @@ public final class Settings {
         * @hide
         */
        public static final String LOCATION_CHANGER = "location_changer";
        /**
         * The location changer is unknown or unable to detect.
         * @hide
         */
        public static final int LOCATION_CHANGER_UNKNOWN = 0;
        /**
         * Location settings in system settings.
         * @hide
         */
        public static final int LOCATION_CHANGER_SYSTEM_SETTINGS = 1;
        /**
         * The location icon in drop down notification drawer.
         * @hide
@@ -6313,6 +6316,14 @@ public final class Settings {
        @SystemApi
        public static final int LOCATION_MODE_ON = LOCATION_MODE_HIGH_ACCURACY;
        /**
         * The accuracy in meters used for coarsening location for clients with only the coarse
         * location permission.
         *
         * @hide
         */
        public static final String LOCATION_COARSE_ACCURACY_M = "locationCoarseAccuracy";
        /**
         * A flag containing settings used for biometric weak
         * @hide
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ interface ILocationManager
    boolean startGnssBatch(long periodNanos, boolean wakeOnFifoFull, String packageName);
    void flushGnssBatch(String packageName);
    boolean stopGnssBatch();
    boolean injectLocation(in Location location);
    void injectLocation(in Location location);

    @UnsupportedAppUsage
    List<String> getAllProviders();
+4 −9
Original line number Diff line number Diff line
@@ -63,24 +63,19 @@ public class Location implements Parcelable {
     */
    public static final int FORMAT_SECONDS = 2;

    /**
     * Bundle key for a version of the location that has been fed through
     * LocationFudger. Allows location providers to flag locations as being
     * safe for use with ACCESS_COARSE_LOCATION permission.
     *
     * @hide
     */
    public static final String EXTRA_COARSE_LOCATION = "coarseLocation";

    /**
     * Bundle key for a version of the location containing no GPS data.
     * Allows location providers to flag locations as being safe to
     * feed to LocationFudger.
     *
     * @hide
     * @deprecated As of Android R, this extra is longer in use, since it is not necessary to keep
     * gps locations separate from other locations for coarsening. Providers that do not need to
     * support platforms below Android R should not use this constant.
     */
    @TestApi
    @SystemApi
    @Deprecated
    public static final String EXTRA_NO_GPS_LOCATION = "noGPSLocation";

    /**
Loading