共用方式為


DevicePolicyManager.ResetPasswordWithToken Method

Definition

Called by device or profile owner to force set a new device unlock password or a managed profile challenge on current user.

[Android.Runtime.Register("resetPasswordWithToken", "(Landroid/content/ComponentName;Ljava/lang/String;[BI)Z", "GetResetPasswordWithToken_Landroid_content_ComponentName_Ljava_lang_String_arrayBIHandler", ApiSince=26)]
[Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_RESET_PASSWORD")]
public virtual bool ResetPasswordWithToken (Android.Content.ComponentName? admin, string? password, byte[]? token, Android.App.Admin.ResetPasswordFlags flags);
[<Android.Runtime.Register("resetPasswordWithToken", "(Landroid/content/ComponentName;Ljava/lang/String;[BI)Z", "GetResetPasswordWithToken_Landroid_content_ComponentName_Ljava_lang_String_arrayBIHandler", ApiSince=26)>]
[<Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_RESET_PASSWORD")>]
abstract member ResetPasswordWithToken : Android.Content.ComponentName * string * byte[] * Android.App.Admin.ResetPasswordFlags -> bool
override this.ResetPasswordWithToken : Android.Content.ComponentName * string * byte[] * Android.App.Admin.ResetPasswordFlags -> bool

Parameters

admin
ComponentName

Which DeviceAdminReceiver this request is associated with. Null if the caller is not a device admin.

password
String

The new password for the user. null or empty clears the password.

token
Byte[]

the password reset token previously provisioned by #setResetPasswordToken.

flags
ResetPasswordFlags

May be 0 or combination of #RESET_PASSWORD_REQUIRE_ENTRY and #RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT.

Returns

Returns true if the password was applied, or false if it is not acceptable for the current constraints.

Attributes

Remarks

Called by device or profile owner to force set a new device unlock password or a managed profile challenge on current user. This takes effect immediately.

Unlike #resetPassword, this API can change the password even before the user or device is unlocked or decrypted. The supplied token must have been previously provisioned via #setResetPasswordToken, and in active state #isResetPasswordTokenActive.

The given password must be sufficient for the current password quality and length constraints as returned by #getPasswordQuality(ComponentName) and #getPasswordMinimumLength(ComponentName); if it does not meet these constraints, then it will be rejected and false returned. Note that the password may be a stronger quality, for example, a password containing alphanumeric characters when the requested quality is only numeric.

Calling with a null or empty password will clear any existing PIN, pattern or password if the current password constraints allow it.

On devices not supporting PackageManager#FEATURE_SECURE_LOCK_SCREEN feature, calling this methods has no effect - the password is always empty - and false is returned.

Java documentation for android.app.admin.DevicePolicyManager.resetPasswordWithToken(android.content.ComponentName, java.lang.String, byte[], int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to