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

Commit 3b07923b authored by Elis Elliott's avatar Elis Elliott Committed by Automerger Merge Worker
Browse files

Merge "Only call canUserCallLockTask when the caller is a DPC" into udc-dev...

Merge "Only call canUserCallLockTask when the caller is a DPC" into udc-dev am: 6daf38c0 am: e8f897e0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23434561



Change-Id: I65f41a05106a5677a3cb6d683ee6fb69c54a7451
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents a73b99ad e8f897e0
Loading
Loading
Loading
Loading
+12 −13
Original line number Diff line number Diff line
@@ -11113,7 +11113,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                || hasCallingOrSelfPermission(permission.INTERACT_ACROSS_USERS);
    }
    private boolean canUserUseLockTaskLocked(int userId) {
    private boolean canDPCManagedUserUseLockTaskLocked(int userId) {
        if (isUserAffiliatedWithDeviceLocked(userId)) {
            return true;
        }
@@ -11123,13 +11123,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            return false;
        }
        
        if (!isPermissionCheckFlagEnabled() && !isPolicyEngineForFinanceFlagEnabled()) {
        final ComponentName profileOwner = getProfileOwnerAsUser(userId);
        if (profileOwner == null) {
            return false;
        }
        }
        // Managed profiles are not allowed to use lock task
        if (isManagedProfile(userId)) {
            return false;
@@ -11142,7 +11139,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        final int userId = caller.getUserId();
        enforceCanQuery(MANAGE_DEVICE_POLICY_LOCK_TASK, caller.getPackageName(), userId);
        if (!canUserUseLockTaskLocked(userId)) {
        if ((isDeviceOwner(caller) || isProfileOwner(caller))
                && !canDPCManagedUserUseLockTaskLocked(userId)) {
            throw new SecurityException("User " + userId + " is not allowed to use lock task");
        }
    }
@@ -11158,7 +11156,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                caller.getPackageName(),
                userId
        );
        if (!canUserUseLockTaskLocked(userId)) {
        if ((isDeviceOwner(caller) || isProfileOwner(caller))
                && !canDPCManagedUserUseLockTaskLocked(userId)) {
            throw new SecurityException("User " + userId + " is not allowed to use lock task");
        }
        return enforcingAdmin;
@@ -11169,7 +11168,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                || isDefaultDeviceOwner(caller) || isFinancedDeviceOwner(caller));
        final int userId =  caller.getUserId();
        if (!canUserUseLockTaskLocked(userId)) {
        if (!canDPCManagedUserUseLockTaskLocked(userId)) {
            throw new SecurityException("User " + userId + " is not allowed to use lock task");
        }
    }
@@ -15101,7 +15100,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            final List<UserInfo> userInfos = mUserManager.getAliveUsers();
            for (int i = userInfos.size() - 1; i >= 0; i--) {
                int userId = userInfos.get(i).id;
                if (canUserUseLockTaskLocked(userId)) {
                if (canDPCManagedUserUseLockTaskLocked(userId)) {
                    continue;
                }