Include userId in the exception message for diagnostics

This is needed to restore the order of events causing
the issue. I'd prefer to check this locally, but the bug
is tricky to reproduce, only happened once on my device.

Bug: 131834071
Test: builds
Change-Id: I5ac2196de5b7583300ef2e7770aa093de86972b0
This commit is contained in:
Pavel Grafov
2019-06-21 12:18:59 +01:00
parent 353402fc4a
commit 965b91f01c

View File

@@ -8703,15 +8703,17 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
enforceSystemUserOrPermission(permission);
}
private void enforceManagedProfile(int userHandle, String message) {
if(!isManagedProfile(userHandle)) {
throw new SecurityException("You can not " + message + " outside a managed profile.");
private void enforceManagedProfile(int userId, String message) {
if (!isManagedProfile(userId)) {
throw new SecurityException(String.format(
"You can not %s outside a managed profile, userId = %d", message, userId));
}
}
private void enforceNotManagedProfile(int userHandle, String message) {
if(isManagedProfile(userHandle)) {
throw new SecurityException("You can not " + message + " for a managed profile.");
private void enforceNotManagedProfile(int userId, String message) {
if (isManagedProfile(userId)) {
throw new SecurityException(String.format(
"You can not %s for a managed profile, userId = %d", message, userId));
}
}