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

Commit e878706d authored by Pavel Grafov's avatar Pavel Grafov
Browse files

Add COPE related metric.

* setManagedProfileMaximumTimeOff
* setPersonalAppsSuspended
* COMP -> COPE migration

Test: OrgOwnedProfileOwnerTest#testSetManagedProfileMaximumTimeOffLogged
Test: OrgOwnedProfileOwnerTest#testSetPersonalAppsSuspendedLogged
Test: manual, via "adb shell cmd stats print-logs" + "adb logcat | grep statsd" during boot
Bug: 148788010
Change-Id: Iaf09b536328bdb6623a2d4f6c92f73cd7f94f28c
parent 69b9dcf5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -159,4 +159,7 @@ enum EventId {
  ALLOW_MODIFICATION_OF_ADMIN_CONFIGURED_NETWORKS = 132;
  SET_TIME = 133;
  SET_TIME_ZONE = 134;
  SET_PERSONAL_APPS_SUSPENDED = 135;
  SET_MANAGED_PROFILE_MAXIMUM_TIME_OFF = 136;
  COMP_TO_ORG_OWNED_PO_MIGRATED = 137;
}
+21 −3
Original line number Diff line number Diff line
@@ -2542,7 +2542,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
     * corporate owned device.
     */
    @GuardedBy("getLockObject()")
    private void maybeMigrateToProfileOnOrganizationOwnedDeviceLocked() {
    private void migrateToProfileOnOrganizationOwnedDeviceIfCompLocked() {
        logIfVerbose("Checking whether we need to migrate COMP ");
        final int doUserId = mOwners.getDeviceOwnerUserId();
        if (doUserId == UserHandle.USER_NULL) {
@@ -2605,6 +2605,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        // Note: KeyChain keys are not removed and will remain accessible for the apps that have
        // been given grants to use them.
        DevicePolicyEventLogger
                .createEvent(DevicePolicyEnums.COMP_TO_ORG_OWNED_PO_MIGRATED)
                .setAdmin(poAdminComponent)
                .write();
    }
    private void moveDoPoliciesToProfileParentAdmin(ActiveAdmin doAdmin, ActiveAdmin parentAdmin) {
@@ -3865,7 +3870,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            case SystemService.PHASE_ACTIVITY_MANAGER_READY:
                maybeStartSecurityLogMonitorOnActivityManagerReady();
                synchronized (getLockObject()) {
                    maybeMigrateToProfileOnOrganizationOwnedDeviceLocked();
                    migrateToProfileOnOrganizationOwnedDeviceIfCompLocked();
                }
                final int userId = getManagedUserId(UserHandle.USER_SYSTEM);
                if (userId >= 0) {
@@ -15545,6 +15550,12 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        mInjector.binderWithCleanCallingIdentity(
                () -> applyPersonalAppsSuspension(callingUserId, suspended));
        DevicePolicyEventLogger
                .createEvent(DevicePolicyEnums.SET_PERSONAL_APPS_SUSPENDED)
                .setAdmin(who)
                .setBoolean(suspended)
                .write();
    }
    /**
@@ -15716,9 +15727,16 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        mInjector.binderWithCleanCallingIdentity(
                () -> updatePersonalAppSuspension(userId, mUserManager.isUserUnlocked()));
        DevicePolicyEventLogger
                .createEvent(DevicePolicyEnums.SET_MANAGED_PROFILE_MAXIMUM_TIME_OFF)
                .setAdmin(who)
                .setTimePeriod(timeoutMs)
                .write();
    }
    void enforceHandlesCheckPolicyComplianceIntent(@UserIdInt int userId, String packageName) {
    private void enforceHandlesCheckPolicyComplianceIntent(
            @UserIdInt int userId, String packageName) {
        mInjector.binderWithCleanCallingIdentity(() -> {
            final Intent intent = new Intent(DevicePolicyManager.ACTION_CHECK_POLICY_COMPLIANCE);
            intent.setPackage(packageName);