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
This commit is contained in:
Rubin Xu
2019-01-11 11:18:33 +00:00
parent be09f2801e
commit 417601034d

View File

@@ -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;
}