Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3da2cf7d authored by Kholoud Mohamed's avatar Kholoud Mohamed
Browse files

Fix lock task logging for permission based admins

Fixes: 278061827
Test: btest a.d.c.LockTaskTest#startLockTask_recordsMetric*
Change-Id: If591dd6cf5bf1bc3a2f2f4232a2edc54665a3018
parent 73c35de0
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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