• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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