Merge "Fix lock task clearing for affiliated users" into udc-dev am: 029eb856a3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22766263

Change-Id: Icb12b7f3073916debda07573892c53131ec2fad2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Kholoud Mohamed
2023-04-24 15:39:42 +00:00
committed by Automerger Merge Worker

View File

@@ -14957,18 +14957,34 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
continue;
}
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);
if (isPolicyEngineForFinanceFlagEnabled()) {
Map<EnforcingAdmin, PolicyValue<LockTaskPolicy>> policies =
mDevicePolicyEngine.getLocalPoliciesSetByAdmins(
PolicyDefinition.LOCK_TASK, userId);
Set<EnforcingAdmin> admins = new HashSet<>(policies.keySet());
for (EnforcingAdmin admin : admins) {
if (admin.hasAuthority(EnforcingAdmin.DPC_AUTHORITY)) {
mDevicePolicyEngine.removeLocalPolicy(
PolicyDefinition.LOCK_TASK, admin, userId);
}
}
} 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);
}
}
}
});