# @ohos.dlpPermission (æ•°æ®é˜²æ³„æ¼)(系统接å£) æ•°æ®é˜²æ³„æ¼ï¼ˆDLP)是系统æä¾›çš„系统级的数æ®é˜²æ³„æ¼è§£å†³æ–¹æ¡ˆï¼Œæä¾›è·¨è®¾å¤‡çš„æ–‡ä»¶çš„æƒé™ç®¡ç†ã€åР坆å˜å‚¨ã€æŽˆæƒè®¿é—®ç‰èƒ½åŠ›ã€‚ > **说明:** > > - 本模å—首批接å£ä»ŽAPI version 10开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„æ–°å¢žæŽ¥å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 > - 当å‰é¡µé¢ä»…åŒ…å«æœ¬æ¨¡å—的系统接å£ï¼Œå…¶ä»–公开接å£å‚è§[@ohos.dlpPermission (æ•°æ®é˜²æ³„æ¼)](js-apis-dlppermission.md)。 ## å¯¼å…¥æ¨¡å— ```ts import { dlpPermission } from '@kit.DataProtectionKit'; ``` ## dlpPermission.getDLPGatheringPolicy getDLPGatheringPolicy(): Promise<GatheringPolicyType> 查询DLP沙箱èšåˆç–略。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<[GatheringPolicyType](#gatheringpolicytype)> | Promise对象。返回当å‰DLP沙箱èšåˆç–略。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 19100001 | Invalid parameter value. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { BusinessError } from '@kit.BasicServicesKit'; try { let res: Promise<dlpPermission.GatheringPolicyType> = dlpPermission.getDLPGatheringPolicy(); // èŽ·å–æ²™ç®±èšåˆç–ç•¥ console.info('res', JSON.stringify(res)); } catch (err) { console.error('error', (err as BusinessError).code, (err as BusinessError).message); // 失败报错 } ``` ## dlpPermission.getDLPGatheringPolicy getDLPGatheringPolicy(callback: AsyncCallback<GatheringPolicyType>): void 查询DLP沙箱èšåˆç–略。使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<[GatheringPolicyType](#gatheringpolicytype)> | 是 | 回调函数。err为undefine时表示查询æˆåŠŸï¼›å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { BusinessError } from '@kit.BasicServicesKit'; try { dlpPermission.getDLPGatheringPolicy((err, res) => { if (err != undefined) { console.error('getDLPGatheringPolicy error,', err.code, err.message); } else { console.info('res', JSON.stringify(res)); } }); // èŽ·å–æ²™ç®±èšåˆç–ç•¥ } catch (err) { console.error('getDLPGatheringPolicy error,', (err as BusinessError).code, (err as BusinessError).message); } ``` ## dlpPermission.installDLPSandbox installDLPSandbox(bundleName: string, access: DLPFileAccess, userId: number, uri: string): Promise<DLPSandboxInfo> 安装一个应用的DLP沙箱。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果返回应用沙箱信æ¯ã€‚ **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | bundleName | string | 是 | 应用包å。 | | access | [DLPFileAccess](js-apis-dlppermission.md#dlpfileaccess) | 是 | DLP文件授æƒç±»åž‹ã€‚ | | userId | number | 是 | 当å‰çš„用户ID,通过账å·å系统获å–çš„OSè´¦å·ID,默认主用户ID:100。 | | uri | string | 是 | DLP文件的URI。 | **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<[DLPSandboxInfo](#dlpsandboxinfo)> | Promise对象。安装沙箱应用,返回应用沙箱信æ¯ã€‚ | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; try { let res: Promise<dlpPermission.DLPSandboxInfo> = dlpPermission.installDLPSandbox('com.ohos.note', dlpPermission.DLPFileAccess.READ_ONLY, 100, uri); // 安装DLP沙箱 console.info('res', JSON.stringify(res)); } catch (err) { console.error('error', (err as BusinessError).code, (err as BusinessError).message); // 失败报错 } ``` ## dlpPermission.installDLPSandbox installDLPSandbox(bundleName: string, access: DLPFileAccess, userId: number, uri:string, callback: AsyncCallback<DLPSandboxInfo>): void 安装一个应用的DLP沙箱。使用callbackæ–¹å¼å¼‚æ¥è¿”回应用沙箱信æ¯ã€‚ **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | bundleName | string | 是 | 应用包å。 | | access | [DLPFileAccess](js-apis-dlppermission.md#dlpfileaccess) | 是 | DLP文件授æƒç±»åž‹ã€‚ | | userId | number | 是 | 当å‰çš„用户ID,通过账å·å系统获å–的系账å·ID,默认主用户ID:100。 | | uri | string | 是 | DLP文件的URI。 | | callback | AsyncCallback<[DLPSandboxInfo](#dlpsandboxinfo)> | 是 | 获å–应用沙箱信æ¯çš„回调。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; try { dlpPermission.installDLPSandbox('com.ohos.note', dlpPermission.DLPFileAccess.READ_ONLY, 100, uri, (err, res) => { if (err != undefined) { console.error('installDLPSandbox error,', err.code, err.message); } else { console.info('res', JSON.stringify(res)); } }); // 安装DLP沙箱 } catch (err) { console.error('installDLPSandbox error,', (err as BusinessError).code, (err as BusinessError).message); } ``` ## dlpPermission.uninstallDLPSandbox uninstallDLPSandbox(bundleName: string, userId: number, appIndex: number): Promise<void> å¸è½½ä¸€ä¸ªåº”用的DLP沙箱。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | bundleName | string | 是 | 应用包å。 | | userId | number | 是 | 当å‰çš„用户ID,通过账å·å系统获å–的系统账å·ID,默认主用户ID:100 | | appIndex | number | 是 | DLP沙箱å·ã€‚ | **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; try { dlpPermission.installDLPSandbox('com.ohos.note', dlpPermission.DLPFileAccess.READ_ONLY, 100, uri).then((res)=>{ console.info('res', JSON.stringify(res)); dlpPermission.uninstallDLPSandbox('com.ohos.note', 100, res.appIndex); // å¸è½½DLP沙箱 }); // 安装DLP沙箱 } catch (err) { console.error('error', (err as BusinessError).code, (err as BusinessError).message); // 失败报错 } ``` ## dlpPermission.uninstallDLPSandbox uninstallDLPSandbox(bundleName: string, userId: number, appIndex: number, callback: AsyncCallback<void>): void å¸è½½ä¸€ä¸ªåº”用的DLP沙箱。使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | bundleName | string | 是 | 应用包å。 | | userId | number | 是 | 当å‰çš„用户ID,通过账å·å系统获å–的系统账å·ID,默认主用户ID:100。 | | appIndex | number | 是 | DLP沙箱å·ï¼Œå³installDLPSandbox接å£è°ƒç”¨æˆåŠŸåŽçš„返回值。 | | callback | AsyncCallback<void> | 是 | 获å–å¸è½½ç»“果的回调。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; try { dlpPermission.installDLPSandbox('com.ohos.note', dlpPermission.DLPFileAccess.READ_ONLY, 100, uri).then((res)=>{ console.info('res', JSON.stringify(res)); dlpPermission.uninstallDLPSandbox('com.ohos.note', 100, res.appIndex, (err, res) => { if (err != undefined) { console.error('uninstallDLPSandbox error,', err.code, err.message); } else { console.info('res', JSON.stringify(res)); } }); }); // 安装DLP沙箱 } catch (err) { console.error('uninstallDLPSandbox error,', (err as BusinessError).code, (err as BusinessError).message); } ``` ## dlpPermission.on('uninstallDLPSandbox') on(type: 'uninstallDLPSandbox', listener: Callback<DLPSandboxState>): void 注册监å¬DLP沙箱å¸è½½äº‹ä»¶ã€‚ **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | 'uninstallDLPSandbox' | 是 | 监å¬äº‹ä»¶ç±»åž‹ã€‚固定值为'uninstallDLPSandbox':DLP沙箱å¸è½½äº‹ä»¶ | | listener | Callback<[DLPSandboxState](#dlpsandboxstate)> | 是 | 沙箱应用å¸è½½äº‹ä»¶çš„回调。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed. | | 19100001 | Invalid parameter value. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { BusinessError } from '@kit.BasicServicesKit'; try { dlpPermission.on('uninstallDLPSandbox', (info: dlpPermission.DLPSandboxState) => { console.info('uninstallDLPSandbox event', info.appIndex, info.bundleName) }); // 订阅 } catch (err) { console.error('error', (err as BusinessError).code, (err as BusinessError).message); // 失败报错 } ``` ## dlpPermission.off('uninstallDLPSandbox') off(type: 'uninstallDLPSandbox', listener?: Callback<DLPSandboxState>): void å–æ¶ˆç›‘å¬DLP沙箱å¸è½½äº‹ä»¶ã€‚ **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | 'uninstallDLPSandbox' | 是 | 监å¬äº‹ä»¶ç±»åž‹ã€‚固定值为'uninstallDLPSandbox':DLP沙箱å¸è½½äº‹ä»¶ | | listener | Callback<[DLPSandboxState](#dlpsandboxstate)> | å¦ | 沙箱应用å¸è½½äº‹ä»¶çš„å›žè°ƒã€‚é»˜è®¤ä¸ºç©ºï¼Œè¡¨ç¤ºå–æ¶ˆè¯¥ç±»åž‹äº‹ä»¶çš„æ‰€æœ‰å›žè°ƒã€‚ | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed. | | 19100001 | Invalid parameter value. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { BusinessError } from '@kit.BasicServicesKit'; try { dlpPermission.off('uninstallDLPSandbox', (info: dlpPermission.DLPSandboxState) => { console.info('uninstallDLPSandbox event', info.appIndex, info.bundleName) }); // å–æ¶ˆè®¢é˜… } catch (err) { console.error('error', (err as BusinessError).code, (err as BusinessError).message); // 失败报错 } ``` ## DLPFile 管ç†DLPFile的实例,表示一个DLP文件对象,需è¦é€šè¿‡[generateDLPFile](#dlppermissiongeneratedlpfile)/[openDLPFile](#dlppermissionopendlpfile11)获å–DLPFile的示例。 ### 属性 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.Security.DataLossPrevention | åç§° | 类型 | åªè¯» | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | -------- | | dlpProperty | [DLPProperty](#dlpproperty) | å¦ | 是 | 表示DLP文件授æƒç›¸å…³ä¿¡æ¯ã€‚ | ### addDLPLinkFile addDLPLinkFile(linkFileName: string): Promise<void> 在FUSE文件系统(Filesystem in Userspace)æ·»åŠ link文件(FUSEæ–‡ä»¶ç³»ç»Ÿä¸æ˜ 射到密文的虚拟文件,对该文件的读写æ“ä½œä¼šåŒæ¥åˆ°DLP文件)。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | linkFileName | string | 是 | 用于fuse文件系统的link文件å。 | **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } try { dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{ dlpFile.addDLPLinkFile('test.txt.dlp.link'); // æ·»åŠ link文件 dlpFile.closeDLPFile(); //å…³é—DLP对象 }); // 打开DLP文件 } catch (err) { console.error('error', (err as BusinessError).code, (err as BusinessError).message); // 失败报错 } fileIo.closeSync(file); ``` ### addDLPLinkFile addDLPLinkFile(linkFileName: string, callback: AsyncCallback<void>): void 在FUSE䏿·»åŠ link文件,使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | linkFileName | string | 是 | 用于fuse文件系统的link文件å。 | | callback | AsyncCallback<void> | 是 | èŽ·å–æ·»åŠ ç»“æžœçš„å›žè°ƒã€‚ | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } try { dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{ dlpFile.addDLPLinkFile('test.txt.dlp.link', async (err, res) => { if (err != undefined) { console.error('addDLPLinkFile error,', err.code, err.message); await dlpFile.closeDLPFile(); //å…³é—DLP对象 } else { console.info('res', JSON.stringify(res)); } }); }); // 打开DLP文件 } catch (err) { console.error('addDLPLinkFile error,', (err as BusinessError).code, (err as BusinessError).message); } ``` ### stopFuseLink stopFuseLink(): Promise<void> åœæ¢FUSEå…³è”读写。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 19100001 | Invalid parameter value. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } try { dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{ dlpFile.addDLPLinkFile('test.txt.dlp.link'); // æ·»åŠ link文件 dlpFile.stopFuseLink(); // æš‚åœlink读写 dlpFile.closeDLPFile(); //å…³é—DLP对象 }); // 打开DLP文件 } catch (err) { console.error('error', (err as BusinessError).code, (err as BusinessError).message); // 失败报错 } fileIo.closeSync(file); ``` ### stopFuseLink stopFuseLink(callback: AsyncCallback<void>): void åœæ¢FUSEå…³è”读写,使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | 是 | 获å–åœæ¢ç»“果的回调。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } try { dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{ dlpFile.addDLPLinkFile('test.txt.dlp.link'); // æ·»åŠ link文件 dlpFile.stopFuseLink(async (err, res) => { if (err != undefined) { console.error('stopFuseLink error,', err.code, err.message); await dlpFile.closeDLPFile(); //å…³é—DLP对象 } else { console.info('res', JSON.stringify(res)); } }); }); // 打开DLP文件 } catch (err) { console.error('stopFuseLink error,', (err as BusinessError).code, (err as BusinessError).message); } ``` ### resumeFuseLink resumeFuseLink(): Promise<void> æ¢å¤FUSEå…³è”读写。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 19100001 | Invalid parameter value. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } try { dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{ dlpFile.addDLPLinkFile('test.txt.dlp.link'); // æ·»åŠ link文件 dlpFile.stopFuseLink(); // æš‚åœlink读写 dlpFile.resumeFuseLink(); // æ¢å¤link读写 dlpFile.closeDLPFile(); //å…³é—DLP对象 }); // 打开DLP文件 } catch (err) { console.error('error', (err as BusinessError).code, (err as BusinessError).message); // 失败报错 } fileIo.closeSync(file); ``` ### resumeFuseLink resumeFuseLink(callback: AsyncCallback<void>): void æ¢å¤FUSEå…³è”读写,使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | 是 | èŽ·å–æ¢å¤ç»“果的回调。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } try { dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{ dlpFile.addDLPLinkFile('test.txt.dlp.link'); // æ·»åŠ link文件 dlpFile.stopFuseLink(); // æš‚åœlink读写 dlpFile.resumeFuseLink(async (err, res) => { if (err != undefined) { console.error('resumeFuseLink error,', err.code, err.message); await dlpFile.closeDLPFile(); //å…³é—DLP对象 } else { console.info('res', JSON.stringify(res)); } }); }); // 打开DLP文件 } catch (err) { console.error('resumeFuseLink error,', (err as BusinessError).code, (err as BusinessError).message); } ``` ### replaceDLPLinkFile replaceDLPLinkFile(linkFileName: string): Promise<void> 替æ¢link文件。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | linkFileName | string | 是 | 用于fuse文件系统的link文件å。 | **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } try { dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{ dlpFile.addDLPLinkFile('test.txt.dlp.link'); // æ·»åŠ link文件 dlpFile.stopFuseLink(); // æš‚åœlink读写 dlpFile.replaceDLPLinkFile('test_new.txt.dlp.link'); // 替æ¢link文件 dlpFile.resumeFuseLink(); // æ¢å¤link读写 dlpFile.closeDLPFile(); //å…³é—DLP对象 }); // 打开DLP文件 } catch (err) { console.error('error', (err as BusinessError).code, (err as BusinessError).message); // 失败报错 } fileIo.closeSync(file); ``` ### replaceDLPLinkFile replaceDLPLinkFile(linkFileName: string, callback: AsyncCallback<void>): void 替æ¢link文件,使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | linkFileName | string | 是 | 用于fuse文件系统的link文件å。 | | callback | AsyncCallback<void> | 是 | èŽ·å–æ›¿æ¢ç»“果的回调。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } try { dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{ dlpFile.addDLPLinkFile('test.txt.dlp.link'); // æ·»åŠ link文件 dlpFile.stopFuseLink(); // æš‚åœlink读写 dlpFile.replaceDLPLinkFile('test_new.txt.dlp.link', async (err, res) => { // 替æ¢link文件 if (err != undefined) { console.error('replaceDLPLinkFile error,', err.code, err.message); await dlpFile.closeDLPFile(); //å…³é—DLP对象 } else { console.info('res', JSON.stringify(res)); await dlpFile.resumeFuseLink(); // æ¢å¤link读写 } }); }); // 打开DLP文件 } catch (err) { console.error('error,', (err as BusinessError).code, (err as BusinessError).message); } ``` ### deleteDLPLinkFile deleteDLPLinkFile(linkFileName: string): Promise<void> åˆ é™¤fuse文件系统ä¸åˆ›å»ºçš„link文件。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | linkFileName | string | 是 | 用于fuse文件系统的link文件å。 | **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } try { dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{ dlpFile.addDLPLinkFile('test.txt.dlp.link'); // æ·»åŠ link文件 dlpFile.deleteDLPLinkFile('test.txt.dlp.link'); // åˆ é™¤link文件 dlpFile.closeDLPFile(); //å…³é—DLP对象 }); // 打开DLP文件 } catch (err) { console.error('error', (err as BusinessError).code, (err as BusinessError).message); // 失败报错 } fileIo.closeSync(file); ``` ### deleteDLPLinkFile deleteDLPLinkFile(linkFileName: string, callback: AsyncCallback<void>): void åˆ é™¤link文件,使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | linkFileName | string | 是 | 用于fuse文件系统的link文件å。 | | callback | AsyncCallback<void> | 是 | 获å–åˆ é™¤ç»“æžœçš„å›žè°ƒã€‚ | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } try { dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{ dlpFile.addDLPLinkFile('test.txt.dlp.link'); // æ·»åŠ link文件 dlpFile.deleteDLPLinkFile('test.txt.dlp.link', async (err, res) => { // åˆ é™¤link文件 if (err != undefined) { console.error('deleteDLPLinkFile error,', err.code, err.message); await dlpFile.closeDLPFile(); //å…³é—DLP对象 } else { console.info('res', JSON.stringify(res)); } }); }); // 打开DLP文件 } catch (err) { console.error('error,', (err as BusinessError).code, (err as BusinessError).message); } ``` ### recoverDLPFile recoverDLPFile(plaintextFd: number): Promise<void> 移除DLP文件的æƒé™æŽ§åˆ¶ï¼Œæ¢å¤æˆæ˜Žæ–‡æ–‡ä»¶ã€‚使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | plaintextFd | number | 是 | ç›®æ ‡æ˜Žæ–‡æ–‡ä»¶çš„fd。 | **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100002 | Credential task error. | | 19100003 | Credential task time out. | | 19100004 | Credential service error. | | 19100005 | Credential authentication server error. | | 19100008 | The file is not a DLP file. | | 19100009 | Failed to operate the DLP file. | | 19100010 | The DLP file is read only. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } let destFile = fileIo.openSync("destUri"); try { dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{ dlpFile.recoverDLPFile(destFile.fd); // 还原DLP文件 dlpFile.closeDLPFile(); //å…³é—DLP对象 }); // 打开DLP文件 } catch (err) { console.error('error', (err as BusinessError).code, (err as BusinessError).message); // 失败报错 } fileIo.closeSync(file); fileIo.closeSync(destFile); ``` ### recoverDLPFile recoverDLPFile(plaintextFd: number, callback: AsyncCallback<void>): void 移除DLP文件的æƒé™æŽ§åˆ¶ï¼Œæ¢å¤æˆæ˜Žæ–‡æ–‡ä»¶ï¼Œä½¿ç”¨callbackæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | plaintextFd | number | 是 | ç›®æ ‡æ˜Žæ–‡æ–‡ä»¶çš„fd。 | | callback | AsyncCallback<void> | 是 | èŽ·å–æ¢å¤ç»“果的回调。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100002 | Credential task error. | | 19100003 | Credential task time out. | | 19100004 | Credential service error. | | 19100005 | Credential authentication server error. | | 19100008 | The file is not a DLP file. | | 19100009 | Failed to operate the DLP file. | | 19100010 | The DLP file is read only. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } let destFile = fileIo.openSync("destUri"); try { dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{ dlpFile.recoverDLPFile(destFile.fd, async (err, res) => { // 还原DLP文件 if (err != undefined) { console.error('recoverDLPFile error,', err.code, err.message); await dlpFile.closeDLPFile(); //å…³é—DLP对象 } else { console.info('res', JSON.stringify(res)); } }); }); // 打开DLP文件 } catch (err) { console.error('error,', (err as BusinessError).code, (err as BusinessError).message); } ``` ### closeDLPFile closeDLPFile(): Promise<void> å…³é—DLPFile,释放对象。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention > **说明:** > > dlpFileä¸å†ä½¿ç”¨ï¼Œåº”该关é—释放内å˜ï¼Œä¸”对象ä¸åº”ç»§ç»ä½¿ç”¨ã€‚ **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 19100001 | Invalid parameter value. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } try { dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{ dlpFile.closeDLPFile(); //å…³é—DLP对象 }); // 打开DLP文件 } catch (err) { console.error('error', (err as BusinessError).code, (err as BusinessError).message); // 失败报错 } fileIo.closeSync(file); ``` ### closeDLPFile closeDLPFile(callback: AsyncCallback<void>): void å…³é—DLPFile,释放对象,使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention > **说明:** > > dlpFileä¸å†ä½¿ç”¨ï¼Œåº”该关é—释放内å˜ï¼Œä¸”对象ä¸åº”ç»§ç»ä½¿ç”¨ã€‚ **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | 是 | 获å–å…³é—结果的回调。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } try { dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{ dlpFile.closeDLPFile((err, res) => { // å…³é—DLP文件 if (err != undefined) { console.error('closeDLPFile error,', err.code, err.message); } else { console.info('res', JSON.stringify(res)); } fileIo.closeSync(file); }); }); // 打开DLP文件 } catch (err) { console.error('error,', (err as BusinessError).code, (err as BusinessError).message); fileIo.closeSync(file); } ``` ## dlpPermission.generateDLPFile generateDLPFile(plaintextFd: number, ciphertextFd: number, property: DLPProperty): Promise<DLPFile> å°†æ˜Žæ–‡æ–‡ä»¶åŠ å¯†ç”Ÿæˆæƒé™å—控文件,仅在授æƒåˆ—表内的用户å¯ä»¥æ‰“开,授æƒåˆåˆ†ä¸ºå®Œå…¨æŽ§åˆ¶æƒé™å’Œåªè¯»æƒé™ã€‚获å–DLPFile管ç†å¯¹è±¡ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | plaintextFd | number | 是 | å¾…åŠ å¯†æ˜Žæ–‡æ–‡ä»¶çš„fd。 | | ciphertextFd | number | 是 | ç›®æ ‡åŠ å¯†æ–‡ä»¶çš„fd。 | | property | [DLPProperty](#dlpproperty) | 是 | 授æƒç”¨æˆ·ä¿¡æ¯ï¼šæŽˆæƒç”¨æˆ·åˆ—表ã€ownerè´¦å·ã€è”系人账å·ã€‚ | **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<[DLPFile](#dlpfile)> | Promise对象。返回对象表示æˆåŠŸç”ŸæˆDLP文件,返回null表示失败。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100002 | Credential task error. | | 19100003 | Credential task time out. | | 19100004 | Credential service error. | | 19100005 | Credential authentication server error. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { BusinessError } from '@kit.BasicServicesKit'; let dlpUri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt"; let file = fileIo.openSync(uri); let dlp = fileIo.openSync(dlpUri); try { let dlpProperty: dlpPermission.DLPProperty = { ownerAccount: 'zhangsan', ownerAccountType: dlpPermission.AccountType.DOMAIN_ACCOUNT, authUserList: [], contactAccount: 'zhangsan', offlineAccess: true, ownerAccountID: 'xxxxxxx', everyoneAccessList: [] }; dlpPermission.generateDLPFile(file.fd, dlp.fd, dlpProperty).then((dlpFile)=>{ dlpFile.closeDLPFile(); //å…³é—DLP对象 }); // 生æˆDLP文件 } catch (err) { console.error('error', (err as BusinessError).code, (err as BusinessError).message); // 失败报错 } fileIo.closeSync(file); fileIo.closeSync(dlp); ``` ## dlpPermission.generateDLPFile generateDLPFile(plaintextFd: number, ciphertextFd: number, property: DLPProperty, callback: AsyncCallback<DLPFile>): void DLP管ç†åº”用调用该接å£ï¼Œå°†æ˜Žæ–‡æ–‡ä»¶åŠ å¯†ç”Ÿæˆæƒé™å—控文件,仅在授æƒåˆ—表内的用户å¯ä»¥æ‰“开,授æƒåˆåˆ†ä¸ºå®Œå…¨æŽ§åˆ¶æƒé™å’Œåªè¯»æƒé™ã€‚获å–DLPFile管ç†å¯¹è±¡ï¼Œä½¿ç”¨callbackæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | plaintextFd | number | 是 | å¾…åŠ å¯†æ˜Žæ–‡æ–‡ä»¶çš„fd。 | | ciphertextFd | number | 是 | ç›®æ ‡åŠ å¯†æ–‡ä»¶çš„fd。 | | property | [DLPProperty](#dlpproperty) | 是 | 授æƒç”¨æˆ·ä¿¡æ¯ï¼šæŽˆæƒç”¨æˆ·åˆ—表ã€ownerè´¦å·ã€è”系人账å·ã€‚ | | callback | AsyncCallback<[DLPFile](#dlpfile)> | 是 | 回调函数。返回DLPFile对象。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100002 | Credential task error. | | 19100003 | Credential task time out. | | 19100004 | Credential service error. | | 19100005 | Credential authentication server error. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { BusinessError } from '@kit.BasicServicesKit'; let dlpUri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt"; let file = fileIo.openSync(uri); let dlp = fileIo.openSync(dlpUri); try { let dlpProperty: dlpPermission.DLPProperty = { ownerAccount: 'zhangsan', ownerAccountType: dlpPermission.AccountType.DOMAIN_ACCOUNT, authUserList: [], contactAccount: 'zhangsan', offlineAccess: true, ownerAccountID: 'xxxxxxx', everyoneAccessList: [] }; dlpPermission.generateDLPFile(file.fd, dlp.fd, dlpProperty, (err, res) => { // 生æˆDLP文件 if (err != undefined) { console.error('generateDLPFile error,', err.code, err.message); } else { console.info('res', JSON.stringify(res)); } }); } catch (err) { console.error('error,', (err as BusinessError).code, (err as BusinessError).message); fileIo.closeSync(file); } ``` ## dlpPermission.openDLPFile<sup>11+</sup> openDLPFile(ciphertextFd: number, appId: string): Promise<DLPFile> 打开DLP文件。获å–DLPFile管ç†å¯¹è±¡ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | ciphertextFd | number | 是 | åŠ å¯†æ–‡ä»¶çš„fd。 | | appId | string | 是 | 调用方身份。 | **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<[DLPFile](#dlpfile)> | Promise对象。返回对象表示打开生æˆDLP文件,返回null表示失败。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100002 | Credential task error. | | 19100003 | Credential task time out. | | 19100004 | Credential service error. | | 19100005 | Credential authentication server error. | | 19100008 | The file is not a DLP file. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | | 19100018 | Not authorized application. | | 19100019 | The DLP file has expired. | | 19100020 | No network connection. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } try { dlpPermission.openDLPFile(file.fd, appId).then((dlpFile)=>{ dlpFile.closeDLPFile(); //å…³é—DLP对象 }); // 打开DLP文件 } catch (err) { console.error('error', (err as BusinessError).code, (err as BusinessError).message); // 失败报错 } fileIo.closeSync(file); ``` ## dlpPermission.openDLPFile<sup>11+</sup> openDLPFile(ciphertextFd: number, appId: string, callback: AsyncCallback<DLPFile>): void DLP管ç†åº”用调用该接å£ï¼Œæ‰“å¼€DLP文件。获å–DLPFile管ç†å¯¹è±¡ï¼Œä½¿ç”¨callbackæ–¹å¼å¼‚æ¥è¿”回结果。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **éœ€è¦æƒé™ï¼š** ohos.permission.ACCESS_DLP_FILE **系统能力:** SystemCapability.Security.DataLossPrevention **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | ciphertextFd | number | 是 | åŠ å¯†æ–‡ä»¶çš„fd。 | | appId | string | 是 | 调用方身份。 | | callback | AsyncCallback<[DLPFile](#dlpfile)> | 是 | 回调函数。返回DLPFile对象。 | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[DLPæœåŠ¡é”™è¯¯ç ](errorcode-dlp.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | -------- | | 201 | Permission denied. | | 202 | Non-system applications use system APIs. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | | 19100001 | Invalid parameter value. | | 19100002 | Credential task error. | | 19100003 | Credential task time out. | | 19100004 | Credential service error. | | 19100005 | Credential authentication server error. | | 19100008 | The file is not a DLP file. | | 19100009 | Failed to operate the DLP file. | | 19100011 | The system ability works abnormally. | | 19100018 | Not authorized application. | | 19100019 | The DLP file has expired. | | 19100020 | No network connection. | **示例:** ```ts import { dlpPermission } from '@kit.DataProtectionKit'; import { fileIo } from '@kit.CoreFileKit'; import { bundleManager } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; let uri = "file://docs/storage/Users/currentUser/Desktop/test.txt.dlp"; let file = fileIo.openSync(uri); let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let appId = ""; let bundleName = 'com.ohos.note'; let userId = 100; try{ bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { if (err) { console.error('error', err.code, err.message); } else { appId = data.signatureInfo.appId; } }) } catch (err) { console.error('error', err.code, err.message); } try { dlpPermission.openDLPFile(file.fd, appId, (err, res) => { // 打开DLP文件 if (err != undefined) { console.error('openDLPFile error,', err.code, err.message); } else { console.info('res', JSON.stringify(res)); } }); } catch (err) { console.error('error,', (err as BusinessError).code, (err as BusinessError).message); fileIo.closeSync(file); } ``` ## DLPSandboxInfo 表示DLP沙箱的信æ¯ã€‚ **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.Security.DataLossPrevention | åç§° | 类型 | å¯è¯» | å¯å†™ | 说明 | | -------- | -------- | -------- | -------- | -------- | | appIndex | number | 是 | å¦ | 表示DLP沙箱应用索引。 | | tokenID | number | 是 | å¦ | 表示DLP沙箱应用的tokenID。 | ## DLPSandboxState DLP沙箱身份。 **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.Security.DataLossPrevention | åç§° | 类型 | å¯è¯» | å¯å†™ | 说明 | | -------- | -------- | -------- | -------- | -------- | | bundleName | string | 是 | å¦ | 表示应用包å。 | | appIndex | number | 是 | å¦ | 表示DLP沙箱应用索引。 | ## AccountType 授æƒè´¦å·ç±»åž‹çš„æžšä¸¾ã€‚ **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.Security.DataLossPrevention | åç§° | 值 | 说明 | | -------- | -------- | -------- | | CLOUD_ACCOUNT | 1 | 表示云账å·ã€‚ | | DOMAIN_ACCOUNT | 2 | 表示域账å·ã€‚ | ## AuthUser 表示授æƒç”¨æˆ·æ•°æ®ã€‚ **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.Security.DataLossPrevention | åç§° | 类型 | åªè¯» | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | -------- | | authAccount | string | å¦ | 是 | 表示被授æƒç”¨æˆ·è´¦å·ã€‚ | | authAccountType | [AccountType](#accounttype) | å¦ | 是 | 表示被授æƒç”¨æˆ·è´¦å·ç±»åž‹ã€‚ | | dlpFileAccess | [DLPFileAccess](js-apis-dlppermission.md#dlpfileaccess) | å¦ | 是 | 表示被授予的æƒé™ã€‚ | | permExpiryTime | number | å¦ | 是 | 表示授æƒåˆ°æœŸæ—¶é—´ã€‚ | ## DLPProperty 表示授æƒç›¸å…³ä¿¡æ¯ã€‚ **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.Security.DataLossPrevention | åç§° | 类型 | åªè¯» | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | -------- | | ownerAccount | string | å¦ | 是 | 表示æƒé™è®¾ç½®è€…è´¦å·ã€‚ | | ownerAccountID | string | å¦ | 是 | 表示æƒé™è®¾ç½®è€…è´¦å·çš„ID。 | | ownerAccountType | [AccountType](#accounttype) | å¦ | 是 | 表示æƒé™è®¾ç½®è€…è´¦å·ç±»åž‹ã€‚ | | authUserList | Array<[AuthUser](#authuser)> | å¦ | å¦ | 表示授æƒç”¨æˆ·åˆ—表,默认为空。 | | contactAccount | string | å¦ | 是 | 表示è”系人账å·ã€‚ | | offlineAccess | boolean | å¦ | 是 | è¡¨ç¤ºæ˜¯å¦æ˜¯ç¦»çº¿æ‰“开。 | | everyoneAccessList | Array<[DLPFileAccess](js-apis-dlppermission.md#dlpfileaccess)> | å¦ | å¦ | 表示授予所有人的æƒé™ï¼Œé»˜è®¤ä¸ºç©ºã€‚ | | expireTime<sup>11+</sup> | number | å¦ | å¦ | 表示文件æƒé™åˆ°æœŸæ—¶é—´æˆ³ï¼Œé»˜è®¤ä¸ºç©ºã€‚ | ## GatheringPolicyType DLP沙箱èšåˆç–略类型的枚举。沙箱èšåˆè¡¨ç¤ºåŒä¸€æƒé™ç±»åž‹çš„DLP文件,在åŒä¸€ä¸ªæ²™ç®±å†…打开,例如在åŒä¸€ä¸ªæ²™ç®±å†…使用ä¸åŒtab页打开;沙箱éžèšåˆè¡¨ç¤ºä¸åŒDLP文件在ä¸åŒæ²™ç®±æ‰“开。 **系统能力:** SystemCapability.Security.DataLossPrevention **系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **傿•°ï¼š** | åç§° | 值 | 说明 | | -------- | -------- | -------- | | GATHERING | 1 | 表示沙箱èšåˆã€‚ | | NON_GATHERING | 2 | 表示沙箱éžèšåˆã€‚ |