diff options
| author | 2023-05-09 22:30:51 +0000 | |
|---|---|---|
| committer | 2023-05-10 16:50:45 +0000 | |
| commit | 3da2cf7dc3953623eaa7597b6e1b0aeb62bc1873 (patch) | |
| tree | d3efa230e55a3658a5c03a78b63d5427b4c8b538 | |
| parent | 73c35de08c588da6ef824a348a5073ed7dda3007 (diff) | |
Fix lock task logging for permission based admins
Fixes: 278061827
Test: btest a.d.c.LockTaskTest#startLockTask_recordsMetric*
Change-Id: If591dd6cf5bf1bc3a2f2f4232a2edc54665a3018
| -rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 662fd3daeed9..ef45ceedb7f2 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -15156,6 +15156,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { for (ActiveAdmin admin : policy.mAdminList) { final boolean ownsDevice = isDeviceOwner(admin.info.getComponent(), userHandle); final boolean ownsProfile = isProfileOwner(admin.info.getComponent(), userHandle); + // TODO(b/281738975): Should we be logging this for all admins? if (ownsDevice || ownsProfile) { if (isEnabled) { sendAdminCommandLocked(admin, DeviceAdminReceiver.ACTION_LOCK_TASK_ENTERING, @@ -15172,6 +15173,20 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } } } + // TODO(b/281738975): Should we be logging this for all admins? + for(EnforcingAdmin admin : mDevicePolicyEngine.getLocalPoliciesSetByAdmins( + PolicyDefinition.LOCK_TASK, userHandle).keySet()) { + if (admin.hasAuthority(EnforcingAdmin.DPC_AUTHORITY)) { + // already handled above + continue; + } + DevicePolicyEventLogger + .createEvent(DevicePolicyEnums.SET_LOCKTASK_MODE_ENABLED) + .setAdmin(admin.getPackageName()) + .setBoolean(isEnabled) + .setStrings(pkg) + .write(); + } } @Override |