1# dlp_permission_api.h 2<!--Kit: Data Protection Kit--> 3<!--Subsystem: Security--> 4<!--Owner: @winnieHuYu--> 5<!--SE: @lucky-jinduo--> 6<!--TSE: @nacyli--> 7 8## Overview 9 10Defines the APIs for cross-device file access management, encrypted storage, and access authorization. 11 12**Library**: libohdlp_permission.so 13 14**File to include**: <DataProtectionKit/dlp_permission_api.h> 15 16**System capability**: SystemCapability.Security.DataLossPrevention 17 18**Since**: 14 19 20**Related module**: [DlpPermissionApi](capi-dlppermissionapi.md) 21 22## Summary 23 24### Enums 25 26| Name| typedef Keyword| Description| 27| -- | -- | -- | 28| [DLP_ErrCode](#dlp_errcode) | DLP_ErrCode | Enumerates the DLP error codes.| 29| [DLP_FileAccess](#dlp_fileaccess) | DLP_FileAccess | Enumerates the permissions on a DLP file.| 30 31### Functions 32 33| Name| Description| 34| -- | -- | 35| [DLP_ErrCode OH_DLP_GetDlpPermissionInfo(DLP_FileAccess *dlpFileAccess, uint32_t *flags)](#oh_dlp_getdlppermissioninfo) | Obtains the permission information of this DLP file.| 36| [DLP_ErrCode OH_DLP_GetOriginalFileName(const char *fileName, char *originalFileName)](#oh_dlp_getoriginalfilename) | Obtains the original file name of a DLP file.| 37| [DLP_ErrCode OH_DLP_IsInSandbox(bool *isInSandbox)](#oh_dlp_isinsandbox) | Checks whether this application is running in a DLP sandbox environment.| 38| [DLP_ErrCode OH_DLP_SetSandboxAppConfig(const char *configInfo)](#oh_dlp_setsandboxappconfig) | Sets sandbox application configuration.| 39| [DLP_ErrCode OH_DLP_GetSandboxAppConfig(char *configInfo)](#oh_dlp_getsandboxappconfig) | Obtains the sandbox application configuration.| 40| [DLP_ErrCode OH_DLP_CleanSandboxAppConfig()](#oh_dlp_cleansandboxappconfig) | Cleans the sandbox application configuration.| 41 42## Enum Description 43 44### DLP_ErrCode 45 46``` 47enum DLP_ErrCode 48``` 49 50**Description** 51 52Enumerates the DLP error codes. 53 54**Since**: 14 55 56| Enum| Description| 57| -- | -- | 58| ERR_OH_SUCCESS = 0 | The operation is successful.| 59| ERR_OH_INVALID_PARAMETER = 19100001 | Invalid parameters are specified.| 60| ERR_OH_API_ONLY_FOR_SANDBOX = 19100006 | The caller is not a DLP sandbox application.| 61| ERR_OH_API_NOT_FOR_SANDBOX = 19100007 | The API is not available to a DLP sandbox application.| 62| ERR_OH_SYSTEM_SERVICE_EXCEPTION = 19100011 | The system service is abnormal.| 63| ERR_OH_OUT_OF_MEMORY = 19100012 | The memory allocation fails.| 64| ERR_OH_APPLICATION_NOT_AUTHORIZED = 19100018 | The application is not authorized to perform the operation.| 65 66### DLP_FileAccess 67 68``` 69enum DLP_FileAccess 70``` 71 72**Description** 73 74Enumerates the permissions on a DLP file. 75 76**Since**: 14 77 78| Enum| Description| 79| -- | -- | 80| NO_PERMISSION = 0 | No permission on the file.| 81| READ_ONLY = 1 | Read-only permission.| 82| CONTENT_EDIT = 2 | Editing permission.| 83| FULL_CONTROL = 3 | Full control.| 84 85 86## Function Description 87 88### OH_DLP_GetDlpPermissionInfo() 89 90``` 91DLP_ErrCode OH_DLP_GetDlpPermissionInfo(DLP_FileAccess *dlpFileAccess, uint32_t *flags) 92``` 93 94**Description** 95 96Obtains the permission information of this DLP file. 97 98**Since**: 14 99 100 101**Parameters** 102 103| Parameter| Description| 104| -- | -- | 105| [DLP_FileAccess](#dlp_fileaccess) *dlpFileAccess | User permission on the DLP file, for example, read-only.| 106| uint32_t *flags | Pointer to the operation permissions allowed for the DLP file. The options are as follows:<br>**0x00000000** indicates no permission on the file.<br>**0x00000001** indicates the permission for viewing the file.<br>**0x00000002** indicates the permission for saving the file.<br>**0x00000004** indicates the permission for saving the file as another file.<br>**0x00000008** indicates the permission for editing the file.<br>**0x00000010** indicates the permission for capturing screenshots of the file.<br>**0x00000020** indicates the permission for sharing the screen, on which the file is open.<br>**0x00000040** indicates the permission for recording the screen, on which the file is open.<br>**0x00000080** indicates the permission for copying the file.<br>**0x00000100** indicates the permission for printing the file.<br>**0x00000200** indicates the permission for exporting the file.<br>**0x00000400** indicates the permission for modifying the permissions on the file.| 107 108**Return value** 109 110| Type| Description| 111| -- | -- | 112| [DLP_ErrCode](#dlp_errcode) | Returns **0** if the operation is successful.<br> Returns **19100001** if invalid parameters are detected.<br> Returns **19100006** when the access is denied for a non-DLP sandbox application.<br> Returns **19100011** when the system service is abnormal.<br> Returns **19100012** if the memory allocation fails.| 113 114### OH_DLP_GetOriginalFileName() 115 116``` 117DLP_ErrCode OH_DLP_GetOriginalFileName(const char *fileName, char *originalFileName) 118``` 119 120**Description** 121 122Obtains the original file name of a DLP file. 123 124**Since**: 14 125 126 127**Parameters** 128 129| Parameter| Description| 130| -- | -- | 131| const char *fileName | Pointer to the target file whose original file name is to be obtained.| 132| char *originalFileName | Double pointer to the original file name obtained.| 133 134**Return value** 135 136| Type| Description| 137| -- | -- | 138| [DLP_ErrCode](#dlp_errcode) | Returns **0** if the operation is successful.<br> Returns **19100001** if invalid parameters are detected.<br> Returns **19100012** if the memory allocation fails.| 139 140### OH_DLP_IsInSandbox() 141 142``` 143DLP_ErrCode OH_DLP_IsInSandbox(bool *isInSandbox) 144``` 145 146**Description** 147 148Checks whether this application is running in a DLP sandbox environment. 149 150**Since**: 14 151 152 153**Parameters** 154 155| Parameter| Description| 156| -- | -- | 157| bool *isInSandbox | Pointer to the value indicating whether the application is running in a DLP sandbox environment.| 158 159**Return value** 160 161| Type| Description| 162| -- | -- | 163| [DLP_ErrCode](#dlp_errcode) | Returns **0** if the operation is successful.<br> Returns **19100011** when the system service is abnormal.<br> Returns **19100012** if the memory allocation fails.| 164 165### OH_DLP_SetSandboxAppConfig() 166 167``` 168DLP_ErrCode OH_DLP_SetSandboxAppConfig(const char *configInfo) 169``` 170 171**Description** 172 173Sets sandbox application configuration. 174 175**Since**: 14 176 177 178**Parameters** 179 180| Parameter| Description| 181| -- | -- | 182| const char *configInfo | Pointer to the sandbox application configuration obtained.| 183 184**Return value** 185 186| Type| Description| 187| -- | -- | 188| [DLP_ErrCode](#dlp_errcode) | Returns **0** if the operation is successful.<br> Returns **19100001** if invalid parameters are detected.<br> Returns **19100007** if the API cannot be called by a DLP sandbox application.<br> Returns **19100011** when the system service is abnormal.<br> Returns **19100018** if the application is unauthorized.| 189 190### OH_DLP_GetSandboxAppConfig() 191 192``` 193DLP_ErrCode OH_DLP_GetSandboxAppConfig(char *configInfo) 194``` 195 196**Description** 197 198Obtains the sandbox application configuration. 199 200**Since**: 14 201 202 203**Parameters** 204 205| Parameter| Description| 206| -- | -- | 207| char *configInfo | Pointer to the sandbox application configuration obtained.| 208 209**Return value** 210 211| Type| Description| 212| -- | -- | 213| [DLP_ErrCode](#dlp_errcode) | Returns **0** if the operation is successful.<br> Returns **19100011** when the system service is abnormal.<br> Returns **19100012** if the memory allocation fails.<br> Returns **19100018** if the application is unauthorized.| 214 215### OH_DLP_CleanSandboxAppConfig() 216 217``` 218DLP_ErrCode OH_DLP_CleanSandboxAppConfig() 219``` 220 221**Description** 222 223Cleans the sandbox application configuration. 224 225**Since**: 14 226 227**Return value** 228 229| Type| Description| 230| -- | -- | 231| [DLP_ErrCode](#dlp_errcode) | Returns **0** if the operation is successful.<br> Returns **19100007** if the API cannot be called by a DLP sandbox application.<br> Returns **19100011** when the system service is abnormal.<br> Returns **19100018** if the application is unauthorized.| 232