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