Fix possible NPE in DPMS.

If there's no ActiveAdmin for the given user then the ternary
expression would return null, which immediately will throw an NPE as it
gets auto-unboxed into from Boolean to boolean.

Bug: 217923092
Test: errorprone build
Change-Id: I4043f0061e5a23e4d5aa408917f6d51b8bbf22ec
This commit is contained in:
Michael Wright
2022-02-04 19:00:44 +00:00
parent 010aa30bc4
commit 2e7197c2ae
2 changed files with 2 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ java_defaults {
"-Xep:AndroidFrameworkCompatChange:ERROR",
// "-Xep:AndroidFrameworkUid:ERROR",
"-Xep:SelfEquals:ERROR",
"-Xep:NullTernary:ERROR",
// NOTE: only enable to generate local patchfiles
// "-XepPatchChecks:refaster:frameworks/base/errorprone/refaster/EfficientXml.java.refaster",
// "-XepPatchLocation:/tmp/refaster/",

View File

@@ -6847,7 +6847,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
String.format(NOT_SYSTEM_CALLER_MSG, "call isAlwaysOnVpnLockdownEnabledForUser"));
synchronized (getLockObject()) {
ActiveAdmin admin = getDeviceOrProfileOwnerAdminLocked(userHandle);
return admin != null ? admin.mAlwaysOnVpnLockdown : null;
return admin != null && admin.mAlwaysOnVpnLockdown;
}
}