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

Commit 9b132e13 authored by Eran Messeri's avatar Eran Messeri
Browse files

Revert: Prevent auto-granting of location permission via DPM

Revert the change where the DPC could no longer set location permissions
by calling DevicePolicyManager.setPermissionGrantState.

Bug: 148631522
Bug: 147650798
Test: manual
Test: see cts tests in associated CL.
Change-Id: Ic6ebb7c8001a8e356296bc6459fc3530e0531070
parent ea2a3361
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -9447,16 +9447,6 @@ public class DevicePolicyManager {
     * {@link android.os.Build.VERSION_CODES#M} the app-op matching the permission is set to
     * {@link android.app.AppOpsManager#MODE_IGNORED}, but the permission stays granted.
     *
     * NOTE: Starting from Android R, location-related permissions cannot be granted by the
     * admin: Calling this method with {@link #PERMISSION_GRANT_STATE_GRANTED} for any of the
     * following permissions will return false:
     *
     * <ul>
     * <li>{@code ACCESS_FINE_LOCATION}</li>
     * <li>{@code ACCESS_BACKGROUND_LOCATION}</li>
     * <li>{@code ACCESS_COARSE_LOCATION}</li>
     * </ul>
     *
     * @param admin Which profile or device owner this request is associated with.
     * @param packageName The application to grant or revoke a permission to.
     * @param permission The permission to grant or revoke.
+0 −15
Original line number Diff line number Diff line
@@ -458,8 +458,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    // A collection of user restrictions that are deprecated and should simply be ignored.
    private static final Set<String> DEPRECATED_USER_RESTRICTIONS;
    private static final String AB_DEVICE_KEY = "ro.build.ab_update";
    // Permissions related to location which must not be granted automatically
    private static  final Set<String> LOCATION_PERMISSIONS;
    static {
        SECURE_SETTINGS_WHITELIST = new ArraySet<>();
@@ -504,11 +502,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        DEPRECATED_USER_RESTRICTIONS = Sets.newHashSet(
                UserManager.DISALLOW_ADD_MANAGED_PROFILE,
                UserManager.DISALLOW_REMOVE_MANAGED_PROFILE);
        LOCATION_PERMISSIONS = Sets.newHashSet(
                permission.ACCESS_FINE_LOCATION,
                permission.ACCESS_BACKGROUND_LOCATION,
                permission.ACCESS_COARSE_LOCATION);
    }
    /**
@@ -12516,14 +12509,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                            true);
                }
                // Prevent granting location-related permissions without user consent.
                if (LOCATION_PERMISSIONS.contains(permission)
                        && grantState == DevicePolicyManager.PERMISSION_GRANT_STATE_GRANTED
                        && !isUnattendedManagedKioskUnchecked()) {
                    callback.sendResult(null);
                    return;
                }
                if (grantState == DevicePolicyManager.PERMISSION_GRANT_STATE_GRANTED
                        || grantState == DevicePolicyManager.PERMISSION_GRANT_STATE_DENIED
                        || grantState == DevicePolicyManager.PERMISSION_GRANT_STATE_DEFAULT) {