DevicePolicyManager.SetCameraDisabled(ComponentName, Boolean) 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 disable all cameras on the device, for this user.
[Android.Runtime.Register("setCameraDisabled", "(Landroid/content/ComponentName;Z)V", "GetSetCameraDisabled_Landroid_content_ComponentName_ZHandler")]
[Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_CAMERA")]
public virtual void SetCameraDisabled (Android.Content.ComponentName? admin, bool disabled);
[<Android.Runtime.Register("setCameraDisabled", "(Landroid/content/ComponentName;Z)V", "GetSetCameraDisabled_Landroid_content_ComponentName_ZHandler")>]
[<Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_CAMERA")>]
abstract member SetCameraDisabled : Android.Content.ComponentName * bool -> unit
override this.SetCameraDisabled : Android.Content.ComponentName * bool -> unit
Parameters
- admin
- ComponentName
Which DeviceAdminReceiver
this request is associated with or null if
the caller is not a device admin
- disabled
- Boolean
Whether or not the camera should be disabled.
- Attributes
Remarks
Called by an application that is administering the device to disable all cameras on the device, for this user. After setting this, no applications running as this user will be able to access any cameras on the device.
This method can be called on the DevicePolicyManager
instance, returned by #getParentProfileInstance(ComponentName)
, where the caller must be the profile owner of an organization-owned managed profile.
If the caller is device owner, then the restriction will be applied to all users. If called on the parent instance, then the restriction will be applied on the personal profile.
The calling device admin must have requested DeviceAdminInfo#USES_POLICY_DISABLE_CAMERA
to be able to call this method; if it has not, a security exception will be thrown.
<b>Note</b>, this policy type is deprecated for legacy device admins since android.os.Build.VERSION_CODES#Q
. On Android android.os.Build.VERSION_CODES#Q
devices, legacy device admins targeting SDK version android.os.Build.VERSION_CODES#P
or below can still call this API to disable camera, while legacy device admins targeting SDK version android.os.Build.VERSION_CODES#Q
will receive a SecurityException. Starting from Android android.os.Build.VERSION_CODES#R
, requests to disable camera from legacy device admins targeting SDK version android.os.Build.VERSION_CODES#P
or below will be silently ignored.
Starting from Build.VERSION_CODES#UPSIDE_DOWN_CAKE
, after the camera disabled 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 returned from DevicePolicyIdentifiers#getIdentifierForUserRestriction(String)
with user restriction UserManager#DISALLOW_CAMERA
<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.
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.