From 417601034da4aaaae4b1621f4aa223cdd6703231 Mon Sep 17 00:00:00 2001 From: Rubin Xu Date: Fri, 11 Jan 2019 11:18:33 +0000 Subject: [PATCH] Do not emit WTF if there is no delegate WTF should only be logged when there is more than one delegates, not when there is none. Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testKeyManagement and check logcat for the absence of WTF logs Bug: 122363826 Change-Id: I51972ec4fabb2de70a6fe1700afae3aea95e34ab --- .../server/devicepolicy/DevicePolicyManagerService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 7f6895a4cf832..149eb5debc744 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -6101,7 +6101,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { synchronized (getLockObject()) { delegates = getDelegatePackagesInternalLocked(scope, userId); } - if (delegates.size() != 1) { + if (delegates.size() == 0) { + return null; + } else if (delegates.size() > 1) { Slog.wtf(LOG_TAG, "More than one delegate holds " + scope); return null; }