• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Access Token Manager
2
3Access Token Manager (atm) is a tool used to query<!--Del--> and set<!--DelEnd--> the information such as permission and usage type of an application process. It provides the capability of access control based on the token ID, bundle name, and process name.
4
5## Environment Setup
6Before using this tool, you must obtain [hdc](../dfx/hdc.md) and run the **hdc shell** command.
7
8## Commands
9
10| Command               | Description|
11| ------------------- | -----------|
12| help                | Displays the commands supported by the atm tool.|
13| <!--DelRow-->perm   | Grants or revokes a permission for an application process.|
14| <!--DelRow-->toggle | Sets or obtains the toggle status of the permission dialog box or permission usage records. This command is available only for the root version.|
15| dump                | Obtains access control data.|
16
17## help
18
19```bash
20# Display the help information.
21atm help
22```
23
24
25<!--Del-->
26
27## perm
28```bash
29atm perm [-h] [-g -i <token-id> -p <permission-name>] [-c -i <token-id> -p <permission-name>]
30```
31
32**Parameters of the perm command**
33| Parameter                                              | Description                 |
34| -------------------------------------------------- | ---------------------- |
35| -h                                        | Displays help information.| Commands supported by the **atm perm** command.|
36| -g&nbsp;-i \<token-id\>&nbsp;-p \<permission-name\> | Grants a specified permission to an application based on the token ID of the application process. The **-g**, **-i**, and **-p** parameters are mandatory. The return value indicates whether the operation is successful.   |
37| -c&nbsp;-i \<token-id\>&nbsp;-p \<permission-name\> | Cancels a specified permission for an application based on the token ID of the application process. The **-c**, **-i**, and **-p** parameters are mandatory. The return value indicates whether the operation is successful.   |
38
39Example:
40
41```bash
42# Display the help information about the atm perm command.
43atm perm -h
44
45# Grant the camera permission to an application process.
46atm perm -g -i ********* -p ohos.permission.CAMERA
47
48# Revoke the camera permission for an application process.
49atm perm -c -i ********* -p ohos.permission.CAMERA
50```
51
52
53## toggle
54
55```bash
56atm toggle [-h] [-r -s -i <user-id> -p <permission-name> -k <status>] [-r -o -i <user-id> -p <permission-name>]
57```
58**Parameters of the toggle command**
59
60| Parameter                                                          | Description                               |
61| ----------------------------------------------------------------- | ----------------------------------- |
62| -h                                                     | Displays help information.             |
63| -r&nbsp;-s&nbsp;-i \<user-id\>&nbsp;-p \<permission-name\>&nbsp;-k \<status\> | Sets the toggle status (specified by status) of a specified permission of a specified user. The **-r**, **-s**, **-i**, **-p** and **-k** parameters are mandatory. The return value indicates whether the operation is successful.|
64| -r&nbsp;-o&nbsp;-i \<user-id\>&nbsp;-p \<permission-name\> | Obtains the toggle status of a specified permission for a specified user. The **-r**, **-o**, **-i**, and **-p** parameters are mandatory.|
65
66Example:
67
68```bash
69# Display the help information about the atm toggle command.
70atm toggle -h
71
72# Enable the camera permission for user 0.
73atm toggle -r -s -i 0 -p ohos.permission.CAMERA -k 1
74
75# Obtain the toggle state of the camera permission for user 0.
76atm toggle -r -o -i 0 -p ohos.permission.CAMERA
77```
78
79## toggle
80
81```bash
82atm toggle [-h] [-u -s -i <user-id> -k <status>] [-u -o -i <user-id>]
83```
84**Parameters of the toggle command**
85
86| Parameter                                                          | Description                               |
87| ----------------------------------------------------------------- | ----------------------------------- |
88| -h                                                     | Displays help information.             |
89| -u&nbsp;-s&nbsp;-i \<user-id\>&nbsp;-k \<status\> | Sets the toggle status (specified by **status**) of the permission usage records. The **-u**, **-s**, **-i** and **-k** parameters are mandatory. The return value indicates whether the operation is successful.|
90| -u&nbsp;-o&nbsp;-i \<user-id\>&nbsp; | Obtains the toggle status of the permission usage records for a specified user. The **-**, **-o**, and **-i** parameters are mandatory.|
91
92Example:
93
94```bash
95# Display the help information about the atm toggle command.
96atm toggle -h
97
98# Enable the toggle status of the permission usage records for user 0.
99atm toggle -u -s -i 0 -k 1
100
101# Obtain the toggle status of the permission usage records of user 0.
102atm toggle -u -o -i 0
103```
104
105<!--DelEnd-->
106
107
108## dump
109
110<!--RP1-->
111```bash
112atm dump [-h] [-t [-i <token-id>] [-b <bundle-name>] [-n <process-name>]] [-r [-i <token-id>] [-p <permission-name>]] [-v [-i <token-id>] [-p <permission-name>]]
113```
114<!--RP1End-->
115
116In the following commands, the **-t**, <!--Del-->**-r** <!--DelEnd-->and **-v** parameters are mandatory, and the *-i*, *-b*, *-n* and *-p* parameters are optional. For <!--Del-->**atm dump -r** and <!--DelEnd-->**atm dump -v**, the *-i* and *-p* parameters can be used together. For **atm dump -t**, the *-i*, *-b*, and *-n* parameters can only be used independently.
117
118| Parameter                                         | Description                                                |
119| ----------------------------------------------- | ---------------------------------------------------- |
120| -h                                     | Displays help information.                             |
121| -t                                     | Dumps information about all application processes in the system. This parameter is mandatory.                            |
122| -t&nbsp;-i \<token-id\>                     | Dumps the permission information of an application based on the token ID of the application process. This parameter is optional.            |
123| -t&nbsp;-b \<bundle-name\>                  |  Dumps the permission information of an application based on the bundle name of the application process. This parameter is optional.    |
124| -t&nbsp;-n \<process-name\>                 |  Dumps the permission information of an application based on the process name of the application process. This parameter is optional. |
125| <!--DelRow-->-r                        |  Dumps all permission usage records in the system. This parameter is mandatory.                          |
126| <!--DelRow-->-r&nbsp;-i \<token-id\>        | Dumps the permission usage records of an application based on the token ID of the application process. This parameter is optional.       |
127| <!--DelRow-->-r&nbsp;-p \<permission-name\> | Dumps the usage records of a permission with the specified permission name. This parameter is optional.                       |
128| -v                                     | Dumps the permission usage types of all application processes in the system. This parameter is mandatory.                   |
129| -v&nbsp;-i \<token-id\>                     | Dumps the permission usage types of an application based on the token ID of the application process. This parameter is optional.        |
130| -v&nbsp;-p \<permission-name\>              | Dumps the usage types of a permission with the specified permission name. This parameter is optional.                       |
131
132Example:
133
134```bash
135#Display the help information about the atm dump command.
136atm dump -h
137
138#Dump the token IDs and bundle names of all application processes in the system.
139atm dump -t
140
141#Dump the permission information based on the token ID.
142atm dump -t -i *********
143
144#Dump the permission information based on the bundle name.
145atm dump -t -b ohos.telephony.resources
146
147#Dump the permission information based on the process name.
148atm dump -t -n *********
149
150#Dump the permission types of all applications.
151atm dump -v
152
153#Dump the permission usage types based on the token ID.
154atm dump -v -i *********
155
156#Dump the permission usage types based on the permission name.
157atm dump -v -p ohos.permission.CAMERA
158
159#Dump the permission usage types based on the token ID and permission name.
160atm dump -v -i ********* -p ohos.permission.CAMERA
161```
162
163<!--Del-->
164```bash
165#Dump all permission usage records in the system.
166atm dump -r
167
168#Dump the permission usage records based on the token ID.
169atm dump -r -i *********
170
171#Dump the permission usage records based on the permission name.
172atm dump -r -p ohos.permission.CAMERA
173
174#Dump the permission usage records based on the token ID and permission name.
175atm dump -r -i ********* -p ohos.permission.CAMERA
176```
177<!--DelEnd-->
178