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

Commit e011ffe2 authored by Alex Johnston's avatar Alex Johnston
Browse files

Add DPMS reset password metrics

PDD: https://eldar.corp.google.com/assessments/875507949

RESET_PASSWORD
We log this when the admin forces a new password for the
device or the managed profile.
There is no log data (only the event).

RESET_PASSWORD_WITH_TOKEN
We log this when the admin forces a new password for the
device or the managed profile. The admin can change the
password even before the device is unlocked, as long as the
password reset token was previously provisioned.
There is no log data (only the event).

Bug: 186740337
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
      atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testResetPasswordWithToken
Change-Id: I07b66904e423bc6e1f4bdd4ae44aad0cae6d537b
parent 1d2868c4
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -4929,10 +4929,16 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        final CallerIdentity caller = getCallerIdentity();
        final int userHandle = caller.getUserId();
        // As of R, only privlleged caller holding RESET_PASSWORD can call resetPassword() to
        // As of R, only privileged caller holding RESET_PASSWORD can call resetPassword() to
        // set password to an unsecured user.
        if (hasCallingPermission(permission.RESET_PASSWORD)) {
            return setPasswordPrivileged(password, flags, caller);
            final boolean result = setPasswordPrivileged(password, flags, caller);
            if (result) {
                DevicePolicyEventLogger
                        .createEvent(DevicePolicyEnums.RESET_PASSWORD)
                        .write();
            }
            return result;
        }
        // If caller has PO (or DO) throw or fail silently depending on its target SDK level.
@@ -15226,8 +15232,15 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            DevicePolicyData policy = getUserData(caller.getUserId());
            if (policy.mPasswordTokenHandle != 0) {
                final String password = passwordOrNull != null ? passwordOrNull : "";
                return resetPasswordInternal(password, policy.mPasswordTokenHandle, token,
                        flags, caller);
                final boolean result = resetPasswordInternal(password, policy.mPasswordTokenHandle,
                        token, flags, caller);
                if (result) {
                    DevicePolicyEventLogger
                            .createEvent(DevicePolicyEnums.RESET_PASSWORD_WITH_TOKEN)
                            .setAdmin(caller.getComponentName())
                            .write();
                }
                return result;
            } else {
                Slogf.w(LOG_TAG, "No saved token handle");
            }