DevicePolicyManager.SetSecurityLoggingEnabled(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 device owner or a profile owner of an organization-owned managed profile to control the security logging feature.
[Android.Runtime.Register("setSecurityLoggingEnabled", "(Landroid/content/ComponentName;Z)V", "GetSetSecurityLoggingEnabled_Landroid_content_ComponentName_ZHandler", ApiSince=24)]
[Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_SECURITY_LOGGING")]
public virtual void SetSecurityLoggingEnabled (Android.Content.ComponentName? admin, bool enabled);
[<Android.Runtime.Register("setSecurityLoggingEnabled", "(Landroid/content/ComponentName;Z)V", "GetSetSecurityLoggingEnabled_Landroid_content_ComponentName_ZHandler", ApiSince=24)>]
[<Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_SECURITY_LOGGING")>]
abstract member SetSecurityLoggingEnabled : Android.Content.ComponentName * bool -> unit
override this.SetSecurityLoggingEnabled : Android.Content.ComponentName * bool -> unit
Parameters
- admin
- ComponentName
Which device admin this request is associated with, or null
if called by a delegated app.
- enabled
- Boolean
whether security logging should be enabled or not.
- Attributes
Remarks
Called by device owner or a profile owner of an organization-owned managed profile to control the security logging feature.
Security logs contain various information intended for security auditing purposes. When security logging is enabled by any app other than the device owner, certain security logs are not visible (for example personal app launch events) or they will be redacted (for example, details of the physical volume mount events). Please see SecurityEvent
for details.
<strong>Note:</strong> The device owner won't be able to retrieve security logs if there are unaffiliated secondary users or profiles on the device, regardless of whether the feature is enabled. Logs will be discarded if the internal buffer fills up while waiting for all users to become affiliated. Therefore it's recommended that affiliation ids are set for new users as soon as possible after provisioning via #setAffiliationIds
. Non device owners are not subject to this restriction since all privacy-sensitive events happening outside the managed profile would have been redacted already.
Starting from Build.VERSION_CODES#VANILLA_ICE_CREAM
, after the security logging 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#SECURITY_LOGGING_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.
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.