diff --git a/README.md b/README.md index 9763fce..c2fdf6a 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,69 @@ The following figure shows the architecture of the PermissionManager application └── LICENSE # License file ``` +## Installation, operation and commissioning + +### 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). diff --git a/README_zh.md b/README_zh.md index 71dd617..63cfd3b 100644 --- a/README_zh.md +++ b/README_zh.md @@ -1,8 +1,5 @@ # 访问控制 - - [简介](#简介) - - [目录](#目录) - - [相关仓](#相关仓) ## 简介 @@ -28,6 +25,69 @@ └── LICENSE # 许可文件 ``` +## 安装、运行、调试 + +### 应用安装 + +- 代码编译有两个文件需要将后缀名修改为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 +``` + ## 使用说明 参见使用说明 [使用说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-guidelines.md)