Merge "Fix DPM check logic for AppUsageLimitObserver (un)registering" into rvc-dev am: 0a78a5ad9d

Change-Id: I45bfc3fda7d0e020259c7ef315f21742455e0877
This commit is contained in:
TreeHugger Robot
2020-05-12 05:38:57 +00:00
committed by Automerger Merge Worker

View File

@@ -1847,7 +1847,7 @@ public class UsageStatsService extends SystemService implements
final DevicePolicyManagerInternal dpmInternal = getDpmInternal();
if (!hasPermissions(callingPackage,
Manifest.permission.SUSPEND_APPS, Manifest.permission.OBSERVE_APP_USAGE)
&& (dpmInternal != null && !dpmInternal.isActiveSupervisionApp(callingUid))) {
&& (dpmInternal == null || !dpmInternal.isActiveSupervisionApp(callingUid))) {
throw new SecurityException("Caller must be the active supervision app or "
+ "it must have both SUSPEND_APPS and OBSERVE_APP_USAGE permissions");
}
@@ -1874,7 +1874,7 @@ public class UsageStatsService extends SystemService implements
final DevicePolicyManagerInternal dpmInternal = getDpmInternal();
if (!hasPermissions(callingPackage,
Manifest.permission.SUSPEND_APPS, Manifest.permission.OBSERVE_APP_USAGE)
&& (dpmInternal != null && !dpmInternal.isActiveSupervisionApp(callingUid))) {
&& (dpmInternal == null || !dpmInternal.isActiveSupervisionApp(callingUid))) {
throw new SecurityException("Caller must be the active supervision app or "
+ "it must have both SUSPEND_APPS and OBSERVE_APP_USAGE permissions");
}