@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
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| status | DlpFeatureStatus | Yes | DLP status. |
Returns
| Type | Description |
|---|---|
| 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 Code | Error Message |
|---|---|
| 202 | Non-system applications use system APIs. |
| 19100001 | Invalid parameter value. |
| 19100011 | The 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
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| isSuccess | boolean | No | No | Whether 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
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| dlpFeatureStatus | DlpFeatureStatus | No | No | DLP 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
| Name | Value | Description |
|---|---|---|
| NOT_ENABLED_FEATURE | 0 | DLP disabled. |
| ENABLED_FEATURE | 1 | DLP enabled. |
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 capi-dlp-permission-api-h
openharmony 鸿蒙 capi-dlppermissionapi
openharmony 鸿蒙 js-apis-dlppermission-sys