• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit AbilityKit
19 */
20
21import { AsyncCallback, Callback } from './@ohos.base';
22import { Permissions } from './permissions';
23
24/**
25 * @namespace privacyManager
26 * @syscap SystemCapability.Security.AccessToken
27 * @since arkts {'1.1':'9', '1.2':'20'}
28 * @arkts 1.1&1.2
29 */
30declare namespace privacyManager {
31  /**
32   * Adds access record of sensitive permission.
33   *
34   * @permission ohos.permission.PERMISSION_USED_STATS
35   * @param { int } tokenID - Token ID of the application.
36   * @param { Permissions } permissionName - Name of the permission to be added.
37   * @param { int } successCount - Access count.
38   * @param { int } failCount - Reject count.
39   * @returns { Promise<void> } Promise that returns no value.
40   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
41   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS".
42   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
43   * @throws { BusinessError } 12100001 - Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters, or the count value is invalid.
44   * @throws { BusinessError } 12100002 - The specified tokenID does not exist or refer to an application process.
45   * @throws { BusinessError } 12100003 - The specified permission does not exist or is not a user_grant permission.
46   * @throws { BusinessError } 12100007 - The service is abnormal.
47   * @throws { BusinessError } 12100008 - Out of memory.
48   * @syscap SystemCapability.Security.AccessToken
49   * @systemapi
50   * @since 9
51   */
52  /**
53   * Adds an access record of a sensitive permission.
54   *
55   * @permission ohos.permission.PERMISSION_USED_STATS
56   * @param { int } tokenID - Token ID of the application.
57   * @param { Permissions } permissionName - Name of the permission accessed.
58   * @param { int } successCount - Number of successful accesses to the permission.
59   * @param { int } failCount - Number of failed accesses to the permission.
60   * @param { AddPermissionUsedRecordOptions } [options] - Options to be added.
61   * @returns { Promise<void> } Promise that returns no value.
62   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
63   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS".
64   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
65   * @throws { BusinessError } 12100001 - Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters, the count value is invalid,
66   *  or usedType in AddPermissionUsedRecordOptions is invalid.
67   * @throws { BusinessError } 12100002 - The specified tokenID does not exist or refer to an application process.
68   * @throws { BusinessError } 12100003 - The specified permission does not exist or is not a user_grant permission.
69   * @throws { BusinessError } 12100007 - The service is abnormal.
70   * @throws { BusinessError } 12100008 - Out of memory.
71   * @syscap SystemCapability.Security.AccessToken
72   * @systemapi
73   * @since arkts {'1.1':'12', '1.2':'20'}
74   * @arkts 1.1&1.2
75   */
76  function addPermissionUsedRecord(
77    tokenID: int,
78    permissionName: Permissions,
79    successCount: int,
80    failCount: int,
81    options?: AddPermissionUsedRecordOptions
82  ): Promise<void>;
83
84  /**
85   * Adds access record of sensitive permission.
86   *
87   * @permission ohos.permission.PERMISSION_USED_STATS
88   * @param { int } tokenID - Token ID of the application.
89   * @param { Permissions } permissionName - Name of the permission to be added.
90   * @param { int } successCount - Access count.
91   * @param { int } failCount - Reject count.
92   * @param { AsyncCallback<void> } callback - Asynchronous callback interface.
93   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
94   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS".
95   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
96   * @throws { BusinessError } 12100001 - Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters, or the count value is invalid.
97   * @throws { BusinessError } 12100002 - The specified tokenID does not exist or refer to an application process.
98   * @throws { BusinessError } 12100003 - The specified permission does not exist or is not a user_grant permission.
99   * @throws { BusinessError } 12100007 - The service is abnormal.
100   * @throws { BusinessError } 12100008 - Out of memory.
101   * @syscap SystemCapability.Security.AccessToken
102   * @systemapi
103   * @since arkts {'1.1':'9', '1.2':'20'}
104   * @arkts 1.1&1.2
105   */
106  function addPermissionUsedRecord(
107    tokenID: int,
108    permissionName: Permissions,
109    successCount: int,
110    failCount: int,
111    callback: AsyncCallback<void>
112  ): void;
113
114  /**
115   * Queries the access records of sensitive permission.
116   *
117   * @permission ohos.permission.PERMISSION_USED_STATS
118   * @param { PermissionUsedRequest } request - The request of permission used records.
119   * @returns { Promise<PermissionUsedResponse> } Return the response of permission used records.
120   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
121   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS".
122   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
123   * @throws { BusinessError } 12100001 - Invalid parameter. The value of flag, begin, or end in request is invalid.
124   * @throws { BusinessError } 12100002 - The specified tokenID does not exist or refer to an application process.
125   * @throws { BusinessError } 12100003 - The specified permission does not exist or is not a user_grant permission.
126   * @throws { BusinessError } 12100007 - The service is abnormal.
127   * @throws { BusinessError } 12100008 - Out of memory.
128   * @syscap SystemCapability.Security.AccessToken
129   * @systemapi
130   * @since 9
131   */
132  function getPermissionUsedRecord(request: PermissionUsedRequest): Promise<PermissionUsedResponse>;
133
134  /**
135   * Queries the access records of sensitive permission.
136   *
137   * @permission ohos.permission.PERMISSION_USED_STATS
138   * @param { PermissionUsedRequest } request - The request of permission used records.
139   * @param { AsyncCallback<PermissionUsedResponse> } callback - Return the response of permission used records.
140   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
141   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS".
142   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
143   * @throws { BusinessError } 12100001 - Invalid parameter. The value of flag, begin, or end in request is invalid.
144   * @throws { BusinessError } 12100002 - The specified tokenID does not exist or refer to an application process.
145   * @throws { BusinessError } 12100003 - The specified permission does not exist or is not a user_grant permission.
146   * @throws { BusinessError } 12100007 - The service is abnormal.
147   * @throws { BusinessError } 12100008 - Out of memory.
148   * @syscap SystemCapability.Security.AccessToken
149   * @systemapi
150   * @since 9
151   */
152  function getPermissionUsedRecord(
153    request: PermissionUsedRequest,
154    callback: AsyncCallback<PermissionUsedResponse>
155  ): void;
156
157  /**
158   * Start using sensitive permission.
159   *
160   * @permission ohos.permission.PERMISSION_USED_STATS
161   * @param { number } tokenID - Token ID of the application.
162   * @param { Permissions } permissionName - Name of the permission to be started.
163   * @returns { Promise<void> } Promise that returns no value.
164   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
165   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS".
166   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
167   * @throws { BusinessError } 12100001 - Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters,
168   *  or the type of the specified tokenID is not of the application type.
169   * @throws { BusinessError } 12100002 - The specified tokenID does not exist or refer to an application process.
170   * @throws { BusinessError } 12100003 - The specified permission does not exist or is not a user_grant permission.
171   * @throws { BusinessError } 12100004 - The API is used repeatedly with the same input.
172   *  It means the application specified by the tokenID has been using the specified permission.
173   * @throws { BusinessError } 12100007 - The service is abnormal.
174   * @throws { BusinessError } 12100008 - Out of memory.
175   * @syscap SystemCapability.Security.AccessToken
176   * @systemapi
177   * @since 9
178   */
179  function startUsingPermission(tokenID: number, permissionName: Permissions): Promise<void>;
180
181  /**
182   * Start using sensitive permission.
183   *
184   * @permission ohos.permission.PERMISSION_USED_STATS
185   * @param { number } tokenID - Token ID of the application.
186   * @param { Permissions } permissionName - Name of the permission to be started.
187   * @param { number } [pid] - Pid of the application, default -1.
188   * @param { PermissionUsedType } [usedType] - Used type of the permission accessed, default NORMAL_TYPE.
189   * @returns { Promise<void> } Promise that returns no value.
190   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
191   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS".
192   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
193   * @throws { BusinessError } 12100001 - Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters,
194   *  the type of the specified tokenID is not of the application type, or usedType is invalid.
195   * @throws { BusinessError } 12100002 - The specified tokenID does not exist or refer to an application process.
196   * @throws { BusinessError } 12100003 - The specified permission does not exist or is not a user_grant permission.
197   * @throws { BusinessError } 12100004 - The API is used repeatedly with the same input.
198   *  It means the application specified by the tokenID has been using the specified permission.
199   * @throws { BusinessError } 12100007 - The service is abnormal.
200   * @throws { BusinessError } 12100008 - Out of memory.
201   * @syscap SystemCapability.Security.AccessToken
202   * @systemapi
203   * @since 18
204   */
205  function startUsingPermission(
206    tokenID: number,
207    permissionName: Permissions,
208    pid?: number,
209    usedType?: PermissionUsedType
210  ): Promise<void>;
211
212  /**
213   * Start using sensitive permission.
214   *
215   * @permission ohos.permission.PERMISSION_USED_STATS
216   * @param { number } tokenID - Token ID of the application.
217   * @param { Permissions } permissionName - Name of the permission to be started.
218   * @param { AsyncCallback<void> } callback - Asynchronous callback interface.
219   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
220   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS".
221   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
222   * @throws { BusinessError } 12100001 - Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters,
223   *  or the type of the specified tokenID is not of the application type.
224   * @throws { BusinessError } 12100002 - The specified tokenID does not exist or refer to an application process.
225   * @throws { BusinessError } 12100003 - The specified permission does not exist or is not a user_grant permission.
226   * @throws { BusinessError } 12100004 - The API is used repeatedly with the same input.
227   *  It means the application specified by the tokenID has been using the specified permission.
228   * @throws { BusinessError } 12100007 - The service is abnormal.
229   * @throws { BusinessError } 12100008 - Out of memory.
230   * @syscap SystemCapability.Security.AccessToken
231   * @systemapi
232   * @since 9
233   */
234  function startUsingPermission(tokenID: number, permissionName: Permissions, callback: AsyncCallback<void>): void;
235
236  /**
237   * Stop using sensitive permission.
238   *
239   * @permission ohos.permission.PERMISSION_USED_STATS
240   * @param { number } tokenID - Token ID of the application.
241   * @param { Permissions } permissionName - Name of the permission to be stopped.
242   * @returns { Promise<void> } Promise that returns no value.
243   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
244   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS".
245   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
246   * @throws { BusinessError } 12100001 - Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters,
247   *  or the type of the specified tokenID is not of the application type.
248   * @throws { BusinessError } 12100002 - The specified tokenID does not exist or refer to an application process.
249   * @throws { BusinessError } 12100003 - The specified permission does not exist or is not a user_grant permission.
250   * @throws { BusinessError } 12100004 - The API is not used in pair with 'startUsingPermission'.
251   * @throws { BusinessError } 12100007 - The service is abnormal.
252   * @throws { BusinessError } 12100008 - Out of memory.
253   * @syscap SystemCapability.Security.AccessToken
254   * @systemapi
255   * @since 9
256   */
257  function stopUsingPermission(tokenID: number, permissionName: Permissions): Promise<void>;
258
259  /**
260   * Stop using sensitive permission.
261   *
262   * @permission ohos.permission.PERMISSION_USED_STATS
263   * @param { number } tokenID - Token ID of the application.
264   * @param { Permissions } permissionName - Name of the permission to be stopped.
265   * @param { number } [pid] - Pid of the application, default -1.
266   * @returns { Promise<void> } Promise that returns no value.
267   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
268   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS".
269   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
270   * @throws { BusinessError } 12100001 - Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters,
271   *  or the type of the specified tokenID is not of the application type.
272   * @throws { BusinessError } 12100002 - The specified tokenID does not exist or refer to an application process.
273   * @throws { BusinessError } 12100003 - The specified permission does not exist or is not a user_grant permission.
274   * @throws { BusinessError } 12100004 - The API is not used in pair with 'startUsingPermission'.
275   * @throws { BusinessError } 12100007 - The service is abnormal.
276   * @throws { BusinessError } 12100008 - Out of memory.
277   * @syscap SystemCapability.Security.AccessToken
278   * @systemapi
279   * @since 18
280   */
281  function stopUsingPermission(
282    tokenID: number,
283    permissionName: Permissions,
284    pid?: number
285  ): Promise<void>;
286
287  /**
288   * Stop using sensitive permission.
289   *
290   * @permission ohos.permission.PERMISSION_USED_STATS
291   * @param { number } tokenID - Token ID of the application.
292   * @param { Permissions } permissionName - Name of the permission to be stopped.
293   * @param { AsyncCallback<void> } callback - Asynchronous callback interface.
294   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
295   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS".
296   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
297   * @throws { BusinessError } 12100001 - Invalid parameter. The tokenID is 0, the permissionName exceeds 256 characters,
298   *  or the type of the specified tokenID is not of the application type.
299   * @throws { BusinessError } 12100002 - The specified tokenID does not exist or refer to an application process.
300   * @throws { BusinessError } 12100003 - The specified permission does not exist or is not a user_grant permission.
301   * @throws { BusinessError } 12100004 - The API is not used in pair with 'startUsingPermission'.
302   * @throws { BusinessError } 12100007 - The service is abnormal.
303   * @throws { BusinessError } 12100008 - Out of memory.
304   * @syscap SystemCapability.Security.AccessToken
305   * @systemapi
306   * @since 9
307   */
308  function stopUsingPermission(tokenID: number, permissionName: Permissions, callback: AsyncCallback<void>): void;
309
310  /**
311   * Subscribes to the change of active state of the specified permission.
312   *
313   * @permission ohos.permission.PERMISSION_USED_STATS
314   * @param { 'activeStateChange' } type - Event type. This parameter cannot change.
315   * @param { Array<Permissions> } permissionList - Indicates the permission list, which are specified. This parameter cannot be null or empty.
316   * @param { Callback<ActiveChangeResponse> } callback Callback for listening permission change.
317   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
318   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS".
319   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
320   * @throws { BusinessError } 12100001 - Invalid parameter. The permissionList exceeds the size limit, or the permissionNames in the list are all invalid.
321   * @throws { BusinessError } 12100004 - The API is used repeatedly with the same input.
322   * @throws { BusinessError } 12100005 - The registration time has exceeded the limit.
323   * @throws { BusinessError } 12100007 - The service is abnormal.
324   * @throws { BusinessError } 12100008 - Out of memory.
325   * @syscap SystemCapability.Security.AccessToken
326   * @systemapi
327   * @since arkts {'1.1':'9', '1.2':'20'}
328   * @arkts 1.1&1.2
329   */
330  function on(
331    type: 'activeStateChange',
332    permissionList: Array<Permissions>,
333    callback: Callback<ActiveChangeResponse>
334  ): void;
335
336  /**
337   * Unsubscribes to the change of active state of the specified permission.
338   *
339   * @permission ohos.permission.PERMISSION_USED_STATS
340   * @param { 'activeStateChange' } type - Event type. This parameter cannot change.
341   * @param { Array<Permissions> } permissionList - Indicates the permission list, which are specified. This parameter cannot be null or empty.
342   * @param { Callback<ActiveChangeResponse> } [callback] - Callback for listening permission change.
343   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
344   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS".
345   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
346   * @throws { BusinessError } 12100001 - Invalid parameter. The permissionList is not in the listening list.
347   * @throws { BusinessError } 12100004 - The API is not used in pair with 'on'.
348   * @throws { BusinessError } 12100007 - The service is abnormal.
349   * @throws { BusinessError } 12100008 - Out of memory.
350   * @syscap SystemCapability.Security.AccessToken
351   * @systemapi
352   * @since arkts {'1.1':'9', '1.2':'20'}
353   * @arkts 1.1&1.2
354   */
355  function off(
356    type: 'activeStateChange',
357    permissionList: Array<Permissions>,
358    callback?: Callback<ActiveChangeResponse>
359  ): void;
360
361  /**
362   * Obtains the used type of the permission accessed.
363   *
364   * @permission ohos.permission.PERMISSION_USED_STATS
365   * @param { int } tokenId - Token ID of the application. By default, all token IDs of the device are returned.
366   * @param { Permissions } permissionName - Name of the permission to query. By default, all permissions of the device are returned.
367   * @returns { Promise<Array<PermissionUsedTypeInfo>> } Promise used to return the information obtained.
368   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types.
369   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS".
370   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
371   * @throws { BusinessError } 12100001 - Invalid parameter. PermissionName exceeds 256 characters.
372   * @throws { BusinessError } 12100002 - The input tokenId does not exist.
373   * @throws { BusinessError } 12100003 - The input permissionName does not exist.
374   * @syscap SystemCapability.Security.AccessToken
375   * @systemapi
376   * @since 12
377   */
378
379  /**
380   * Obtains the used type of the permission accessed.
381   *
382   * @permission ohos.permission.PERMISSION_USED_STATS
383   * @param { int | null } [tokenId] - Token ID of the application. By default, all token IDs of the device
384   *     are returned.
385   * @param { Permissions } [permissionName] - Name of the permission to query. By default, all permissions
386   *     of the device are returned.
387   * @returns { Promise<Array<PermissionUsedTypeInfo>> } Promise used to return the information obtained.
388   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission
389   *     "ohos.permission.PERMISSION_USED_STATS".
390   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
391   * @throws { BusinessError } 12100001 - Invalid parameter. PermissionName exceeds 256 characters.
392   * @throws { BusinessError } 12100002 - The input tokenId does not exist.
393   * @throws { BusinessError } 12100003 - The input permissionName does not exist.
394   * @syscap SystemCapability.Security.AccessToken
395   * @systemapi
396   * @since 20
397   */
398  function getPermissionUsedTypeInfos(tokenId?: int | null, permissionName?: Permissions): Promise<Array<PermissionUsedTypeInfo>>;
399
400  /**
401   * Sets the toggle state of permission access records for the current user.
402   *
403   * @permission ohos.permission.PERMISSION_RECORD_TOGGLE
404   * @param { boolean } status - The toggle status to be set.
405   * @returns { Promise<void> } The promise returned by the function.
406   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
407   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_RECORD_TOGGLE".
408   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
409   * @throws { BusinessError } 12100007 - The service is abnormal.
410   * @throws { BusinessError } 12100009 - Common inner error.
411   * @syscap SystemCapability.Security.AccessToken
412   * @systemapi
413   * @since 18
414   */
415  function setPermissionUsedRecordToggleStatus(status: boolean): Promise<void>;
416
417  /**
418   * Obtains the toggle state of permission access records of the current user.
419   *
420   * @permission ohos.permission.PERMISSION_USED_STATS
421   * @returns { Promise<boolean> } Return the toggle status.
422   * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS".
423   * @throws { BusinessError } 202 - Not system app. Interface caller is not a system app.
424   * @throws { BusinessError } 12100007 - The service is abnormal.
425   * @syscap SystemCapability.Security.AccessToken
426   * @systemapi
427   * @since 18
428   */
429  function getPermissionUsedRecordToggleStatus(): Promise<boolean>;
430
431  /**
432   * Enum for permission for status.
433   *
434   * @enum { int } PermissionActiveStatus
435   * @syscap SystemCapability.Security.AccessToken
436   * @systemapi
437   * @since arkts {'1.1':'9', '1.2':'20'}
438   * @arkts 1.1&1.2
439   */
440  enum PermissionActiveStatus {
441    /**
442     * permission is not used yet.
443     *
444     * @syscap SystemCapability.Security.AccessToken
445     * @systemapi
446     * @since arkts {'1.1':'9', '1.2':'20'}
447     * @arkts 1.1&1.2
448     */
449    PERM_INACTIVE = 0,
450
451    /**
452     * permission is used in front_end.
453     *
454     * @syscap SystemCapability.Security.AccessToken
455     * @systemapi
456     * @since arkts {'1.1':'9', '1.2':'20'}
457     * @arkts 1.1&1.2
458     */
459    PERM_ACTIVE_IN_FOREGROUND = 1,
460
461    /**
462     * permission is used in back_end.
463     *
464     * @syscap SystemCapability.Security.AccessToken
465     * @systemapi
466     * @since arkts {'1.1':'9', '1.2':'20'}
467     * @arkts 1.1&1.2
468     */
469    PERM_ACTIVE_IN_BACKGROUND = 2
470  }
471
472  /**
473   * Indicates the response of permission active status.
474   *
475   * @interface ActiveChangeResponse
476   * @syscap SystemCapability.Security.AccessToken
477   * @systemapi
478   * @since arkts {'1.1':'9', '1.2':'20'}
479   * @arkts 1.1&1.2
480   */
481  interface ActiveChangeResponse {
482    /**
483     * AccessTokenID which called the interface
484     *
485     * @type { ?int }
486     * @syscap SystemCapability.Security.AccessToken
487     * @systemapi
488     * @since arkts {'1.1':'18', '1.2':'20'}
489     * @arkts 1.1&1.2
490     */
491    callingTokenId?: int;
492
493    /**
494     * AccessTokenID
495     *
496     * @type { int }
497     * @syscap SystemCapability.Security.AccessToken
498     * @systemapi
499     * @since arkts {'1.1':'9', '1.2':'20'}
500     * @arkts 1.1&1.2
501     */
502    tokenId: int;
503
504    /**
505     * The permission name
506     *
507     * @type { Permissions }
508     * @syscap SystemCapability.Security.AccessToken
509     * @systemapi
510     * @since arkts {'1.1':'9', '1.2':'20'}
511     * @arkts 1.1&1.2
512     */
513    permissionName: Permissions;
514
515    /**
516     * The device id
517     *
518     * @type { string }
519     * @syscap SystemCapability.Security.AccessToken
520     * @systemapi
521     * @since arkts {'1.1':'9', '1.2':'20'}
522     * @arkts 1.1&1.2
523     */
524    deviceId: string;
525
526    /**
527     * The active status name
528     *
529     * @type { PermissionActiveStatus }
530     * @syscap SystemCapability.Security.AccessToken
531     * @systemapi
532     * @since arkts {'1.1':'9', '1.2':'20'}
533     * @arkts 1.1&1.2
534     */
535    activeStatus: PermissionActiveStatus;
536
537    /**
538     * Used type of the permission accessed.
539     *
540     * @type { ?PermissionUsedType }
541     * @syscap SystemCapability.Security.AccessToken
542     * @systemapi
543     * @since arkts {'1.1':'18', '1.2':'20'}
544     * @arkts 1.1&1.2
545     */
546    usedType?: PermissionUsedType;
547  }
548
549  /**
550   * PermissionUsageFlag.
551   *
552   * @enum { number } PermissionUsageFlag
553   * @syscap SystemCapability.Security.AccessToken
554   * @systemapi
555   * @since 9
556   */
557  enum PermissionUsageFlag {
558    /**
559     * permission used summary
560     *
561     * @syscap SystemCapability.Security.AccessToken
562     * @systemapi
563     * @since 9
564     */
565    FLAG_PERMISSION_USAGE_SUMMARY = 0,
566    /**
567     * permission used detail
568     *
569     * @syscap SystemCapability.Security.AccessToken
570     * @systemapi
571     * @since 9
572     */
573    FLAG_PERMISSION_USAGE_DETAIL = 1
574  }
575
576  /**
577   * Provides request of querying permission used records.
578   *
579   * @interface PermissionUsedRequest
580   * @syscap SystemCapability.Security.AccessToken
581   * @systemapi
582   * @since 9
583   */
584  interface PermissionUsedRequest {
585    /**
586     * AccessTokenID
587     *
588     * @type { ?number }
589     * @syscap SystemCapability.Security.AccessToken
590     * @systemapi
591     * @since 9
592     */
593    tokenId?: number;
594
595    /**
596     * Distribute flag
597     *
598     * @type { ?boolean }
599     * @default false
600     * @syscap SystemCapability.Security.AccessToken
601     * @systemapi
602     * @since 9
603     */
604    isRemote?: boolean;
605
606    /**
607     * The device id
608     *
609     * @type { ?string }
610     * @syscap SystemCapability.Security.AccessToken
611     * @systemapi
612     * @since 9
613     */
614    deviceId?: string;
615
616    /**
617     * The bundle name
618     *
619     * @type { ?string }
620     * @syscap SystemCapability.Security.AccessToken
621     * @systemapi
622     * @since 9
623     */
624    bundleName?: string;
625
626    /**
627     * The list of permission name
628     *
629     * @type { ?Array<Permissions> }
630     * @syscap SystemCapability.Security.AccessToken
631     * @systemapi
632     * @since 9
633     */
634    permissionNames?: Array<Permissions>;
635
636    /**
637     * The begin time, in milliseconds
638     *
639     * @type { ?number }
640     * @default 0
641     * @syscap SystemCapability.Security.AccessToken
642     * @systemapi
643     * @since 9
644     */
645    beginTime?: number;
646
647    /**
648     * The end time, in milliseconds
649     *
650     * @type { ?number }
651     * @default 0
652     * @syscap SystemCapability.Security.AccessToken
653     * @systemapi
654     * @since 9
655     */
656    endTime?: number;
657
658    /**
659     * The permission usage flag
660     *
661     * @type { PermissionUsageFlag }
662     * @syscap SystemCapability.Security.AccessToken
663     * @systemapi
664     * @since 9
665     */
666    flag: PermissionUsageFlag;
667  }
668
669  /**
670   * Provides response of querying permission used records.
671   *
672   * @interface PermissionUsedResponse
673   * @syscap SystemCapability.Security.AccessToken
674   * @systemapi
675   * @since 9
676   */
677  interface PermissionUsedResponse {
678    /**
679     * The begin time, in milliseconds
680     *
681     * @type { number }
682     * @syscap SystemCapability.Security.AccessToken
683     * @systemapi
684     * @since 9
685     */
686    beginTime: number;
687
688    /**
689     * The end time, in milliseconds
690     *
691     * @type { number }
692     * @syscap SystemCapability.Security.AccessToken
693     * @systemapi
694     * @since 9
695     */
696    endTime: number;
697
698    /**
699     * The list of permission used records of bundle
700     *
701     * @type { Array<BundleUsedRecord> }
702     * @syscap SystemCapability.Security.AccessToken
703     * @systemapi
704     * @since 9
705     */
706    bundleRecords: Array<BundleUsedRecord>;
707  }
708
709  /**
710   * BundleUsedRecord.
711   *
712   * @interface BundleUsedRecord
713   * @syscap SystemCapability.Security.AccessToken
714   * @systemapi
715   * @since 9
716   */
717  interface BundleUsedRecord {
718    /**
719     * AccessTokenID
720     *
721     * @type { number }
722     * @syscap SystemCapability.Security.AccessToken
723     * @systemapi
724     * @since 9
725     */
726    tokenId: number;
727
728    /**
729     * Distribute flag
730     *
731     * @type { boolean }
732     * @syscap SystemCapability.Security.AccessToken
733     * @systemapi
734     * @since 9
735     */
736    isRemote: boolean;
737
738    /**
739     * The device id
740     *
741     * @type { string }
742     * @syscap SystemCapability.Security.AccessToken
743     * @systemapi
744     * @since 9
745     */
746    deviceId: string;
747
748    /**
749     * The bundle name
750     *
751     * @type { string }
752     * @syscap SystemCapability.Security.AccessToken
753     * @systemapi
754     * @since 9
755     */
756    bundleName: string;
757
758    /**
759     * The list of permission used records
760     *
761     * @type { Array<PermissionUsedRecord> }
762     * @syscap SystemCapability.Security.AccessToken
763     * @systemapi
764     * @since 9
765     */
766    permissionRecords: Array<PermissionUsedRecord>;
767  }
768
769  /**
770   * PermissionUsedRecord.
771   *
772   * @interface PermissionUsedRecord
773   * @syscap SystemCapability.Security.AccessToken
774   * @systemapi
775   * @since 9
776   */
777  interface PermissionUsedRecord {
778    /**
779     * The permission name
780     *
781     * @type { Permissions }
782     * @syscap SystemCapability.Security.AccessToken
783     * @systemapi
784     * @since 9
785     */
786    permissionName: Permissions;
787
788    /**
789     * The access counts
790     *
791     * @type { number }
792     * @syscap SystemCapability.Security.AccessToken
793     * @systemapi
794     * @since 9
795     */
796    accessCount: number;
797
798    /**
799     * The reject counts
800     *
801     * @type { number }
802     * @syscap SystemCapability.Security.AccessToken
803     * @systemapi
804     * @since 9
805     */
806    rejectCount: number;
807
808    /**
809     * The last access time, in milliseconds
810     *
811     * @type { number }
812     * @syscap SystemCapability.Security.AccessToken
813     * @systemapi
814     * @since 9
815     */
816    lastAccessTime: number;
817
818    /**
819     * The last reject time, in milliseconds
820     *
821     * @type { number }
822     * @syscap SystemCapability.Security.AccessToken
823     * @systemapi
824     * @since 9
825     */
826    lastRejectTime: number;
827
828    /**
829     * The last access duration, in milliseconds
830     *
831     * @type { number }
832     * @syscap SystemCapability.Security.AccessToken
833     * @systemapi
834     * @since 9
835     */
836    lastAccessDuration: number;
837
838    /**
839     * The list of access records of details
840     *
841     * @type { Array<UsedRecordDetail> }
842     * @syscap SystemCapability.Security.AccessToken
843     * @systemapi
844     * @since 9
845     */
846    accessRecords: Array<UsedRecordDetail>;
847
848    /**
849     * The list of reject records of details
850     *
851     * @type { Array<UsedRecordDetail> }
852     * @syscap SystemCapability.Security.AccessToken
853     * @systemapi
854     * @since 9
855     */
856    rejectRecords: Array<UsedRecordDetail>;
857  }
858
859  /**
860   * UsedRecordDetail.
861   *
862   * @interface UsedRecordDetail
863   * @syscap SystemCapability.Security.AccessToken
864   * @systemapi
865   * @since 9
866   */
867  interface UsedRecordDetail {
868    /**
869     * The status
870     *
871     * @type { number }
872     * @syscap SystemCapability.Security.AccessToken
873     * @systemapi
874     * @since 9
875     */
876    status: number;
877
878    /**
879     * Indicates the status of lockscreen.
880     *
881     * @type { ?number }
882     * @syscap SystemCapability.Security.AccessToken
883     * @systemapi
884     * @since 11
885     */
886    lockScreenStatus?: number;
887
888    /**
889     * Timestamp, in milliseconds
890     *
891     * @type { number }
892     * @syscap SystemCapability.Security.AccessToken
893     * @systemapi
894     * @since 9
895     */
896    timestamp: number;
897
898    /**
899     * The value of successCount or failCount passed in to addPermissionUsedRecord.
900     *
901     * @type { ?number }
902     * @syscap SystemCapability.Security.AccessToken
903     * @systemapi
904     * @since 11
905     */
906    count?: number;
907
908    /**
909     * Access duration, in milliseconds
910     *
911     * @type { number }
912     * @syscap SystemCapability.Security.AccessToken
913     * @systemapi
914     * @since 9
915     */
916    accessDuration: number;
917
918    /**
919     * Used type of the permission accessed.
920     *
921     * @type { ?PermissionUsedType }
922     * @syscap SystemCapability.Security.AccessToken
923     * @systemapi
924     * @since 12
925     */
926    usedType?: PermissionUsedType;
927  }
928
929  /**
930   * Enumerates the means by which sensitive resources are accessed.
931   *
932   * @enum { int } PermissionUsedType
933   * @syscap SystemCapability.Security.AccessToken
934   * @systemapi
935   * @since arkts {'1.1':'12', '1.2':'20'}
936   * @arkts 1.1&1.2
937   */
938  enum PermissionUsedType {
939    /**
940     * Sensitive resources are accessed with the declared permission or permission granted by the user.
941     *
942     * @syscap SystemCapability.Security.AccessToken
943     * @systemapi
944     * @since arkts {'1.1':'12', '1.2':'20'}
945     * @arkts 1.1&1.2
946     */
947    NORMAL_TYPE = 0,
948
949    /**
950     * Sensitive resources are accessed through a picker.
951     *
952     * @syscap SystemCapability.Security.AccessToken
953     * @systemapi
954     * @since arkts {'1.1':'12', '1.2':'20'}
955     * @arkts 1.1&1.2
956     */
957    PICKER_TYPE = 1,
958
959    /**
960     * Sensitive resources are accessed through a security component.
961     *
962     * @syscap SystemCapability.Security.AccessToken
963     * @systemapi
964     * @since arkts {'1.1':'12', '1.2':'20'}
965     * @arkts 1.1&1.2
966     */
967    SECURITY_COMPONENT_TYPE = 2
968  }
969
970  /**
971   * Information about the permission used type.
972   *
973   * @interface PermissionUsedTypeInfo
974   * @syscap SystemCapability.Security.AccessToken
975   * @systemapi
976   * @since 12
977   */
978  interface PermissionUsedTypeInfo {
979    /**
980     * Token ID of the application.
981     *
982     * @type { number }
983     * @syscap SystemCapability.Security.AccessToken
984     * @systemapi
985     * @since 12
986     */
987    tokenId: number;
988
989    /**
990     * Name of the permission accessed.
991     *
992     * @type { Permissions }
993     * @syscap SystemCapability.Security.AccessToken
994     * @systemapi
995     * @since 12
996     */
997    permissionName: Permissions;
998
999    /**
1000     * Used type of the permission accessed.
1001     *
1002     * @type { PermissionUsedType }
1003     * @syscap SystemCapability.Security.AccessToken
1004     * @systemapi
1005     * @since 12
1006     */
1007    usedType: PermissionUsedType;
1008  }
1009
1010  /**
1011   * Additional information to add.
1012   *
1013   * @interface AddPermissionUsedRecordOptions
1014   * @syscap SystemCapability.Security.AccessToken
1015   * @systemapi
1016   * @since arkts {'1.1':'12', '1.2':'20'}
1017   * @arkts 1.1&1.2
1018   */
1019  interface AddPermissionUsedRecordOptions {
1020    /**
1021     * Used type of the permission accessed.
1022     *
1023     * @type { ?PermissionUsedType }
1024     * @syscap SystemCapability.Security.AccessToken
1025     * @systemapi
1026     * @since arkts {'1.1':'12', '1.2':'20'}
1027     * @arkts 1.1&1.2
1028     */
1029    usedType?: PermissionUsedType;
1030  }
1031}
1032
1033export default privacyManager;
1034export { Permissions };