• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-6558

entry/12-May-2024-264198

figures/12-May-2024-

hvigor/12-May-2024-3922

permissionmanager/12-May-2024-8,3737,834

signature/12-May-2024-1513

.gitignoreD12-May-202482 77

LICENSED12-May-202410.1 KiB177150

OAT.xmlD12-May-20245.7 KiB8434

README.mdD12-May-20243 KiB9872

README_zh.mdD12-May-20243 KiB9872

build-profile.json5D12-May-20241.4 KiB6059

bundle.jsonD12-May-2024747 3232

hvigorfile.jsD12-May-2024777 171

hvigorwD12-May-20241.9 KiB6253

hvigorw.batD12-May-20242.1 KiB7859

oh-package-lock.json5D12-May-20241 KiB2827

oh-package.json5D12-May-2024822 2625

README.md

1# PermissionManager
2
3
4## Introduction
5
6PermissionManager, a system application preset in OpenHarmony, provides permission dialog boxes, permission management settings, and permission usage records during the running of apps.
7
8The following figure shows the architecture of the PermissionManager application.
9![](figures/application-framework_en.png)
10## Directory Structure
11
12```
13/applications/standard/permission_manager
14├── entry                              # Directory of the entry module
15├── permissionmanager                  # Directory of the PermissionManager module
16│   ├── src/main/ets                   # ets module
17│   │       ├── Application            # abilitystage directory
18│   │       ├── MainAbility            # Permission management ability
19│   │       ├── ServiceExtAbility      # serviceExtension configuration
20│   │       ├── common                 # Common utilities
21│   │       └── pages                  # Pages
22│   ├──  resources                     # Global resource files
23│   └──  module.json5                  # Global configuration file
24├── signature                          # Certificate files
25└── LICENSE                            # License file
26```
27
28## Installation, operation and commissioning<a name="section1548654218"></a>
29
30### Application installation
31
32- There are two files that need to change the suffix to json5
33
34```
35/AppScope/app.json
36/permissionmanager/src/main/module.json
37```
38
39- Uninstall preset rights management for the first installation
40
41```html
42hdc shell mount -o remount,rw /
43hdc shell rm -rf /system/app/com.ohos.permissionmanager
44hdc shell rm -rf /data/*
45hdc shell reboot
46```
47
48- Install the signed hap package
49
50```html
51hdc install Packet path
52```
53
54### Application running
55
56- Permission dialog:[requestPermissionsFromUser](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9)
57```JS
58import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
59let atManager = abilityAccessCtrl.createAtManager();
60try {
61    atManager.requestPermissionsFromUser(this.context, ['ohos.permission.CAMERA'], (err, data)=>{
62        console.info('data:' + JSON.stringify(data));
63        console.info('data permissions:' + data.permissions);
64        console.info('data authResults:' + data.authResults);
65    });
66} catch(err) {
67    console.log(`catch err->${JSON.stringify(err)}`);
68}
69```
70
71- Permission manager
72
73Settings-Privacy-Permission Manager
74
75### Application debugging
76
77- Add log to the program
78
79```JS
80const TAG = "PermissionManager_Log"
81console.info(TAG + `log`);
82```
83- Grab log:
84
85```
86hdc shell hilog -Q pidoff
87hdc shell -b D
88hdc shell hilog -r && hdc hilog > log.txt
89```
90
91### How to Use
92
93For details, see [Permission Application Guide](https://gitee.com/openharmony/docs/blob/master/en/application-dev/security/accesstoken-guidelines.md).
94
95## Repositories Involved
96
97**[security\_access\_token](https://gitee.com/openharmony/security_access_token)**
98

README_zh.md

1# 访问控制<a name="ZH-CN_TOPIC_0000001101239136"></a>
2
3
4## 简介<a name="section11660541593"></a>
5
6权限管理应用是OpenHarmony中预置的系统系统应用,为用户提供运行时权限弹框、权限管理设置和权限使用记录展示等功能。
7
8权限管理应用的架构图如下所示:
9![](figures/application-framework.png)
10## 目录<a name="section161941989596"></a>
11
12```
13/applications/standard/permission_manager
14├── entry                              # entry模块目录
15├── permissionmanager                  # 权限管理模块目录
16│   ├── src/main/ets                   # ets模块
17│   │       ├── Application            # abilitystage目录
18│   │       ├── MainAbility            # 权限管理ability
19│   │       ├── ServiceExtAbility      # serviceExtension配置目录
20│   │       ├── common                 # 公共工具目录
21│   │       └── pages                  # 页面目录
22│   ├──  resources                     # 全局资源文件目录
23│   └──  module.json5                  # 全局配置文件
24├── signature                          # 证书文件目录
25└── LICENSE                            # 许可文件
26```
27
28## 安装、运行、调试<a name="section1548654218"></a>
29
30### 应用安装
31
32- 代码编译有两个文件需要将后缀名修改为json5
33
34```
35/AppScope/app.json
36/permissionmanager/src/main/module.json
37```
38
39- 初次安装需要卸载系统预置的权限管理
40
41```html
42hdc shell mount -o remount,rw /
43hdc shell rm -rf /system/app/com.ohos.permissionmanager
44hdc shell rm -rf /data/*
45hdc shell reboot
46```
47
48- 安装签过名的hap包
49
50```html
51hdc install 包路径
52```
53
54### 应用运行
55
56- 权限弹窗:[requestPermissionsFromUser](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9)
57```JS
58import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
59let atManager = abilityAccessCtrl.createAtManager();
60try {
61    atManager.requestPermissionsFromUser(this.context, ['ohos.permission.CAMERA'], (err, data)=>{
62        console.info('data:' + JSON.stringify(data));
63        console.info('data permissions:' + data.permissions);
64        console.info('data authResults:' + data.authResults);
65    });
66} catch(err) {
67    console.log(`catch err->${JSON.stringify(err)}`);
68}
69```
70
71- 权限管理
72
73设置-隐私-权限管理
74
75### 应用调试
76
77- 在程序中添加 log
78
79```JS
80const TAG = "PermissionManager_Log"
81console.info(TAG + `log`);
82```
83- 抓取log日志:
84
85```
86hdc shell hilog -Q pidoff
87hdc shell -b D
88hdc shell hilog -r && hdc hilog > log.txt
89```
90
91## 使用说明<a name="section123459000"></a>
92
93参见使用说明 [使用说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-guidelines.md)
94
95## 相关仓<a name="section1371113476307"></a>
96
97**[security\_access\_token](https://gitee.com/openharmony/security_access_token/blob/master/README_zh.md)**
98