Readme更新

Signed-off-by: fanchenxuan <fanchenxuan@huawei.com>
This commit is contained in:
fanchenxuan 2023-05-30 17:46:09 +08:00
parent 3761895ebe
commit f62d8618a9
2 changed files with 126 additions and 3 deletions

View File

@ -25,6 +25,69 @@ The following figure shows the architecture of the PermissionManager application
└── LICENSE # License file
```
## Installation, operation and commissioning<a name="section1548654218"></a>
### Application installation
- There are two files that need to change the suffix to json5
```
/AppScope/app.json
/permissionmanager/src/main/module.json
```
- Uninstall preset rights management for the first installation
```html
hdc shell mount -o remount,rw /
hdc shell rm -rf /system/app/com.ohos.permissionmanager
hdc shell rm -rf /data/*
hdc shell reboot
```
- Install the signed hap package
```html
hdc install Packet path
```
### Application running
- Permission dialog[requestPermissionsFromUser](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9)
```JS
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
try {
atManager.requestPermissionsFromUser(this.context, ['ohos.permission.CAMERA'], (err, data)=>{
console.info('data:' + JSON.stringify(data));
console.info('data permissions:' + data.permissions);
console.info('data authResults:' + data.authResults);
});
} catch(err) {
console.log(`catch err->${JSON.stringify(err)}`);
}
```
- Permission manager
Settings-Privacy-Permission Manager
### Application debugging
- Add log to the program
```JS
const TAG = "PermissionManager_Log"
console.info(TAG + `log`);
```
- Grab log
```
hdc shell hilog -Q pidoff
hdc shell -b D
hdc shell hilog -r && hdc hilog > log.txt
```
### How to Use
For details, see [Permission Application Guide](https://gitee.com/openharmony/docs/blob/master/en/application-dev/security/accesstoken-guidelines.md).

View File

@ -1,8 +1,5 @@
# 访问控制<a name="ZH-CN_TOPIC_0000001101239136"></a>
- [简介<a name="section11660541593"></a>](#简介)
- [目录<a name="section161941989596"></a>](#目录)
- [相关仓<a name="section1371113476307"></a>](#相关仓)
## 简介<a name="section11660541593"></a>
@ -28,6 +25,69 @@
└── LICENSE # 许可文件
```
## 安装、运行、调试<a name="section1548654218"></a>
### 应用安装
- 代码编译有两个文件需要将后缀名修改为json5
```
/AppScope/app.json
/permissionmanager/src/main/module.json
```
- 初次安装需要卸载系统预置的权限管理
```html
hdc shell mount -o remount,rw /
hdc shell rm -rf /system/app/com.ohos.permissionmanager
hdc shell rm -rf /data/*
hdc shell reboot
```
- 安装签过名的hap包
```html
hdc install 包路径
```
### 应用运行
- 权限弹窗:[requestPermissionsFromUser](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9)
```JS
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
try {
atManager.requestPermissionsFromUser(this.context, ['ohos.permission.CAMERA'], (err, data)=>{
console.info('data:' + JSON.stringify(data));
console.info('data permissions:' + data.permissions);
console.info('data authResults:' + data.authResults);
});
} catch(err) {
console.log(`catch err->${JSON.stringify(err)}`);
}
```
- 权限管理
设置-隐私-权限管理
### 应用调试
- 在程序中添加 log
```JS
const TAG = "PermissionManager_Log"
console.info(TAG + `log`);
```
- 抓取log日志
```
hdc shell hilog -Q pidoff
hdc shell -b D
hdc shell hilog -r && hdc hilog > log.txt
```
## 使用说明<a name="section123459000"></a>
参见使用说明 [使用说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-guidelines.md)