Udostępnij za pośrednictwem


DevicePolicyManager.ClearUserRestriction(ComponentName, String) Method

Definition

Called by a profile owner, device owner or a holder of any permission that is associated with a user restriction to clear a user restriction specified by the key.

[Android.Runtime.Register("clearUserRestriction", "(Landroid/content/ComponentName;Ljava/lang/String;)V", "GetClearUserRestriction_Landroid_content_ComponentName_Ljava_lang_String_Handler")]
public virtual void ClearUserRestriction (Android.Content.ComponentName admin, string? key);
[<Android.Runtime.Register("clearUserRestriction", "(Landroid/content/ComponentName;Ljava/lang/String;)V", "GetClearUserRestriction_Landroid_content_ComponentName_Ljava_lang_String_Handler")>]
abstract member ClearUserRestriction : Android.Content.ComponentName * string -> unit
override this.ClearUserRestriction : Android.Content.ComponentName * string -> unit

Parameters

admin
ComponentName

Which DeviceAdminReceiver this request is associated with.

key
String

The key of the restriction.

Attributes

Remarks

Called by a profile owner, device owner or a holder of any permission that is associated with a user restriction to clear a user restriction specified by the key.

The calling device admin must be a profile or device owner; if it is not, a security exception will be thrown.

The profile owner of an organization-owned managed profile may invoke this method on the DevicePolicyManager instance it obtained from #getParentProfileInstance(ComponentName), for clearing device-wide restrictions.

See the constants in android.os.UserManager for the list of restrictions. These constants state in their documentation which permission is required to manage the restriction using this API.

For callers targeting Android android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE or above, calling this API will result in clearing any local and global restriction with the specified key that was previously set by the caller.

Starting from Build.VERSION_CODES#UPSIDE_DOWN_CAKE, after the user restriction policy has been cleared, PolicyUpdateReceiver#onPolicySetResult(Context, String, Bundle, TargetUser, PolicyUpdateResult) will notify the admin on whether the policy was successfully cleared or not. This callback will contain: <ul> <li> The policy identifier returned from DevicePolicyIdentifiers#getIdentifierForUserRestriction(String)<li> The TargetUser that this policy relates to <li> The PolicyUpdateResult, which will be PolicyUpdateResult#RESULT_POLICY_SET if the policy was successfully cleared or the reason the policy failed to be cleared (e.g. PolicyUpdateResult#RESULT_FAILURE_CONFLICTING_ADMIN_POLICY) </ul> If there has been a change to the policy, PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser, PolicyUpdateResult) will notify the admin of this change. This callback will contain the same parameters as PolicyUpdateReceiver#onPolicySetResult and the PolicyUpdateResult will contain the reason why the policy changed.

Java documentation for android.app.admin.DevicePolicyManager.clearUserRestriction(android.content.ComponentName, java.lang.String).

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