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

This commit is contained in:
TreeHugger Robot
2020-05-12 05:26:36 +00:00
committed by Android (Google) Code Review

View File

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