Merge "Fix lock task clearing for affiliated users" into udc-dev

This commit is contained in:
Kholoud Mohamed
2023-04-24 14:48:58 +00:00
committed by Android (Google) Code Review

View File

@@ -14957,18 +14957,34 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
continue; continue;
} }
final List<String> lockTaskPackages = getUserData(userId).mLockTaskPackages; if (isPolicyEngineForFinanceFlagEnabled()) {
// TODO(b/278438525): handle in the policy engine Map<EnforcingAdmin, PolicyValue<LockTaskPolicy>> policies =
if (!lockTaskPackages.isEmpty()) { mDevicePolicyEngine.getLocalPoliciesSetByAdmins(
Slogf.d(LOG_TAG, PolicyDefinition.LOCK_TASK, userId);
"User id " + userId + " not affiliated. Clearing lock task packages"); Set<EnforcingAdmin> admins = new HashSet<>(policies.keySet());
setLockTaskPackagesLocked(userId, Collections.<String>emptyList()); for (EnforcingAdmin admin : admins) {
} if (admin.hasAuthority(EnforcingAdmin.DPC_AUTHORITY)) {
final int lockTaskFeatures = getUserData(userId).mLockTaskFeatures; mDevicePolicyEngine.removeLocalPolicy(
if (lockTaskFeatures != DevicePolicyManager.LOCK_TASK_FEATURE_NONE){ PolicyDefinition.LOCK_TASK, admin, userId);
Slogf.d(LOG_TAG, }
"User id " + userId + " not affiliated. Clearing lock task features"); }
setLockTaskFeaturesLocked(userId, DevicePolicyManager.LOCK_TASK_FEATURE_NONE); } else {
final List<String> lockTaskPackages = getUserData(userId).mLockTaskPackages;
// TODO(b/278438525): handle in the policy engine
if (!lockTaskPackages.isEmpty()) {
Slogf.d(LOG_TAG,
"User id " + userId
+ " not affiliated. Clearing lock task packages");
setLockTaskPackagesLocked(userId, Collections.<String>emptyList());
}
final int lockTaskFeatures = getUserData(userId).mLockTaskFeatures;
if (lockTaskFeatures != DevicePolicyManager.LOCK_TASK_FEATURE_NONE) {
Slogf.d(LOG_TAG,
"User id " + userId
+ " not affiliated. Clearing lock task features");
setLockTaskFeaturesLocked(userId,
DevicePolicyManager.LOCK_TASK_FEATURE_NONE);
}
} }
} }
}); });