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

Commit a2b73480 authored by David Christie's avatar David Christie
Browse files

Fix QuickSettings to honor location setting for restricted users (b/10553306).

Generally when a user is location restricted, location will be off.
But just in case location is on and locked in that state, we should
respect that in the UI.

Change-Id: I112139db447ba6dbf4c7c38600406fb5ba6a1fa8
parent 0cdc24a2
Loading
Loading
Loading
Loading
+5 −6
Original line number Original line Diff line number Diff line
@@ -129,6 +129,8 @@ public class LocationController extends BroadcastReceiver {
        // setting won't be fully enabled until the user accepts the agreement.
        // setting won't be fully enabled until the user accepts the agreement.
        int mode = enabled
        int mode = enabled
                ? Settings.Secure.LOCATION_MODE_HIGH_ACCURACY : Settings.Secure.LOCATION_MODE_OFF;
                ? Settings.Secure.LOCATION_MODE_HIGH_ACCURACY : Settings.Secure.LOCATION_MODE_OFF;
        // QuickSettings always runs as the owner, so specifically set the settings
        // for the current foreground user.
        return Settings.Secure
        return Settings.Secure
                .putIntForUser(cr, Settings.Secure.LOCATION_MODE, mode, currentUserId);
                .putIntForUser(cr, Settings.Secure.LOCATION_MODE, mode, currentUserId);
    }
    }
@@ -137,14 +139,11 @@ public class LocationController extends BroadcastReceiver {
     * Returns true if location isn't disabled in settings.
     * Returns true if location isn't disabled in settings.
     */
     */
    public boolean isLocationEnabled() {
    public boolean isLocationEnabled() {
        int currentUserId = ActivityManager.getCurrentUser();
        if (isUserLocationRestricted(currentUserId)) {
            return false;
        }

        ContentResolver resolver = mContext.getContentResolver();
        ContentResolver resolver = mContext.getContentResolver();
        // QuickSettings always runs as the owner, so specifically retrieve the settings
        // for the current foreground user.
        int mode = Settings.Secure.getIntForUser(resolver, Settings.Secure.LOCATION_MODE,
        int mode = Settings.Secure.getIntForUser(resolver, Settings.Secure.LOCATION_MODE,
                Settings.Secure.LOCATION_MODE_OFF, currentUserId);
                Settings.Secure.LOCATION_MODE_OFF, ActivityManager.getCurrentUser());
        return mode != Settings.Secure.LOCATION_MODE_OFF;
        return mode != Settings.Secure.LOCATION_MODE_OFF;
    }
    }