Name Date Size

..25-Oct-20244 KiB

.gitignoreH A D25-Oct-2024119

AppScope/H25-Oct-20244 KiB

build-profile.json5H A D25-Oct-20241.1 KiB

entry/H25-Oct-20244 KiB

hvigor/H25-Oct-20244 KiB

hvigorfile.tsH A D25-Oct-2024800

hvigorwH A D25-Oct-20242 KiB

hvigorw.batH A D25-Oct-20242.1 KiB

oh-package-lock.json5H A D25-Oct-20241.1 KiB

oh-package.json5H A D25-Oct-2024233

ohosTest.mdH A D25-Oct-20244.8 KiB

README_zh.mdH A D25-Oct-20245.8 KiB

screenshots/device/H25-Oct-20244 KiB

README_zh.md

1# DLPManager
2
3### 介绍
4
5本示例主要展示了DLP文件管理相关的功能,使用[@ohos.dlpPermission](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-data-protection-kit/js-apis-dlppermission-sys.md)、[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md)、[@ohos.file.fileAccess](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-fileAccess-sys.md)、[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md)、[@ohos.app.ability.Want](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-want.md)等接口,实现了生成和打开DLP文件、查看原始应用沙箱目录的原始文件打开列表、编辑保存文件、拉取文件夹、查看文件权限和监听DLP文件的功能。
6
7### 效果预览
8
9|主页|文件内容页|
10|--------------------------------|--------------------------------|
11|<img src="screenshots/device/index.jpeg" style="zoom: 50%;" />|<img src="screenshots/device/dlpPage.jpeg" style="zoom: 50%;" />|
12
13使用说明
14
151.进入界面,显示原始应用沙箱目录获取原始文件访问列表。
16
172.点击右上角的图标,可以获取沙箱保留信息。
18
193.点击右下角的加号图标,可以跳转进入文件夹。
20
214.点击某个文件,可以显示其文件内容。
22
235.在文件显示页面,可以点击下面的编辑图标对文件内容进行编辑,编辑后点击保存图标进行保存;点击更多可以文件另存为,查看权限。
24
256.设置txt文件权限时需输入用户账号点击回车后才能点击确认按钮。
26
27### 工程目录
28
29```
30entry/src/main/ets/
31|---entryability
32|   |---EntryAbility.ets               // dlpSample应用的ability
33|   |---FuncAbility.ets                // dlp文件显示的ability
34|---media
35|   |---dlpPage.ets                    // dlp文件内容页
36|   |---filePage.ets                   // 原始文件内容页
37|   |---MediaFileUri.ts                // 函数方法
38|---pages
39|   |---Index.ets                      // 首页
40|---utils
41|   |---Logger.ts                      // 日志工具
42```
43### 具体实现
44
45* 本实例获取DLP文件和普通文件列表的功能结主要封装在Index,源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets) 。
46    * 获取列表信息:在Index页面中通过onPageShow()调用fs.listFile()、fs.stat()等方法能够应用沙箱路径下的原始文件列表;通过context.startAbility(want)对DLP文件进行生成和打开,通过dlpPermission的接口查看DLP文件的权限。
47
48### 相关权限
49
50| 权限名                                                       | 权限说明                                      | 级别         |
51| ------------------------------------------------------------ | --------------------------------------------- | ------------ |
52| [ohos.permission.MEDIA_LOCATION](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionmedia_location) | 允许应用访问用户媒体文件中的地理位置信息      | normal       |
53| [ohos.permission.FILE_ACCESS_MANAGER](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionfile_access_manager) | 允许文件管理类应用通过FAF框架访问公共数据文件 | system_basic |
54| [ohos.permission.GET_BUNDLE_INFO_PRIVILEGED](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_bundle_info_privileged) | 允许查询应用的基本信息和敏感信息              | system_basic |
55| [ohos.permission.ACCESS_DLP_FILE](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionaccess_dlp_file) | 允许对DLP文件进行权限配置和管理               | system_core  |
56| [ohos.permission.START_INVISIBLE_ABILITY](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionstart_invisible_ability) | 无论Ability是否可见,都允许应用进行调用       | system_core  |
57
58### 依赖
59
60不涉及。
61
62### 约束与限制
63
641.本示例仅支持标准系统上运行。
65
662.本示例已适配API version 11版本SDK,版本号:4.1.3.3。
67
683.本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400 构建 2023年4月7日)及以上版本才可编译运行。
69
704.本示例签名时需修改sdk文件夹下`UnsgnedReleasedProfileTemplate.json`文件,如下所示:
71```json
72{
73  "bundle-info": {
74    "developer-id": "OpenHarmony",
75    "distribution-certificate": "",
76    "bundle-name": "com.sample.dlpmanager",
77    "apl": "normal",
78    "app-feature": "hos_system_app"
79  },
80  "acls": {
81    "allowed-acls": [
82      "ohos.permission.MEDIA_LOCATION",
83      "ohos.permission.FILE_ACCESS_MANAGER",
84      "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
85      "ohos.permission.ACCESS_DLP_FILE",
86      "ohos.permission.START_INVISIBLE_ABILITY",
87      "ohos.permission.START_ABILITIES_FROM_BACKGROUND",
88      "ohos.permission.ABILITY_BACKGROUND_COMMUNICATION",
89      "ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS",
90      "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
91      "ohos.permission.PROXY_AUTHORIZATION_URI"
92    ]
93  }
94}
95```
96
97### 下载
98
99如需单独下载本工程,执行如下命令:
100```
101git init
102git config core.sparsecheckout true
103echo code/SystemFeature/Security/DLPManager > .git/info/sparse-checkout
104git remote add origin https://gitee.com/openharmony/applications_app_samples.git
105git pull origin master
106
107```
108