DevicePolicyManager.SetPasswordQuality(ComponentName, PasswordQuality) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Called by an application that is administering the device to set the password restrictions it is imposing.
[Android.Runtime.Register("setPasswordQuality", "(Landroid/content/ComponentName;I)V", "GetSetPasswordQuality_Landroid_content_ComponentName_IHandler")]
public virtual void SetPasswordQuality (Android.Content.ComponentName admin, Android.App.Admin.PasswordQuality quality);
[<Android.Runtime.Register("setPasswordQuality", "(Landroid/content/ComponentName;I)V", "GetSetPasswordQuality_Landroid_content_ComponentName_IHandler")>]
abstract member SetPasswordQuality : Android.Content.ComponentName * Android.App.Admin.PasswordQuality -> unit
override this.SetPasswordQuality : Android.Content.ComponentName * Android.App.Admin.PasswordQuality -> unit
Parameters
- admin
- ComponentName
Which DeviceAdminReceiver
this request is associated with.
- quality
- PasswordQuality
The new desired quality. One of #PASSWORD_QUALITY_UNSPECIFIED
,
#PASSWORD_QUALITY_BIOMETRIC_WEAK
,
#PASSWORD_QUALITY_SOMETHING
, #PASSWORD_QUALITY_NUMERIC
,
#PASSWORD_QUALITY_NUMERIC_COMPLEX
, #PASSWORD_QUALITY_ALPHABETIC
,
#PASSWORD_QUALITY_ALPHANUMERIC
or #PASSWORD_QUALITY_COMPLEX
.
- Attributes
Remarks
Called by an application that is administering the device to set the password restrictions it is imposing. After setting this, the user will not be able to enter a new password that is not at least as restrictive as what has been set. Note that the current password will remain until the user has set a new one, so the change does not take place immediately. To prompt the user for a new password, use #ACTION_SET_NEW_PASSWORD
or #ACTION_SET_NEW_PARENT_PROFILE_PASSWORD
after calling this method.
Quality constants are ordered so that higher values are more restrictive; thus the highest requested quality constant (between the policy set here, the user's preference, and any other considerations) is the one that is in effect.
On devices not supporting PackageManager#FEATURE_SECURE_LOCK_SCREEN
feature, the password is always treated as empty.
The calling device admin must have requested DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD
to be able to call this method; if it has not, a security exception will be thrown.
Apps targeting android.os.Build.VERSION_CODES#R
and below can call this method on the DevicePolicyManager
instance returned by #getParentProfileInstance(ComponentName)
in order to set restrictions on the parent profile. Apps targeting android.os.Build.VERSION_CODES#S
and above, with the exception of a profile owner on an organization-owned device (as can be identified by #isOrganizationOwnedDeviceWithManagedProfile
), will get a IllegalArgumentException
when calling this method on the parent DevicePolicyManager
instance.
<strong>Note:</strong> Specifying password requirements using this method clears the password complexity requirements set using #setRequiredPasswordComplexity(int)
. If this method is called on the DevicePolicyManager
instance returned by #getParentProfileInstance(ComponentName)
, then password complexity requirements set on the primary DevicePolicyManager
must be cleared first by calling #setRequiredPasswordComplexity
with #PASSWORD_COMPLEXITY_NONE) first.
<p><string>Note:</strong> this method is ignored on {PackageManager#FEATURE_AUTOMOTIVE automotive builds
.
This member is deprecated. Prefer using #setRequiredPasswordComplexity(int)
, to require a password that satisfies a complexity level defined by the platform, rather than specifying custom password requirement. Setting custom, overly-complicated password requirements leads to passwords that are hard for users to remember and may not provide any security benefits given as Android uses hardware-backed throttling to thwart online and offline brute-forcing of the device's screen lock. Company-owned devices (fully-managed and organization-owned managed profile devices) are able to continue using this method, though it is recommended that #setRequiredPasswordComplexity(int)
should be used instead.
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.