openharmony_ci 9fd6f1e3a6 !469 修改函数名
Merge pull request !469 from 丁巧巧/0912b
2025-09-13 06:26:24 +00:00
2025-07-10 19:57:47 +08:00
2025-03-04 10:51:10 +08:00
2022-12-19 11:05:40 +08:00
2025-07-09 14:43:13 +08:00
2025-09-12 11:35:18 +08:00
2024-12-28 16:01:28 +08:00
2025-04-15 14:16:12 +08:00
2025-05-13 03:04:42 +00:00
2024-12-04 15:33:00 +08:00
2024-12-04 15:33:00 +08:00
2024-07-08 20:12:39 +08:00
2023-07-28 17:28:39 +08:00
2022-08-30 09:17:44 +08:00
2024-08-26 11:44:58 +08:00
2025-04-16 09:13:26 +08:00
2024-10-23 16:22:13 +08:00
2023-06-05 17:16:01 +08:00
2023-06-05 17:16:01 +08:00

PermissionManager

Introduction

PermissionManager, a system application preset in OpenHarmony, provides permission dialog boxes, permission management settings, and permission usage records during the running of apps.

The following figure shows the architecture of the PermissionManager application.

Directory Structure

/applications/standard/permission_manager
├── entry                              # Directory of the entry module
├── permissionmanager                  # Directory of the PermissionManager module
│   ├── src/main/ets                   # ets module
│   │       ├── Application            # abilitystage directory
│   │       ├── MainAbility            # Permission management ability
│   │       ├── ServiceExtAbility      # serviceExtension configuration
│   │       ├── common                 # Common utilities
│   │       └── pages                  # Pages
│   ├──  resources                     # Global resource files
│   └──  module.json5                  # Global configuration file
├── signature                          # Certificate files
└── 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
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
hdc install Packet path

Application running

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
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.

Repositories Involved

security_access_token

S
Description
权限管理应用是OpenHarmony中预置的系统系统应用,为用户提供运行时权限弹框、权限管理设置和权限使用记录展示等功能。
Readme 3.2 MiB
Languages
TypeScript 85.3%
JavaScript 14.7%