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

Commit 0c6f2d41 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update setLocationEnabled in DPM"

parents 49f80422 103ba9e8
Loading
Loading
Loading
Loading
+12 −23
Original line number Diff line number Diff line
@@ -10993,21 +10993,13 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    @Override
    public void setLocationEnabled(ComponentName who, boolean locationEnabled) {
        Preconditions.checkNotNull(who, "ComponentName is null");
        int userId = mInjector.userHandleGetCallingUserId();
        synchronized (getLockObject()) {
            getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
        enforceDeviceOwner(who);
            if (!isDeviceOwner(who, userId) && !isCurrentUserDemo()) {
                throw new SecurityException(
                        "Permission denial: Profile owners cannot update location settings");
            }
        }
        UserHandle userHandle = mInjector.binderGetCallingUserHandle();
        mInjector.binderWithCleanCallingIdentity(
                () -> mInjector.getLocationManager().setLocationEnabledForUser(locationEnabled,
                        userHandle));
        long ident = mInjector.binderClearCallingIdentity();
        try {
            mInjector.getLocationManager().setLocationEnabledForUser(
                    locationEnabled, UserHandle.of(userId));
        DevicePolicyEventLogger
                .createEvent(DevicePolicyEnums.SET_SECURE_SETTING)
                .setAdmin(who)
@@ -11015,9 +11007,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                        locationEnabled ? Settings.Secure.LOCATION_MODE_ON
                                : Settings.Secure.LOCATION_MODE_OFF))
                .write();
        } finally {
            mInjector.binderRestoreCallingIdentity(ident);
        }
    }
    @Override