Fix NPE with missing DPMI

DevicePolicyManagerInternal is not always available (when device admin
is not an enabled feature), so treat it as nullable in
WallpaperManagerService.

Does not need to be cherry-picked since cherry-pick CL
I103c45ea61814e476eea197d357ef0ce75edefdc already accounts for this.

Fixes: 174642338
Bug: 144048540
Bug: 172682826
Bug: 153995973
Change-Id: Ib7ad0d6d1038ad4dd3fec7c617ef3c23c911293d
This commit is contained in:
Alex Kershaw
2020-12-02 13:31:14 +00:00
parent 5b36ee3f1d
commit f7d5bc1201

View File

@@ -2846,8 +2846,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
if (!uidMatchPackage) {
return false; // callingPackage was faked.
}
if (LocalServices.getService(DevicePolicyManagerInternal.class)
.isDeviceOrProfileOwnerInCallingUser(callingPackage)) {
final DevicePolicyManagerInternal dpmi =
LocalServices.getService(DevicePolicyManagerInternal.class);
if (dpmi != null && dpmi.isDeviceOrProfileOwnerInCallingUser(callingPackage)) {
return true;
}
final int callingUserId = UserHandle.getCallingUserId();