다음을 통해 공유


DevicePolicyManager.SetContentProtectionPolicy Method

Definition

Sets the content protection policy which controls scanning for deceptive apps.

[Android.Runtime.Register("setContentProtectionPolicy", "(Landroid/content/ComponentName;I)V", "GetSetContentProtectionPolicy_Landroid_content_ComponentName_IHandler", ApiSince=35)]
[Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_CONTENT_PROTECTION")]
public virtual void SetContentProtectionPolicy (Android.Content.ComponentName? admin, Android.App.Admin.ContentProtectionPolicy policy);
[<Android.Runtime.Register("setContentProtectionPolicy", "(Landroid/content/ComponentName;I)V", "GetSetContentProtectionPolicy_Landroid_content_ComponentName_IHandler", ApiSince=35)>]
[<Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_CONTENT_PROTECTION")>]
abstract member SetContentProtectionPolicy : Android.Content.ComponentName * Android.App.Admin.ContentProtectionPolicy -> unit
override this.SetContentProtectionPolicy : Android.Content.ComponentName * Android.App.Admin.ContentProtectionPolicy -> unit

Parameters

admin
ComponentName

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

policy
ContentProtectionPolicy

The content protection policy to set. One of #CONTENT_PROTECTION_NOT_CONTROLLED_BY_POLICY, #CONTENT_PROTECTION_DISABLED or #CONTENT_PROTECTION_ENABLED.

Attributes

Remarks

Sets the content protection policy which controls scanning for deceptive apps.

This function can only be called by the device owner, a profile owner of an affiliated user or profile, or the profile owner when no device owner is set or holders of the permission android.Manifest.permission#MANAGE_DEVICE_POLICY_CONTENT_PROTECTION. See #isAffiliatedUser. Any policy set via this method will be cleared if the user becomes unaffiliated.

After the content protection policy has been set, PolicyUpdateReceiver#onPolicySetResult(Context, String, Bundle, TargetUser, PolicyUpdateResult) will notify the admin on whether the policy was successfully set or not. This callback will contain: <ul> <li> The policy identifier DevicePolicyIdentifiers#CONTENT_PROTECTION_POLICY<li> The TargetUser that this policy relates to <li> The PolicyUpdateResult, which will be PolicyUpdateResult#RESULT_POLICY_SET if the policy was successfully set or the reason the policy failed to be set (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.setContentProtectionPolicy(android.content.ComponentName, 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