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 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 489 * <br> 2. Failed to apply for memory. 490 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 491 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 492 * @throws { BusinessError } 10000006 - Failed to get the application information. 493 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 494 * @systemapi Hide this for inner system use. 495 * @since 9 496 */ 497 function isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void; 498 499 /** 500 * Checks whether the application with a specified bundle name is in the idle state. 501 * 502 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 503 * @param { string } bundleName - Indicates the bundle name of the application to query. 504 * @returns { Promise<boolean> } the promise returned by isIdleState. 505 * <p> boolean value is true mean the application is idle in a particular period; false mean otherwise. 506 * The time range of the particular period is defined by the system, which may be hours or days.</p> 507 * @throws { BusinessError } 201 - Permission denied. 508 * @throws { BusinessError } 202 - Not System App. 509 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 510 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 511 * @throws { BusinessError } 801 - Capability not supported. 512 * @throws { BusinessError } 10000001 - Memory operation failed. 513 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 514 * <br> 2. Failed to apply for memory. 515 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 516 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 517 * @throws { BusinessError } 10000006 - Failed to get the application information. 518 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 519 * @systemapi Hide this for inner system use. 520 * @since 9 521 */ 522 function isIdleState(bundleName: string): Promise<boolean>; 523 524 /** 525 * Checks whether the application with a specified bundle name is in the idle state. 526 * 527 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 528 * @param { string } bundleName - Indicates the bundle name of the application to query. 529 * @returns { boolean } 530 * <p> boolean value is true mean the application is idle in a particular period; false mean otherwise. 531 * The time range of the particular period is defined by the system, which may be hours or days.</p> 532 * @throws { BusinessError } 201 - Permission denied. 533 * @throws { BusinessError } 202 - Not System App. 534 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 535 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 536 * @throws { BusinessError } 801 - Capability not supported. 537 * @throws { BusinessError } 10000001 - Memory operation failed. 538 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 539 * <br> 2. Failed to apply for memory. 540 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 541 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 542 * @throws { BusinessError } 10000006 - Failed to get the application information. 543 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 544 * @systemapi Hide this for inner system use. 545 * @since 10 546 */ 547 function isIdleStateSync(bundleName: string): boolean; 548 549 /** 550 * Queries the app group of the calling application. 551 * <p>The priority defined in a priority group restricts the resource usage of an application, 552 * for example, restricting the running of background tasks. </p> 553 * 554 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 555 * @param { AsyncCallback<number> } callback - the callback of queryAppGroup. 556 * <p> Returns the app group of the calling application.</p> 557 * @throws { BusinessError } 201 - Permission denied. 558 * @throws { BusinessError } 202 - Not System App. 559 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 560 * @throws { BusinessError } 801 - Capability not supported. 561 * @throws { BusinessError } 10000001 - Memory operation failed. 562 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 563 * <br> 2. Failed to apply for memory. 564 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 565 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 566 * @throws { BusinessError } 10000005 - Application is not installed. 567 * @throws { BusinessError } 10000006 - Failed to get the application information. 568 * @throws { BusinessError } 10100002 - Failed to get the application group information. 569 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 570 * @systemapi Hide this for inner system use. 571 * @since 9 572 */ 573 function queryAppGroup(callback: AsyncCallback<number>): void; 574 575 /** 576 * Queries the app group of the calling application. 577 * <p>The priority defined in a priority group restricts the resource usage of an application, 578 * for example, restricting the running of background tasks. </p> 579 * 580 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 581 * @returns { Promise<number> } the promise returned by queryAppGroup. 582 * <p> Returns the app group of the calling application.</p> 583 * @throws { BusinessError } 201 - Permission denied. 584 * @throws { BusinessError } 202 - Not System App. 585 * @throws { BusinessError } 801 - Capability not supported. 586 * @throws { BusinessError } 10000001 - Memory operation failed. 587 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 588 * <br> 2. Failed to apply for memory. 589 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 590 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 591 * @throws { BusinessError } 10000005 - Application is not installed. 592 * @throws { BusinessError } 10000006 - Failed to get the application information. 593 * @throws { BusinessError } 10100002 - Failed to get the application group information. 594 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 595 * @systemapi Hide this for inner system use. 596 * @since 9 597 */ 598 function queryAppGroup(): Promise<number>; 599 600 /** 601 * Queries the app group of the calling application. 602 * <p>The priority defined in a priority group restricts the resource usage of an application, 603 * for example, restricting the running of background tasks. </p> 604 * 605 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 606 * @returns { number } Returns the app group of the calling application. 607 * @throws { BusinessError } 201 - Permission denied. 608 * @throws { BusinessError } 202 - Not System App. 609 * @throws { BusinessError } 801 - Capability not supported. 610 * @throws { BusinessError } 10000001 - Memory operation failed. 611 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 612 * <br> 2. Failed to apply for memory. 613 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 614 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 615 * @throws { BusinessError } 10000005 - Application is not installed. 616 * @throws { BusinessError } 10000006 - Failed to get the application information. 617 * @throws { BusinessError } 10100002 - Failed to get the application group information. 618 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 619 * @systemapi Hide this for inner system use. 620 * @since 10 621 */ 622 function queryAppGroupSync(): number; 623 624 /** 625 * Queries the usage priority group by bundleName. 626 * <p>The priority defined in a priority group restricts the resource usage of an application, 627 * for example, restricting the running of background tasks. </p> 628 * 629 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 630 * @param { string } bundleName - name of the application. 631 * @param { AsyncCallback<number> } callback - the callback of queryAppGroup. 632 * <p> the usage priority group of the calling application.</p> 633 * @throws { BusinessError } 201 - Permission denied. 634 * @throws { BusinessError } 202 - Not System App. 635 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 636 * @throws { BusinessError } 801 - Capability not supported. 637 * @throws { BusinessError } 10000001 - Memory operation failed. 638 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 639 * <br> 2. Failed to apply for memory. 640 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 641 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 642 * @throws { BusinessError } 10000005 - Application is not installed. 643 * @throws { BusinessError } 10000006 - Failed to get the application information. 644 * @throws { BusinessError } 10100002 - Failed to get the application group information. 645 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 646 * @systemapi Hide this for inner system use. 647 * @since 9 648 */ 649 function queryAppGroup(bundleName: string, callback: AsyncCallback<number>): void; 650 651 /** 652 * Queries the usage priority group by bundleName. 653 * <p>The priority defined in a priority group restricts the resource usage of an application, 654 * for example, restricting the running of background tasks. </p> 655 * 656 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 657 * @param { string } bundleName - name of the application. 658 * @returns { Promise<number> } the promise returned by queryAppGroup. 659 * <p> the usage priority group of the calling application.</p> 660 * @throws { BusinessError } 201 - Permission denied. 661 * @throws { BusinessError } 202 - Not System App. 662 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 663 * @throws { BusinessError } 801 - Capability not supported. 664 * @throws { BusinessError } 10000001 - Memory operation failed. 665 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 666 * <br> 2. Failed to apply for memory. 667 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 668 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 669 * @throws { BusinessError } 10000005 - Application is not installed. 670 * @throws { BusinessError } 10000006 - Failed to get the application information. 671 * @throws { BusinessError } 10100002 - Failed to get the application group information. 672 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 673 * @systemapi Hide this for inner system use. 674 * @since 9 675 */ 676 function queryAppGroup(bundleName: string): Promise<number>; 677 678 /** 679 * Queries the usage priority group by bundleName. 680 * <p>The priority defined in a priority group restricts the resource usage of an application, 681 * for example, restricting the running of background tasks. </p> 682 * 683 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 684 * @param { string } bundleName - name of the application. 685 * @returns { number } the usage priority group of the calling application. 686 * @throws { BusinessError } 201 - Permission denied. 687 * @throws { BusinessError } 202 - Not System App. 688 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 689 * @throws { BusinessError } 801 - Capability not supported. 690 * @throws { BusinessError } 10000001 - Memory operation failed. 691 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 692 * <br> 2. Failed to apply for memory. 693 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 694 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 695 * @throws { BusinessError } 10000005 - Application is not installed. 696 * @throws { BusinessError } 10000006 - Failed to get the application information. 697 * @throws { BusinessError } 10100002 - Failed to get the application group information. 698 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 699 * @systemapi Hide this for inner system use. 700 * @since 10 701 */ 702 function queryAppGroupSync(bundleName: string): number; 703 704 /** 705 * @typedef { Record<string, BundleStatsInfo> } 706 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 707 * @systemapi Hide this for inner system use. 708 * @since 9 709 */ 710 type BundleStatsMap = Record<string, BundleStatsInfo>; 711 712 /** 713 * Queries usage information about each bundle within a specified period. 714 * <p>This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.</p> 715 * 716 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 717 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 718 * @param { number } end - Indicates the end time of the query period, in milliseconds. 719 * @param { AsyncCallback<BundleStatsMap> } callback - the callback of queryBundleStatsInfos, 720 * <p> the {@link BundleStatsMap} objects containing the usage information about each bundle.</p> 721 * @throws { BusinessError } 201 - Permission denied. 722 * @throws { BusinessError } 202 - Not System App. 723 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 724 * @throws { BusinessError } 801 - Capability not supported. 725 * @throws { BusinessError } 10000001 - Memory operation failed. 726 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 727 * <br> 2. Failed to apply for memory. 728 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 729 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 730 * @throws { BusinessError } 10000006 - Failed to get the application information. 731 * @throws { BusinessError } 10000007 - Failed to get the system time. 732 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 733 * @systemapi Hide this for inner system use. 734 * @since 9 735 */ 736 function queryBundleStatsInfos(begin: number, end: number, callback: AsyncCallback<BundleStatsMap>): void; 737 738 /** 739 * Queries usage information about each bundle within a specified period. 740 * <p>This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.</p> 741 * 742 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 743 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 744 * @param { number } end - Indicates the end time of the query period, in milliseconds. 745 * @returns { Promise<BundleStatsMap> } the promise returned by queryBundleStatsInfos. 746 * <p> the {@link BundleStatsMap} objects containing the usage information about each bundle.</p> 747 * @throws { BusinessError } 201 - Permission denied. 748 * @throws { BusinessError } 202 - Not System App. 749 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 750 * @throws { BusinessError } 801 - Capability not supported. 751 * @throws { BusinessError } 10000001 - Memory operation failed. 752 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 753 * <br> 2. Failed to apply for memory. 754 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 755 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 756 * @throws { BusinessError } 10000006 - Failed to get the application information. 757 * @throws { BusinessError } 10000007 - Failed to get the system time. 758 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 759 * @systemapi Hide this for inner system use. 760 * @since 9 761 */ 762 function queryBundleStatsInfos(begin: number, end: number): Promise<BundleStatsMap>; 763 764 /** 765 * @typedef { Record<string, Array<BundleStatsInfo>> } 766 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 767 * @systemapi Hide this for inner system use. 768 * @since 15 769 */ 770 type AppStatsMap = Record<string, Array<BundleStatsInfo>>; 771 772 /** 773 * Queries usage information about each application within a specified period. 774 * <p>This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.</p> 775 * 776 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 777 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 778 * @param { number } end - Indicates the end time of the query period, in milliseconds. 779 * @returns { Promise<AppStatsMap> } the promise returned by queryAppStatsInfos. 780 * <p> the {@link AppStatsMap} objects containing the usage information about each application.</p> 781 * @throws { BusinessError } 201 - Permission denied. 782 * @throws { BusinessError } 202 - Not System App. 783 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 784 * @throws { BusinessError } 801 - Capability not supported. 785 * @throws { BusinessError } 10000001 - Memory operation failed. 786 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 787 * <br> 2. Failed to apply for memory. 788 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 789 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 790 * @throws { BusinessError } 10000006 - Failed to get the application information. 791 * @throws { BusinessError } 10000007 - Failed to get the system time. 792 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 793 * @systemapi Hide this for inner system use. 794 * @since 15 795 */ 796 function queryAppStatsInfos(begin: number, end: number): Promise<AppStatsMap>; 797 798 /** 799 * Queries the last usage timestamp by bundleName and app index. 800 * 801 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 802 * @param { string } bundleName - name of the application. 803 * @param { appInfo } bundle name and app index info for each application. 804 * @returns { Promise<AppStatsMap> } the promise returned by queryLastUseTime. 805 * <p> the {@link AppStatsMap} objects containing the usage information about each application.</p> 806 * @throws { BusinessError } 201 - Permission denied. 807 * @throws { BusinessError } 202 - Not System App. 808 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 809 * @throws { BusinessError } 801 - Capability not supported. 810 * @throws { BusinessError } 10000001 - Memory operation failed. 811 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 812 * <br> 2. Failed to apply for memory. 813 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 814 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 815 * @throws { BusinessError } 10000006 - Failed to get the application information. 816 * @throws { BusinessError } 10000007 - Failed to get the system time. 817 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 818 * @systemapi Hide this for inner system use. 819 * @since 15 820 */ 821 function queryLastUseTime(appInfo: Record<string, Array<number>>): Promise<AppStatsMap>; 822 823 /** 824 * Declares interval type. 825 * 826 * @enum { number } 827 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 828 * @systemapi Hide this for inner system use. 829 * @since 9 830 */ 831 export enum IntervalType { 832 /** 833 * Indicates the interval type that will determine the optimal interval based on the start and end time. 834 * 835 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 836 * @systemapi Hide this for inner system use. 837 * @since 9 838 */ 839 BY_OPTIMIZED = 0, 840 841 /** 842 * Indicates the daily interval. 843 * 844 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 845 * @systemapi Hide this for inner system use. 846 * @since 9 847 */ 848 BY_DAILY = 1, 849 850 /** 851 * Indicates the weekly interval. 852 * 853 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 854 * @systemapi Hide this for inner system use. 855 * @since 9 856 */ 857 BY_WEEKLY = 2, 858 859 /** 860 * Indicates the monthly interval. 861 * 862 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 863 * @systemapi Hide this for inner system use. 864 * @since 9 865 */ 866 BY_MONTHLY = 3, 867 868 /** 869 * Indicates the annually interval. 870 * 871 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 872 * @systemapi Hide this for inner system use. 873 * @since 9 874 */ 875 BY_ANNUALLY = 4 876 } 877 878 /** 879 * Queries usage information about each bundle within a specified period at a specified interval. 880 * 881 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 882 * @param { IntervalType } byInterval - Indicates the interval at which the usage statistics are queried. 883 * <p> The value can be {@link #BY_OPTIMIZED}, {@link #BY_DAILY}, 884 * {@link #BY_WEEKLY}, {@link #BY_MONTHLY}, or {@link #BY_ANNUALLY}.</p> 885 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 886 * @param { number } end - Indicates the end time of the query period, in milliseconds. 887 * @param { AsyncCallback<Array<BundleStatsInfo>> } callback - the callback of queryBundleStatsInfoByInterval. 888 * <p> the list of {@link BundleStatsInfo} objects containing the usage information about each bundle.</p> 889 * @throws { BusinessError } 201 - Permission denied. 890 * @throws { BusinessError } 202 - Not System App. 891 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 892 * @throws { BusinessError } 801 - Capability not supported. 893 * @throws { BusinessError } 10000001 - Memory operation failed. 894 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 895 * <br> 2. Failed to apply for memory. 896 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 897 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 898 * @throws { BusinessError } 10000006 - Failed to get the application information. 899 * @throws { BusinessError } 10000007 - Failed to get the system time. 900 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 901 * @systemapi Hide this for inner system use. 902 * @since 9 903 */ 904 function queryBundleStatsInfoByInterval( 905 byInterval: IntervalType, 906 begin: number, 907 end: number, 908 callback: AsyncCallback<Array<BundleStatsInfo>> 909 ): void; 910 911 /** 912 * Queries usage information about each bundle within a specified period at a specified interval. 913 * 914 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 915 * @param { IntervalType } byInterval - Indicates the interval at which the usage statistics are queried. 916 * <p> The value can be {@link #BY_OPTIMIZED}, {@link #BY_DAILY}, 917 * {@link #BY_WEEKLY}, {@link #BY_MONTHLY}, or {@link #BY_ANNUALLY}.</p> 918 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 919 * @param { number } end - Indicates the end time of the query period, in milliseconds. 920 * @returns { Promise<Array<BundleStatsInfo>> } the promise returned by queryBundleStatsInfoByInterval. 921 * <p> the list of {@link BundleStatsInfo} objects containing the usage information about each bundle.</p> 922 * @throws { BusinessError } 201 - Permission denied. 923 * @throws { BusinessError } 202 - Not System App. 924 * @throws { BusinessError } 401 - Parameter error. Possible cause: Parameter verification failed. 925 * @throws { BusinessError } 801 - Capability not supported. 926 * @throws { BusinessError } 10000001 - Memory operation failed. 927 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 928 * <br> 2. Failed to apply for memory. 929 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 930 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 931 * @throws { BusinessError } 10000006 - Failed to get the application information. 932 * @throws { BusinessError } 10000007 - Failed to get the system time. 933 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 934 * @systemapi Hide this for inner system use. 935 * @since 9 936 */ 937 function queryBundleStatsInfoByInterval( 938 byInterval: IntervalType, 939 begin: number, 940 end: number 941 ): Promise<Array<BundleStatsInfo>>; 942 943 /** 944 * Queries state data of all bundles within a specified period identified by the start and end time. 945 * 946 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 947 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 948 * @param { number } end - Indicates the end time of the query period, in milliseconds. 949 * @param { AsyncCallback<Array<BundleEvents>> } callback - the promise returned by queryBundleEvents. 950 * <p> the list of {@link BundleEvents} objects containing the state data of all bundles.</p> 951 * @throws { BusinessError } 201 - Permission denied. 952 * @throws { BusinessError } 202 - Not System App. 953 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 954 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 955 * @throws { BusinessError } 801 - Capability not supported. 956 * @throws { BusinessError } 10000001 - Memory operation failed. 957 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 958 * <br> 2. Failed to apply for memory. 959 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 960 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 961 * @throws { BusinessError } 10000006 - Failed to get the application information. 962 * @throws { BusinessError } 10000007 - Failed to get the system time. 963 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 964 * @systemapi Hide this for inner system use. 965 * @since 9 966 */ 967 function queryBundleEvents(begin: number, end: number, callback: AsyncCallback<Array<BundleEvents>>): void; 968 969 /** 970 * Queries state data of all bundles within a specified period identified by the start and end time. 971 * 972 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 973 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 974 * @param { number } end - Indicates the end time of the query period, in milliseconds. 975 * @returns { Promise<Array<BundleEvents>> } the promise returned by queryBundleEvents. 976 * <p> the list of {@link BundleEvents} objects containing the state data of all bundles.</p> 977 * @throws { BusinessError } 201 - Permission denied. 978 * @throws { BusinessError } 202 - Not System App. 979 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 980 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 981 * @throws { BusinessError } 801 - Capability not supported. 982 * @throws { BusinessError } 10000001 - Memory operation failed. 983 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 984 * <br> 2. Failed to apply for memory. 985 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 986 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 987 * @throws { BusinessError } 10000006 - Failed to get the application information. 988 * @throws { BusinessError } 10000007 - Failed to get the system time. 989 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 990 * @systemapi Hide this for inner system use. 991 * @since 9 992 */ 993 function queryBundleEvents(begin: number, end: number): Promise<Array<BundleEvents>>; 994 995 /** 996 * Queries state data of the current bundle within a specified period. 997 * 998 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 999 * @param { number } end - Indicates the end time of the query period, in milliseconds. 1000 * @param { AsyncCallback<Array<BundleEvents>> } callback - the callback of queryCurrentBundleEvents. 1001 * <p> the {@link BundleEvents} object Array containing the state data of the current bundle.</p> 1002 * @throws { BusinessError } 202 - Not System App. 1003 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1004 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1005 * @throws { BusinessError } 801 - Capability not supported. 1006 * @throws { BusinessError } 10000001 - Memory operation failed. 1007 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1008 * <br> 2. Failed to apply for memory. 1009 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1010 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1011 * @throws { BusinessError } 10000006 - Failed to get the application information. 1012 * @throws { BusinessError } 10000007 - Failed to get the system time. 1013 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1014 * @systemapi Hide this for inner system use. 1015 * @since 9 1016 */ 1017 function queryCurrentBundleEvents(begin: number, end: number, callback: AsyncCallback<Array<BundleEvents>>): void; 1018 1019 /** 1020 * Queries state data of the current bundle within a specified period. 1021 * 1022 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 1023 * @param { number } end - Indicates the end time of the query period, in milliseconds. 1024 * @returns { Promise<Array<BundleEvents>> } the promise returned by queryCurrentBundleEvents. 1025 * <p> the {@link BundleEvents} object Array containing the state data of the current bundle.</p> 1026 * @throws { BusinessError } 202 - Not System App. 1027 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1028 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1029 * @throws { BusinessError } 801 - Capability not supported. 1030 * @throws { BusinessError } 10000001 - Memory operation failed. 1031 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1032 * <br> 2. Failed to apply for memory. 1033 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1034 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1035 * @throws { BusinessError } 10000006 - Failed to get the application information. 1036 * @throws { BusinessError } 10000007 - Failed to get the system time. 1037 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1038 * @systemapi Hide this for inner system use. 1039 * @since 9 1040 */ 1041 function queryCurrentBundleEvents(begin: number, end: number): Promise<Array<BundleEvents>>; 1042 1043 /** 1044 * Queries recently module usage records with maxNum. 1045 * 1046 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1047 * @param { number } maxNum - Indicates max record number in result, max value is 1000, default value is 1000. 1048 * @param { AsyncCallback<Array<HapModuleInfo>> } callback - the callback of queryModuleUsageRecords. 1049 * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p> 1050 * @throws { BusinessError } 201 - Permission denied. 1051 * @throws { BusinessError } 202 - Not System App. 1052 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1053 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1054 * @throws { BusinessError } 801 - Capability not supported. 1055 * @throws { BusinessError } 10000001 - Memory operation failed. 1056 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1057 * <br> 2. Failed to apply for memory. 1058 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1059 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1060 * @throws { BusinessError } 10000006 - Failed to get the application information. 1061 * @throws { BusinessError } 10000007 - Failed to get the system time. 1062 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1063 * @systemapi Hide this for inner system use. 1064 * @since 9 1065 */ 1066 function queryModuleUsageRecords(maxNum: number, callback: AsyncCallback<Array<HapModuleInfo>>): void; 1067 1068 /** 1069 * Queries recently module usage records with maxNum. 1070 * 1071 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1072 * @param { number } maxNum - Indicates max record number in result, max value is 1000, default value is 1000. 1073 * @returns { Promise<Array<HapModuleInfo>> } the promise returned by queryModuleUsageRecords. 1074 * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p> 1075 * @throws { BusinessError } 201 - Permission denied. 1076 * @throws { BusinessError } 202 - Not System App. 1077 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1078 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1079 * @throws { BusinessError } 801 - Capability not supported. 1080 * @throws { BusinessError } 10000001 - Memory operation failed. 1081 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1082 * <br> 2. Failed to apply for memory. 1083 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1084 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1085 * @throws { BusinessError } 10000006 - Failed to get the application information. 1086 * @throws { BusinessError } 10000007 - Failed to get the system time. 1087 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1088 * @systemapi Hide this for inner system use. 1089 * @since 9 1090 */ 1091 function queryModuleUsageRecords(maxNum: number): Promise<Array<HapModuleInfo>>; 1092 1093 /** 1094 * Queries recently module usage records. 1095 * 1096 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1097 * @param { AsyncCallback<Array<HapModuleInfo>> } callback - the callback of queryModuleUsageRecords. 1098 * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p> 1099 * @throws { BusinessError } 201 - Permission denied. 1100 * @throws { BusinessError } 202 - Not System App. 1101 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1102 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1103 * @throws { BusinessError } 801 - Capability not supported. 1104 * @throws { BusinessError } 10000001 - Memory operation failed. 1105 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1106 * <br> 2. Failed to apply for memory. 1107 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1108 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1109 * @throws { BusinessError } 10000006 - Failed to get the application information. 1110 * @throws { BusinessError } 10000007 - Failed to get the system time. 1111 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1112 * @systemapi Hide this for inner system use. 1113 * @since 9 1114 */ 1115 function queryModuleUsageRecords(callback: AsyncCallback<Array<HapModuleInfo>>): void; 1116 1117 /** 1118 * Queries recently module usage records. 1119 * 1120 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1121 * @returns { Promise<Array<HapModuleInfo>> } the promise returned by queryModuleUsageRecords. 1122 * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p> 1123 * @throws { BusinessError } 201 - Permission denied. 1124 * @throws { BusinessError } 202 - Not System App. 1125 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1126 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1127 * @throws { BusinessError } 801 - Capability not supported. 1128 * @throws { BusinessError } 10000001 - Memory operation failed. 1129 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1130 * <br> 2. Failed to apply for memory. 1131 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1132 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1133 * @throws { BusinessError } 10000006 - Failed to get the application information. 1134 * @throws { BusinessError } 10000007 - Failed to get the system time. 1135 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1136 * @systemapi Hide this for inner system use. 1137 * @since 9 1138 */ 1139 function queryModuleUsageRecords(): Promise<Array<HapModuleInfo>>; 1140 1141 /** 1142 * Declares group type. 1143 * 1144 * @enum { number } 1145 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1146 * @systemapi Hide this for inner system use. 1147 * @since 9 1148 */ 1149 export enum GroupType { 1150 /** 1151 * Indicates the alive group. 1152 * 1153 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1154 * @systemapi Hide this for inner system use. 1155 * @since 9 1156 */ 1157 ALIVE_GROUP = 10, 1158 1159 /** 1160 * Indicates the daily group. 1161 * 1162 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1163 * @systemapi Hide this for inner system use. 1164 * @since 9 1165 */ 1166 DAILY_GROUP = 20, 1167 1168 /** 1169 * Indicates the fixed group. 1170 * 1171 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1172 * @systemapi Hide this for inner system use. 1173 * @since 9 1174 */ 1175 FIXED_GROUP = 30, 1176 1177 /** 1178 * Indicates the rare group. 1179 * 1180 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1181 * @systemapi Hide this for inner system use. 1182 * @since 9 1183 */ 1184 RARE_GROUP = 40, 1185 1186 /** 1187 * Indicates the limit group. 1188 * 1189 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1190 * @systemapi Hide this for inner system use. 1191 * @since 9 1192 */ 1193 LIMITED_GROUP = 50, 1194 1195 /** 1196 * Indicates the never group. 1197 * 1198 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1199 * @systemapi Hide this for inner system use. 1200 * @since 9 1201 */ 1202 NEVER_GROUP = 60 1203 } 1204 1205 /** 1206 * Set app group by bundleName. 1207 * 1208 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1209 * @param { string } bundleName - name of the application. 1210 * @param { GroupType } newGroup - the group of the application whose name is bundleName. 1211 * @param { AsyncCallback<void> } callback - the callback of setAppGroup. 1212 * @throws { BusinessError } 201 - Permission denied. 1213 * @throws { BusinessError } 202 - Not System App. 1214 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1215 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1216 * @throws { BusinessError } 801 - Capability not supported. 1217 * @throws { BusinessError } 10000001 - Memory operation failed. 1218 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1219 * <br> 2. Failed to apply for memory. 1220 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1221 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1222 * @throws { BusinessError } 10000006 - Failed to get the application information. 1223 * @throws { BusinessError } 10100001 - Repeated operation on the application group. 1224 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1225 * @systemapi Hide this for inner system use. 1226 * @since 9 1227 */ 1228 function setAppGroup(bundleName: string, newGroup: GroupType, callback: AsyncCallback<void>): void; 1229 1230 /** 1231 * Set app group by bundleName. 1232 * 1233 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1234 * @param { string } bundleName - name of the application. 1235 * @param { GroupType } newGroup - the group of the application whose name is bundleName. 1236 * @returns { Promise<void> } the promise returned by setAppGroup. 1237 * @throws { BusinessError } 201 - Permission denied. 1238 * @throws { BusinessError } 202 - Not System App. 1239 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1240 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1241 * @throws { BusinessError } 801 - Capability not supported. 1242 * @throws { BusinessError } 10000001 - Memory operation failed. 1243 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1244 * <br> 2. Failed to apply for memory. 1245 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1246 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1247 * @throws { BusinessError } 10000006 - Failed to get the application information. 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 setAppGroup(bundleName: string, newGroup: GroupType): Promise<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 * @param { AsyncCallback<void> } callback - the callback of 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 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1269 * <br> 2. Failed to apply for memory. 1270 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1271 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1272 * @throws { BusinessError } 10100001 - Repeated operation on the application group. 1273 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1274 * @systemapi Hide this for inner system use. 1275 * @since 9 1276 */ 1277 function registerAppGroupCallBack(groupCallback: Callback<AppGroupCallbackInfo>, callback: AsyncCallback<void>): void; 1278 1279 /** 1280 * Register appGroup change callback to service. 1281 * 1282 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1283 * @param { Callback<AppGroupCallbackInfo> } groupCallback - 1284 * <p> callback of AppGroupCallbackInfo when the group of app changed.</p> 1285 * @returns { Promise<void> } the promise returned by registerAppGroupCallBack. 1286 * @throws { BusinessError } 201 - Permission denied. 1287 * @throws { BusinessError } 202 - Not System App. 1288 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1289 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1290 * @throws { BusinessError } 801 - Capability not supported. 1291 * @throws { BusinessError } 10000001 - Memory operation failed. 1292 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1293 * <br> 2. Failed to apply for memory. 1294 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1295 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1296 * @throws { BusinessError } 10100001 - Repeated operation on the application group. 1297 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1298 * @systemapi Hide this for inner system use. 1299 * @since 9 1300 */ 1301 function registerAppGroupCallBack(groupCallback: Callback<AppGroupCallbackInfo>): Promise<void>; 1302 1303 /** 1304 * Unregister appGroup change callback from service. 1305 * 1306 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1307 * @param { AsyncCallback<void> } callback - the callback of unregisterAppGroupCallBack. 1308 * @throws { BusinessError } 201 - Permission denied. 1309 * @throws { BusinessError } 202 - Not System App. 1310 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1311 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1312 * @throws { BusinessError } 801 - Capability not supported. 1313 * @throws { BusinessError } 10000001 - Memory operation failed. 1314 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1315 * <br> 2. Failed to apply for memory. 1316 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1317 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1318 * @throws { BusinessError } 10100001 - Repeated operation on the application group. 1319 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1320 * @systemapi Hide this for inner system use. 1321 * @since 9 1322 */ 1323 function unregisterAppGroupCallBack(callback: AsyncCallback<void>): void; 1324 1325 /** 1326 * Unregister appGroup change callback from service. 1327 * 1328 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1329 * @returns { Promise<void> } the promise returned by unregisterAppGroupCallBack. 1330 * @throws { BusinessError } 201 - Permission denied. 1331 * @throws { BusinessError } 202 - Not System App. 1332 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1333 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1334 * @throws { BusinessError } 801 - Capability not supported. 1335 * @throws { BusinessError } 10000001 - Memory operation failed. 1336 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1337 * <br> 2. Failed to apply for memory. 1338 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1339 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1340 * @throws { BusinessError } 10100001 - Repeated operation on the application group. 1341 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup 1342 * @systemapi Hide this for inner system use. 1343 * @since 9 1344 */ 1345 function unregisterAppGroupCallBack(): Promise<void>; 1346 1347 /** 1348 * Queries device event states data within a specified period identified by the start and end time. 1349 * 1350 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1351 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 1352 * @param { number } end - Indicates the end time of the query period, in milliseconds. 1353 * @param { AsyncCallback<Array<DeviceEventStats>> } callback - the callback of queryDeviceEventStats. 1354 * <p> the {@link DeviceEventStats} object Array containing the event states data.</p> 1355 * @throws { BusinessError } 201 - Permission denied. 1356 * @throws { BusinessError } 202 - Not System App. 1357 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1358 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1359 * @throws { BusinessError } 801 - Capability not supported. 1360 * @throws { BusinessError } 10000001 - Memory operation failed. 1361 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1362 * <br> 2. Failed to apply for memory. 1363 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1364 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1365 * @throws { BusinessError } 10000006 - Failed to get the application information. 1366 * @throws { BusinessError } 10000007 - Failed to get the system time. 1367 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1368 * @systemapi Hide this for inner system use. 1369 * @since 9 1370 */ 1371 function queryDeviceEventStats(begin: number, end: number, callback: AsyncCallback<Array<DeviceEventStats>>): void; 1372 1373 /** 1374 * Queries device event states data within a specified period identified by the start and end time. 1375 * 1376 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1377 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 1378 * @param { number } end - Indicates the end time of the query period, in milliseconds. 1379 * @returns { Promise<Array<DeviceEventStats>> } the promise returned by queryDeviceEventStats. 1380 * <p> the {@link DeviceEventStats} object Array containing the event states data.</p> 1381 * @throws { BusinessError } 201 - Permission denied. 1382 * @throws { BusinessError } 202 - Not System App. 1383 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1384 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1385 * @throws { BusinessError } 801 - Capability not supported. 1386 * @throws { BusinessError } 10000001 - Memory operation failed. 1387 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1388 * <br> 2. Failed to apply for memory. 1389 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1390 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1391 * @throws { BusinessError } 10000006 - Failed to get the application information. 1392 * @throws { BusinessError } 10000007 - Failed to get the system time. 1393 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1394 * @systemapi Hide this for inner system use. 1395 * @since 9 1396 */ 1397 function queryDeviceEventStats(begin: number, end: number): Promise<Array<DeviceEventStats>>; 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 * @param { AsyncCallback<Array<DeviceEventStats>> } callback - the callback of 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 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1414 * <br> 2. Failed to apply for memory. 1415 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1416 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1417 * @throws { BusinessError } 10000006 - Failed to get the application information. 1418 * @throws { BusinessError } 10000007 - Failed to get the system time. 1419 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1420 * @systemapi Hide this for inner system use. 1421 * @since 9 1422 */ 1423 function queryNotificationEventStats( 1424 begin: number, 1425 end: number, 1426 callback: AsyncCallback<Array<DeviceEventStats>> 1427 ): void; 1428 1429 /** 1430 * Queries app notification number within a specified period identified by the start and end time. 1431 * 1432 * @permission ohos.permission.BUNDLE_ACTIVE_INFO 1433 * @param { number } begin - Indicates the start time of the query period, in milliseconds. 1434 * @param { number } end - Indicates the end time of the query period, in milliseconds. 1435 * @returns { Promise<Array<DeviceEventStats>> } the promise returned by queryNotificationEventStats. 1436 * <p> the {@link DeviceEventStats} object Array containing the event states data.</p> 1437 * @throws { BusinessError } 201 - Permission denied. 1438 * @throws { BusinessError } 202 - Not System App. 1439 * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 1440 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 1441 * @throws { BusinessError } 801 - Capability not supported. 1442 * @throws { BusinessError } 10000001 - Memory operation failed. 1443 * @throws { BusinessError } 10000002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters; 1444 * <br> 2. Failed to apply for memory. 1445 * @throws { BusinessError } 10000003 - Failed to get system ability manager. 1446 * @throws { BusinessError } 10000004 - Failed to access the device usage service. 1447 * @throws { BusinessError } 10000006 - Failed to get the application information. 1448 * @throws { BusinessError } 10000007 - Failed to get the system time. 1449 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App 1450 * @systemapi Hide this for inner system use. 1451 * @since 9 1452 */ 1453 function queryNotificationEventStats(begin: number, end: number): Promise<Array<DeviceEventStats>>; 1454} 1455 1456export default usageStatistics; 1457