From bc630497b490de679b6856801521dc4a36416325 Mon Sep 17 00:00:00 2001 From: Vladislav Kuzkokov Date: Fri, 23 Feb 2018 17:45:21 +0100 Subject: [PATCH] Check printing restriction for correct user. Work profile uses the same instance of PrintManager and DPM as the primary user. We have to explicitly check restriction for calling user. Bug: 73768054 Test: Set restriction in Work profile, check that it applies only in work profile. Change-Id: Iaa63ce000fc84b7d0ee2bd0ff008f1c0f7272a87 --- .../server/devicepolicy/DevicePolicyManagerService.java | 3 ++- .../java/com/android/server/print/PrintManagerService.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 875334413b5ac..fb56e83e46a95 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -10410,7 +10410,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { public CharSequence getPrintingDisabledReasonForUser(@UserIdInt int userId) { synchronized (DevicePolicyManagerService.this) { DevicePolicyData policy = getUserData(userId); - if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_PRINTING)) { + if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_PRINTING, + UserHandle.of(userId))) { Log.e(LOG_TAG, "printing is enabled"); return null; } diff --git a/services/print/java/com/android/server/print/PrintManagerService.java b/services/print/java/com/android/server/print/PrintManagerService.java index e8620edc9d5e6..83a125d1fc366 100644 --- a/services/print/java/com/android/server/print/PrintManagerService.java +++ b/services/print/java/com/android/server/print/PrintManagerService.java @@ -718,7 +718,8 @@ public final class PrintManagerService extends SystemService { } private boolean isPrintingEnabled() { - return !mUserManager.hasUserRestriction(UserManager.DISALLOW_PRINTING); + return !mUserManager.hasUserRestriction(UserManager.DISALLOW_PRINTING, + Binder.getCallingUserHandle()); } private void dump(@NonNull DualDumpOutputStream dumpStream,