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