1e41f4b71Sopenharmony_ci# @ohos.dlpPermission (DLP) (System API)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciData loss prevention (DLP) is a system solution provided to prevent data disclosure. The **dlpPermission** module provides APIs for cross-device file access management, encrypted storage, and access authorization.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci> - This topic describes only the system APIs provided by the module. For details about its public APIs, see [@ohos.dlpPermission](js-apis-dlppermission.md).
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Modules to Import
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci```ts
13e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
14e41f4b71Sopenharmony_ci```
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci## dlpPermission.getDLPGatheringPolicy
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_cigetDLPGatheringPolicy(): Promise<GatheringPolicyType>
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ciObtains the DLP sandbox gathering policy. This API uses a promise to return the result.
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci**System API**: This is a system API.
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci**Return value**
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci| Type | Description |
31e41f4b71Sopenharmony_ci| -------- | -------- |
32e41f4b71Sopenharmony_ci| Promise<[GatheringPolicyType](#gatheringpolicytype)> | Promise used to return the DLP sandbox aggregation policy obtained. |
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci**Error codes**
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci| ID | Error Message |
39e41f4b71Sopenharmony_ci| -------- | -------- |
40e41f4b71Sopenharmony_ci| 201 | Permission denied. |
41e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
42e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
43e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci**Example**
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci```ts
48e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
49e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_citry {
52e41f4b71Sopenharmony_ci  let res: Promise<dlpPermission.GatheringPolicyType> = dlpPermission.getDLPGatheringPolicy(); // Obtain the sandbox gathering policy.
53e41f4b71Sopenharmony_ci  console.info('res', JSON.stringify(res));
54e41f4b71Sopenharmony_ci} catch (err) {
55e41f4b71Sopenharmony_ci  console.error('error', (err as BusinessError).code, (err as BusinessError).message); // Error reported if the operation fails.
56e41f4b71Sopenharmony_ci}
57e41f4b71Sopenharmony_ci```
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci## dlpPermission.getDLPGatheringPolicy
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_cigetDLPGatheringPolicy(callback: AsyncCallback&lt;GatheringPolicyType&gt;): void
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ciObtains the DLP sandbox gathering policy. This API uses an asynchronous callback to return the result.
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci**System API**: This is a system API.
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci**Parameters**
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
74e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
75e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;[GatheringPolicyType](#gatheringpolicytype)&gt; | Yes | Callback invoked to return the result.<br>If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object. |
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci**Error codes**
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci| ID | Error Message |
82e41f4b71Sopenharmony_ci| -------- | -------- |
83e41f4b71Sopenharmony_ci| 201 | Permission denied. |
84e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
85e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Incorrect parameter types. |
86e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
87e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci**Example**
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci```ts
92e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
93e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_citry {
96e41f4b71Sopenharmony_ci  dlpPermission.getDLPGatheringPolicy((err, res) => {
97e41f4b71Sopenharmony_ci    if (err != undefined) {
98e41f4b71Sopenharmony_ci      console.error('getDLPGatheringPolicy error,', err.code, err.message);
99e41f4b71Sopenharmony_ci    } else {
100e41f4b71Sopenharmony_ci      console.info('res', JSON.stringify(res));
101e41f4b71Sopenharmony_ci    }
102e41f4b71Sopenharmony_ci  }); // Obtain the sandbox gathering policy.
103e41f4b71Sopenharmony_ci} catch (err) {
104e41f4b71Sopenharmony_ci  console.error('getDLPGatheringPolicy error,', (err as BusinessError).code, (err as BusinessError).message);
105e41f4b71Sopenharmony_ci}
106e41f4b71Sopenharmony_ci```
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci## dlpPermission.installDLPSandbox
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ciinstallDLPSandbox(bundleName: string, access: DLPFileAccess, userId: number, uri: string): Promise&lt;DLPSandboxInfo&gt;
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ciInstalls a DLP sandbox application for an application. This API uses a promise to return the sandbox application installed.
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci**System API**: This is a system API.
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci**Parameters**
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
123e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
124e41f4b71Sopenharmony_ci| bundleName | string | Yes | Bundle name of the application. |
125e41f4b71Sopenharmony_ci| access | [DLPFileAccess](js-apis-dlppermission.md#dlpfileaccess) | Yes | Permission on the DLP file. |
126e41f4b71Sopenharmony_ci| userId | number | Yes | Current user ID, which is the system account ID obtained by the account subsystem. The default super user ID is **100**. |
127e41f4b71Sopenharmony_ci| uri | string | Yes | URI of the DLP file. |
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci**Return value**
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci| Type | Description |
132e41f4b71Sopenharmony_ci| -------- | -------- |
133e41f4b71Sopenharmony_ci| Promise&lt;[DLPSandboxInfo](#dlpsandboxinfo)&gt; | Promise used to return the information about the sandbox application installed. |
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci**Error codes**
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ci| ID | Error Message |
140e41f4b71Sopenharmony_ci| -------- | -------- |
141e41f4b71Sopenharmony_ci| 201 | Permission denied. |
142e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
143e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
144e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
145e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci**Example**
148e41f4b71Sopenharmony_ci
149e41f4b71Sopenharmony_ci```ts
150e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
151e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
154e41f4b71Sopenharmony_citry {
155e41f4b71Sopenharmony_ci  let res: Promise<dlpPermission.DLPSandboxInfo> = dlpPermission.installDLPSandbox('com.ohos.note', dlpPermission.DLPFileAccess.READ_ONLY, 100, uri); // Install a DLP sandbox application.
156e41f4b71Sopenharmony_ci  console.info('res', JSON.stringify(res));
157e41f4b71Sopenharmony_ci} catch (err) {
158e41f4b71Sopenharmony_ci  console.error('error', (err as BusinessError).code, (err as BusinessError).message); // Error reported if the operation fails.
159e41f4b71Sopenharmony_ci}
160e41f4b71Sopenharmony_ci```
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci## dlpPermission.installDLPSandbox
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ciinstallDLPSandbox(bundleName: string, access: DLPFileAccess, userId: number, uri:string, callback: AsyncCallback&lt;DLPSandboxInfo&gt;): void
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ciInstalls a DLP sandbox application for an application. This API uses an asynchronous callback to return the index of the sandbox application installed.
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci**System API**: This is a system API.
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci**Parameters**
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
177e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
178e41f4b71Sopenharmony_ci| bundleName | string | Yes | Bundle name of the application. |
179e41f4b71Sopenharmony_ci| access | [DLPFileAccess](js-apis-dlppermission.md#dlpfileaccess) | Yes | Permission on the DLP file. |
180e41f4b71Sopenharmony_ci| userId | number | Yes | Current user ID, which is the system account ID obtained by the account subsystem. The default super user ID is **100**. |
181e41f4b71Sopenharmony_ci| uri | string | Yes | URI of the DLP file. |
182e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;[DLPSandboxInfo](#dlpsandboxinfo)&gt; | Yes | Callback invoked to return the information about the sandbox application installed. |
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci**Error codes**
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci| ID | Error Message |
189e41f4b71Sopenharmony_ci| -------- | -------- |
190e41f4b71Sopenharmony_ci| 201 | Permission denied. |
191e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
192e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
193e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
194e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ci**Example**
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ci```ts
199e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
200e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
203e41f4b71Sopenharmony_citry {
204e41f4b71Sopenharmony_ci  dlpPermission.installDLPSandbox('com.ohos.note', dlpPermission.DLPFileAccess.READ_ONLY, 100, uri, (err, res) => {
205e41f4b71Sopenharmony_ci    if (err != undefined) {
206e41f4b71Sopenharmony_ci      console.error('installDLPSandbox error,', err.code, err.message);
207e41f4b71Sopenharmony_ci    } else {
208e41f4b71Sopenharmony_ci      console.info('res', JSON.stringify(res));
209e41f4b71Sopenharmony_ci    }
210e41f4b71Sopenharmony_ci  }); // Install a DLP sandbox application.
211e41f4b71Sopenharmony_ci} catch (err) {
212e41f4b71Sopenharmony_ci  console.error('installDLPSandbox error,', (err as BusinessError).code, (err as BusinessError).message);
213e41f4b71Sopenharmony_ci}
214e41f4b71Sopenharmony_ci```
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci## dlpPermission.uninstallDLPSandbox
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ciuninstallDLPSandbox(bundleName: string, userId: number, appIndex: number): Promise&lt;void&gt;
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ciUninstalls a DLP sandbox application for an application. This API uses a promise to return the result.
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_ci**System API**: This is a system API.
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci**Parameters**
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
231e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
232e41f4b71Sopenharmony_ci| bundleName | string | Yes | Bundle name of the application. |
233e41f4b71Sopenharmony_ci| userId | number | Yes | Current user ID, which is the system account ID obtained by the account subsystem. The default super user ID is **100**. |
234e41f4b71Sopenharmony_ci| appIndex | number | Yes | DLP sandbox index. |
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci**Return value**
237e41f4b71Sopenharmony_ci
238e41f4b71Sopenharmony_ci| Type | Description |
239e41f4b71Sopenharmony_ci| -------- | -------- |
240e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value. |
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci**Error codes**
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci| ID | Error Message |
247e41f4b71Sopenharmony_ci| -------- | -------- |
248e41f4b71Sopenharmony_ci| 201 | Permission denied. |
249e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
250e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
251e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
252e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci**Example**
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci```ts
257e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
258e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
261e41f4b71Sopenharmony_citry {
262e41f4b71Sopenharmony_ci  dlpPermission.installDLPSandbox('com.ohos.note', dlpPermission.DLPFileAccess.READ_ONLY, 100, uri).then((res)=>{
263e41f4b71Sopenharmony_ci    console.info('res', JSON.stringify(res));
264e41f4b71Sopenharmony_ci    dlpPermission.uninstallDLPSandbox('com.ohos.note', 100, res.appIndex); // Uninstall a DLP sandbox application.
265e41f4b71Sopenharmony_ci  }); // Install a DLP sandbox application.
266e41f4b71Sopenharmony_ci} catch (err) {
267e41f4b71Sopenharmony_ci  console.error('error', (err as BusinessError).code, (err as BusinessError).message); // Error reported if the operation fails.
268e41f4b71Sopenharmony_ci}
269e41f4b71Sopenharmony_ci```
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ci## dlpPermission.uninstallDLPSandbox
272e41f4b71Sopenharmony_ci
273e41f4b71Sopenharmony_ciuninstallDLPSandbox(bundleName: string, userId: number, appIndex: number, callback: AsyncCallback&lt;void&gt;): void
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_ciUninstalls a DLP sandbox application for an application. This API uses an asynchronous callback to return the result.
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_ci**System API**: This is a system API.
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
280e41f4b71Sopenharmony_ci
281e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
282e41f4b71Sopenharmony_ci
283e41f4b71Sopenharmony_ci**Parameters**
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
286e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
287e41f4b71Sopenharmony_ci| bundleName | string | Yes | Bundle name of the application. |
288e41f4b71Sopenharmony_ci| userId | number | Yes | Current user ID, which is the system account ID obtained by the account subsystem. The default super user ID is **100**. |
289e41f4b71Sopenharmony_ci| appIndex | number | Yes | DLP sandbox application index, which is the value returned after **installDLPSandbox** is successfully called. |
290e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the uninstallation result. |
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci**Error codes**
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_ci| ID | Error Message |
297e41f4b71Sopenharmony_ci| -------- | -------- |
298e41f4b71Sopenharmony_ci| 201 | Permission denied. |
299e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
300e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
301e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
302e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci**Example**
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_ci```ts
307e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
308e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
311e41f4b71Sopenharmony_citry {
312e41f4b71Sopenharmony_ci  dlpPermission.installDLPSandbox('com.ohos.note', dlpPermission.DLPFileAccess.READ_ONLY, 100, uri).then((res)=>{
313e41f4b71Sopenharmony_ci    console.info('res', JSON.stringify(res));
314e41f4b71Sopenharmony_ci    dlpPermission.uninstallDLPSandbox('com.ohos.note', 100, res.appIndex, (err, res) => {
315e41f4b71Sopenharmony_ci      if (err != undefined) {
316e41f4b71Sopenharmony_ci        console.error('uninstallDLPSandbox error,', err.code, err.message);
317e41f4b71Sopenharmony_ci      } else {
318e41f4b71Sopenharmony_ci        console.info('res', JSON.stringify(res));
319e41f4b71Sopenharmony_ci      }
320e41f4b71Sopenharmony_ci    });
321e41f4b71Sopenharmony_ci  }); // Install a DLP sandbox application.
322e41f4b71Sopenharmony_ci} catch (err) {
323e41f4b71Sopenharmony_ci  console.error('uninstallDLPSandbox error,', (err as BusinessError).code, (err as BusinessError).message);
324e41f4b71Sopenharmony_ci}
325e41f4b71Sopenharmony_ci```
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ci## dlpPermission.on('uninstallDLPSandbox')
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_cion(type: 'uninstallDLPSandbox', listener: Callback&lt;DLPSandboxState&gt;): void
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ciSubscribes to a DLP sandbox uninstall event.
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci**System API**: This is a system API.
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
336e41f4b71Sopenharmony_ci
337e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ci**Parameters**
340e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
341e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
342e41f4b71Sopenharmony_ci| type | 'uninstallDLPSandbox' | Yes | Event type. It has a fixed value of **uninstallDLPSandbox**, which indicates the DLP sandbox application uninstall event. |
343e41f4b71Sopenharmony_ci| listener | Callback&lt;[DLPSandboxState](#dlpsandboxstate)&gt; | Yes | Callback invoked when a sandbox application is uninstalled. |
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci**Error codes**
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci| ID | Error Message |
350e41f4b71Sopenharmony_ci| -------- | -------- |
351e41f4b71Sopenharmony_ci| 201 | Permission denied. |
352e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
353e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed. |
354e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
355e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci**Example**
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ci```ts
360e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
361e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
362e41f4b71Sopenharmony_ci
363e41f4b71Sopenharmony_citry {
364e41f4b71Sopenharmony_ci  dlpPermission.on('uninstallDLPSandbox', (info: dlpPermission.DLPSandboxState) => {
365e41f4b71Sopenharmony_ci    console.info('uninstallDLPSandbox event', info.appIndex, info.bundleName)
366e41f4b71Sopenharmony_ci  // Subscribe to the DLP sandbox application uninstall event.
367e41f4b71Sopenharmony_ci} catch (err) {
368e41f4b71Sopenharmony_ci  console.error('error', (err as BusinessError).code, (err as BusinessError).message); // Error reported if the operation fails.
369e41f4b71Sopenharmony_ci}
370e41f4b71Sopenharmony_ci```
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_ci## dlpPermission.off('uninstallDLPSandbox')
373e41f4b71Sopenharmony_ci
374e41f4b71Sopenharmony_cioff(type: 'uninstallDLPSandbox', listener?: Callback&lt;DLPSandboxState&gt;): void
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_ciUnsubscribes from the DLP sandbox uninstall event.
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ci**System API**: This is a system API.
379e41f4b71Sopenharmony_ci
380e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
381e41f4b71Sopenharmony_ci
382e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
383e41f4b71Sopenharmony_ci
384e41f4b71Sopenharmony_ci**Parameters**
385e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
386e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
387e41f4b71Sopenharmony_ci| type | 'uninstallDLPSandbox' | Yes | Event type. It has a fixed value of **uninstallDLPSandbox**, which indicates the DLP sandbox application uninstall event. |
388e41f4b71Sopenharmony_ci| listener | Callback&lt;[DLPSandboxState](#dlpsandboxstate)&gt; | No | Callback for the sandbox uninstall event. By default, this parameter is left blank, which unregisters all callbacks for the sandbox uninstall event. |
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ci**Error codes**
391e41f4b71Sopenharmony_ci
392e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
393e41f4b71Sopenharmony_ci
394e41f4b71Sopenharmony_ci| ID | Error Message |
395e41f4b71Sopenharmony_ci| -------- | -------- |
396e41f4b71Sopenharmony_ci| 201 | Permission denied. |
397e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
398e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed. |
399e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
400e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
401e41f4b71Sopenharmony_ci
402e41f4b71Sopenharmony_ci**Example**
403e41f4b71Sopenharmony_ci
404e41f4b71Sopenharmony_ci```ts
405e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
406e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
407e41f4b71Sopenharmony_ci
408e41f4b71Sopenharmony_citry {
409e41f4b71Sopenharmony_ci  dlpPermission.off('uninstallDLPSandbox', (info: dlpPermission.DLPSandboxState) => {
410e41f4b71Sopenharmony_ci    console.info('uninstallDLPSandbox event', info.appIndex, info.bundleName)
411e41f4b71Sopenharmony_ci  // Unsubscribe from the DLP sandbox uninstall events.
412e41f4b71Sopenharmony_ci} catch (err) {
413e41f4b71Sopenharmony_ci  console.error('error', (err as BusinessError).code, (err as BusinessError).message); // Error reported if the operation fails.
414e41f4b71Sopenharmony_ci}
415e41f4b71Sopenharmony_ci```
416e41f4b71Sopenharmony_ci
417e41f4b71Sopenharmony_ci## DLPFile
418e41f4b71Sopenharmony_ci
419e41f4b71Sopenharmony_ciProvides APIs for managing DLP files. A **DLPFile** instance indicates a DLP file object. You can use [generateDLPFile](#dlppermissiongeneratedlpfile) or [openDLPFile](#dlppermissionopendlpfile11) to obtain a **DLPFile** instance.
420e41f4b71Sopenharmony_ci
421e41f4b71Sopenharmony_ci### Attributes
422e41f4b71Sopenharmony_ci
423e41f4b71Sopenharmony_ci**System API**: This is a system API.
424e41f4b71Sopenharmony_ci
425e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
426e41f4b71Sopenharmony_ci
427e41f4b71Sopenharmony_ci| Name | Type | Read Only | Mandatory | Description |
428e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
429e41f4b71Sopenharmony_ci| dlpProperty | [DLPProperty](#dlpproperty) | No | Yes | Authorized user information. |
430e41f4b71Sopenharmony_ci
431e41f4b71Sopenharmony_ci### addDLPLinkFile
432e41f4b71Sopenharmony_ci
433e41f4b71Sopenharmony_ciaddDLPLinkFile(linkFileName: string): Promise&lt;void&gt;
434e41f4b71Sopenharmony_ci
435e41f4b71Sopenharmony_ciAdds a link file to the Filesystem in Userspace (FUSE). The link file is a virtual file mapped to the ciphertext in the FUSE. The read and write operations on the link file will be synchronized to the DLP file. This API uses a promise to return the result.
436e41f4b71Sopenharmony_ci
437e41f4b71Sopenharmony_ci**System API**: This is a system API.
438e41f4b71Sopenharmony_ci
439e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
440e41f4b71Sopenharmony_ci
441e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
442e41f4b71Sopenharmony_ci
443e41f4b71Sopenharmony_ci**Parameters**
444e41f4b71Sopenharmony_ci
445e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
446e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
447e41f4b71Sopenharmony_ci| linkFileName | string | Yes | Name of the link file to add. |
448e41f4b71Sopenharmony_ci
449e41f4b71Sopenharmony_ci**Return value**
450e41f4b71Sopenharmony_ci
451e41f4b71Sopenharmony_ci| Type | Description |
452e41f4b71Sopenharmony_ci| -------- | -------- |
453e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value. |
454e41f4b71Sopenharmony_ci
455e41f4b71Sopenharmony_ci**Error codes**
456e41f4b71Sopenharmony_ci
457e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
458e41f4b71Sopenharmony_ci
459e41f4b71Sopenharmony_ci| ID | Error Message |
460e41f4b71Sopenharmony_ci| -------- | -------- |
461e41f4b71Sopenharmony_ci| 201 | Permission denied. |
462e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
463e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
464e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
465e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
466e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci**Example**
469e41f4b71Sopenharmony_ci
470e41f4b71Sopenharmony_ci```ts
471e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
472e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
473e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
474e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
477e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
478e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
479e41f4b71Sopenharmony_cilet appId = "";
480e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
481e41f4b71Sopenharmony_cilet userId = 100;
482e41f4b71Sopenharmony_ci
483e41f4b71Sopenharmony_citry{
484e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
485e41f4b71Sopenharmony_ci    if (err) {
486e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
487e41f4b71Sopenharmony_ci    } else {
488e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
489e41f4b71Sopenharmony_ci    }
490e41f4b71Sopenharmony_ci  })
491e41f4b71Sopenharmony_ci} catch (err) {
492e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
493e41f4b71Sopenharmony_ci}
494e41f4b71Sopenharmony_ci
495e41f4b71Sopenharmony_citry {
496e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{
497e41f4b71Sopenharmony_ci    dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file.
498e41f4b71Sopenharmony_ci    dlpFile.closeDLPFile(); // Close the DLPFile instance.
499e41f4b71Sopenharmony_ci  }); // Open a DLP file.
500e41f4b71Sopenharmony_ci} catch (err) {
501e41f4b71Sopenharmony_ci  console.error('error', (err as BusinessError).code, (err as BusinessError).message); // Error reported if the operation fails.
502e41f4b71Sopenharmony_ci}
503e41f4b71Sopenharmony_cifileIo.closeSync(file);
504e41f4b71Sopenharmony_ci```
505e41f4b71Sopenharmony_ci
506e41f4b71Sopenharmony_ci### addDLPLinkFile
507e41f4b71Sopenharmony_ci
508e41f4b71Sopenharmony_ciaddDLPLinkFile(linkFileName: string, callback: AsyncCallback&lt;void&gt;): void
509e41f4b71Sopenharmony_ci
510e41f4b71Sopenharmony_ciAdds a link file to the FUSE. This API uses an asynchronous callback to return the result.
511e41f4b71Sopenharmony_ci
512e41f4b71Sopenharmony_ci**System API**: This is a system API.
513e41f4b71Sopenharmony_ci
514e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
515e41f4b71Sopenharmony_ci
516e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
517e41f4b71Sopenharmony_ci
518e41f4b71Sopenharmony_ci**Parameters**
519e41f4b71Sopenharmony_ci
520e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
521e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
522e41f4b71Sopenharmony_ci| linkFileName | string | Yes | Name of the link file to add. |
523e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
524e41f4b71Sopenharmony_ci
525e41f4b71Sopenharmony_ci**Error codes**
526e41f4b71Sopenharmony_ci
527e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
528e41f4b71Sopenharmony_ci
529e41f4b71Sopenharmony_ci| ID | Error Message |
530e41f4b71Sopenharmony_ci| -------- | -------- |
531e41f4b71Sopenharmony_ci| 201 | Permission denied. |
532e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
533e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
534e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
535e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
536e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
537e41f4b71Sopenharmony_ci
538e41f4b71Sopenharmony_ci**Example**
539e41f4b71Sopenharmony_ci
540e41f4b71Sopenharmony_ci```ts
541e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
542e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
543e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
544e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
545e41f4b71Sopenharmony_ci
546e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
547e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
548e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
549e41f4b71Sopenharmony_cilet appId = "";
550e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
551e41f4b71Sopenharmony_cilet userId = 100;
552e41f4b71Sopenharmony_ci
553e41f4b71Sopenharmony_citry{
554e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
555e41f4b71Sopenharmony_ci    if (err) {
556e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
557e41f4b71Sopenharmony_ci    } else {
558e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
559e41f4b71Sopenharmony_ci    }
560e41f4b71Sopenharmony_ci  })
561e41f4b71Sopenharmony_ci} catch (err) {
562e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
563e41f4b71Sopenharmony_ci}
564e41f4b71Sopenharmony_ci
565e41f4b71Sopenharmony_citry {
566e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{
567e41f4b71Sopenharmony_ci    dlpFile.addDLPLinkFile('test.txt.dlp.link', async (err, res) => {
568e41f4b71Sopenharmony_ci      if (err != undefined) {
569e41f4b71Sopenharmony_ci        console.error('addDLPLinkFile error,', err.code, err.message);
570e41f4b71Sopenharmony_ci        await dlpFile.closeDLPFile(); // Close the DLPFile instance.
571e41f4b71Sopenharmony_ci      } else {
572e41f4b71Sopenharmony_ci        console.info('res', JSON.stringify(res));
573e41f4b71Sopenharmony_ci      }
574e41f4b71Sopenharmony_ci    });
575e41f4b71Sopenharmony_ci  }); // Open a DLP file.
576e41f4b71Sopenharmony_ci} catch (err) {
577e41f4b71Sopenharmony_ci  console.error('addDLPLinkFile error,', (err as BusinessError).code, (err as BusinessError).message);
578e41f4b71Sopenharmony_ci}
579e41f4b71Sopenharmony_ci```
580e41f4b71Sopenharmony_ci
581e41f4b71Sopenharmony_ci### stopFuseLink
582e41f4b71Sopenharmony_ci
583e41f4b71Sopenharmony_cistopFuseLink(): Promise&lt;void&gt;
584e41f4b71Sopenharmony_ci
585e41f4b71Sopenharmony_ciStops the read and write on the FUSE. This API uses a promise to return the result.
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_ci**System API**: This is a system API.
588e41f4b71Sopenharmony_ci
589e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
590e41f4b71Sopenharmony_ci
591e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
592e41f4b71Sopenharmony_ci
593e41f4b71Sopenharmony_ci**Return value**
594e41f4b71Sopenharmony_ci
595e41f4b71Sopenharmony_ci| Type | Description |
596e41f4b71Sopenharmony_ci| -------- | -------- |
597e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value. |
598e41f4b71Sopenharmony_ci
599e41f4b71Sopenharmony_ci**Error codes**
600e41f4b71Sopenharmony_ci
601e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
602e41f4b71Sopenharmony_ci
603e41f4b71Sopenharmony_ci| ID | Error Message |
604e41f4b71Sopenharmony_ci| -------- | -------- |
605e41f4b71Sopenharmony_ci| 201 | Permission denied. |
606e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
607e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
608e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
609e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
610e41f4b71Sopenharmony_ci
611e41f4b71Sopenharmony_ci**Example**
612e41f4b71Sopenharmony_ci
613e41f4b71Sopenharmony_ci```ts
614e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
615e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
616e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
617e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
618e41f4b71Sopenharmony_ci
619e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
620e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
621e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
622e41f4b71Sopenharmony_cilet appId = "";
623e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
624e41f4b71Sopenharmony_cilet userId = 100;
625e41f4b71Sopenharmony_ci
626e41f4b71Sopenharmony_citry{
627e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
628e41f4b71Sopenharmony_ci    if (err) {
629e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
630e41f4b71Sopenharmony_ci    } else {
631e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
632e41f4b71Sopenharmony_ci    }
633e41f4b71Sopenharmony_ci  })
634e41f4b71Sopenharmony_ci} catch (err) {
635e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
636e41f4b71Sopenharmony_ci}
637e41f4b71Sopenharmony_ci
638e41f4b71Sopenharmony_citry {
639e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{
640e41f4b71Sopenharmony_ci    dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file.
641e41f4b71Sopenharmony_ci    dlpFile.stopFuseLink(); // Stop read/write on the link file.
642e41f4b71Sopenharmony_ci    dlpFile.closeDLPFile(); // Close the DLPFile instance.
643e41f4b71Sopenharmony_ci  }); // Open a DLP file.
644e41f4b71Sopenharmony_ci} catch (err) {
645e41f4b71Sopenharmony_ci  console.error('error', (err as BusinessError).code, (err as BusinessError).message); // Error reported if the operation fails.
646e41f4b71Sopenharmony_ci}
647e41f4b71Sopenharmony_cifileIo.closeSync(file);
648e41f4b71Sopenharmony_ci```
649e41f4b71Sopenharmony_ci
650e41f4b71Sopenharmony_ci### stopFuseLink
651e41f4b71Sopenharmony_ci
652e41f4b71Sopenharmony_cistopFuseLink(callback: AsyncCallback&lt;void&gt;): void
653e41f4b71Sopenharmony_ci
654e41f4b71Sopenharmony_ciStops the read and write on the FUSE. This API uses an asynchronous callback to return the result.
655e41f4b71Sopenharmony_ci
656e41f4b71Sopenharmony_ci**System API**: This is a system API.
657e41f4b71Sopenharmony_ci
658e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
659e41f4b71Sopenharmony_ci
660e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
661e41f4b71Sopenharmony_ci
662e41f4b71Sopenharmony_ci**Parameters**
663e41f4b71Sopenharmony_ci
664e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
665e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
666e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
667e41f4b71Sopenharmony_ci
668e41f4b71Sopenharmony_ci**Error codes**
669e41f4b71Sopenharmony_ci
670e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
671e41f4b71Sopenharmony_ci
672e41f4b71Sopenharmony_ci| ID | Error Message |
673e41f4b71Sopenharmony_ci| -------- | -------- |
674e41f4b71Sopenharmony_ci| 201 | Permission denied. |
675e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
676e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Incorrect parameter types. |
677e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
678e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
679e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
680e41f4b71Sopenharmony_ci
681e41f4b71Sopenharmony_ci**Example**
682e41f4b71Sopenharmony_ci
683e41f4b71Sopenharmony_ci```ts
684e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
685e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
686e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
687e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
688e41f4b71Sopenharmony_ci
689e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
690e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
691e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
692e41f4b71Sopenharmony_cilet appId = "";
693e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
694e41f4b71Sopenharmony_cilet userId = 100;
695e41f4b71Sopenharmony_ci
696e41f4b71Sopenharmony_citry{
697e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
698e41f4b71Sopenharmony_ci    if (err) {
699e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
700e41f4b71Sopenharmony_ci    } else {
701e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
702e41f4b71Sopenharmony_ci    }
703e41f4b71Sopenharmony_ci  })
704e41f4b71Sopenharmony_ci} catch (err) {
705e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
706e41f4b71Sopenharmony_ci}
707e41f4b71Sopenharmony_ci
708e41f4b71Sopenharmony_citry {
709e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{
710e41f4b71Sopenharmony_ci    dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file.
711e41f4b71Sopenharmony_ci    dlpFile.stopFuseLink(async (err, res) => {
712e41f4b71Sopenharmony_ci      if (err != undefined) {
713e41f4b71Sopenharmony_ci        console.error('stopFuseLink error,', err.code, err.message);
714e41f4b71Sopenharmony_ci        await dlpFile.closeDLPFile(); // Close the DLPFile instance.
715e41f4b71Sopenharmony_ci      } else {
716e41f4b71Sopenharmony_ci        console.info('res', JSON.stringify(res));
717e41f4b71Sopenharmony_ci      }
718e41f4b71Sopenharmony_ci    });
719e41f4b71Sopenharmony_ci  }); // Open a DLP file.
720e41f4b71Sopenharmony_ci} catch (err) {
721e41f4b71Sopenharmony_ci  console.error('stopFuseLink error,', (err as BusinessError).code, (err as BusinessError).message);
722e41f4b71Sopenharmony_ci}
723e41f4b71Sopenharmony_ci```
724e41f4b71Sopenharmony_ci
725e41f4b71Sopenharmony_ci### resumeFuseLink
726e41f4b71Sopenharmony_ci
727e41f4b71Sopenharmony_ciresumeFuseLink(): Promise&lt;void&gt;
728e41f4b71Sopenharmony_ci
729e41f4b71Sopenharmony_ciResumes the read and write on the FUSE. This API uses a promise to return the result.
730e41f4b71Sopenharmony_ci
731e41f4b71Sopenharmony_ci**System API**: This is a system API.
732e41f4b71Sopenharmony_ci
733e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
734e41f4b71Sopenharmony_ci
735e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
736e41f4b71Sopenharmony_ci
737e41f4b71Sopenharmony_ci**Return value**
738e41f4b71Sopenharmony_ci
739e41f4b71Sopenharmony_ci| Type | Description |
740e41f4b71Sopenharmony_ci| -------- | -------- |
741e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value. |
742e41f4b71Sopenharmony_ci
743e41f4b71Sopenharmony_ci**Error codes**
744e41f4b71Sopenharmony_ci
745e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
746e41f4b71Sopenharmony_ci
747e41f4b71Sopenharmony_ci| ID | Error Message |
748e41f4b71Sopenharmony_ci| -------- | -------- |
749e41f4b71Sopenharmony_ci| 201 | Permission denied. |
750e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
751e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
752e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
753e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
754e41f4b71Sopenharmony_ci
755e41f4b71Sopenharmony_ci**Example**
756e41f4b71Sopenharmony_ci
757e41f4b71Sopenharmony_ci```ts
758e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
759e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
760e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
761e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
762e41f4b71Sopenharmony_ci
763e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
764e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
765e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
766e41f4b71Sopenharmony_cilet appId = "";
767e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
768e41f4b71Sopenharmony_cilet userId = 100;
769e41f4b71Sopenharmony_ci
770e41f4b71Sopenharmony_citry{
771e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
772e41f4b71Sopenharmony_ci    if (err) {
773e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
774e41f4b71Sopenharmony_ci    } else {
775e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
776e41f4b71Sopenharmony_ci    }
777e41f4b71Sopenharmony_ci  })
778e41f4b71Sopenharmony_ci} catch (err) {
779e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
780e41f4b71Sopenharmony_ci}
781e41f4b71Sopenharmony_ci
782e41f4b71Sopenharmony_citry {
783e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{
784e41f4b71Sopenharmony_ci    dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file.
785e41f4b71Sopenharmony_ci    dlpFile.stopFuseLink(); // Stop read/write on the link file.
786e41f4b71Sopenharmony_ci    dlpFile.resumeFuseLink(); // Resume read/write on the link file.
787e41f4b71Sopenharmony_ci    dlpFile.closeDLPFile(); // Close the DLPFile instance.
788e41f4b71Sopenharmony_ci  }); // Open a DLP file.
789e41f4b71Sopenharmony_ci} catch (err) {
790e41f4b71Sopenharmony_ci  console.error('error', (err as BusinessError).code, (err as BusinessError).message); // Error reported if the operation fails.
791e41f4b71Sopenharmony_ci}
792e41f4b71Sopenharmony_cifileIo.closeSync(file);
793e41f4b71Sopenharmony_ci```
794e41f4b71Sopenharmony_ci
795e41f4b71Sopenharmony_ci### resumeFuseLink
796e41f4b71Sopenharmony_ci
797e41f4b71Sopenharmony_ciresumeFuseLink(callback: AsyncCallback&lt;void&gt;): void
798e41f4b71Sopenharmony_ci
799e41f4b71Sopenharmony_ciResumes the read and write on the FUSE. This API uses an asynchronous callback to return the result.
800e41f4b71Sopenharmony_ci
801e41f4b71Sopenharmony_ci**System API**: This is a system API.
802e41f4b71Sopenharmony_ci
803e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
804e41f4b71Sopenharmony_ci
805e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
806e41f4b71Sopenharmony_ci
807e41f4b71Sopenharmony_ci**Parameters**
808e41f4b71Sopenharmony_ci
809e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
810e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
811e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
812e41f4b71Sopenharmony_ci
813e41f4b71Sopenharmony_ci**Error codes**
814e41f4b71Sopenharmony_ci
815e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
816e41f4b71Sopenharmony_ci
817e41f4b71Sopenharmony_ci| ID | Error Message |
818e41f4b71Sopenharmony_ci| -------- | -------- |
819e41f4b71Sopenharmony_ci| 201 | Permission denied. |
820e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
821e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Incorrect parameter types. |
822e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
823e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
824e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
825e41f4b71Sopenharmony_ci
826e41f4b71Sopenharmony_ci**Example**
827e41f4b71Sopenharmony_ci
828e41f4b71Sopenharmony_ci```ts
829e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
830e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
831e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
832e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
833e41f4b71Sopenharmony_ci
834e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
835e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
836e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
837e41f4b71Sopenharmony_cilet appId = "";
838e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
839e41f4b71Sopenharmony_cilet userId = 100;
840e41f4b71Sopenharmony_ci
841e41f4b71Sopenharmony_citry{
842e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
843e41f4b71Sopenharmony_ci    if (err) {
844e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
845e41f4b71Sopenharmony_ci    } else {
846e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
847e41f4b71Sopenharmony_ci    }
848e41f4b71Sopenharmony_ci  })
849e41f4b71Sopenharmony_ci} catch (err) {
850e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
851e41f4b71Sopenharmony_ci}
852e41f4b71Sopenharmony_ci
853e41f4b71Sopenharmony_citry {
854e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{
855e41f4b71Sopenharmony_ci    dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file.
856e41f4b71Sopenharmony_ci    dlpFile.stopFuseLink(); // Stop read/write on the link file.
857e41f4b71Sopenharmony_ci    dlpFile.resumeFuseLink(async (err, res) => {
858e41f4b71Sopenharmony_ci      if (err != undefined) {
859e41f4b71Sopenharmony_ci        console.error('resumeFuseLink error,', err.code, err.message);
860e41f4b71Sopenharmony_ci        await dlpFile.closeDLPFile(); // Close the DLPFile instance.
861e41f4b71Sopenharmony_ci      } else {
862e41f4b71Sopenharmony_ci        console.info('res', JSON.stringify(res));
863e41f4b71Sopenharmony_ci      }
864e41f4b71Sopenharmony_ci    });
865e41f4b71Sopenharmony_ci  }); // Open a DLP file.
866e41f4b71Sopenharmony_ci} catch (err) {
867e41f4b71Sopenharmony_ci  console.error('resumeFuseLink error,', (err as BusinessError).code, (err as BusinessError).message);
868e41f4b71Sopenharmony_ci}
869e41f4b71Sopenharmony_ci```
870e41f4b71Sopenharmony_ci
871e41f4b71Sopenharmony_ci### replaceDLPLinkFile
872e41f4b71Sopenharmony_ci
873e41f4b71Sopenharmony_cireplaceDLPLinkFile(linkFileName: string): Promise&lt;void&gt;
874e41f4b71Sopenharmony_ci
875e41f4b71Sopenharmony_ciReplaces a link file. This API uses a promise to return the result.
876e41f4b71Sopenharmony_ci
877e41f4b71Sopenharmony_ci**System API**: This is a system API.
878e41f4b71Sopenharmony_ci
879e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
880e41f4b71Sopenharmony_ci
881e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
882e41f4b71Sopenharmony_ci
883e41f4b71Sopenharmony_ci**Parameters**
884e41f4b71Sopenharmony_ci
885e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
886e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
887e41f4b71Sopenharmony_ci| linkFileName | string | Yes| Name of the link file to replace.|
888e41f4b71Sopenharmony_ci
889e41f4b71Sopenharmony_ci**Return value**
890e41f4b71Sopenharmony_ci
891e41f4b71Sopenharmony_ci| Type | Description |
892e41f4b71Sopenharmony_ci| -------- | -------- |
893e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value. |
894e41f4b71Sopenharmony_ci
895e41f4b71Sopenharmony_ci**Error codes**
896e41f4b71Sopenharmony_ci
897e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
898e41f4b71Sopenharmony_ci
899e41f4b71Sopenharmony_ci| ID | Error Message |
900e41f4b71Sopenharmony_ci| -------- | -------- |
901e41f4b71Sopenharmony_ci| 201 | Permission denied. |
902e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
903e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
904e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
905e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
906e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
907e41f4b71Sopenharmony_ci
908e41f4b71Sopenharmony_ci**Example**
909e41f4b71Sopenharmony_ci
910e41f4b71Sopenharmony_ci```ts
911e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
912e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
913e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
914e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
915e41f4b71Sopenharmony_ci
916e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
917e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
918e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
919e41f4b71Sopenharmony_cilet appId = "";
920e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
921e41f4b71Sopenharmony_cilet userId = 100;
922e41f4b71Sopenharmony_ci
923e41f4b71Sopenharmony_citry{
924e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
925e41f4b71Sopenharmony_ci    if (err) {
926e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
927e41f4b71Sopenharmony_ci    } else {
928e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
929e41f4b71Sopenharmony_ci    }
930e41f4b71Sopenharmony_ci  })
931e41f4b71Sopenharmony_ci} catch (err) {
932e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
933e41f4b71Sopenharmony_ci}
934e41f4b71Sopenharmony_ci
935e41f4b71Sopenharmony_citry {
936e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{
937e41f4b71Sopenharmony_ci    dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file.
938e41f4b71Sopenharmony_ci    dlpFile.stopFuseLink(); // Stop read/write on the link file.
939e41f4b71Sopenharmony_ci    dlpFile.replaceDLPLinkFile('test_new.txt.dlp.link'); // Replace the link file.
940e41f4b71Sopenharmony_ci    dlpFile.resumeFuseLink(); // Resume read/write on the link file.
941e41f4b71Sopenharmony_ci    dlpFile.closeDLPFile(); // Close the DLPFile instance.
942e41f4b71Sopenharmony_ci  }); // Open a DLP file.
943e41f4b71Sopenharmony_ci} catch (err) {
944e41f4b71Sopenharmony_ci  console.error('error', (err as BusinessError).code, (err as BusinessError).message); // Error reported if the operation fails.
945e41f4b71Sopenharmony_ci}
946e41f4b71Sopenharmony_cifileIo.closeSync(file);
947e41f4b71Sopenharmony_ci```
948e41f4b71Sopenharmony_ci
949e41f4b71Sopenharmony_ci### replaceDLPLinkFile
950e41f4b71Sopenharmony_ci
951e41f4b71Sopenharmony_cireplaceDLPLinkFile(linkFileName: string, callback: AsyncCallback&lt;void&gt;): void
952e41f4b71Sopenharmony_ci
953e41f4b71Sopenharmony_ciReplaces a link file. This API uses an asynchronous callback to return the result.
954e41f4b71Sopenharmony_ci
955e41f4b71Sopenharmony_ci**System API**: This is a system API.
956e41f4b71Sopenharmony_ci
957e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
958e41f4b71Sopenharmony_ci
959e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
960e41f4b71Sopenharmony_ci
961e41f4b71Sopenharmony_ci**Parameters**
962e41f4b71Sopenharmony_ci
963e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
964e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
965e41f4b71Sopenharmony_ci| linkFileName | string | Yes| Name of the link file to replace.|
966e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
967e41f4b71Sopenharmony_ci
968e41f4b71Sopenharmony_ci**Error codes**
969e41f4b71Sopenharmony_ci
970e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
971e41f4b71Sopenharmony_ci
972e41f4b71Sopenharmony_ci| ID | Error Message |
973e41f4b71Sopenharmony_ci| -------- | -------- |
974e41f4b71Sopenharmony_ci| 201 | Permission denied. |
975e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
976e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
977e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
978e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
979e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
980e41f4b71Sopenharmony_ci
981e41f4b71Sopenharmony_ci**Example**
982e41f4b71Sopenharmony_ci
983e41f4b71Sopenharmony_ci```ts
984e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
985e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
986e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
987e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
988e41f4b71Sopenharmony_ci
989e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
990e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
991e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
992e41f4b71Sopenharmony_cilet appId = "";
993e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
994e41f4b71Sopenharmony_cilet userId = 100;
995e41f4b71Sopenharmony_ci
996e41f4b71Sopenharmony_citry{
997e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
998e41f4b71Sopenharmony_ci    if (err) {
999e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
1000e41f4b71Sopenharmony_ci    } else {
1001e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
1002e41f4b71Sopenharmony_ci    }
1003e41f4b71Sopenharmony_ci  })
1004e41f4b71Sopenharmony_ci} catch (err) {
1005e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
1006e41f4b71Sopenharmony_ci}
1007e41f4b71Sopenharmony_ci
1008e41f4b71Sopenharmony_citry {
1009e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{
1010e41f4b71Sopenharmony_ci    dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file.
1011e41f4b71Sopenharmony_ci    dlpFile.stopFuseLink(); // Stop read/write on the link file.
1012e41f4b71Sopenharmony_ci    dlpFile.replaceDLPLinkFile('test_new.txt.dlp.link', async (err, res) => { // Replace a link file.
1013e41f4b71Sopenharmony_ci      if (err != undefined) {
1014e41f4b71Sopenharmony_ci        console.error('replaceDLPLinkFile error,', err.code, err.message);
1015e41f4b71Sopenharmony_ci        await dlpFile.closeDLPFile(); // Close the DLPFile instance.
1016e41f4b71Sopenharmony_ci      } else {
1017e41f4b71Sopenharmony_ci        console.info('res', JSON.stringify(res));
1018e41f4b71Sopenharmony_ci        await dlpFile.resumeFuseLink(); // Resume read/write on the link file.
1019e41f4b71Sopenharmony_ci      }
1020e41f4b71Sopenharmony_ci    });
1021e41f4b71Sopenharmony_ci  }); // Open a DLP file.
1022e41f4b71Sopenharmony_ci} catch (err) {
1023e41f4b71Sopenharmony_ci  console.error('error,', (err as BusinessError).code, (err as BusinessError).message);
1024e41f4b71Sopenharmony_ci}
1025e41f4b71Sopenharmony_ci```
1026e41f4b71Sopenharmony_ci
1027e41f4b71Sopenharmony_ci### deleteDLPLinkFile
1028e41f4b71Sopenharmony_ci
1029e41f4b71Sopenharmony_cideleteDLPLinkFile(linkFileName: string): Promise&lt;void&gt;
1030e41f4b71Sopenharmony_ci
1031e41f4b71Sopenharmony_ciDeletes a link file from the FUSE. This API uses a promise to return the result.
1032e41f4b71Sopenharmony_ci
1033e41f4b71Sopenharmony_ci**System API**: This is a system API.
1034e41f4b71Sopenharmony_ci
1035e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
1036e41f4b71Sopenharmony_ci
1037e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1038e41f4b71Sopenharmony_ci
1039e41f4b71Sopenharmony_ci**Parameters**
1040e41f4b71Sopenharmony_ci
1041e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
1042e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1043e41f4b71Sopenharmony_ci| linkFileName | string | Yes| Name of the link file to delete.|
1044e41f4b71Sopenharmony_ci
1045e41f4b71Sopenharmony_ci**Return value**
1046e41f4b71Sopenharmony_ci
1047e41f4b71Sopenharmony_ci| Type | Description |
1048e41f4b71Sopenharmony_ci| -------- | -------- |
1049e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value. |
1050e41f4b71Sopenharmony_ci
1051e41f4b71Sopenharmony_ci**Error codes**
1052e41f4b71Sopenharmony_ci
1053e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
1054e41f4b71Sopenharmony_ci
1055e41f4b71Sopenharmony_ci| ID | Error Message |
1056e41f4b71Sopenharmony_ci| -------- | -------- |
1057e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1058e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
1059e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1060e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
1061e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
1062e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
1063e41f4b71Sopenharmony_ci
1064e41f4b71Sopenharmony_ci**Example**
1065e41f4b71Sopenharmony_ci
1066e41f4b71Sopenharmony_ci```ts
1067e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
1068e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
1069e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
1070e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1071e41f4b71Sopenharmony_ci
1072e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
1073e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
1074e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
1075e41f4b71Sopenharmony_cilet appId = "";
1076e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
1077e41f4b71Sopenharmony_cilet userId = 100;
1078e41f4b71Sopenharmony_ci
1079e41f4b71Sopenharmony_citry{
1080e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
1081e41f4b71Sopenharmony_ci    if (err) {
1082e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
1083e41f4b71Sopenharmony_ci    } else {
1084e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
1085e41f4b71Sopenharmony_ci    }
1086e41f4b71Sopenharmony_ci  })
1087e41f4b71Sopenharmony_ci} catch (err) {
1088e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
1089e41f4b71Sopenharmony_ci}
1090e41f4b71Sopenharmony_ci
1091e41f4b71Sopenharmony_citry {
1092e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{
1093e41f4b71Sopenharmony_ci    dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file.
1094e41f4b71Sopenharmony_ci    dlpFile.deleteDLPLinkFile('test.txt.dlp.link'); // Delete the link file.
1095e41f4b71Sopenharmony_ci    dlpFile.closeDLPFile(); // Close the DLPFile instance.
1096e41f4b71Sopenharmony_ci  }); // Open a DLP file.
1097e41f4b71Sopenharmony_ci} catch (err) {
1098e41f4b71Sopenharmony_ci  console.error('error', (err as BusinessError).code, (err as BusinessError).message); // Error reported if the operation fails.
1099e41f4b71Sopenharmony_ci}
1100e41f4b71Sopenharmony_cifileIo.closeSync(file);
1101e41f4b71Sopenharmony_ci```
1102e41f4b71Sopenharmony_ci
1103e41f4b71Sopenharmony_ci### deleteDLPLinkFile
1104e41f4b71Sopenharmony_ci
1105e41f4b71Sopenharmony_cideleteDLPLinkFile(linkFileName: string, callback: AsyncCallback&lt;void&gt;): void
1106e41f4b71Sopenharmony_ci
1107e41f4b71Sopenharmony_ciDeletes a link file. This API uses an asynchronous callback to return the result.
1108e41f4b71Sopenharmony_ci
1109e41f4b71Sopenharmony_ci**System API**: This is a system API.
1110e41f4b71Sopenharmony_ci
1111e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
1112e41f4b71Sopenharmony_ci
1113e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1114e41f4b71Sopenharmony_ci
1115e41f4b71Sopenharmony_ci**Parameters**
1116e41f4b71Sopenharmony_ci
1117e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
1118e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1119e41f4b71Sopenharmony_ci| linkFileName | string | Yes| Name of the link file to delete.|
1120e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
1121e41f4b71Sopenharmony_ci
1122e41f4b71Sopenharmony_ci**Error codes**
1123e41f4b71Sopenharmony_ci
1124e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
1125e41f4b71Sopenharmony_ci
1126e41f4b71Sopenharmony_ci| ID | Error Message |
1127e41f4b71Sopenharmony_ci| -------- | -------- |
1128e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1129e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
1130e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1131e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
1132e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
1133e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
1134e41f4b71Sopenharmony_ci
1135e41f4b71Sopenharmony_ci**Example**
1136e41f4b71Sopenharmony_ci
1137e41f4b71Sopenharmony_ci```ts
1138e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
1139e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
1140e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
1141e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1142e41f4b71Sopenharmony_ci
1143e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
1144e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
1145e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
1146e41f4b71Sopenharmony_cilet appId = "";
1147e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
1148e41f4b71Sopenharmony_cilet userId = 100;
1149e41f4b71Sopenharmony_ci
1150e41f4b71Sopenharmony_citry{
1151e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
1152e41f4b71Sopenharmony_ci    if (err) {
1153e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
1154e41f4b71Sopenharmony_ci    } else {
1155e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
1156e41f4b71Sopenharmony_ci    }
1157e41f4b71Sopenharmony_ci  })
1158e41f4b71Sopenharmony_ci} catch (err) {
1159e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
1160e41f4b71Sopenharmony_ci}
1161e41f4b71Sopenharmony_ci
1162e41f4b71Sopenharmony_citry {
1163e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{
1164e41f4b71Sopenharmony_ci    dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file.
1165e41f4b71Sopenharmony_ci    dlpFile.deleteDLPLinkFile('test.txt.dlp.link', async (err, res) => { // Delete a link file.
1166e41f4b71Sopenharmony_ci      if (err != undefined) {
1167e41f4b71Sopenharmony_ci        console.error('deleteDLPLinkFile error,', err.code, err.message);
1168e41f4b71Sopenharmony_ci        await dlpFile.closeDLPFile(); // Close the DLPFile instance.
1169e41f4b71Sopenharmony_ci      } else {
1170e41f4b71Sopenharmony_ci        console.info('res', JSON.stringify(res));
1171e41f4b71Sopenharmony_ci      }
1172e41f4b71Sopenharmony_ci    });
1173e41f4b71Sopenharmony_ci  }); // Open a DLP file.
1174e41f4b71Sopenharmony_ci} catch (err) {
1175e41f4b71Sopenharmony_ci  console.error('error,', (err as BusinessError).code, (err as BusinessError).message);
1176e41f4b71Sopenharmony_ci}
1177e41f4b71Sopenharmony_ci```
1178e41f4b71Sopenharmony_ci
1179e41f4b71Sopenharmony_ci### recoverDLPFile
1180e41f4b71Sopenharmony_ci
1181e41f4b71Sopenharmony_cirecoverDLPFile(plaintextFd: number): Promise&lt;void&gt;
1182e41f4b71Sopenharmony_ci
1183e41f4b71Sopenharmony_ciRecovers the plaintext of a DLP file. This API uses a promise to return the result.
1184e41f4b71Sopenharmony_ci
1185e41f4b71Sopenharmony_ci**System API**: This is a system API.
1186e41f4b71Sopenharmony_ci
1187e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
1188e41f4b71Sopenharmony_ci
1189e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1190e41f4b71Sopenharmony_ci
1191e41f4b71Sopenharmony_ci**Parameters**
1192e41f4b71Sopenharmony_ci
1193e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
1194e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1195e41f4b71Sopenharmony_ci| plaintextFd | number | Yes | FD of the target plaintext file. |
1196e41f4b71Sopenharmony_ci
1197e41f4b71Sopenharmony_ci**Return value**
1198e41f4b71Sopenharmony_ci
1199e41f4b71Sopenharmony_ci| Type | Description |
1200e41f4b71Sopenharmony_ci| -------- | -------- |
1201e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value. |
1202e41f4b71Sopenharmony_ci
1203e41f4b71Sopenharmony_ci**Error codes**
1204e41f4b71Sopenharmony_ci
1205e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
1206e41f4b71Sopenharmony_ci
1207e41f4b71Sopenharmony_ci| ID | Error Message |
1208e41f4b71Sopenharmony_ci| -------- | -------- |
1209e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1210e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
1211e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1212e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
1213e41f4b71Sopenharmony_ci| 19100002 | Credential task error. |
1214e41f4b71Sopenharmony_ci| 19100003 | Credential task time out. |
1215e41f4b71Sopenharmony_ci| 19100004 | Credential service error. |
1216e41f4b71Sopenharmony_ci| 19100005 | Credential authentication server error. |
1217e41f4b71Sopenharmony_ci| 19100008 | The file is not a DLP file. |
1218e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
1219e41f4b71Sopenharmony_ci| 19100010 | The DLP file is read only. |
1220e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
1221e41f4b71Sopenharmony_ci
1222e41f4b71Sopenharmony_ci**Example**
1223e41f4b71Sopenharmony_ci
1224e41f4b71Sopenharmony_ci```ts
1225e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
1226e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
1227e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
1228e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1229e41f4b71Sopenharmony_ci
1230e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
1231e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
1232e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
1233e41f4b71Sopenharmony_cilet appId = "";
1234e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
1235e41f4b71Sopenharmony_cilet userId = 100;
1236e41f4b71Sopenharmony_ci
1237e41f4b71Sopenharmony_citry{
1238e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
1239e41f4b71Sopenharmony_ci    if (err) {
1240e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
1241e41f4b71Sopenharmony_ci    } else {
1242e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
1243e41f4b71Sopenharmony_ci    }
1244e41f4b71Sopenharmony_ci  })
1245e41f4b71Sopenharmony_ci} catch (err) {
1246e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
1247e41f4b71Sopenharmony_ci}
1248e41f4b71Sopenharmony_ci
1249e41f4b71Sopenharmony_cilet destFile = fileIo.openSync("destUri");
1250e41f4b71Sopenharmony_citry {
1251e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{
1252e41f4b71Sopenharmony_ci    dlpFile.recoverDLPFile(destFile.fd); // Recover the plain text from the DLP file.
1253e41f4b71Sopenharmony_ci    dlpFile.closeDLPFile(); // Close the DLPFile instance.
1254e41f4b71Sopenharmony_ci  }); // Open a DLP file.
1255e41f4b71Sopenharmony_ci} catch (err) {
1256e41f4b71Sopenharmony_ci  console.error('error', (err as BusinessError).code, (err as BusinessError).message); // Error reported if the operation fails.
1257e41f4b71Sopenharmony_ci}
1258e41f4b71Sopenharmony_cifileIo.closeSync(file);
1259e41f4b71Sopenharmony_cifileIo.closeSync(destFile);
1260e41f4b71Sopenharmony_ci```
1261e41f4b71Sopenharmony_ci
1262e41f4b71Sopenharmony_ci### recoverDLPFile
1263e41f4b71Sopenharmony_ci
1264e41f4b71Sopenharmony_cirecoverDLPFile(plaintextFd: number, callback: AsyncCallback&lt;void&gt;): void
1265e41f4b71Sopenharmony_ci
1266e41f4b71Sopenharmony_ciRecovers the plaintext of a DLP file. This API uses an asynchronous callback to return the result.
1267e41f4b71Sopenharmony_ci
1268e41f4b71Sopenharmony_ci**System API**: This is a system API.
1269e41f4b71Sopenharmony_ci
1270e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
1271e41f4b71Sopenharmony_ci
1272e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1273e41f4b71Sopenharmony_ci
1274e41f4b71Sopenharmony_ci**Parameters**
1275e41f4b71Sopenharmony_ci
1276e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
1277e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1278e41f4b71Sopenharmony_ci| plaintextFd | number | Yes | FD of the target plaintext file. |
1279e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
1280e41f4b71Sopenharmony_ci
1281e41f4b71Sopenharmony_ci**Error codes**
1282e41f4b71Sopenharmony_ci
1283e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
1284e41f4b71Sopenharmony_ci
1285e41f4b71Sopenharmony_ci| ID | Error Message |
1286e41f4b71Sopenharmony_ci| -------- | -------- |
1287e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1288e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
1289e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1290e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
1291e41f4b71Sopenharmony_ci| 19100002 | Credential task error. |
1292e41f4b71Sopenharmony_ci| 19100003 | Credential task time out. |
1293e41f4b71Sopenharmony_ci| 19100004 | Credential service error. |
1294e41f4b71Sopenharmony_ci| 19100005 | Credential authentication server error. |
1295e41f4b71Sopenharmony_ci| 19100008 | The file is not a DLP file. |
1296e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
1297e41f4b71Sopenharmony_ci| 19100010 | The DLP file is read only. |
1298e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
1299e41f4b71Sopenharmony_ci
1300e41f4b71Sopenharmony_ci**Example**
1301e41f4b71Sopenharmony_ci
1302e41f4b71Sopenharmony_ci```ts
1303e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
1304e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
1305e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
1306e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1307e41f4b71Sopenharmony_ci
1308e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
1309e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
1310e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
1311e41f4b71Sopenharmony_cilet appId = "";
1312e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
1313e41f4b71Sopenharmony_cilet userId = 100;
1314e41f4b71Sopenharmony_ci
1315e41f4b71Sopenharmony_citry{
1316e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
1317e41f4b71Sopenharmony_ci    if (err) {
1318e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
1319e41f4b71Sopenharmony_ci    } else {
1320e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
1321e41f4b71Sopenharmony_ci    }
1322e41f4b71Sopenharmony_ci  })
1323e41f4b71Sopenharmony_ci} catch (err) {
1324e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
1325e41f4b71Sopenharmony_ci}
1326e41f4b71Sopenharmony_ci
1327e41f4b71Sopenharmony_cilet destFile = fileIo.openSync("destUri");
1328e41f4b71Sopenharmony_citry {
1329e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{
1330e41f4b71Sopenharmony_ci    dlpFile.recoverDLPFile(destFile.fd, async (err, res) => { // Recover the plaintext of a DLP file.
1331e41f4b71Sopenharmony_ci      if (err != undefined) {
1332e41f4b71Sopenharmony_ci        console.error('recoverDLPFile error,', err.code, err.message);
1333e41f4b71Sopenharmony_ci        await dlpFile.closeDLPFile(); // Close the DLPFile instance.
1334e41f4b71Sopenharmony_ci      } else {
1335e41f4b71Sopenharmony_ci        console.info('res', JSON.stringify(res));
1336e41f4b71Sopenharmony_ci      }
1337e41f4b71Sopenharmony_ci    });
1338e41f4b71Sopenharmony_ci  }); // Open a DLP file.
1339e41f4b71Sopenharmony_ci} catch (err) {
1340e41f4b71Sopenharmony_ci  console.error('error,', (err as BusinessError).code, (err as BusinessError).message);
1341e41f4b71Sopenharmony_ci}
1342e41f4b71Sopenharmony_ci```
1343e41f4b71Sopenharmony_ci
1344e41f4b71Sopenharmony_ci### closeDLPFile
1345e41f4b71Sopenharmony_ci
1346e41f4b71Sopenharmony_cicloseDLPFile(): Promise&lt;void&gt;
1347e41f4b71Sopenharmony_ci
1348e41f4b71Sopenharmony_ciCloses this **DLPFile** instance. This API uses a promise to return the result.
1349e41f4b71Sopenharmony_ci
1350e41f4b71Sopenharmony_ci**System API**: This is a system API.
1351e41f4b71Sopenharmony_ci
1352e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
1353e41f4b71Sopenharmony_ci
1354e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1355e41f4b71Sopenharmony_ci
1356e41f4b71Sopenharmony_ci> **NOTE**
1357e41f4b71Sopenharmony_ci>
1358e41f4b71Sopenharmony_ci> If a DLP file is no longer used, close the **dlpFile** instance to release the memory.
1359e41f4b71Sopenharmony_ci
1360e41f4b71Sopenharmony_ci**Return value**
1361e41f4b71Sopenharmony_ci
1362e41f4b71Sopenharmony_ci| Type | Description |
1363e41f4b71Sopenharmony_ci| -------- | -------- |
1364e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value. |
1365e41f4b71Sopenharmony_ci
1366e41f4b71Sopenharmony_ci**Error codes**
1367e41f4b71Sopenharmony_ci
1368e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
1369e41f4b71Sopenharmony_ci
1370e41f4b71Sopenharmony_ci| ID | Error Message |
1371e41f4b71Sopenharmony_ci| -------- | -------- |
1372e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1373e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
1374e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
1375e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
1376e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
1377e41f4b71Sopenharmony_ci
1378e41f4b71Sopenharmony_ci**Example**
1379e41f4b71Sopenharmony_ci
1380e41f4b71Sopenharmony_ci```ts
1381e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
1382e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
1383e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
1384e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1385e41f4b71Sopenharmony_ci
1386e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
1387e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
1388e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
1389e41f4b71Sopenharmony_cilet appId = "";
1390e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
1391e41f4b71Sopenharmony_cilet userId = 100;
1392e41f4b71Sopenharmony_ci
1393e41f4b71Sopenharmony_citry{
1394e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
1395e41f4b71Sopenharmony_ci    if (err) {
1396e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
1397e41f4b71Sopenharmony_ci    } else {
1398e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
1399e41f4b71Sopenharmony_ci    }
1400e41f4b71Sopenharmony_ci  })
1401e41f4b71Sopenharmony_ci} catch (err) {
1402e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
1403e41f4b71Sopenharmony_ci}
1404e41f4b71Sopenharmony_ci
1405e41f4b71Sopenharmony_citry {
1406e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{
1407e41f4b71Sopenharmony_ci    dlpFile.closeDLPFile(); // Close the DLPFile instance.
1408e41f4b71Sopenharmony_ci  }); // Open a DLP file.
1409e41f4b71Sopenharmony_ci} catch (err) {
1410e41f4b71Sopenharmony_ci  console.error('error', (err as BusinessError).code, (err as BusinessError).message); // Error reported if the operation fails.
1411e41f4b71Sopenharmony_ci}
1412e41f4b71Sopenharmony_cifileIo.closeSync(file);
1413e41f4b71Sopenharmony_ci```
1414e41f4b71Sopenharmony_ci
1415e41f4b71Sopenharmony_ci### closeDLPFile
1416e41f4b71Sopenharmony_ci
1417e41f4b71Sopenharmony_cicloseDLPFile(callback: AsyncCallback&lt;void&gt;): void
1418e41f4b71Sopenharmony_ci
1419e41f4b71Sopenharmony_ciCloses this **DLPFile** instance. This API uses an asynchronous callback to return the result.
1420e41f4b71Sopenharmony_ci
1421e41f4b71Sopenharmony_ci**System API**: This is a system API.
1422e41f4b71Sopenharmony_ci
1423e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
1424e41f4b71Sopenharmony_ci
1425e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1426e41f4b71Sopenharmony_ci
1427e41f4b71Sopenharmony_ci> **NOTE**
1428e41f4b71Sopenharmony_ci>
1429e41f4b71Sopenharmony_ci> If a DLP file is no longer used, close the **dlpFile** instance to release the memory.
1430e41f4b71Sopenharmony_ci
1431e41f4b71Sopenharmony_ci**Parameters**
1432e41f4b71Sopenharmony_ci
1433e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
1434e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1435e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
1436e41f4b71Sopenharmony_ci
1437e41f4b71Sopenharmony_ci**Error codes**
1438e41f4b71Sopenharmony_ci
1439e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
1440e41f4b71Sopenharmony_ci
1441e41f4b71Sopenharmony_ci| ID | Error Message |
1442e41f4b71Sopenharmony_ci| -------- | -------- |
1443e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1444e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
1445e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Incorrect parameter types. |
1446e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
1447e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
1448e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
1449e41f4b71Sopenharmony_ci
1450e41f4b71Sopenharmony_ci**Example**
1451e41f4b71Sopenharmony_ci
1452e41f4b71Sopenharmony_ci```ts
1453e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
1454e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
1455e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
1456e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1457e41f4b71Sopenharmony_ci
1458e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
1459e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
1460e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
1461e41f4b71Sopenharmony_cilet appId = "";
1462e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
1463e41f4b71Sopenharmony_cilet userId = 100;
1464e41f4b71Sopenharmony_ci
1465e41f4b71Sopenharmony_citry{
1466e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
1467e41f4b71Sopenharmony_ci    if (err) {
1468e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
1469e41f4b71Sopenharmony_ci    } else {
1470e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
1471e41f4b71Sopenharmony_ci    }
1472e41f4b71Sopenharmony_ci  })
1473e41f4b71Sopenharmony_ci} catch (err) {
1474e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
1475e41f4b71Sopenharmony_ci}
1476e41f4b71Sopenharmony_ci
1477e41f4b71Sopenharmony_citry {
1478e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{
1479e41f4b71Sopenharmony_ci    dlpFile.closeDLPFile((err, res) => {// Close the DLP file.
1480e41f4b71Sopenharmony_ci      if (err != undefined) {
1481e41f4b71Sopenharmony_ci        console.error('closeDLPFile error,', err.code, err.message);
1482e41f4b71Sopenharmony_ci      } else {
1483e41f4b71Sopenharmony_ci        console.info('res', JSON.stringify(res));
1484e41f4b71Sopenharmony_ci      }
1485e41f4b71Sopenharmony_ci      fileIo.closeSync(file);
1486e41f4b71Sopenharmony_ci    });
1487e41f4b71Sopenharmony_ci  }); // Open a DLP file.
1488e41f4b71Sopenharmony_ci} catch (err) {
1489e41f4b71Sopenharmony_ci  console.error('error,', (err as BusinessError).code, (err as BusinessError).message);
1490e41f4b71Sopenharmony_ci  fileIo.closeSync(file);
1491e41f4b71Sopenharmony_ci}
1492e41f4b71Sopenharmony_ci```
1493e41f4b71Sopenharmony_ci
1494e41f4b71Sopenharmony_ci## dlpPermission.generateDLPFile
1495e41f4b71Sopenharmony_ci
1496e41f4b71Sopenharmony_cigenerateDLPFile(plaintextFd: number, ciphertextFd: number, property: DLPProperty): Promise&lt;DLPFile&gt;
1497e41f4b71Sopenharmony_ci
1498e41f4b71Sopenharmony_ciGenerates a DLP file, which is an encrypted file that can be accessed only by authorized users. The users can have the full control permission or read-only permission on the DLP file. This API uses a promise to return the result.
1499e41f4b71Sopenharmony_ci
1500e41f4b71Sopenharmony_ci**System API**: This is a system API.
1501e41f4b71Sopenharmony_ci
1502e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
1503e41f4b71Sopenharmony_ci
1504e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1505e41f4b71Sopenharmony_ci
1506e41f4b71Sopenharmony_ci**Parameters**
1507e41f4b71Sopenharmony_ci
1508e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
1509e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1510e41f4b71Sopenharmony_ci| plaintextFd | number | Yes | FD of the plaintext file to be encrypted. |
1511e41f4b71Sopenharmony_ci| ciphertextFd | number | Yes | FD of the encrypted file. |
1512e41f4b71Sopenharmony_ci| property | [DLPProperty](#dlpproperty) | Yes | Authorization information, which includes the authorized user list, owner account, and contact account information. |
1513e41f4b71Sopenharmony_ci
1514e41f4b71Sopenharmony_ci**Return value**
1515e41f4b71Sopenharmony_ci
1516e41f4b71Sopenharmony_ci| Type | Description |
1517e41f4b71Sopenharmony_ci| -------- | -------- |
1518e41f4b71Sopenharmony_ci| Promise&lt;[DLPFile](#dlpfile)&gt; | Promise used to return the result. If the operation is successful, a **DLPFile** instance is returned. Otherwise, **null** is returned. |
1519e41f4b71Sopenharmony_ci
1520e41f4b71Sopenharmony_ci**Error codes**
1521e41f4b71Sopenharmony_ci
1522e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
1523e41f4b71Sopenharmony_ci
1524e41f4b71Sopenharmony_ci| ID | Error Message |
1525e41f4b71Sopenharmony_ci| -------- | -------- |
1526e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1527e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
1528e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1529e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
1530e41f4b71Sopenharmony_ci| 19100002 | Credential task error. |
1531e41f4b71Sopenharmony_ci| 19100003 | Credential task time out. |
1532e41f4b71Sopenharmony_ci| 19100004 | Credential service error. |
1533e41f4b71Sopenharmony_ci| 19100005 | Credential authentication server error. |
1534e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
1535e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
1536e41f4b71Sopenharmony_ci
1537e41f4b71Sopenharmony_ci**Example**
1538e41f4b71Sopenharmony_ci
1539e41f4b71Sopenharmony_ci```ts
1540e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
1541e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
1542e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1543e41f4b71Sopenharmony_ci
1544e41f4b71Sopenharmony_cilet dlpUri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
1545e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt";
1546e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
1547e41f4b71Sopenharmony_cilet dlp = fileIo.openSync(dlpUri);
1548e41f4b71Sopenharmony_citry {
1549e41f4b71Sopenharmony_ci  let dlpProperty: dlpPermission.DLPProperty = {
1550e41f4b71Sopenharmony_ci    ownerAccount: 'zhangsan',
1551e41f4b71Sopenharmony_ci    ownerAccountType: dlpPermission.AccountType.DOMAIN_ACCOUNT,
1552e41f4b71Sopenharmony_ci    authUserList: [],
1553e41f4b71Sopenharmony_ci    contactAccount: 'zhangsan',
1554e41f4b71Sopenharmony_ci    offlineAccess: true,
1555e41f4b71Sopenharmony_ci    ownerAccountID: 'xxxxxxx',
1556e41f4b71Sopenharmony_ci    everyoneAccessList: []
1557e41f4b71Sopenharmony_ci  };
1558e41f4b71Sopenharmony_ci  dlpPermission.generateDLPFile(file.fd, dlp.fd, dlpProperty).then((dlpFile)=>{
1559e41f4b71Sopenharmony_ci    dlpFile.closeDLPFile(); // Close the DLPFile instance.
1560e41f4b71Sopenharmony_ci  }); // Generate a DLP file.
1561e41f4b71Sopenharmony_ci} catch (err) {
1562e41f4b71Sopenharmony_ci  console.error('error', (err as BusinessError).code, (err as BusinessError).message); // Error reported if the operation fails.
1563e41f4b71Sopenharmony_ci}
1564e41f4b71Sopenharmony_cifileIo.closeSync(file);
1565e41f4b71Sopenharmony_cifileIo.closeSync(dlp);
1566e41f4b71Sopenharmony_ci```
1567e41f4b71Sopenharmony_ci
1568e41f4b71Sopenharmony_ci## dlpPermission.generateDLPFile
1569e41f4b71Sopenharmony_ci
1570e41f4b71Sopenharmony_cigenerateDLPFile(plaintextFd: number, ciphertextFd: number, property: DLPProperty, callback: AsyncCallback&lt;DLPFile&gt;): void
1571e41f4b71Sopenharmony_ci
1572e41f4b71Sopenharmony_ciGenerates a DLP file, which is an encrypted file that can be accessed only by authorized users. The users can have the full control permission or read-only permission on the DLP file. This API uses an asynchronous callback to return the result.
1573e41f4b71Sopenharmony_ci
1574e41f4b71Sopenharmony_ci**System API**: This is a system API.
1575e41f4b71Sopenharmony_ci
1576e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
1577e41f4b71Sopenharmony_ci
1578e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1579e41f4b71Sopenharmony_ci
1580e41f4b71Sopenharmony_ci**Parameters**
1581e41f4b71Sopenharmony_ci
1582e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
1583e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1584e41f4b71Sopenharmony_ci| plaintextFd | number | Yes | FD of the plaintext file to be encrypted. |
1585e41f4b71Sopenharmony_ci| ciphertextFd | number | Yes | FD of the encrypted file. |
1586e41f4b71Sopenharmony_ci| property | [DLPProperty](#dlpproperty) | Yes | Authorization information, which includes the authorized user list, owner account, and contact account information. |
1587e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;[DLPFile](#dlpfile)&gt; | Yes | Callback invoked to return the **DLPFile** instance created. |
1588e41f4b71Sopenharmony_ci
1589e41f4b71Sopenharmony_ci**Error codes**
1590e41f4b71Sopenharmony_ci
1591e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
1592e41f4b71Sopenharmony_ci
1593e41f4b71Sopenharmony_ci| ID | Error Message |
1594e41f4b71Sopenharmony_ci| -------- | -------- |
1595e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1596e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
1597e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1598e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
1599e41f4b71Sopenharmony_ci| 19100002 | Credential task error. |
1600e41f4b71Sopenharmony_ci| 19100003 | Credential task time out. |
1601e41f4b71Sopenharmony_ci| 19100004 | Credential service error. |
1602e41f4b71Sopenharmony_ci| 19100005 | Credential authentication server error. |
1603e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
1604e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
1605e41f4b71Sopenharmony_ci
1606e41f4b71Sopenharmony_ci**Example**
1607e41f4b71Sopenharmony_ci
1608e41f4b71Sopenharmony_ci```ts
1609e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
1610e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
1611e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1612e41f4b71Sopenharmony_ci
1613e41f4b71Sopenharmony_cilet dlpUri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
1614e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt";
1615e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
1616e41f4b71Sopenharmony_cilet dlp = fileIo.openSync(dlpUri);
1617e41f4b71Sopenharmony_citry {
1618e41f4b71Sopenharmony_ci  let dlpProperty: dlpPermission.DLPProperty = {
1619e41f4b71Sopenharmony_ci    ownerAccount: 'zhangsan',
1620e41f4b71Sopenharmony_ci    ownerAccountType: dlpPermission.AccountType.DOMAIN_ACCOUNT,
1621e41f4b71Sopenharmony_ci    authUserList: [],
1622e41f4b71Sopenharmony_ci    contactAccount: 'zhangsan',
1623e41f4b71Sopenharmony_ci    offlineAccess: true,
1624e41f4b71Sopenharmony_ci    ownerAccountID: 'xxxxxxx',
1625e41f4b71Sopenharmony_ci    everyoneAccessList: []
1626e41f4b71Sopenharmony_ci  };
1627e41f4b71Sopenharmony_ci  dlpPermission.generateDLPFile(file.fd, dlp.fd, dlpProperty, (err, res) => { // Generate a DLP file.
1628e41f4b71Sopenharmony_ci    if (err != undefined) {
1629e41f4b71Sopenharmony_ci      console.error('generateDLPFile error,', err.code, err.message);
1630e41f4b71Sopenharmony_ci    } else {
1631e41f4b71Sopenharmony_ci      console.info('res', JSON.stringify(res));
1632e41f4b71Sopenharmony_ci    }
1633e41f4b71Sopenharmony_ci  });
1634e41f4b71Sopenharmony_ci} catch (err) {
1635e41f4b71Sopenharmony_ci  console.error('error,', (err as BusinessError).code, (err as BusinessError).message);
1636e41f4b71Sopenharmony_ci  fileIo.closeSync(file);
1637e41f4b71Sopenharmony_ci}
1638e41f4b71Sopenharmony_ci```
1639e41f4b71Sopenharmony_ci
1640e41f4b71Sopenharmony_ci## dlpPermission.openDLPFile<sup>11+</sup>
1641e41f4b71Sopenharmony_ci
1642e41f4b71Sopenharmony_ciopenDLPFile(ciphertextFd: number, appId: string): Promise&lt;DLPFile&gt;
1643e41f4b71Sopenharmony_ci
1644e41f4b71Sopenharmony_ciOpens a DLP file. This API uses a promise to return the result.
1645e41f4b71Sopenharmony_ci
1646e41f4b71Sopenharmony_ci**System API**: This is a system API.
1647e41f4b71Sopenharmony_ci
1648e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
1649e41f4b71Sopenharmony_ci
1650e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1651e41f4b71Sopenharmony_ci
1652e41f4b71Sopenharmony_ci**Parameters**
1653e41f4b71Sopenharmony_ci
1654e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
1655e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1656e41f4b71Sopenharmony_ci| ciphertextFd | number | Yes | FD of the encrypted file. |
1657e41f4b71Sopenharmony_ci| appId | string | Yes | ID of the caller. |
1658e41f4b71Sopenharmony_ci
1659e41f4b71Sopenharmony_ci**Return value**
1660e41f4b71Sopenharmony_ci
1661e41f4b71Sopenharmony_ci| Type | Description |
1662e41f4b71Sopenharmony_ci| -------- | -------- |
1663e41f4b71Sopenharmony_ci| Promise&lt;[DLPFile](#dlpfile)&gt; | Promise used to return the result. If the operation is successful, a **DLPFile** instance is returned. Otherwise, **null** is returned. |
1664e41f4b71Sopenharmony_ci
1665e41f4b71Sopenharmony_ci**Error codes**
1666e41f4b71Sopenharmony_ci
1667e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
1668e41f4b71Sopenharmony_ci
1669e41f4b71Sopenharmony_ci| ID | Error Message |
1670e41f4b71Sopenharmony_ci| -------- | -------- |
1671e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1672e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
1673e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1674e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
1675e41f4b71Sopenharmony_ci| 19100002 | Credential task error. |
1676e41f4b71Sopenharmony_ci| 19100003 | Credential task time out. |
1677e41f4b71Sopenharmony_ci| 19100004 | Credential service error. |
1678e41f4b71Sopenharmony_ci| 19100005 | Credential authentication server error. |
1679e41f4b71Sopenharmony_ci| 19100008 | The file is not a DLP file. |
1680e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
1681e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
1682e41f4b71Sopenharmony_ci| 19100018 | Not authorized application. |
1683e41f4b71Sopenharmony_ci| 19100019 | The DLP file has expired. |
1684e41f4b71Sopenharmony_ci| 19100020 | No network connection. |
1685e41f4b71Sopenharmony_ci
1686e41f4b71Sopenharmony_ci**Example**
1687e41f4b71Sopenharmony_ci
1688e41f4b71Sopenharmony_ci```ts
1689e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
1690e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
1691e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
1692e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1693e41f4b71Sopenharmony_ci
1694e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
1695e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
1696e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
1697e41f4b71Sopenharmony_cilet appId = "";
1698e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
1699e41f4b71Sopenharmony_cilet userId = 100;
1700e41f4b71Sopenharmony_ci
1701e41f4b71Sopenharmony_citry{
1702e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
1703e41f4b71Sopenharmony_ci    if (err) {
1704e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
1705e41f4b71Sopenharmony_ci    } else {
1706e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
1707e41f4b71Sopenharmony_ci    }
1708e41f4b71Sopenharmony_ci  })
1709e41f4b71Sopenharmony_ci} catch (err) {
1710e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
1711e41f4b71Sopenharmony_ci}
1712e41f4b71Sopenharmony_ci
1713e41f4b71Sopenharmony_citry {
1714e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{
1715e41f4b71Sopenharmony_ci    dlpFile.closeDLPFile(); // Close the DLPFile instance.
1716e41f4b71Sopenharmony_ci  }); // Open a DLP file.
1717e41f4b71Sopenharmony_ci} catch (err) {
1718e41f4b71Sopenharmony_ci  console.error('error', (err as BusinessError).code, (err as BusinessError).message); // Error reported if the operation fails.
1719e41f4b71Sopenharmony_ci}
1720e41f4b71Sopenharmony_cifileIo.closeSync(file);
1721e41f4b71Sopenharmony_ci```
1722e41f4b71Sopenharmony_ci
1723e41f4b71Sopenharmony_ci## dlpPermission.openDLPFile<sup>11+</sup>
1724e41f4b71Sopenharmony_ci
1725e41f4b71Sopenharmony_ciopenDLPFile(ciphertextFd: number, appId: string, callback: AsyncCallback&lt;DLPFile&gt;): void
1726e41f4b71Sopenharmony_ci
1727e41f4b71Sopenharmony_ciOpens a DLP file. This API uses an asynchronous callback to return the result.
1728e41f4b71Sopenharmony_ci
1729e41f4b71Sopenharmony_ci**System API**: This is a system API.
1730e41f4b71Sopenharmony_ci
1731e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_DLP_FILE
1732e41f4b71Sopenharmony_ci
1733e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1734e41f4b71Sopenharmony_ci
1735e41f4b71Sopenharmony_ci**Parameters**
1736e41f4b71Sopenharmony_ci
1737e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
1738e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1739e41f4b71Sopenharmony_ci| ciphertextFd | number | Yes | FD of the encrypted file. |
1740e41f4b71Sopenharmony_ci| appId | string | Yes | ID of the caller. |
1741e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;[DLPFile](#dlpfile)&gt; | Yes| Callback invoked to return the **DLPFile** instance opened.|
1742e41f4b71Sopenharmony_ci
1743e41f4b71Sopenharmony_ci**Error codes**
1744e41f4b71Sopenharmony_ci
1745e41f4b71Sopenharmony_ciFor details about the error codes, see [DLP Service Error Codes](errorcode-dlp.md).
1746e41f4b71Sopenharmony_ci
1747e41f4b71Sopenharmony_ci| ID | Error Message |
1748e41f4b71Sopenharmony_ci| -------- | -------- |
1749e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1750e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. |
1751e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1752e41f4b71Sopenharmony_ci| 19100001 | Invalid parameter value. |
1753e41f4b71Sopenharmony_ci| 19100002 | Credential task error. |
1754e41f4b71Sopenharmony_ci| 19100003 | Credential task time out. |
1755e41f4b71Sopenharmony_ci| 19100004 | Credential service error. |
1756e41f4b71Sopenharmony_ci| 19100005 | Credential authentication server error. |
1757e41f4b71Sopenharmony_ci| 19100008 | The file is not a DLP file. |
1758e41f4b71Sopenharmony_ci| 19100009 | Failed to operate the DLP file. |
1759e41f4b71Sopenharmony_ci| 19100011 | The system ability works abnormally. |
1760e41f4b71Sopenharmony_ci| 19100018 | Not authorized application. |
1761e41f4b71Sopenharmony_ci| 19100019 | The DLP file has expired. |
1762e41f4b71Sopenharmony_ci| 19100020 | No network connection. |
1763e41f4b71Sopenharmony_ci
1764e41f4b71Sopenharmony_ci**Example**
1765e41f4b71Sopenharmony_ci
1766e41f4b71Sopenharmony_ci```ts
1767e41f4b71Sopenharmony_ciimport { dlpPermission } from '@kit.DataProtectionKit';
1768e41f4b71Sopenharmony_ciimport { fileIo } from '@kit.CoreFileKit';
1769e41f4b71Sopenharmony_ciimport { bundleManager } from '@kit.AbilityKit';
1770e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1771e41f4b71Sopenharmony_ci
1772e41f4b71Sopenharmony_cilet uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp";
1773e41f4b71Sopenharmony_cilet file = fileIo.openSync(uri);
1774e41f4b71Sopenharmony_cilet bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
1775e41f4b71Sopenharmony_cilet appId = "";
1776e41f4b71Sopenharmony_cilet bundleName = 'com.ohos.note';
1777e41f4b71Sopenharmony_cilet userId = 100;
1778e41f4b71Sopenharmony_ci
1779e41f4b71Sopenharmony_citry{
1780e41f4b71Sopenharmony_ci  bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => {
1781e41f4b71Sopenharmony_ci    if (err) {
1782e41f4b71Sopenharmony_ci      console.error('error', err.code, err.message);
1783e41f4b71Sopenharmony_ci    } else {
1784e41f4b71Sopenharmony_ci      appId = data.signatureInfo.appId;
1785e41f4b71Sopenharmony_ci    }
1786e41f4b71Sopenharmony_ci  })
1787e41f4b71Sopenharmony_ci} catch (err) {
1788e41f4b71Sopenharmony_ci  console.error('error', err.code, err.message);
1789e41f4b71Sopenharmony_ci}
1790e41f4b71Sopenharmony_ci
1791e41f4b71Sopenharmony_citry {
1792e41f4b71Sopenharmony_ci  dlpPermission.openDLPFile(file.fd, appId, (err, res) => { // Open a DLP file.
1793e41f4b71Sopenharmony_ci    if (err != undefined) {
1794e41f4b71Sopenharmony_ci      console.error('openDLPFile error,', err.code, err.message);
1795e41f4b71Sopenharmony_ci    } else {
1796e41f4b71Sopenharmony_ci      console.info('res', JSON.stringify(res));
1797e41f4b71Sopenharmony_ci    }
1798e41f4b71Sopenharmony_ci  });
1799e41f4b71Sopenharmony_ci} catch (err) {
1800e41f4b71Sopenharmony_ci  console.error('error,', (err as BusinessError).code, (err as BusinessError).message);
1801e41f4b71Sopenharmony_ci  fileIo.closeSync(file);
1802e41f4b71Sopenharmony_ci}
1803e41f4b71Sopenharmony_ci```
1804e41f4b71Sopenharmony_ci
1805e41f4b71Sopenharmony_ci## DLPSandboxInfo
1806e41f4b71Sopenharmony_ci
1807e41f4b71Sopenharmony_ciRepresents the DLP sandbox information.
1808e41f4b71Sopenharmony_ci
1809e41f4b71Sopenharmony_ci**System API**: This is a system API.
1810e41f4b71Sopenharmony_ci
1811e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1812e41f4b71Sopenharmony_ci
1813e41f4b71Sopenharmony_ci| Name | Type | Readable | Writable | Description |
1814e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
1815e41f4b71Sopenharmony_ci| appIndex | number | Yes | No | Index of the DLP sandbox application. |
1816e41f4b71Sopenharmony_ci| tokenID | number | Yes | No | Token ID of the DLP sandbox application. |
1817e41f4b71Sopenharmony_ci
1818e41f4b71Sopenharmony_ci## DLPSandboxState
1819e41f4b71Sopenharmony_ci
1820e41f4b71Sopenharmony_ciRepresents the DLP sandbox identity information.
1821e41f4b71Sopenharmony_ci
1822e41f4b71Sopenharmony_ci**System API**: This is a system API.
1823e41f4b71Sopenharmony_ci
1824e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1825e41f4b71Sopenharmony_ci
1826e41f4b71Sopenharmony_ci| Name | Type | Readable | Writable | Description |
1827e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
1828e41f4b71Sopenharmony_ci| bundleName | string | Yes | No | Bundle name of the application. |
1829e41f4b71Sopenharmony_ci| appIndex | number | Yes | No | Index of the DLP sandbox application. |
1830e41f4b71Sopenharmony_ci
1831e41f4b71Sopenharmony_ci## AccountType
1832e41f4b71Sopenharmony_ci
1833e41f4b71Sopenharmony_ciEnumerates the types of authorized accounts.
1834e41f4b71Sopenharmony_ci
1835e41f4b71Sopenharmony_ci**System API**: This is a system API.
1836e41f4b71Sopenharmony_ci
1837e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1838e41f4b71Sopenharmony_ci
1839e41f4b71Sopenharmony_ci| Name | Value | Description |
1840e41f4b71Sopenharmony_ci| -------- | -------- | -------- |
1841e41f4b71Sopenharmony_ci| CLOUD_ACCOUNT | 1 | Cloud account. |
1842e41f4b71Sopenharmony_ci| DOMAIN_ACCOUNT | 2 | Domain account. |
1843e41f4b71Sopenharmony_ci
1844e41f4b71Sopenharmony_ci## AuthUser
1845e41f4b71Sopenharmony_ci
1846e41f4b71Sopenharmony_ciRepresents the user authorization information.
1847e41f4b71Sopenharmony_ci
1848e41f4b71Sopenharmony_ci**System API**: This is a system API.
1849e41f4b71Sopenharmony_ci
1850e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1851e41f4b71Sopenharmony_ci
1852e41f4b71Sopenharmony_ci| Name | Type | Read Only | Mandatory | Description |
1853e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
1854e41f4b71Sopenharmony_ci| authAccount | string | No | Yes | Account of the user who can access the DLP file. |
1855e41f4b71Sopenharmony_ci| authAccountType | [AccountType](#accounttype) | No | Yes | Type of the account. |
1856e41f4b71Sopenharmony_ci| dlpFileAccess | [DLPFileAccess](js-apis-dlppermission.md#dlpfileaccess) | No | Yes | Permission granted to the user. |
1857e41f4b71Sopenharmony_ci| permExpiryTime | number | No | Yes | Time when the authorization expires. |
1858e41f4b71Sopenharmony_ci
1859e41f4b71Sopenharmony_ci## DLPProperty
1860e41f4b71Sopenharmony_ci
1861e41f4b71Sopenharmony_ciRepresents the authorization information.
1862e41f4b71Sopenharmony_ci
1863e41f4b71Sopenharmony_ci**System API**: This is a system API.
1864e41f4b71Sopenharmony_ci
1865e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1866e41f4b71Sopenharmony_ci
1867e41f4b71Sopenharmony_ci| Name | Type | Read Only | Mandatory | Description |
1868e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
1869e41f4b71Sopenharmony_ci| ownerAccount | string | No | Yes | Account of the owner who can set the permission. |
1870e41f4b71Sopenharmony_ci| ownerAccountID | string | No | Yes | Account ID of the owner. |
1871e41f4b71Sopenharmony_ci| ownerAccountType | [AccountType](#accounttype) | No | Yes | Account type of the owner. |
1872e41f4b71Sopenharmony_ci| authUserList | Array&lt;[AuthUser](#authuser)&gt; | No | No | List of users who are authorized to access the DLP file. By default, this parameter is left blank. |
1873e41f4b71Sopenharmony_ci| contactAccount | string | No| Yes| Account of the contact.|
1874e41f4b71Sopenharmony_ci| offlineAccess | boolean | No | Yes | Whether the file can be accessed offline. |
1875e41f4b71Sopenharmony_ci| everyoneAccessList | Array&lt;[DLPFileAccess](js-apis-dlppermission.md#dlpfileaccess)&gt; | No | No | Permission granted to everyone. This parameter is left blank by default. |
1876e41f4b71Sopenharmony_ci| expireTime<sup>11+</sup> | number | No | No | Timestamp when the file permission has expired. This parameter is left blank by default. |
1877e41f4b71Sopenharmony_ci
1878e41f4b71Sopenharmony_ci## GatheringPolicyType
1879e41f4b71Sopenharmony_ci
1880e41f4b71Sopenharmony_ciEnumerates the DLP sandbox gathering policy types. **GATHERING** allows the DLP files of the same permission type to be opened in a sandbox. For example, open different tab pages in a sandbox. **NON_GATHERING** allows different DLP files to be opened in different sandboxes.
1881e41f4b71Sopenharmony_ci
1882e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.DataLossPrevention
1883e41f4b71Sopenharmony_ci
1884e41f4b71Sopenharmony_ci**System API**: This is a system API.
1885e41f4b71Sopenharmony_ci
1886e41f4b71Sopenharmony_ci**Parameters**
1887e41f4b71Sopenharmony_ci
1888e41f4b71Sopenharmony_ci| Name | Value | Description |
1889e41f4b71Sopenharmony_ci| -------- | -------- | -------- |
1890e41f4b71Sopenharmony_ci| GATHERING | 1 | Allows the DLP files of the same permission type to be opened in a sandbox. For example, the files of the same permission type can be opened in tab pages of a window. |
1891e41f4b71Sopenharmony_ci| NON_GATHERING | 2 | Allows the DLP files of different permission types to be opened in different sandboxes. |
1892