From e1297b03bfe1ffac9a6e797e656e9fe359410f2b Mon Sep 17 00:00:00 2001 From: Eran Messeri Date: Tue, 19 Jan 2021 21:43:26 +0000 Subject: [PATCH] Log metrics for setting Organization ID As a proxy for measuring adoption of Enrollment-specific ID. Bug: 168627890 Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testEnrollmentSpecificIdCorrectCalculation com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testEnrollmentSpecificIdCorrectCalculation Change-Id: I1dc22d49ac0398bd6284e8c3639c6147819b08f0 --- .../devicepolicy/DevicePolicyManagerService.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 7d199cab1d358..23ff489625920 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -15830,8 +15830,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { Log.i(LOG_TAG, String.format("Setting Enterprise ID to %s for user %d", organizationId, userId)); + final String ownerPackage; synchronized (getLockObject()) { - ActiveAdmin owner = getDeviceOrProfileOwnerAdminLocked(userId); + final ActiveAdmin owner = getDeviceOrProfileOwnerAdminLocked(userId); // As the caller is the system, it must specify the component name of the profile owner // as a safety check. Preconditions.checkCallAuthorization( @@ -15839,6 +15840,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { String.format("The Profile Owner or Device Owner may only set the Enterprise ID" + " on its own user, called on user %d but owner user is %d", userId, owner.getUserHandle().getIdentifier())); + ownerPackage = owner.info.getPackageName(); Preconditions.checkState( TextUtils.isEmpty(owner.mOrganizationId) || owner.mOrganizationId.equals( organizationId), @@ -15856,5 +15858,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { saveSettingsLocked(userId); }); } + + DevicePolicyEventLogger + .createEvent(DevicePolicyEnums.SET_ORGANIZATION_ID) + .setAdmin(ownerPackage) + .setBoolean(isManagedProfile(userId)) + .write(); } }