openharmony 鸿蒙 js-apis-dlpsetdlpfeature-sys

2026-08-25 浏览 (1)

@ohos.dlpSetDlpFeature (DLP) (System API)

This module controls the Data Loss Prevention (DLP) feature, including enabling or disabling DLP and returning the DLP status.

Since: 26.0.0

NOTE

The APIs provided by this module are system APIs.

Modules to Import

import { dlpSetDlpFeature } from '@kit.DataProtectionKit';

dlpSetDlpFeature.setDlpFeature

setDlpFeature(status: DlpFeatureStatus): Promise<StatusInfoResult>

Sets the DLP status. This API uses a promise to return the result.

When this feature is enabled, right-click the file to be encrypted, and the encryption option is displayed in the shortcut menu.

Since: 26.0.0

Model restriction: This API can be used only in the stage model.

System API: This is a system API.

System capability: SystemCapability.Security.DataLossPrevention

Parameters

ParameterTypeMandatoryDescription
statusDlpFeatureStatusYesDLP status.

Returns

TypeDescription
Promise<StatusInfoResult>Promise used to return the DLP status.

Error Codes

For details about the error codes, see Universal Error Codes and DLP Service Error Codes.

Error CodeError Message
202Non-system applications use system APIs.
19100001Invalid parameter value.
19100011The system ability works abnormally.

Example

import { dlpSetDlpFeature } from '@kit.DataProtectionKit';
import { BusinessError } from '@kit.BasicServicesKit';

async exampleFunction() {
  try {
    let res: dlpSetDlpFeature.StatusInfoResult =
      await dlpSetDlpFeature.setDlpFeature(dlpSetDlpFeature.DlpFeatureStatus.ENABLED_FEATURE);
    console.info('setDlpFeature result: ', JSON.stringify(res));
  } catch (err) {
    console.error('setDlpFeature failed', (err as BusinessError).code, (err as BusinessError).message);
  }
}

StatusInfoResult

Describes the DLP settings.

Since: 26.0.0

Model restriction: This API can be used only in the stage model.

System API: This is a system API.

System capability: SystemCapability.Security.DataLossPrevention

NameTypeRead-OnlyOptionalDescription
isSuccessbooleanNoNoWhether the DLP setting is successful. true indicates that the setting is successful, and false indicates that the setting fails.

DLPFeatureInfo

Sets the DLP status.

Since: 26.0.0

Model restriction: This API can be used only in the stage model.

System API: This is a system API.

System capability: SystemCapability.Security.DataLossPrevention

NameTypeRead-OnlyOptionalDescription
dlpFeatureStatusDlpFeatureStatusNoNoDLP status.

DlpFeatureStatus

Enumerates DLP statuses.

Since: 26.0.0

Model restriction: This API can be used only in the stage model.

System API: This is a system API.

System capability: SystemCapability.Security.DataLossPrevention

NameValueDescription
NOT_ENABLED_FEATURE0DLP disabled.
ENABLED_FEATURE1DLP enabled.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-dlp-permission-api-h

openharmony 鸿蒙 errorcode-dlp

openharmony 鸿蒙 capi-dlppermissionapi

openharmony 鸿蒙 js-apis-dlppermission-sys

openharmony 鸿蒙 Readme-EN

openharmony 鸿蒙 js-apis-dlppermission

openharmony 鸿蒙 js-apis-identifySensitiveContent

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/CDSQ1VOS