• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.privacyManager (隐私管理)(系统接口)
2
3本模块主要提供权限使用记录等隐私管理接口。
4
5> **说明:**
6>
7> - 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8> - 本模块为系统接口。
9
10## 导入模块
11
12```ts
13import { privacyManager } from '@kit.AbilityKit';
14```
15
16
17## privacyManager.addPermissionUsedRecord
18
19addPermissionUsedRecord(tokenID: number, permissionName: Permissions, successCount: number, failCount: number, options?: AddPermissionUsedRecordOptions): Promise<void>
20
21受应用权限保护的应用在被其他服务、应用调用时,可以使用该接口增加一条权限使用记录。使用Promise异步回调。
22权限使用记录包括:调用方的应用身份标识、使用的应用权限名称,和其访问本应用成功、失败的次数。
23
24**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。
25
26**系统能力:** SystemCapability.Security.AccessToken
27
28**参数:**
29
30| 参数名   | 类型                 | 必填 | 说明                                       |
31| -------- | -------------------  | ---- | ------------------------------------------ |
32| tokenID   |  number   | 是   | 调用方的应用身份标识。可通过应用的[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)的accessTokenId字段获得。|
33| permissionName | Permissions | 是   | 应用权限名称。 |
34| successCount | number | 是   | 访问成功的次数。 |
35| failCount | number | 是   | 访问失败的次数。 |
36| options<sup>12+</sup> | [AddPermissionUsedRecordOptions](#addpermissionusedrecordoptions12) | 否   | 添加权限使用记录可选参数,从API version 12开始支持。 |
37
38**返回值:**
39
40| 类型          | 说明                                |
41| :------------ | :---------------------------------- |
42| Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。 |
43
44**错误码:**
45
46以下错误码的详细介绍请参见[访问控制错误码](errorcode-access-token.md)。
47
48| 错误码ID | 错误信息 |
49| -------- | -------- |
50| 201 | Permission denied. Interface caller does not have permission. |
51| 202 | Not System App. Interface caller is not a system app. |
52| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
53| 12100001 | Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters, the count value is invalid, or usedType in AddPermissionUsedRecordOptions is invalid. |
54| 12100002 | The specified tokenID does not exist or refer to an application process. |
55| 12100003 | The specified permission does not exist or is not an user_grant permission. |
56| 12100007 | The service is abnormal. |
57| 12100008 | Out of memory. |
58
59**示例:**
60
61```ts
62import { privacyManager } from '@kit.AbilityKit';
63import { BusinessError } from '@kit.BasicServicesKit';
64
65let tokenID: number = 0; // 可以通过getApplicationInfo获取accessTokenId
66privacyManager.addPermissionUsedRecord(tokenID, 'ohos.permission.READ_AUDIO', 1, 0).then(() => {
67  console.log('addPermissionUsedRecord success');
68}).catch((err: BusinessError) => {
69  console.error(`addPermissionUsedRecord fail, err->${JSON.stringify(err)}`);
70});
71// with options param
72let options: privacyManager.AddPermissionUsedRecordOptions = {
73  usedType: privacyManager.PermissionUsedType.PICKER_TYPE
74};
75privacyManager.addPermissionUsedRecord(tokenID, 'ohos.permission.READ_AUDIO', 1, 0, options).then(() => {
76  console.log('addPermissionUsedRecord success');
77}).catch((err: BusinessError) => {
78  console.error(`addPermissionUsedRecord fail, err->${JSON.stringify(err)}`);
79});
80```
81
82## privacyManager.addPermissionUsedRecord
83
84addPermissionUsedRecord(tokenID: number, permissionName: Permissions, successCount: number, failCount: number, callback: AsyncCallback&lt;void&gt;): void
85
86受应用权限保护的应用在被其他服务、应用调用时,可以使用该接口增加一条权限使用记录。使用callback异步回调。
87权限使用记录包括:调用方的应用身份标识、使用的应用权限名称,和其访问本应用成功、失败的次数。
88
89**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。
90
91**系统能力:** SystemCapability.Security.AccessToken
92
93**参数:**
94
95| 参数名   | 类型                 | 必填 | 说明                                       |
96| -------- | -------------------  | ---- | ------------------------------------------ |
97| tokenID   |  number   | 是   | 调用方的应用身份标识。可通过应用的[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)的accessTokenId字段获得。|
98| permissionName | Permissions | 是   | 应用权限名称,合法的权限名取值可在[应用权限列表](../../security/AccessToken/app-permissions.md)中查询。 |
99| successCount | number | 是   | 访问成功的次数。 |
100| failCount | number | 是   | 访问失败的次数。 |
101| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。当添加使用记录成功时,err为undefined;否则为错误对象。 |
102
103**错误码:**
104
105以下错误码的详细介绍请参见[访问控制错误码](errorcode-access-token.md)。
106
107| 错误码ID | 错误信息 |
108| -------- | -------- |
109| 201 | Permission denied. Interface caller does not have permission. |
110| 202 | Not System App. Interface caller is not a system app. |
111| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
112| 12100001 | Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters, or the count value is invalid. |
113| 12100002 | The specified tokenID does not exist or refer to an application process. |
114| 12100003 | The specified permission does not exist or is not an user_grant permission. |
115| 12100007 | The service is abnormal. |
116| 12100008 | Out of memory. |
117
118**示例:**
119
120```ts
121import { privacyManager } from '@kit.AbilityKit';
122import { BusinessError } from '@kit.BasicServicesKit';
123
124let tokenID: number = 0; // 可以通过getApplicationInfo获取accessTokenId
125privacyManager.addPermissionUsedRecord(tokenID, 'ohos.permission.READ_AUDIO', 1, 0, (err: BusinessError, data: void) => {
126  if (err) {
127    console.error(`addPermissionUsedRecord fail, err->${JSON.stringify(err)}`);
128  } else {
129    console.log('addPermissionUsedRecord success');
130  }
131});
132```
133
134## privacyManager.getPermissionUsedRecord
135
136getPermissionUsedRecord(request: PermissionUsedRequest): Promise&lt;PermissionUsedResponse&gt;
137
138获取历史权限使用记录。使用Promise异步回调。
139
140**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。
141
142**系统能力:** SystemCapability.Security.AccessToken
143
144**参数:**
145
146| 参数名   | 类型                 | 必填 | 说明                                       |
147| -------- | -------------------  | ---- | ------------------------------------------ |
148| request   |  [PermissionUsedRequest](#permissionusedrequest)   | 是   | 查询权限使用记录的请求。              |
149
150**返回值:**
151
152| 类型          | 说明                                |
153| :------------ | :---------------------------------- |
154| Promise<[PermissionUsedResponse](#permissionusedresponse)> | Promise对象。返回查询的权限使用记录。|
155
156**错误码:**
157
158以下错误码的详细介绍请参见[访问控制错误码](errorcode-access-token.md)。
159
160| 错误码ID | 错误信息 |
161| -------- | -------- |
162| 201 | Permission denied. Interface caller does not have permission. |
163| 202 | Not System App. Interface caller is not a system app. |
164| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
165| 12100001 | Invalid parameter. The value of flag in request is invalid. |
166| 12100002 | The specified tokenID does not exist or refer to an application process. |
167| 12100003 | The specified permission does not exist or is not an user_grant permission. |
168| 12100007 | The service is abnormal. |
169| 12100008 | Out of memory. |
170
171**示例:**
172
173```ts
174import { privacyManager } from '@kit.AbilityKit';
175import { BusinessError } from '@kit.BasicServicesKit';
176
177let request: privacyManager.PermissionUsedRequest = {
178    'tokenId': 1,
179    'isRemote': false,
180    'deviceId': 'device',
181    'bundleName': 'bundle',
182    'permissionNames': [],
183    'beginTime': 0,
184    'endTime': 1,
185    'flag':privacyManager.PermissionUsageFlag.FLAG_PERMISSION_USAGE_DETAIL,
186};
187
188privacyManager.getPermissionUsedRecord(request).then((data) => {
189  console.log(`getPermissionUsedRecord success, data->${JSON.stringify(data)}`);
190}).catch((err: BusinessError) => {
191  console.error(`getPermissionUsedRecord fail, err->${JSON.stringify(err)}`);
192});
193```
194
195## privacyManager.getPermissionUsedRecord
196
197getPermissionUsedRecord(request: PermissionUsedRequest, callback: AsyncCallback&lt;PermissionUsedResponse&gt;): void
198
199获取历史权限使用记录。使用callback异步回调。
200
201**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。
202
203**系统能力:** SystemCapability.Security.AccessToken
204
205**参数:**
206
207| 参数名   | 类型                 | 必填 | 说明                                       |
208| -------- | -------------------  | ---- | ------------------------------------------ |
209| request | [PermissionUsedRequest](#permissionusedrequest) | 是 | 查询权限使用记录的请求。 |
210| callback | AsyncCallback<[PermissionUsedResponse](#permissionusedresponse)> | 是 | 回调函数。当查询记录成功时,err为undefined,data为查询到的权限使用记录;否则为错误对象。 |
211
212**错误码:**
213
214以下错误码的详细介绍请参见[访问控制错误码](errorcode-access-token.md)。
215
216| 错误码ID | 错误信息 |
217| -------- | -------- |
218| 201 | Permission denied. Interface caller does not have permission. |
219| 202 | Not System App. Interface caller is not a system app. |
220| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
221| 12100001 | Invalid parameter. The value of flag in request is invalid. |
222| 12100002 | The specified tokenID does not exist or refer to an application process. |
223| 12100003 | The specified permission does not exist or is not an user_grant permission. |
224| 12100007 | The service is abnormal. |
225| 12100008 | Out of memory. |
226
227**示例:**
228
229```ts
230import { privacyManager } from '@kit.AbilityKit';
231import { BusinessError } from '@kit.BasicServicesKit';
232
233let request: privacyManager.PermissionUsedRequest = {
234    'tokenId': 1,
235    'isRemote': false,
236    'deviceId': 'device',
237    'bundleName': 'bundle',
238    'permissionNames': [],
239    'beginTime': 0,
240    'endTime': 1,
241    'flag':privacyManager.PermissionUsageFlag.FLAG_PERMISSION_USAGE_DETAIL,
242};
243
244privacyManager.getPermissionUsedRecord(request, (err: BusinessError, data: privacyManager.PermissionUsedResponse) => {
245  if (err) {
246    console.error(`getPermissionUsedRecord fail, err->${JSON.stringify(err)}`);
247  } else {
248    console.log(`getPermissionUsedRecord success, data->${JSON.stringify(data)}`);
249  }
250});
251```
252
253## privacyManager.setPermissionUsedRecordToggleStatus<sup>18+</sup>
254
255setPermissionUsedRecordToggleStatus(status: boolean): Promise&lt;void&gt;
256
257设置是否记录当前用户的权限使用情况。系统应用调用此接口,可以设置当前用户的权限使用记录开关状态,使用Promise异步回调。
258
259status为true时,[addPermissionUsedRecord](#privacymanageraddpermissionusedrecord)接口可以正常添加使用记录;status为false时,[addPermissionUsedRecord](#privacymanageraddpermissionusedrecord)接口不记录权限使用记录,并且删除当前用户的历史记录。
260
261**需要权限:** ohos.permission.PERMISSION_RECORD_TOGGLE,仅系统应用可用。
262
263**系统能力:** SystemCapability.Security.AccessToken
264
265**参数:**
266
267| 参数名          | 类型   | 必填 | 说明                                  |
268| -------------- | ------ | ---- | ------------------------------------ |
269| status        | boolean | 是   | 权限使用记录开关状态。true为开,false为关。|
270
271**返回值:**
272
273| 类型          | 说明                                    |
274| ------------- | --------------------------------------- |
275| Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。|
276
277**错误码:**
278
279以下错误码的详细介绍请参见[访问控制错误码](errorcode-access-token.md)。
280
281| 错误码ID | 错误信息 |
282| -------- | -------- |
283| 201 | Permission denied. Interface caller does not have permission. |
284| 202 | Not System App. Interface caller is not a system app. |
285| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
286| 12100007 | The service is abnormal. |
287| 12100009 | Common inner error. |
288
289**示例:**
290
291```ts
292import { privacyManager } from '@kit.AbilityKit';
293import { BusinessError } from '@kit.BasicServicesKit';
294
295privacyManager.setPermissionUsedRecordToggleStatus(true).then(() => {
296  console.log('setPermissionUsedRecordToggleStatus success');
297}).catch((err: BusinessError) => {
298  console.error(`setPermissionUsedRecordToggleStatus fail, err->${JSON.stringify(err)}`);
299});
300```
301
302## privacyManager.getPermissionUsedRecordToggleStatus<sup>18+</sup>
303
304getPermissionUsedRecordToggleStatus(): Promise&lt;boolean&gt;
305
306系统应用调用此接口,可以获取当前用户的权限使用记录开关状态,使用Promise异步回调。
307
308**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。
309
310**系统能力:** SystemCapability.Security.AccessToken
311
312**返回值:**
313
314| 类型          | 说明                                    |
315| ------------- | --------------------------------------- |
316| Promise&lt;boolean&gt; | Promise对象。返回当前用户的开关状态值。|
317
318**错误码:**
319
320以下错误码的详细介绍请参见[访问控制错误码](errorcode-access-token.md)。
321
322| 错误码ID | 错误信息 |
323| -------- | -------- |
324| 201 | Permission denied. Interface caller does not have permission. |
325| 202 | Not System App. Interface caller is not a system app. |
326| 12100007 | The service is abnormal. |
327
328**示例:**
329
330```ts
331import { privacyManager } from '@kit.AbilityKit';
332import { BusinessError } from '@kit.BasicServicesKit';
333
334privacyManager.getPermissionUsedRecordToggleStatus().then((res) => {
335  console.log('getPermissionUsedRecordToggleStatus success');
336  if (res == true) {
337    console.log('get status is TRUE');
338  } else {
339    console.log('get status is FALSE');
340  }
341}).catch((err: BusinessError) => {
342  console.error(`getPermissionUsedRecordToggleStatus fail, err->${JSON.stringify(err)}`);
343});
344```
345
346## privacyManager.startUsingPermission
347
348startUsingPermission(tokenID: number, permissionName: Permissions): Promise&lt;void&gt;
349
350系统应用调用此接口,能够传递应用在前后台的权限使用情况,并依据应用的生命周期做出相应的响应。使用Promise异步回调。
351
352当应用开始使用某项权限时,隐私服务将通知隐私指示器该应用正在使用该权限;当应用退出时,隐私服务将通知隐私指示器该应用已停止使用该权限,并清除相应的缓存。
353
354**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。
355
356**系统能力:** SystemCapability.Security.AccessToken
357
358**参数:**
359
360| 参数名          | 类型   | 必填 | 说明                                  |
361| -------------- | ------ | ---- | ------------------------------------ |
362| tokenID        | number | 是   | 调用方的应用身份标识。可通过应用的[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)的accessTokenId字段获得。|
363| permissionName | Permissions | 是   | 需要使用的权限名,合法的权限名取值可在[应用权限列表](../../security/AccessToken/app-permissions.md)中查询。|
364
365**返回值:**
366
367| 类型          | 说明                                    |
368| ------------- | --------------------------------------- |
369| Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。|
370
371**错误码:**
372
373以下错误码的详细介绍请参见[访问控制错误码](errorcode-access-token.md)。
374
375| 错误码ID | 错误信息 |
376| -------- | -------- |
377| 201 | Permission denied. Interface caller does not have permission. |
378| 202 | Not System App. Interface caller is not a system app. |
379| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
380| 12100001 | Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters, or the count value is invalid. |
381| 12100002 | The specified tokenID does not exist or refer to an application process. |
382| 12100003 | The specified permission does not exist or is not an user_grant permission. |
383| 12100004 | The API is used repeatedly with the same input. It means the application specified by the tokenID has been using the specified permission. |
384| 12100007 | The service is abnormal. |
385| 12100008 | Out of memory. |
386
387**示例:**
388
389```ts
390import { privacyManager } from '@kit.AbilityKit';
391import { BusinessError } from '@kit.BasicServicesKit';
392
393let tokenID: number = 0; // 可以通过getApplicationInfo获取accessTokenId
394privacyManager.startUsingPermission(tokenID, 'ohos.permission.READ_AUDIO').then(() => {
395  console.log('startUsingPermission success');
396}).catch((err: BusinessError) => {
397  console.error(`startUsingPermission fail, err->${JSON.stringify(err)}`);
398});
399```
400
401## privacyManager.startUsingPermission<sup>18+</sup>
402
403startUsingPermission(tokenID: number, permissionName: Permissions, pid?: number, usedType?: PermissionUsedType): Promise&lt;void&gt;
404
405系统应用调用此接口,能够传递应用在前后台的权限使用情况,并依据应用的生命周期做出相应的响应。使用Promise异步回调。
406
407当应用按照某种权限授予方式使用权限时,隐私服务将通知隐私指示器该应用正在使用该权限;当应用退出时,隐私服务将通知隐私指示器该应用已停止使用该权限,并清除相应的缓存。
408
409在传递多进程应用的权限使用情况时,可以指定应用进程的pid。若未指定pid,默认按应用响应,在应用退出时,隐私服务通知隐私指示器并清除缓存。
410
411若指定了pid,当该进程退出时,隐私服务通知隐私指示器并清除缓存,此时pid必须为tokenID对应应用的进程pid,不能为其他应用的pid。
412
413**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。
414
415**系统能力:** SystemCapability.Security.AccessToken
416
417**参数:**
418
419| 参数名          | 类型   | 必填 | 说明                                  |
420| -------------- | ------ | ---- | ------------------------------------ |
421| tokenID        | number | 是   | 调用方的应用身份标识。可通过应用的[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)的accessTokenId字段获得。|
422| permissionName | Permissions | 是   | 需要使用的权限名,合法的权限名取值可在[应用权限列表](../../security/AccessToken/app-permissions.md)中查询。|
423| pid            | number | 否   | 调用方的进程pid,默认-1,-1表示不根据进程生命周期响应。|
424| usedType       | [PermissionUsedType](#permissionusedtype12) | 否 | 敏感权限访问方式,默认NORMAL_TYPE。 |
425
426**返回值:**
427
428| 类型          | 说明                                    |
429| ------------- | --------------------------------------- |
430| Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。|
431
432**错误码:**
433
434以下错误码的详细介绍请参见[访问控制错误码](errorcode-access-token.md)。
435
436| 错误码ID | 错误信息 |
437| -------- | -------- |
438| 201 | Permission denied. Interface caller does not have permission. |
439| 202 | Not System App. Interface caller is not a system app. |
440| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
441| 12100001 | Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters, or the count value is invalid. |
442| 12100002 | The specified tokenID does not exist or refer to an application process. |
443| 12100003 | The specified permission does not exist or is not an user_grant permission. |
444| 12100004 | The API is used repeatedly with the same input. It means the application specified by the tokenID has been using the specified permission. |
445| 12100007 | The service is abnormal. |
446| 12100008 | Out of memory. |
447
448**示例:**
449
450```ts
451import { privacyManager } from '@kit.AbilityKit';
452import { BusinessError } from '@kit.BasicServicesKit';
453import { rpc } from '@kit.IPCKit'
454
455let tokenID: number = rpc.IPCSkeleton.getCallingTokenId(); // 也可以通过bundleManager.getBundleInfoForSelfSync获取accessTokenId
456let pid: number = rpc.IPCSkeleton.getCallingPid();
457let usedType: privacyManager.PermissionUsedType = privacyManager.PermissionUsedType.PICKER_TYPE;
458
459// without pid and usedType
460privacyManager.startUsingPermission(tokenID, 'ohos.permission.READ_AUDIO').then(() => {
461  console.log('startUsingPermission success');
462}).catch((err: BusinessError) => {
463  console.error(`startUsingPermission fail, err->${JSON.stringify(err)}`);
464});
465// with pid
466privacyManager.startUsingPermission(tokenID, 'ohos.permission.READ_AUDIO', pid).then(() => {
467  console.log('startUsingPermission success');
468}).catch((err: BusinessError) => {
469  console.error(`startUsingPermission fail, err->${JSON.stringify(err)}`);
470});
471// with usedType
472privacyManager.startUsingPermission(tokenID, 'ohos.permission.READ_AUDIO', -1, usedType).then(() => {
473  console.log('startUsingPermission success');
474}).catch((err: BusinessError) => {
475  console.error(`startUsingPermission fail, err->${JSON.stringify(err)}`);
476});
477// with pid and usedType
478privacyManager.startUsingPermission(tokenID, 'ohos.permission.READ_AUDIO', pid, usedType).then(() => {
479  console.log('startUsingPermission success');
480}).catch((err: BusinessError) => {
481  console.error(`startUsingPermission fail, err->${JSON.stringify(err)}`);
482});
483```
484
485## privacyManager.startUsingPermission
486
487startUsingPermission(tokenID: number, permissionName: Permissions, callback: AsyncCallback&lt;void&gt;): void
488
489系统应用调用此接口,能够传递应用在前后台的权限使用情况,并依据应用的生命周期做出相应的响应。使用callback异步回调。
490
491当应用开始使用某项权限时,隐私服务将通知隐私指示器该应用正在使用该权限;当应用退出时,隐私服务将通知隐私指示器该应用已停止使用该权限,并清除相应的缓存。
492
493**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。
494
495**系统能力:** SystemCapability.Security.AccessToken
496
497**参数:**
498
499| 参数名          | 类型                  | 必填 | 说明                                  |
500| -------------- | --------------------- | ---- | ------------------------------------ |
501| tokenID        | number                | 是   | 调用方的应用身份标识。可通过应用的[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)的accessTokenId字段获得。|
502| permissionName | Permissions                | 是   | 需要使用的权限名,合法的权限名取值可在[应用权限列表](../../security/AccessToken/app-permissions.md)中查询。|
503| callback       | AsyncCallback&lt;void&gt; | 是   | 回调函数。当开始使用权限成功时,err为undefined;否则为错误对象。 |
504
505**错误码:**
506
507以下错误码的详细介绍请参见[访问控制错误码](errorcode-access-token.md)。
508
509| 错误码ID | 错误信息 |
510| -------- | -------- |
511| 201 | Permission denied. Interface caller does not have permission. |
512| 202 | Not System App. Interface caller is not a system app. |
513| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
514| 12100001 | Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters, or the count value is invalid. |
515| 12100002 | The specified tokenID does not exist or refer to an application process. |
516| 12100003 | The specified permission does not exist or is not an user_grant permission. |
517| 12100004 | The API is used repeatedly with the same input. It means the application specified by the tokenID has been using the specified permission. |
518| 12100007 | The service is abnormal. |
519| 12100008 | Out of memory. |
520
521**示例:**
522
523```ts
524import { privacyManager } from '@kit.AbilityKit';
525import { BusinessError } from '@kit.BasicServicesKit';
526
527let tokenID: number = 0; // 可以通过getApplicationInfo获取accessTokenId
528privacyManager.startUsingPermission(tokenID, 'ohos.permission.READ_AUDIO', (err: BusinessError, data: void) => {
529  if (err) {
530    console.error(`startUsingPermission fail, err->${JSON.stringify(err)}`);
531  } else {
532    console.log('startUsingPermission success');
533  }
534});
535```
536
537## privacyManager.stopUsingPermission
538
539stopUsingPermission(tokenID: number, permissionName: Permissions): Promise&lt;void&gt;
540
541应用停止使用某项权限,与Start对应,由系统服务调用。使用Promise异步回调。
542
543**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。
544
545**系统能力:** SystemCapability.Security.AccessToken
546
547**参数:**
548
549| 参数名          | 类型   | 必填 | 说明                                  |
550| -------------- | ------ | ---- | ------------------------------------ |
551| tokenID        | number | 是   | 调用方的应用身份标识。可通过应用的[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)的accessTokenId字段获得。|
552| permissionName | Permissions | 是   | 需要使用的权限名,合法的权限名取值可在[应用权限列表](../../security/AccessToken/app-permissions.md)中查询。|
553
554**返回值:**
555
556| 类型          | 说明                                    |
557| ------------- | --------------------------------------- |
558| Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。|
559
560**错误码:**
561
562以下错误码的详细介绍请参见[访问控制错误码](errorcode-access-token.md)。
563
564| 错误码ID | 错误信息 |
565| -------- | -------- |
566| 201 | Permission denied. Interface caller does not have permission. |
567| 202 | Not System App. Interface caller is not a system app. |
568| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
569| 12100001 | Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters, or the count value is invalid. |
570| 12100002 | The specified tokenID does not exist or refer to an application process. |
571| 12100003 | The specified permission does not exist or is not an user_grant permission. |
572| 12100004 | The API is not used in pair with 'startUsingPermission'. |
573| 12100007 | The service is abnormal. |
574| 12100008 | Out of memory. |
575
576**示例:**
577
578```ts
579import { privacyManager } from '@kit.AbilityKit';
580import { BusinessError } from '@kit.BasicServicesKit';
581
582let tokenID: number = 0; // 可以通过getApplicationInfo获取accessTokenId
583privacyManager.stopUsingPermission(tokenID, 'ohos.permission.READ_AUDIO').then(() => {
584  console.log('stopUsingPermission success');
585}).catch((err: BusinessError) => {
586  console.error(`stopUsingPermission fail, err->${JSON.stringify(err)}`);
587});
588```
589
590## privacyManager.stopUsingPermission<sup>18+</sup>
591
592stopUsingPermission(tokenID: number, permissionName: Permissions, pid?: number): Promise&lt;void&gt;
593
594应用停止使用某项权限,与Start对应,由系统服务调用。使用Promise异步回调。
595
596pid需要与startUsingPermission传入的pid相同。
597
598**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。
599
600**系统能力:** SystemCapability.Security.AccessToken
601
602**参数:**
603
604| 参数名          | 类型   | 必填 | 说明                                  |
605| -------------- | ------ | ---- | ------------------------------------ |
606| tokenID        | number | 是   | 调用方的应用身份标识。可通过应用的[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)的accessTokenId字段获得。|
607| permissionName | Permissions | 是   | 需要使用的权限名,合法的权限名取值可在[应用权限列表](../../security/AccessToken/app-permissions.md)中查询。|
608| pid            | number | 否   | 与startUsingPermission传入的pid相同,默认-1。|
609
610**返回值:**
611
612| 类型          | 说明                                    |
613| ------------- | --------------------------------------- |
614| Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。|
615
616**错误码:**
617
618以下错误码的详细介绍请参见[访问控制错误码](errorcode-access-token.md)。
619
620| 错误码ID | 错误信息 |
621| -------- | -------- |
622| 201 | Permission denied. Interface caller does not have permission. |
623| 202 | Not System App. Interface caller is not a system app. |
624| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
625| 12100001 | Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters, or the count value is invalid. |
626| 12100002 | The specified tokenID does not exist or refer to an application process. |
627| 12100003 | The specified permission does not exist or is not an user_grant permission. |
628| 12100004 | The API is not used in pair with 'startUsingPermission'. |
629| 12100007 | The service is abnormal. |
630| 12100008 | Out of memory. |
631
632**示例:**
633
634```ts
635import { privacyManager } from '@kit.AbilityKit';
636import { BusinessError } from '@kit.BasicServicesKit';
637import { rpc } from '@kit.IPCKit'
638
639let tokenID: number = rpc.IPCSkeleton.getCallingTokenId(); // 也可以通过bundleManager.getBundleInfoForSelfSync获取accessTokenId
640let pid: number = rpc.IPCSkeleton.getCallingPid();
641
642// without pid
643privacyManager.stopUsingPermission(tokenID, 'ohos.permission.READ_AUDIO').then(() => {
644  console.log('stopUsingPermission success');
645}).catch((err: BusinessError) => {
646  console.error(`stopUsingPermission fail, err->${JSON.stringify(err)}`);
647});
648
649// with pid
650privacyManager.stopUsingPermission(tokenID, 'ohos.permission.READ_AUDIO', pid).then(() => {
651  console.log('stopUsingPermission success');
652}).catch((err: BusinessError) => {
653  console.error(`stopUsingPermission fail, err->${JSON.stringify(err)}`);
654});
655```
656
657## privacyManager.stopUsingPermission
658
659stopUsingPermission(tokenID: number, permissionName: Permissions, callback: AsyncCallback&lt;void&gt;): void
660
661应用停止使用某项权限,与Start对应,由系统服务调用。使用callback异步回调。
662
663**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。
664
665**系统能力:** SystemCapability.Security.AccessToken
666
667**参数:**
668
669| 参数名          | 类型                  | 必填 | 说明                                  |
670| -------------- | --------------------- | ---- | ------------------------------------ |
671| tokenID        | number                | 是   | 调用方的应用身份标识。可通过应用的[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)的accessTokenId字段获得。|
672| permissionName | Permissions                | 是   | 需要使用的权限名,合法的权限名取值可在[应用权限列表](../../security/AccessToken/app-permissions.md)中查询。|
673| callback       | AsyncCallback&lt;void&gt; | 是   | 回调函数。当停止使用权限成功时,err为undefined;否则为错误对象。 |
674
675**错误码:**
676
677以下错误码的详细介绍请参见[访问控制错误码](errorcode-access-token.md)。
678
679| 错误码ID | 错误信息 |
680| -------- | -------- |
681| 201 | Permission denied. Interface caller does not have permission. |
682| 202 | Not System App. Interface caller is not a system app. |
683| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
684| 12100001 | Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters, or the count value is invalid. |
685| 12100002 | The specified tokenID does not exist or refer to an application process. |
686| 12100003 | The specified permission does not exist or is not an user_grant permission. |
687| 12100004 | The API is not used in pair with 'startUsingPermission'. |
688| 12100007 | The service is abnormal. |
689| 12100008 | Out of memory. |
690
691**示例:**
692
693```ts
694import { privacyManager } from '@kit.AbilityKit';
695import { BusinessError } from '@kit.BasicServicesKit';
696
697let tokenID: number = 0; // 可以通过getApplicationInfo获取accessTokenId
698privacyManager.stopUsingPermission(tokenID, 'ohos.permission.READ_AUDIO', (err: BusinessError, data: void) => {
699  if (err) {
700    console.error(`stopUsingPermission fail, err->${JSON.stringify(err)}`);
701  } else {
702    console.log('stopUsingPermission success');
703  }
704});
705```
706
707## privacyManager.on
708
709on(type: 'activeStateChange', permissionList: Array&lt;Permissions&gt;, callback: Callback&lt;ActiveChangeResponse&gt;): void
710
711订阅指定权限列表的权限使用状态变更事件。
712
713允许相同permissionList订阅多个callback。
714
715不允许存在交集的permissionList订阅相同callback。
716
717**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。
718
719**系统能力:** SystemCapability.Security.AccessToken
720
721**参数:**
722
723| 参数名             | 类型                   | 必填 | 说明                                                          |
724| ------------------ | --------------------- | ---- | ------------------------------------------------------------ |
725| type               | string                | 是   | 订阅事件类型,固定为'activeStateChange',权限使用状态变更事件。   |
726| permissionList | Array&lt;Permissions&gt;   | 是   | 订阅的权限名列表,为空时表示订阅所有的权限使用状态变化,合法的权限名取值可在[应用权限列表](../../security/AccessToken/app-permissions.md)中查询。|
727| callback | Callback&lt;[ActiveChangeResponse](#activechangeresponse)&gt; | 是 | 订阅指定权限使用状态变更事件的回调。 |
728
729**错误码:**
730
731以下错误码的详细介绍请参见[访问控制错误码](errorcode-access-token.md)。
732
733| 错误码ID | 错误信息 |
734| -------- | -------- |
735| 201 | Permission denied. Interface caller does not have permission. |
736| 202 | Not System App. Interface caller is not a system app. |
737| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
738| 12100001 | Invalid parameter. The tokenID is 0, or the permissionName exceeds 256 characters. |
739| 12100004 | The API is used repeatedly with the same input. |
740| 12100005 | The registration time has exceeded the limitation. |
741| 12100007 | The service is abnormal. |
742| 12100008 | Out of memory. |
743
744**示例:**
745
746```ts
747import { privacyManager, Permissions } from '@kit.AbilityKit';
748import { BusinessError } from '@kit.BasicServicesKit';
749
750let permissionList: Array<Permissions> = [];
751try {
752    privacyManager.on('activeStateChange', permissionList, (data: privacyManager.ActiveChangeResponse) => {
753        console.debug('receive permission state change, data:' + JSON.stringify(data));
754    });
755} catch(err) {
756    console.error(`catch err->${JSON.stringify(err)}`);
757}
758```
759
760## privacyManager.off
761
762off(type: 'activeStateChange', permissionList: Array&lt;Permissions&gt;, callback?: Callback&lt;ActiveChangeResponse&gt;): void
763
764取消订阅指定权限列表的权限使用状态变更事件。
765
766取消订阅不传callback时,批量删除permissionList下面的所有callback。
767
768**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。
769
770**系统能力:** SystemCapability.Security.AccessToken
771
772**参数:**
773
774| 参数名             | 类型                   | 必填 | 说明                                                          |
775| ------------------ | --------------------- | ---- | ------------------------------------------------------------ |
776| type               | string                | 是   | 取消订阅事件类型,固定为'activeStateChange',权限使用状态变更事件。   |
777| permissionList | Array&lt;Permissions&gt;   | 是   | 取消订阅的权限名列表,为空时表示订阅所有的权限状态变化,必须与on的输入一致,合法的权限名取值可在[应用权限列表](../../security/AccessToken/app-permissions.md)中查询。|
778| callback | Callback&lt;[ActiveChangeResponse](#activechangeresponse)&gt; | 否 | 取消订阅指定tokenId与指定权限名状态变更事件的回调。|
779
780**错误码:**
781
782以下错误码的详细介绍请参见[访问控制错误码](errorcode-access-token.md)。
783
784| 错误码ID | 错误信息 |
785| -------- | -------- |
786| 201 | Permission denied. Interface caller does not have permission. |
787| 202 | Not System App. Interface caller is not a system app. |
788| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
789| 12100001 | Invalid parameter. The permissionNames in the list are all invalid, or the list size exceeds 1024 bytes. |
790| 12100004 | The API is not used in pair with 'on'. |
791| 12100007 | The service is abnormal. |
792| 12100008 | Out of memory. |
793
794**示例:**
795
796```ts
797import { privacyManager, Permissions } from '@kit.AbilityKit';
798
799let permissionList: Array<Permissions> = [];
800try {
801    privacyManager.off('activeStateChange', permissionList);
802} catch(err) {
803    console.error(`catch err->${JSON.stringify(err)}`);
804}
805```
806
807## privacyManager.getPermissionUsedTypeInfos<sup>12+</sup>
808
809getPermissionUsedTypeInfos(tokenId?: number, permissionName?: Permissions): Promise&lt;Array&lt;PermissionUsedTypeInfo&gt;&gt;
810
811查询设备上指定应用访问敏感权限时的信息(包括敏感权限名称、敏感权限访问方式)。
812
813**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。
814
815**系统能力:** SystemCapability.Security.AccessToken
816
817**参数:**
818
819| 参数名             | 类型                   | 必填 | 说明                                                          |
820| ------------------ | --------------------- | ---- | ------------------------------------------------------------ |
821| tokenId            | number                | 否   | 访问敏感权限的应用身份标识,为空时表示查询所有应用的敏感权限访问类型信息。   |
822| permissionName     | Permissions           | 否   | 被访问的敏感权限名称,为空时标识查询所有敏感权限的访问类型信息。   |
823
824**返回值:**
825
826| 类型          | 说明                                    |
827| ------------- | --------------------------------------- |
828| Promise&lt;Array&lt;[PermissionUsedTypeInfo](#permissionusedtypeinfo12)&gt;&gt; | Promise对象。返回权限访问类型信息列表的Promise对象。|
829
830**错误码:**
831
832以下错误码的详细介绍请参见[访问控制错误码](errorcode-access-token.md)。
833
834| 错误码ID | 错误信息 |
835| -------- | -------- |
836| 201 | Permission denied. Interface caller does not have permission. |
837| 202 | Not System App. Interface caller is not a system app. |
838| 401 | Parameter error. Possible causes: 1.Incorrect parameter types. |
839| 12100001 | Invalid parameter. PermissionName exceeds 256 characters. |
840| 12100002 | The input tokenId does not exist. |
841| 12100003 | The input permissionName does not exist. |
842
843**示例:**
844
845```ts
846import { privacyManager, Permissions } from '@kit.AbilityKit';
847import { BusinessError } from '@kit.BasicServicesKit';
848
849let tokenId: number = 0; // 可以通过bundleManager.getApplicationInfo获取accessTokenId
850let permissionName: Permissions = 'ohos.permission.CAMERA';
851// without any param
852privacyManager.getPermissionUsedTypeInfos().then(() => {
853  console.log('getPermissionUsedTypeInfos success');
854}).catch((err: BusinessError) => {
855  console.error(`getPermissionUsedTypeInfos fail, err->${JSON.stringify(err)}`);
856});
857// only tokenId
858privacyManager.getPermissionUsedTypeInfos(tokenId).then(() => {
859  console.log('getPermissionUsedTypeInfos success');
860}).catch((err: BusinessError) => {
861  console.error(`getPermissionUsedTypeInfos fail, err->${JSON.stringify(err)}`);
862});
863// only permissionName
864privacyManager.getPermissionUsedTypeInfos(null, permissionName).then(() => {
865  console.log('getPermissionUsedTypeInfos success');
866}).catch((err: BusinessError) => {
867  console.error(`getPermissionUsedTypeInfos fail, err->${JSON.stringify(err)}`);
868});
869// tokenId and permissionName
870privacyManager.getPermissionUsedTypeInfos(tokenId, permissionName).then(() => {
871  console.log('getPermissionUsedTypeInfos success');
872}).catch((err: BusinessError) => {
873  console.error(`getPermissionUsedTypeInfos fail, err->${JSON.stringify(err)}`);
874});
875```
876
877## PermissionUsageFlag
878
879使用记录的查询方式的枚举。
880
881**系统能力:** SystemCapability.Security.AccessToken
882
883| 名称                    | 值 | 说明                   |
884| ----------------------- | ------ | ---------------------- |
885| FLAG_PERMISSION_USAGE_SUMMARY             | 0    | 表示查询总览数据。 |
886| FLAG_PERMISSION_USAGE_DETAIL         | 1    | 表示查询详细数据。         |
887
888## PermissionUsedRequest
889
890表示使用记录的查询请求。
891
892**系统能力:** SystemCapability.Security.AccessToken
893
894| 名称       | 类型             | 必填   | 说明                                       |
895| -------- | -------------- | ---- | ---------------------------------------- |
896| tokenId  | number         | 否    | 目标应用的身份标识。<br/> 默认查询所有应用。         |
897| isRemote | boolean         | 否    | 指定是否查询远端设备。<br/> 默认值false,默认查询本端设备。 |
898| deviceId  | string         | 否    | 目标应用所在设备的ID。<br/> 默认设备ID为本端设备ID。   |
899| bundleName | string         | 否    | 目标应用的包名。<br/> 默认查询所有应用。 |
900| permissionNames  | Array&lt;Permissions&gt;         | 否    | 需要查询的权限集合。<br/> 默认查询所有权限的使用记录。               |
901| beginTime | number         | 否    | 查询的起始时间,单位:ms。<br/>默认值0,不设定起始时间。 |
902| endTime | number         | 否    | 查询的终止时间,单位:ms。<br/>默认值0,不设定终止时间。 |
903| flag | [PermissionUsageFlag](#permissionusageflag)         | 是    | 指定查询方式。 |
904
905## PermissionUsedResponse
906
907表示所有应用的访问记录。
908
909**系统能力:** SystemCapability.Security.AccessToken
910
911| 名称       | 类型             | 可读 | 可写 | 说明                                       |
912| --------- | -------------- | ---- | ---- | ---------------------------------------- |
913| beginTime | number         | 是    | 否    | 查询记录的起始时间,单位:ms。 |
914| endTime   | number         | 是    | 否    | 查询记录的终止时间,单位:ms。 |
915| bundleRecords  | Array&lt;[BundleUsedRecord](#bundleusedrecord)&gt;         | 是    | 否    | 应用的权限使用记录集合。                                 |
916
917## BundleUsedRecord
918
919某个应用的访问记录。
920
921**系统能力:** SystemCapability.Security.AccessToken
922
923| 名称       | 类型             | 可读 | 可写 | 说明                                       |
924| -------- | -------------- | ---- | ---- | ---------------------------------------- |
925| tokenId  | number         | 是    | 否    | 目标应用的身份标识。                                 |
926| isRemote | boolean         | 是    | 否    | 是否是分布式设备。默认值为false,表示不是分布式设备。 |
927| deviceId  | string         | 是    | 否    | 目标应用所在设备的ID。                                 |
928| bundleName | string         | 是    | 否    | 目标应用的包名。 |
929| permissionRecords  | Array&lt;[PermissionUsedRecord](#permissionusedrecord)&gt;         | 是    | 否    | 每个应用的权限使用记录集合。                                 |
930
931## PermissionUsedRecord
932
933某个权限的访问记录。
934
935**系统能力:** SystemCapability.Security.AccessToken
936
937| 名称       | 类型             | 可读 | 可写 | 说明                                       |
938| -------- | -------------- | ---- | ---- | ---------------------------------------- |
939| permissionName  | Permissions         | 是    | 否    | 权限名。                                 |
940| accessCount | number         | 是    | 否    | 该权限访问总次数。 |
941| rejectCount | number         | 是    | 否    | 该权限拒绝总次数。 |
942| lastAccessTime | number         | 是    | 否    | 最后一次访问时间,单位:ms。 |
943| lastRejectTime | number         | 是    | 否    | 最后一次拒绝时间,单位:ms。 |
944| lastAccessDuration | number         | 是    | 否    | 最后一次访问时长,单位:ms。 |
945| accessRecords  | Array&lt;[UsedRecordDetail](#usedrecorddetail)&gt;         | 是    | 否    | 访问记录集合,当flag为FLAG_PERMISSION_USAGE_DETAIL时生效,默认查询10条。                                 |
946| rejectRecords  | Array&lt;[UsedRecordDetail](#usedrecorddetail)&gt;         | 是    | 否    | 拒绝记录集合,当flag为FLAG_PERMISSION_USAGE_DETAIL时生效,默认查询10条。                                 |
947
948## UsedRecordDetail
949
950单次访问记录详情。
951
952**系统能力:** SystemCapability.Security.AccessToken
953
954| 名称       | 类型             | 可读 | 可写 | 说明                                       |
955| -------- | -------------- | ---- | ---- | ---------------------------------------- |
956| status  | number         | 是    | 否    | 访问状态。                                 |
957| lockScreenStatus<sup>11+</sup>  | number         | 是    | 否    | 访问时的锁屏状态。<br> - 1,表示非锁屏场景使用权限。<br> - 2,表示锁屏场景使用权限。                                 |
958| timestamp | number         | 是    | 否    | 访问时的时间戳,单位:ms。 |
959| accessDuration  | number         | 是    | 否    | 访问时长,单位:ms。                                 |
960| count<sup>11+</sup> | number | 是 | 否    | 成功或失败次数。
961| usedType<sup>12+</sup> | [PermissionUsedType](#permissionusedtype12) | 是 | 否    | 敏感权限访问方式。 |
962
963## PermissionActiveStatus
964
965表示权限使用状态变化类型的枚举。
966
967**系统能力:** SystemCapability.Security.AccessToken
968
969| 名称                      | 值     | 说明              |
970| ------------------------- | ------ | ---------------- |
971| PERM_INACTIVE             | 0      | 表示未使用权限。   |
972| PERM_ACTIVE_IN_FOREGROUND | 1      | 表示前台使用权限。 |
973| PERM_ACTIVE_IN_BACKGROUND | 2      | 表示后台使用权限。 |
974
975## ActiveChangeResponse
976
977表示某次权限使用状态变化的详情。
978
979 **系统能力:** SystemCapability.Security.AccessToken
980
981| 名称           | 类型                    | 可读 | 可写 | 说明                   |
982| -------------- | ---------------------- | ---- | ---- | --------------------- |
983| callingTokenId<sup>18+</sup> | number   | 是   | 否   | 接口调用方的应用身份标识,activeStatus是INACTIVE时该值无效。 |
984| tokenId        | number                 | 是   | 否   | 被订阅的应用身份标识。    |
985| permissionName | Permissions            | 是   | 否   | 权限使用状态发生变化的权限名。 |
986| deviceId       | string                 | 是   | 否   | 设备号。                 |
987| activeStatus   | [PermissionActiveStatus](#permissionactivestatus) | 是   | 否   | 权限使用状态变化类型。        |
988| usedType<sup>18+</sup> | [PermissionUsedType](#permissionusedtype12) | 是   | 否   | 敏感权限使用类型,activeStatus是INACTIVE时该值无效。 |
989
990## PermissionUsedType<sup>12+</sup>
991
992表示通过何种方式使用敏感权限的枚举。
993
994**系统能力:** SystemCapability.Security.AccessToken
995
996| 名称                    | 值 | 说明              |
997| ----------------------- | -- | ---------------- |
998| NORMAL_TYPE             | 0  | 表示通过弹窗授权或设置授权的方式来使用敏感权限。   |
999| PICKER_TYPE             | 1  | 表示通过某个PICKER服务来使用敏感权限,此方式未授予权限。 |
1000| SECURITY_COMPONENT_TYPE | 2  | 表示通过安全控件授权的方式来使用敏感权限。 |
1001
1002## PermissionUsedTypeInfo<sup>12+</sup>
1003
1004表示某次权限使用类型的详情。
1005
1006 **系统能力:** SystemCapability.Security.AccessToken
1007
1008| 名称           | 类型                    | 可读 | 可写 | 说明                   |
1009| -------------- | ---------------------- | ---- | ---- | --------------------- |
1010| tokenId        | number                 | 是   | 否   | 访问敏感权限的应用身份标识。 |
1011| permissionName | Permissions            | 是   | 否   | 被访问的敏感权限名称。 |
1012| usedType | [PermissionUsedType](#permissionusedtype12) | 是 | 否    | 敏感权限使用类型。 |
1013
1014## AddPermissionUsedRecordOptions<sup>12+</sup>
1015
1016添加权限使用记录可选参数集。
1017
1018 **系统能力:** SystemCapability.Security.AccessToken
1019
1020| 名称           | 类型                    | 可读 | 可写 | 说明                   |
1021| -------------- | ---------------------- | ---- | ---- | --------------------- |
1022| usedType | [PermissionUsedType](#permissionusedtype12) | 是 | 否    | 敏感权限使用类型。 |
1023