1/* 2 * Copyright (c) 2023 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 BackgroundTasksKit 19 */ 20 21import { AsyncCallback, Callback } from './@ohos.base'; 22 23/** 24 * Provides methods for managing bundle usage statistics, 25 * including the methods for querying bundle usage information and state data. 26 * 27 * <p>You can use the methods defined in this class to query 28 * the usage history and states of bundles in a specified period. 29 * The system stores the query result in a {@link BundleStatsInfo} instance and 30 * then returns it to you. 31 * 32 * @namespace usageStatistics 33 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 34 * @since 9 35 */ 36declare namespace usageStatistics { 37 /** 38 * @interface BundleStatsInfo 39 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 40 * @systemapi Hide this for inner system use. 41 * @since 9 42 */ 43 interface BundleStatsInfo { 44 /** 45 * The identifier of BundleStatsInfo. 46 * @type { number } 47 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 48 * @systemapi Hide this for inner system use. 49 * @since 9 50 */ 51 id: number; 52 53 /** 54 * The total duration, in milliseconds. 55 * @type { ?number } 56 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 57 * @systemapi Hide this for inner system use. 58 * @since 9 59 */ 60 abilityInFgTotalTime?: number; 61 62 /** 63 * The last time when the application was accessed, in milliseconds. 64 * @type { ?number } 65 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 66 * @systemapi Hide this for inner system use. 67 * @since 9 68 */ 69 abilityPrevAccessTime?: number; 70 71 /** 72 * The last time when the application was visible in the foreground, in milliseconds. 73 * @type { ?number } 74 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 75 * @systemapi Hide this for inner system use. 76 * @since 9 77 */ 78 abilityPrevSeenTime?: number; 79 80 /** 81 * The total duration, in milliseconds. 82 * @type { ?number } 83 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 84 * @systemapi Hide this for inner system use. 85 * @since 9 86 */ 87 abilitySeenTotalTime?: number; 88 89 /** 90 * The bundle name of the application. 91 * @type { ?string } 92 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 93 * @systemapi Hide this for inner system use. 94 * @since 9 95 */ 96 bundleName?: string; 97 98 /** 99 * The total duration, in milliseconds. 100 * @type { ?number } 101 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 102 * @systemapi Hide this for inner system use. 103 * @since 9 104 */ 105 fgAbilityAccessTotalTime?: number; 106 107 /** 108 * The last time when the foreground application was accessed, in milliseconds. 109 * @type { ?number } 110 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 111 * @systemapi Hide this for inner system use. 112 * @since 9 113 */ 114 fgAbilityPrevAccessTime?: number; 115 116 /** 117 * The time of the first bundle usage record in this {@code BundleActiveInfo} object, 118 * in milliseconds. 119 * @type { ?number } 120 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 121 * @systemapi Hide this for inner system use. 122 * @since 9 123 */ 124 infosBeginTime?: number; 125 126 /** 127 * The time of the last bundle usage record in this {@code BundleActiveInfo} object, 128 * in milliseconds. 129 * @type { ?number } 130 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 131 * @systemapi Hide this for inner system use. 132 * @since 9 133 */ 134 infosEndTime?: number; 135 136 /** 137 * The app index of the application. 138 * @type { ?number } 139 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 140 * @systemapi Hide this for inner system use. 141 * @since 15 142 */ 143 appIndex?: number; 144 } 145 146 /** 147 * @interface HapFormInfo 148 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 149 * @systemapi Hide this for inner system use. 150 * @since 9 151 */ 152 interface HapFormInfo { 153 /** 154 * The form name. 155 * @type { string } 156 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 157 * @systemapi Hide this for inner system use. 158 * @since 9 159 */ 160 formName: string; 161 162 /** 163 * The form dimension. 164 * @type { number } 165 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 166 * @systemapi Hide this for inner system use. 167 * @since 9 168 */ 169 formDimension: number; 170 171 /** 172 * The form id. 173 * @type { number } 174 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 175 * @systemapi Hide this for inner system use. 176 * @since 9 177 */ 178 formId: number; 179 180 /** 181 * The last time when the form was accessed, in milliseconds.. 182 * @type { number } 183 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 184 * @systemapi Hide this for inner system use. 185 * @since 9 186 */ 187 formLastUsedTime: number; 188 189 /** 190 * The click count of module. 191 * @type { number } 192 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 193 * @systemapi Hide this for inner system use. 194 * @since 9 195 */ 196 count: number; 197 } 198 199 /** 200 * @interface HapModuleInfo 201 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 202 * @systemapi Hide this for inner system use. 203 * @since 9 204 */ 205 interface HapModuleInfo { 206 /** 207 * The device id of module. 208 * @type { ?string } 209 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 210 * @systemapi Hide this for inner system use. 211 * @since 9 212 */ 213 deviceId?: string; 214 215 /** 216 * The bundle name. 217 * @type { string } 218 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 219 * @systemapi Hide this for inner system use. 220 * @since 9 221 */ 222 bundleName: string; 223 224 /** 225 * The module name. 226 * @type { string } 227 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 228 * @systemapi Hide this for inner system use. 229 * @since 9 230 */ 231 moduleName: string; 232 233 /** 234 * The main ability name of module. 235 * @type { ?string } 236 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 237 * @systemapi Hide this for inner system use. 238 * @since 9 239 */ 240 abilityName?: string; 241 242 /** 243 * The label id of application. 244 * @type { ?number } 245 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 246 * @systemapi Hide this for inner system use. 247 * @since 9 248 */ 249 appLabelId?: number; 250 251 /** 252 * The label id of module. 253 * @type { ?number } 254 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 255 * @systemapi Hide this for inner system use. 256 * @since 9 257 */ 258 labelId?: number; 259 260 /** 261 * The description id of application. 262 * @type { ?number } 263 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 264 * @systemapi Hide this for inner system use. 265 * @since 9 266 */ 267 descriptionId?: number; 268 269 /** 270 * The ability id of main ability. 271 * @type { ?number } 272 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 273 * @systemapi Hide this for inner system use. 274 * @since 9 275 */ 276 abilityLableId?: number; 277 278 /** 279 * The description id of main ability. 280 * @type { ?number } 281 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 282 * @systemapi Hide this for inner system use. 283 * @since 9 284 */ 285 abilityDescriptionId?: number; 286 287 /** 288 * The icon id of main ability. 289 * @type { ?number } 290 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 291 * @systemapi Hide this for inner system use. 292 * @since 9 293 */ 294 abilityIconId?: number; 295 296 /** 297 * The launch count of module. 298 * @type { number } 299 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 300 * @systemapi Hide this for inner system use. 301 * @since 9 302 */ 303 launchedCount: number; 304 305 /** 306 * The last time when the module was accessed, in milliseconds. 307 * @type { number } 308 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 309 * @systemapi Hide this for inner system use. 310 * @since 9 311 */ 312 lastModuleUsedTime: number; 313 314 /** 315 * The form usage record list of current module. 316 * @type { Array<HapFormInfo> } 317 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 318 * @systemapi Hide this for inner system use. 319 * @since 9 320 */ 321 formRecords: Array<HapFormInfo>; 322 } 323 324 /** 325 * @interface DeviceEventStats 326 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 327 * @systemapi Hide this for inner system use. 328 * @since 9 329 */ 330 interface DeviceEventStats { 331 /** 332 * The bundle name or system event name. 333 * @type { string } 334 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 335 * @systemapi Hide this for inner system use. 336 * @since 9 337 */ 338 name: string; 339 340 /** 341 * The event id. 342 * @type { number } 343 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 344 * @systemapi Hide this for inner system use. 345 * @since 9 346 */ 347 eventId: number; 348 349 /** 350 * The the event occurrence number. 351 * @type { number } 352 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 353 * @systemapi Hide this for inner system use. 354 * @since 9 355 */ 356 count: number; 357 } 358 359 /** 360 * @interface BundleEvents 361 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 362 * @systemapi Hide this for inner system use. 363 * @since 9 364 */ 365 interface BundleEvents { 366 /** 367 * The usage group of the application. 368 * @type { ?number } 369 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 370 * @systemapi Hide this for inner system use. 371 * @since 9 372 */ 373 appGroup?: number; 374 375 /** 376 * The bundle name. 377 * @type { ?string } 378 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 379 * @systemapi Hide this for inner system use. 380 * @since 9 381 */ 382 bundleName?: string; 383 384 /** 385 * The shortcut ID. 386 * @type { ?string } 387 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 388 * @systemapi Hide this for inner system use. 389 * @since 9 390 */ 391 indexOfLink?: string; 392 393 /** 394 * The class name. 395 * @type { ?string } 396 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 397 * @systemapi Hide this for inner system use. 398 * @since 9 399 */ 400 nameOfClass?: string; 401 402 /** 403 * The time when this state occurred, in milliseconds. 404 * @type { ?number } 405 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 406 * @systemapi Hide this for inner system use. 407 * @since 9 408 */ 409 eventOccurredTime?: number; 410 411 /** 412 * The event id. 413 * @type { ?number } 414 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 415 * @systemapi Hide this for inner system use. 416 * @since 9 417 */ 418 eventId?: number; 419 } 420 421 /** 422 * @interface AppGroupCallbackInfo 423 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 424 * @systemapi Hide this for inner system use. 425 * @since 9 426 */ 427 interface AppGroupCallbackInfo { 428 /** 429 * The usage old group of the application 430 * @type { number } 431 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 432 * @systemapi Hide this for inner system use. 433 * @since 9 434 */ 435 appOldGroup: number; 436 437 /** 438 * The usage new group of the application 439 * @type { number } 440 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 441 * @systemapi Hide this for inner system use. 442 * @since 9 443 */ 444 appNewGroup: number; 445 446 /** 447 * The use id 448 * @type { number } 449 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 450 * @systemapi Hide this for inner system use. 451 * @since 9 452 */ 453 userId: number; 454 455 /** 456 * The change reason 457 * @type { number } 458 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 459 * @systemapi Hide this for inner system use. 460 * @since 9 461 */ 462 changeReason: number; 463 464 /** 465 * The bundle name 466 * @type { string } 467 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 468 * @systemapi Hide this for inner system use. 469 * @since 9 470 */ 471 bundleName: string; 472 } 473 474 /** 475 * Checks whether the application with a specified bundle name is in the idle state. 476 * 477 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 478 * @param { string } bundleName - Indicates the bundle name of the application to query. 479 * @param { AsyncCallback<boolean> } callback - the callback of isIdleState. 480 * <p> boolean value is true mean the application is idle in a particular period; false mean otherwise. 481 * The time range of the particular period is defined by the system, which may be hours or days.</p> 482 * @throws { BusinessError } 201 - Permission denied. 483 * @throws { BusinessError } 202 - Not System App. 484 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 485 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 486 * @throws { BusinessError } 801 - Capability not supported. 487 * @throws { BusinessError } 10000001 - Memory operation failed. 488 * @throws { BusinessError } 10000002 - Parcel operation failed. 489 * @throws { BusinessError } 10000003 - System service operation failed. 490 * @throws { BusinessError } 10000004 - IPC failed. 491 * @throws { BusinessError } 10000006 - Failed to get the application information. 492 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 493 * @systemapi Hide this for inner system use. 494 * @since 9 495 */ 496 function isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void; 497 498 /** 499 * Checks whether the application with a specified bundle name is in the idle state. 500 * 501 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 502 * @param { string } bundleName - Indicates the bundle name of the application to query. 503 * @returns { Promise<boolean> } the promise returned by isIdleState. 504 * <p> boolean value is true mean the application is idle in a particular period; false mean otherwise. 505 * The time range of the particular period is defined by the system, which may be hours or days.</p> 506 * @throws { BusinessError } 201 - Permission denied. 507 * @throws { BusinessError } 202 - Not System App. 508 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 509 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 510 * @throws { BusinessError } 801 - Capability not supported. 511 * @throws { BusinessError } 10000001 - Memory operation failed. 512 * @throws { BusinessError } 10000002 - Parcel operation failed. 513 * @throws { BusinessError } 10000003 - System service operation failed. 514 * @throws { BusinessError } 10000004 - IPC failed. 515 * @throws { BusinessError } 10000006 - Failed to get the application information. 516 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 517 * @systemapi Hide this for inner system use. 518 * @since 9 519 */ 520 function isIdleState(bundleName: string): Promise<boolean>; 521 522 /** 523 * Checks whether the application with a specified bundle name is in the idle state. 524 * 525 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 526 * @param { string } bundleName - Indicates the bundle name of the application to query. 527 * @returns { boolean } 528 * <p> boolean value is true mean the application is idle in a particular period; false mean otherwise. 529 * The time range of the particular period is defined by the system, which may be hours or days.</p> 530 * @throws { BusinessError } 201 - Permission denied. 531 * @throws { BusinessError } 202 - Not System App. 532 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 533 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 534 * @throws { BusinessError } 801 - Capability not supported. 535 * @throws { BusinessError } 10000001 - Memory operation failed. 536 * @throws { BusinessError } 10000002 - Parcel operation failed. 537 * @throws { BusinessError } 10000003 - System service operation failed. 538 * @throws { BusinessError } 10000004 - IPC failed. 539 * @throws { BusinessError } 10000006 - Failed to get the application information. 540 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 541 * @systemapi Hide this for inner system use. 542 * @since 10 543 */ 544 function isIdleStateSync(bundleName: string): boolean; 545 546 /** 547 * Queries the app group of the calling application. 548 * <p>The priority defined in a priority group restricts the resource usage of an application, 549 * for example, restricting the running of background tasks. </p> 550 * 551 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 552 * @param { AsyncCallback<number> } callback - the callback of queryAppGroup. 553 * <p> Returns the app group of the calling application.</p> 554 * @throws { BusinessError } 201 - Permission denied. 555 * @throws { BusinessError } 202 - Not System App. 556 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 557 * @throws { BusinessError } 801 - Capability not supported. 558 * @throws { BusinessError } 10000001 - Memory operation failed. 559 * @throws { BusinessError } 10000002 - Parcel operation failed. 560 * @throws { BusinessError } 10000003 - System service operation failed. 561 * @throws { BusinessError } 10000004 - IPC failed. 562 * @throws { BusinessError } 10000005 - Application is not installed. 563 * @throws { BusinessError } 10000006 - Failed to get the application information. 564 * @throws { BusinessError } 10100002 - Failed to get the application group information. 565 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 566 * @systemapi Hide this for inner system use. 567 * @since 9 568 */ 569 function queryAppGroup(callback: AsyncCallback<number>): void; 570 571 /** 572 * Queries the app group of the calling application. 573 * <p>The priority defined in a priority group restricts the resource usage of an application, 574 * for example, restricting the running of background tasks. </p> 575 * 576 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 577 * @returns { Promise<number> } the promise returned by queryAppGroup. 578 * <p> Returns the app group of the calling application.</p> 579 * @throws { BusinessError } 201 - Permission denied. 580 * @throws { BusinessError } 202 - Not System App. 581 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 582 * @throws { BusinessError } 801 - Capability not supported. 583 * @throws { BusinessError } 10000001 - Memory operation failed. 584 * @throws { BusinessError } 10000002 - Parcel operation failed. 585 * @throws { BusinessError } 10000003 - System service operation failed. 586 * @throws { BusinessError } 10000004 - IPC failed. 587 * @throws { BusinessError } 10000005 - Application is not installed. 588 * @throws { BusinessError } 10000006 - Failed to get the application information. 589 * @throws { BusinessError } 10100002 - Failed to get the application group information. 590 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 591 * @systemapi Hide this for inner system use. 592 * @since 9 593 */ 594 function queryAppGroup(): Promise<number>; 595 596 /** 597 * Queries the app group of the calling application. 598 * <p>The priority defined in a priority group restricts the resource usage of an application, 599 * for example, restricting the running of background tasks. </p> 600 * 601 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 602 * @returns { number } Returns the app group of the calling application. 603 * @throws { BusinessError } 201 - Permission denied. 604 * @throws { BusinessError } 202 - Not System App. 605 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 606 * @throws { BusinessError } 801 - Capability not supported. 607 * @throws { BusinessError } 10000001 - Memory operation failed. 608 * @throws { BusinessError } 10000002 - Parcel operation failed. 609 * @throws { BusinessError } 10000003 - System service operation failed. 610 * @throws { BusinessError } 10000004 - IPC failed. 611 * @throws { BusinessError } 10000005 - Application is not installed. 612 * @throws { BusinessError } 10000006 - Failed to get the application information. 613 * @throws { BusinessError } 10100002 - Failed to get the application group information. 614 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 615 * @systemapi Hide this for inner system use. 616 * @since 10 617 */ 618 function queryAppGroupSync(): number; 619 620 /** 621 * Queries the usage priority group by bundleName. 622 * <p>The priority defined in a priority group restricts the resource usage of an application, 623 * for example, restricting the running of background tasks. </p> 624 * 625 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 626 * @param { string } bundleName - name of the application. 627 * @param { AsyncCallback<number> } callback - the callback of queryAppGroup. 628 * <p> the usage priority group of the calling application.</p> 629 * @throws { BusinessError } 201 - Permission denied. 630 * @throws { BusinessError } 202 - Not System App. 631 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 632 * @throws { BusinessError } 801 - Capability not supported. 633 * @throws { BusinessError } 10000001 - Memory operation failed. 634 * @throws { BusinessError } 10000002 - Parcel operation failed. 635 * @throws { BusinessError } 10000003 - System service operation failed. 636 * @throws { BusinessError } 10000004 - IPC failed. 637 * @throws { BusinessError } 10000005 - Application is not installed. 638 * @throws { BusinessError } 10000006 - Failed to get the application information. 639 * @throws { BusinessError } 10100002 - Failed to get the application group information. 640 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 641 * @systemapi Hide this for inner system use. 642 * @since 9 643 */ 644 function queryAppGroup(bundleName: string, callback: AsyncCallback<number>): void; 645 646 /** 647 * Queries the usage priority group by bundleName. 648 * <p>The priority defined in a priority group restricts the resource usage of an application, 649 * for example, restricting the running of background tasks. </p> 650 * 651 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 652 * @param { string } bundleName - name of the application. 653 * @returns { Promise<number> } the promise returned by queryAppGroup. 654 * <p> the usage priority group of the calling application.</p> 655 * @throws { BusinessError } 201 - Permission denied. 656 * @throws { BusinessError } 202 - Not System App. 657 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 658 * @throws { BusinessError } 801 - Capability not supported. 659 * @throws { BusinessError } 10000001 - Memory operation failed. 660 * @throws { BusinessError } 10000002 - Parcel operation failed. 661 * @throws { BusinessError } 10000003 - System service operation failed. 662 * @throws { BusinessError } 10000004 - IPC failed. 663 * @throws { BusinessError } 10000005 - Application is not installed. 664 * @throws { BusinessError } 10000006 - Failed to get the application information. 665 * @throws { BusinessError } 10100002 - Failed to get the application group information. 666 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 667 * @systemapi Hide this for inner system use. 668 * @since 9 669 */ 670 function queryAppGroup(bundleName: string): Promise<number>; 671 672 /** 673 * Queries the usage priority group by bundleName. 674 * <p>The priority defined in a priority group restricts the resource usage of an application, 675 * for example, restricting the running of background tasks. </p> 676 * 677 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 678 * @param { string } bundleName - name of the application. 679 * @returns { number } the usage priority group of the calling application. 680 * @throws { BusinessError } 201 - Permission denied. 681 * @throws { BusinessError } 202 - Not System App. 682 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 683 * @throws { BusinessError } 801 - Capability not supported. 684 * @throws { BusinessError } 10000001 - Memory operation failed. 685 * @throws { BusinessError } 10000002 - Parcel operation failed. 686 * @throws { BusinessError } 10000003 - System service operation failed. 687 * @throws { BusinessError } 10000004 - IPC failed. 688 * @throws { BusinessError } 10000005 - Application is not installed. 689 * @throws { BusinessError } 10000006 - Failed to get the application information. 690 * @throws { BusinessError } 10100002 - Failed to get the application group information. 691 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 692 * @systemapi Hide this for inner system use. 693 * @since 10 694 */ 695 function queryAppGroupSync(bundleName: string): number; 696 697 /** 698 * @typedef { Record<string, BundleStatsInfo> } 699 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 700 * @systemapi Hide this for inner system use. 701 * @since 9 702 */ 703 type BundleStatsMap = Record<string, BundleStatsInfo>; 704 705 /** 706 * Queries usage information about each bundle within a specified period. 707 * <p>This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.</p> 708 * 709 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 710 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 711 * @param { number } end - Indicates the end time of the query period, in milliseconds. 712 * @param { AsyncCallback<BundleStatsMap> } callback - the callback of queryBundleStatsInfos, 713 * <p> the {@link BundleStatsMap} objects containing the usage information about each bundle.</p> 714 * @throws { BusinessError } 201 - Permission denied. 715 * @throws { BusinessError } 202 - Not System App. 716 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 717 * @throws { BusinessError } 801 - Capability not supported. 718 * @throws { BusinessError } 10000001 - Memory operation failed. 719 * @throws { BusinessError } 10000002 - Parcel operation failed. 720 * @throws { BusinessError } 10000003 - System service operation failed. 721 * @throws { BusinessError } 10000004 - IPC failed. 722 * @throws { BusinessError } 10000006 - Failed to get the application information. 723 * @throws { BusinessError } 10000007 - Failed to get the system time. 724 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 725 * @systemapi Hide this for inner system use. 726 * @since 9 727 */ 728 function queryBundleStatsInfos(begin: number, end: number, callback: AsyncCallback<BundleStatsMap>): void; 729 730 /** 731 * Queries usage information about each bundle within a specified period. 732 * <p>This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.</p> 733 * 734 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 735 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 736 * @param { number } end - Indicates the end time of the query period, in milliseconds. 737 * @returns { Promise<BundleStatsMap> } the promise returned by queryBundleStatsInfos. 738 * <p> the {@link BundleStatsMap} objects containing the usage information about each bundle.</p> 739 * @throws { BusinessError } 201 - Permission denied. 740 * @throws { BusinessError } 202 - Not System App. 741 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 742 * @throws { BusinessError } 801 - Capability not supported. 743 * @throws { BusinessError } 10000001 - Memory operation failed. 744 * @throws { BusinessError } 10000002 - Parcel operation failed. 745 * @throws { BusinessError } 10000003 - System service operation failed. 746 * @throws { BusinessError } 10000004 - IPC failed. 747 * @throws { BusinessError } 10000006 - Failed to get the application information. 748 * @throws { BusinessError } 10000007 - Failed to get the system time. 749 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 750 * @systemapi Hide this for inner system use. 751 * @since 9 752 */ 753 function queryBundleStatsInfos(begin: number, end: number): Promise<BundleStatsMap>; 754 755 /** 756 * @typedef { Record<string, Array<BundleStatsInfo>> } 757 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 758 * @systemapi Hide this for inner system use. 759 * @since 15 760 */ 761 type AppStatsMap = Record<string, Array<BundleStatsInfo>>; 762 763 /** 764 * Queries usage information about each application within a specified period. 765 * <p>This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.</p> 766 * 767 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 768 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 769 * @param { number } end - Indicates the end time of the query period, in milliseconds. 770 * @returns { Promise<AppStatsMap> } the promise returned by queryAppStatsInfos. 771 * <p> the {@link AppStatsMap} objects containing the usage information about each application.</p> 772 * @throws { BusinessError } 201 - Permission denied. 773 * @throws { BusinessError } 202 - Not System App. 774 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 775 * @throws { BusinessError } 801 - Capability not supported. 776 * @throws { BusinessError } 10000001 - Memory operation failed. 777 * @throws { BusinessError } 10000002 - Parcel operation failed. 778 * @throws { BusinessError } 10000003 - System service operation failed. 779 * @throws { BusinessError } 10000004 - IPC failed. 780 * @throws { BusinessError } 10000006 - Failed to get the application information. 781 * @throws { BusinessError } 10000007 - Failed to get the system time. 782 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 783 * @systemapi Hide this for inner system use. 784 * @since 15 785 */ 786 function queryAppStatsInfos(begin: number, end: number): Promise<AppStatsMap>; 787 788 /** 789 * Queries the last usage timestamp by bundleName and app index. 790 * 791 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 792 * @param { string } bundleName - name of the application. 793 * @param { appInfo } bundle name and app index info for each application. 794 * @returns { Promise<AppStatsMap> } the promise returned by queryLastUseTime. 795 * <p> the {@link AppStatsMap} objects containing the usage information about each application.</p> 796 * @throws { BusinessError } 201 - Permission denied. 797 * @throws { BusinessError } 202 - Not System App. 798 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 799 * @throws { BusinessError } 801 - Capability not supported. 800 * @throws { BusinessError } 10000001 - Memory operation failed. 801 * @throws { BusinessError } 10000002 - Parcel operation failed. 802 * @throws { BusinessError } 10000003 - System service operation failed. 803 * @throws { BusinessError } 10000004 - IPC failed. 804 * @throws { BusinessError } 10000006 - Failed to get the application information. 805 * @throws { BusinessError } 10000007 - Failed to get the system time. 806 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 807 * @systemapi Hide this for inner system use. 808 * @since 15 809 */ 810 function queryLastUseTime(appInfo: Record<string, Array<number>>): Promise<AppStatsMap>; 811 812 /** 813 * Declares interval type. 814 * 815 * @enum { number } 816 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 817 * @systemapi Hide this for inner system use. 818 * @since 9 819 */ 820 export enum IntervalType { 821 /** 822 * Indicates the interval type that will determine the optimal interval based on the start and end time. 823 * 824 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 825 * @systemapi Hide this for inner system use. 826 * @since 9 827 */ 828 BY_OPTIMIZED = 0, 829 830 /** 831 * Indicates the daily interval. 832 * 833 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 834 * @systemapi Hide this for inner system use. 835 * @since 9 836 */ 837 BY_DAILY = 1, 838 839 /** 840 * Indicates the weekly interval. 841 * 842 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 843 * @systemapi Hide this for inner system use. 844 * @since 9 845 */ 846 BY_WEEKLY = 2, 847 848 /** 849 * Indicates the monthly interval. 850 * 851 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 852 * @systemapi Hide this for inner system use. 853 * @since 9 854 */ 855 BY_MONTHLY = 3, 856 857 /** 858 * Indicates the annually interval. 859 * 860 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 861 * @systemapi Hide this for inner system use. 862 * @since 9 863 */ 864 BY_ANNUALLY = 4 865 } 866 867 /** 868 * Queries usage information about each bundle within a specified period at a specified interval. 869 * 870 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 871 * @param { IntervalType } byInterval - Indicates the interval at which the usage statistics are queried. 872 * <p> The value can be {@link #BY_OPTIMIZED}, {@link #BY_DAILY}, 873 * {@link #BY_WEEKLY}, {@link #BY_MONTHLY}, or {@link #BY_ANNUALLY}.</p> 874 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 875 * @param { number } end - Indicates the end time of the query period, in milliseconds. 876 * @param { AsyncCallback<Array<BundleStatsInfo>> } callback - the callback of queryBundleStatsInfoByInterval. 877 * <p> the list of {@link BundleStatsInfo} objects containing the usage information about each bundle.</p> 878 * @throws { BusinessError } 201 - Permission denied. 879 * @throws { BusinessError } 202 - Not System App. 880 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 881 * @throws { BusinessError } 801 - Capability not supported. 882 * @throws { BusinessError } 10000001 - Memory operation failed. 883 * @throws { BusinessError } 10000002 - Parcel operation failed. 884 * @throws { BusinessError } 10000003 - System service operation failed. 885 * @throws { BusinessError } 10000004 - IPC failed. 886 * @throws { BusinessError } 10000006 - Failed to get the application information. 887 * @throws { BusinessError } 10000007 - Failed to get the system time. 888 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 889 * @systemapi Hide this for inner system use. 890 * @since 9 891 */ 892 function queryBundleStatsInfoByInterval( 893 byInterval: IntervalType, 894 begin: number, 895 end: number, 896 callback: AsyncCallback<Array<BundleStatsInfo>> 897 ): void; 898 899 /** 900 * Queries usage information about each bundle within a specified period at a specified interval. 901 * 902 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 903 * @param { IntervalType } byInterval - Indicates the interval at which the usage statistics are queried. 904 * <p> The value can be {@link #BY_OPTIMIZED}, {@link #BY_DAILY}, 905 * {@link #BY_WEEKLY}, {@link #BY_MONTHLY}, or {@link #BY_ANNUALLY}.</p> 906 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 907 * @param { number } end - Indicates the end time of the query period, in milliseconds. 908 * @returns { Promise<Array<BundleStatsInfo>> } the promise returned by queryBundleStatsInfoByInterval. 909 * <p> the list of {@link BundleStatsInfo} objects containing the usage information about each bundle.</p> 910 * @throws { BusinessError } 201 - Permission denied. 911 * @throws { BusinessError } 202 - Not System App. 912 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 913 * @throws { BusinessError } 801 - Capability not supported. 914 * @throws { BusinessError } 10000001 - Memory operation failed. 915 * @throws { BusinessError } 10000002 - Parcel operation failed. 916 * @throws { BusinessError } 10000003 - System service operation failed. 917 * @throws { BusinessError } 10000004 - IPC failed. 918 * @throws { BusinessError } 10000006 - Failed to get the application information. 919 * @throws { BusinessError } 10000007 - Failed to get the system time. 920 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 921 * @systemapi Hide this for inner system use. 922 * @since 9 923 */ 924 function queryBundleStatsInfoByInterval( 925 byInterval: IntervalType, 926 begin: number, 927 end: number 928 ): Promise<Array<BundleStatsInfo>>; 929 930 /** 931 * Queries state data of all bundles within a specified period identified by the start and end time. 932 * 933 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 934 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 935 * @param { number } end - Indicates the end time of the query period, in milliseconds. 936 * @param { AsyncCallback<Array<BundleEvents>> } callback - the promise returned by queryBundleEvents. 937 * <p> the list of {@link BundleEvents} objects containing the state data of all bundles.</p> 938 * @throws { BusinessError } 201 - Permission denied. 939 * @throws { BusinessError } 202 - Not System App. 940 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 941 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 942 * @throws { BusinessError } 801 - Capability not supported. 943 * @throws { BusinessError } 10000001 - Memory operation failed. 944 * @throws { BusinessError } 10000002 - Parcel operation failed. 945 * @throws { BusinessError } 10000003 - System service operation failed. 946 * @throws { BusinessError } 10000004 - IPC failed. 947 * @throws { BusinessError } 10000006 - Failed to get the application information. 948 * @throws { BusinessError } 10000007 - Failed to get the system time. 949 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 950 * @systemapi Hide this for inner system use. 951 * @since 9 952 */ 953 function queryBundleEvents(begin: number, end: number, callback: AsyncCallback<Array<BundleEvents>>): void; 954 955 /** 956 * Queries state data of all bundles within a specified period identified by the start and end time. 957 * 958 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 959 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 960 * @param { number } end - Indicates the end time of the query period, in milliseconds. 961 * @returns { Promise<Array<BundleEvents>> } the promise returned by queryBundleEvents. 962 * <p> the list of {@link BundleEvents} objects containing the state data of all bundles.</p> 963 * @throws { BusinessError } 201 - Permission denied. 964 * @throws { BusinessError } 202 - Not System App. 965 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 966 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 967 * @throws { BusinessError } 801 - Capability not supported. 968 * @throws { BusinessError } 10000001 - Memory operation failed. 969 * @throws { BusinessError } 10000002 - Parcel operation failed. 970 * @throws { BusinessError } 10000003 - System service operation failed. 971 * @throws { BusinessError } 10000004 - IPC failed. 972 * @throws { BusinessError } 10000006 - Failed to get the application information. 973 * @throws { BusinessError } 10000007 - Failed to get the system time. 974 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 975 * @systemapi Hide this for inner system use. 976 * @since 9 977 */ 978 function queryBundleEvents(begin: number, end: number): Promise<Array<BundleEvents>>; 979 980 /** 981 * Queries state data of the current bundle within a specified period. 982 * 983 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 984 * @param { number } end - Indicates the end time of the query period, in milliseconds. 985 * @param { AsyncCallback<Array<BundleEvents>> } callback - the callback of queryCurrentBundleEvents. 986 * <p> the {@link BundleEvents} object Array containing the state data of the current bundle.</p> 987 * @throws { BusinessError } 202 - Not System App. 988 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 989 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 990 * @throws { BusinessError } 801 - Capability not supported. 991 * @throws { BusinessError } 10000001 - Memory operation failed. 992 * @throws { BusinessError } 10000002 - Parcel operation failed. 993 * @throws { BusinessError } 10000003 - System service operation failed. 994 * @throws { BusinessError } 10000004 - IPC failed. 995 * @throws { BusinessError } 10000006 - Failed to get the application information. 996 * @throws { BusinessError } 10000007 - Failed to get the system time. 997 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 998 * @systemapi Hide this for inner system use. 999 * @since 9 1000 */ 1001 function queryCurrentBundleEvents(begin: number, end: number, callback: AsyncCallback<Array<BundleEvents>>): void; 1002 1003 /** 1004 * Queries state data of the current bundle within a specified period. 1005 * 1006 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 1007 * @param { number } end - Indicates the end time of the query period, in milliseconds. 1008 * @returns { Promise<Array<BundleEvents>> } the promise returned by queryCurrentBundleEvents. 1009 * <p> the {@link BundleEvents} object Array containing the state data of the current bundle.</p> 1010 * @throws { BusinessError } 202 - Not System App. 1011 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1012 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1013 * @throws { BusinessError } 801 - Capability not supported. 1014 * @throws { BusinessError } 10000001 - Memory operation failed. 1015 * @throws { BusinessError } 10000002 - Parcel operation failed. 1016 * @throws { BusinessError } 10000003 - System service operation failed. 1017 * @throws { BusinessError } 10000004 - IPC failed. 1018 * @throws { BusinessError } 10000006 - Failed to get the application information. 1019 * @throws { BusinessError } 10000007 - Failed to get the system time. 1020 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1021 * @systemapi Hide this for inner system use. 1022 * @since 9 1023 */ 1024 function queryCurrentBundleEvents(begin: number, end: number): Promise<Array<BundleEvents>>; 1025 1026 /** 1027 * Queries recently module usage records with maxNum. 1028 * 1029 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1030 * @param { number } maxNum - Indicates max record number in result, max value is 1000, default value is 1000. 1031 * @param { AsyncCallback<Array<HapModuleInfo>> } callback - the callback of queryModuleUsageRecords. 1032 * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p> 1033 * @throws { BusinessError } 201 - Permission denied. 1034 * @throws { BusinessError } 202 - Not System App. 1035 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1036 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1037 * @throws { BusinessError } 801 - Capability not supported. 1038 * @throws { BusinessError } 10000001 - Memory operation failed. 1039 * @throws { BusinessError } 10000002 - Parcel operation failed. 1040 * @throws { BusinessError } 10000003 - System service operation failed. 1041 * @throws { BusinessError } 10000004 - IPC failed. 1042 * @throws { BusinessError } 10000006 - Failed to get the application information. 1043 * @throws { BusinessError } 10000007 - Failed to get the system time. 1044 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1045 * @systemapi Hide this for inner system use. 1046 * @since 9 1047 */ 1048 function queryModuleUsageRecords(maxNum: number, callback: AsyncCallback<Array<HapModuleInfo>>): void; 1049 1050 /** 1051 * Queries recently module usage records with maxNum. 1052 * 1053 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1054 * @param { number } maxNum - Indicates max record number in result, max value is 1000, default value is 1000. 1055 * @returns { Promise<Array<HapModuleInfo>> } the promise returned by queryModuleUsageRecords. 1056 * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p> 1057 * @throws { BusinessError } 201 - Permission denied. 1058 * @throws { BusinessError } 202 - Not System App. 1059 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1060 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1061 * @throws { BusinessError } 801 - Capability not supported. 1062 * @throws { BusinessError } 10000001 - Memory operation failed. 1063 * @throws { BusinessError } 10000002 - Parcel operation failed. 1064 * @throws { BusinessError } 10000003 - System service operation failed. 1065 * @throws { BusinessError } 10000004 - IPC failed. 1066 * @throws { BusinessError } 10000006 - Failed to get the application information. 1067 * @throws { BusinessError } 10000007 - Failed to get the system time. 1068 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1069 * @systemapi Hide this for inner system use. 1070 * @since 9 1071 */ 1072 function queryModuleUsageRecords(maxNum: number): Promise<Array<HapModuleInfo>>; 1073 1074 /** 1075 * Queries recently module usage records. 1076 * 1077 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1078 * @param { AsyncCallback<Array<HapModuleInfo>> } callback - the callback of queryModuleUsageRecords. 1079 * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p> 1080 * @throws { BusinessError } 201 - Permission denied. 1081 * @throws { BusinessError } 202 - Not System App. 1082 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1083 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1084 * @throws { BusinessError } 801 - Capability not supported. 1085 * @throws { BusinessError } 10000001 - Memory operation failed. 1086 * @throws { BusinessError } 10000002 - Parcel operation failed. 1087 * @throws { BusinessError } 10000003 - System service operation failed. 1088 * @throws { BusinessError } 10000004 - IPC failed. 1089 * @throws { BusinessError } 10000006 - Failed to get the application information. 1090 * @throws { BusinessError } 10000007 - Failed to get the system time. 1091 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1092 * @systemapi Hide this for inner system use. 1093 * @since 9 1094 */ 1095 function queryModuleUsageRecords(callback: AsyncCallback<Array<HapModuleInfo>>): void; 1096 1097 /** 1098 * Queries recently module usage records. 1099 * 1100 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1101 * @returns { Promise<Array<HapModuleInfo>> } the promise returned by queryModuleUsageRecords. 1102 * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p> 1103 * @throws { BusinessError } 201 - Permission denied. 1104 * @throws { BusinessError } 202 - Not System App. 1105 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1106 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1107 * @throws { BusinessError } 801 - Capability not supported. 1108 * @throws { BusinessError } 10000001 - Memory operation failed. 1109 * @throws { BusinessError } 10000002 - Parcel operation failed. 1110 * @throws { BusinessError } 10000003 - System service operation failed. 1111 * @throws { BusinessError } 10000004 - IPC failed. 1112 * @throws { BusinessError } 10000006 - Failed to get the application information. 1113 * @throws { BusinessError } 10000007 - Failed to get the system time. 1114 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1115 * @systemapi Hide this for inner system use. 1116 * @since 9 1117 */ 1118 function queryModuleUsageRecords(): Promise<Array<HapModuleInfo>>; 1119 1120 /** 1121 * Declares group type. 1122 * 1123 * @enum { number } 1124 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1125 * @systemapi Hide this for inner system use. 1126 * @since 9 1127 */ 1128 export enum GroupType { 1129 /** 1130 * Indicates the alive group. 1131 * 1132 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1133 * @systemapi Hide this for inner system use. 1134 * @since 9 1135 */ 1136 ALIVE_GROUP = 10, 1137 1138 /** 1139 * Indicates the daily group. 1140 * 1141 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1142 * @systemapi Hide this for inner system use. 1143 * @since 9 1144 */ 1145 DAILY_GROUP = 20, 1146 1147 /** 1148 * Indicates the fixed group. 1149 * 1150 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1151 * @systemapi Hide this for inner system use. 1152 * @since 9 1153 */ 1154 FIXED_GROUP = 30, 1155 1156 /** 1157 * Indicates the rare group. 1158 * 1159 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1160 * @systemapi Hide this for inner system use. 1161 * @since 9 1162 */ 1163 RARE_GROUP = 40, 1164 1165 /** 1166 * Indicates the limit group. 1167 * 1168 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1169 * @systemapi Hide this for inner system use. 1170 * @since 9 1171 */ 1172 LIMITED_GROUP = 50, 1173 1174 /** 1175 * Indicates the never group. 1176 * 1177 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1178 * @systemapi Hide this for inner system use. 1179 * @since 9 1180 */ 1181 NEVER_GROUP = 60 1182 } 1183 1184 /** 1185 * Set app group by bundleName. 1186 * 1187 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1188 * @param { string } bundleName - name of the application. 1189 * @param { GroupType } newGroup - the group of the application whose name is bundleName. 1190 * @param { AsyncCallback<void> } callback - the callback of setAppGroup. 1191 * @throws { BusinessError } 201 - Permission denied. 1192 * @throws { BusinessError } 202 - Not System App. 1193 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1194 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1195 * @throws { BusinessError } 801 - Capability not supported. 1196 * @throws { BusinessError } 10000001 - Memory operation failed. 1197 * @throws { BusinessError } 10000002 - Parcel operation failed. 1198 * @throws { BusinessError } 10000003 - System service operation failed. 1199 * @throws { BusinessError } 10000004 - IPC failed. 1200 * @throws { BusinessError } 10000006 - Failed to get the application information. 1201 * @throws { BusinessError } 10100001 - Repeated operation on the application group. 1202 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1203 * @systemapi Hide this for inner system use. 1204 * @since 9 1205 */ 1206 function setAppGroup(bundleName: string, newGroup: GroupType, callback: AsyncCallback<void>): void; 1207 1208 /** 1209 * Set app group by bundleName. 1210 * 1211 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1212 * @param { string } bundleName - name of the application. 1213 * @param { GroupType } newGroup - the group of the application whose name is bundleName. 1214 * @returns { Promise<void> } the promise returned by setAppGroup. 1215 * @throws { BusinessError } 201 - Permission denied. 1216 * @throws { BusinessError } 202 - Not System App. 1217 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1218 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1219 * @throws { BusinessError } 801 - Capability not supported. 1220 * @throws { BusinessError } 10000001 - Memory operation failed. 1221 * @throws { BusinessError } 10000002 - Parcel operation failed. 1222 * @throws { BusinessError } 10000003 - System service operation failed. 1223 * @throws { BusinessError } 10000004 - IPC failed. 1224 * @throws { BusinessError } 10000006 - Failed to get the application information. 1225 * @throws { BusinessError } 10100001 - Repeated operation on the application group. 1226 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1227 * @systemapi Hide this for inner system use. 1228 * @since 9 1229 */ 1230 function setAppGroup(bundleName: string, newGroup: GroupType): Promise<void>; 1231 1232 /** 1233 * Register appGroup change callback to service. 1234 * 1235 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1236 * @param { Callback<AppGroupCallbackInfo> } groupCallback - 1237 * <p> callback of AppGroupCallbackInfo when the group of app changed.</p> 1238 * @param { AsyncCallback<void> } callback - the callback of registerAppGroupCallBack. 1239 * @throws { BusinessError } 201 - Permission denied. 1240 * @throws { BusinessError } 202 - Not System App. 1241 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1242 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1243 * @throws { BusinessError } 801 - Capability not supported. 1244 * @throws { BusinessError } 10000001 - Memory operation failed. 1245 * @throws { BusinessError } 10000002 - Parcel operation failed. 1246 * @throws { BusinessError } 10000003 - System service operation failed. 1247 * @throws { BusinessError } 10000004 - IPC failed. 1248 * @throws { BusinessError } 10100001 - Repeated operation on the application group. 1249 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1250 * @systemapi Hide this for inner system use. 1251 * @since 9 1252 */ 1253 function registerAppGroupCallBack(groupCallback: Callback<AppGroupCallbackInfo>, callback: AsyncCallback<void>): void; 1254 1255 /** 1256 * Register appGroup change callback to service. 1257 * 1258 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1259 * @param { Callback<AppGroupCallbackInfo> } groupCallback - 1260 * <p> callback of AppGroupCallbackInfo when the group of app changed.</p> 1261 * @returns { Promise<void> } the promise returned by registerAppGroupCallBack. 1262 * @throws { BusinessError } 201 - Permission denied. 1263 * @throws { BusinessError } 202 - Not System App. 1264 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1265 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1266 * @throws { BusinessError } 801 - Capability not supported. 1267 * @throws { BusinessError } 10000001 - Memory operation failed. 1268 * @throws { BusinessError } 10000002 - Parcel operation failed. 1269 * @throws { BusinessError } 10000003 - System service operation failed. 1270 * @throws { BusinessError } 10000004 - IPC failed. 1271 * @throws { BusinessError } 10100001 - Repeated operation on the application group. 1272 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1273 * @systemapi Hide this for inner system use. 1274 * @since 9 1275 */ 1276 function registerAppGroupCallBack(groupCallback: Callback<AppGroupCallbackInfo>): Promise<void>; 1277 1278 /** 1279 * Unregister appGroup change callback from service. 1280 * 1281 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1282 * @param { AsyncCallback<void> } callback - the callback of unregisterAppGroupCallBack. 1283 * @throws { BusinessError } 201 - Permission denied. 1284 * @throws { BusinessError } 202 - Not System App. 1285 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1286 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1287 * @throws { BusinessError } 801 - Capability not supported. 1288 * @throws { BusinessError } 10000001 - Memory operation failed. 1289 * @throws { BusinessError } 10000002 - Parcel operation failed. 1290 * @throws { BusinessError } 10000003 - System service operation failed. 1291 * @throws { BusinessError } 10000004 - IPC failed. 1292 * @throws { BusinessError } 10100001 - Repeated operation on the application group. 1293 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1294 * @systemapi Hide this for inner system use. 1295 * @since 9 1296 */ 1297 function unregisterAppGroupCallBack(callback: AsyncCallback<void>): void; 1298 1299 /** 1300 * Unregister appGroup change callback from service. 1301 * 1302 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1303 * @returns { Promise<void> } the promise returned by unregisterAppGroupCallBack. 1304 * @throws { BusinessError } 201 - Permission denied. 1305 * @throws { BusinessError } 202 - Not System App. 1306 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1307 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1308 * @throws { BusinessError } 801 - Capability not supported. 1309 * @throws { BusinessError } 10000001 - Memory operation failed. 1310 * @throws { BusinessError } 10000002 - Parcel operation failed. 1311 * @throws { BusinessError } 10000003 - System service operation failed. 1312 * @throws { BusinessError } 10000004 - IPC failed. 1313 * @throws { BusinessError } 10100001 - Repeated operation on the application group. 1314 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1315 * @systemapi Hide this for inner system use. 1316 * @since 9 1317 */ 1318 function unregisterAppGroupCallBack(): Promise<void>; 1319 1320 /** 1321 * Queries device event states data within a specified period identified by the start and end time. 1322 * 1323 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1324 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 1325 * @param { number } end - Indicates the end time of the query period, in milliseconds. 1326 * @param { AsyncCallback<Array<DeviceEventStats>> } callback - the callback of queryDeviceEventStats. 1327 * <p> the {@link DeviceEventStats} object Array containing the event states data.</p> 1328 * @throws { BusinessError } 201 - Permission denied. 1329 * @throws { BusinessError } 202 - Not System App. 1330 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1331 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1332 * @throws { BusinessError } 801 - Capability not supported. 1333 * @throws { BusinessError } 10000001 - Memory operation failed. 1334 * @throws { BusinessError } 10000002 - Parcel operation failed. 1335 * @throws { BusinessError } 10000003 - System service operation failed. 1336 * @throws { BusinessError } 10000004 - IPC failed. 1337 * @throws { BusinessError } 10000006 - Failed to get the application information. 1338 * @throws { BusinessError } 10000007 - Failed to get the system time. 1339 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1340 * @systemapi Hide this for inner system use. 1341 * @since 9 1342 */ 1343 function queryDeviceEventStats(begin: number, end: number, callback: AsyncCallback<Array<DeviceEventStats>>): void; 1344 1345 /** 1346 * Queries device event states data within a specified period identified by the start and end time. 1347 * 1348 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1349 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 1350 * @param { number } end - Indicates the end time of the query period, in milliseconds. 1351 * @returns { Promise<Array<DeviceEventStats>> } the promise returned by queryDeviceEventStats. 1352 * <p> the {@link DeviceEventStats} object Array containing the event states data.</p> 1353 * @throws { BusinessError } 201 - Permission denied. 1354 * @throws { BusinessError } 202 - Not System App. 1355 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1356 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1357 * @throws { BusinessError } 801 - Capability not supported. 1358 * @throws { BusinessError } 10000001 - Memory operation failed. 1359 * @throws { BusinessError } 10000002 - Parcel operation failed. 1360 * @throws { BusinessError } 10000003 - System service operation failed. 1361 * @throws { BusinessError } 10000004 - IPC failed. 1362 * @throws { BusinessError } 10000006 - Failed to get the application information. 1363 * @throws { BusinessError } 10000007 - Failed to get the system time. 1364 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1365 * @systemapi Hide this for inner system use. 1366 * @since 9 1367 */ 1368 function queryDeviceEventStats(begin: number, end: number): Promise<Array<DeviceEventStats>>; 1369 1370 /** 1371 * Queries app notification number within a specified period identified by the start and end time. 1372 * 1373 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1374 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 1375 * @param { number } end - Indicates the end time of the query period, in milliseconds. 1376 * @param { AsyncCallback<Array<DeviceEventStats>> } callback - the callback of queryNotificationEventStats. 1377 * <p> the {@link DeviceEventStats} object Array containing the event states data.</p> 1378 * @throws { BusinessError } 201 - Permission denied. 1379 * @throws { BusinessError } 202 - Not System App. 1380 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1381 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1382 * @throws { BusinessError } 801 - Capability not supported. 1383 * @throws { BusinessError } 10000001 - Memory operation failed. 1384 * @throws { BusinessError } 10000002 - Parcel operation failed. 1385 * @throws { BusinessError } 10000003 - System service operation failed. 1386 * @throws { BusinessError } 10000004 - IPC failed. 1387 * @throws { BusinessError } 10000006 - Failed to get the application information. 1388 * @throws { BusinessError } 10000007 - Failed to get the system time. 1389 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1390 * @systemapi Hide this for inner system use. 1391 * @since 9 1392 */ 1393 function queryNotificationEventStats( 1394 begin: number, 1395 end: number, 1396 callback: AsyncCallback<Array<DeviceEventStats>> 1397 ): void; 1398 1399 /** 1400 * Queries app notification number within a specified period identified by the start and end time. 1401 * 1402 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1403 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 1404 * @param { number } end - Indicates the end time of the query period, in milliseconds. 1405 * @returns { Promise<Array<DeviceEventStats>> } the promise returned by queryNotificationEventStats. 1406 * <p> the {@link DeviceEventStats} object Array containing the event states data.</p> 1407 * @throws { BusinessError } 201 - Permission denied. 1408 * @throws { BusinessError } 202 - Not System App. 1409 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1410 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1411 * @throws { BusinessError } 801 - Capability not supported. 1412 * @throws { BusinessError } 10000001 - Memory operation failed. 1413 * @throws { BusinessError } 10000002 - Parcel operation failed. 1414 * @throws { BusinessError } 10000003 - System service operation failed. 1415 * @throws { BusinessError } 10000004 - IPC failed. 1416 * @throws { BusinessError } 10000006 - Failed to get the application information. 1417 * @throws { BusinessError } 10000007 - Failed to get the system time. 1418 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1419 * @systemapi Hide this for inner system use. 1420 * @since 9 1421 */ 1422 function queryNotificationEventStats(begin: number, end: number): Promise<Array<DeviceEventStats>>; 1423} 1424 1425export default usageStatistics; 1426