• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022  Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { AsyncCallback , Callback} from './basic';
17
18/**
19 * Provides methods for managing bundle usage statistics,
20 * including the methods for querying bundle usage information and state data.
21 *
22 * <p>You can use the methods defined in this class to query
23 * the usage history and states of bundles in a specified period.
24 * The system stores the query result in a {@link BundleStatsInfo} instance and
25 * then returns it to you.
26 *
27 * @namespace usageStatistics
28 * @since 9
29 */
30declare namespace usageStatistics {
31
32    /**
33     * @interface BundleStatsInfo
34     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
35     * @systemapi Hide this for inner system use.
36     * @since 9
37     */
38    interface BundleStatsInfo {
39        /**
40         * The identifier of BundleStatsInfo.
41         */
42        id: number;
43        /**
44         * The total duration, in milliseconds.
45         */
46        abilityInFgTotalTime?: number;
47        /**
48         * The last time when the application was accessed, in milliseconds.
49         */
50        abilityPrevAccessTime?: number;
51        /**
52         * The last time when the application was visible in the foreground, in milliseconds.
53         */
54        abilityPrevSeenTime?: number;
55        /**
56         * The total duration, in milliseconds.
57         */
58        abilitySeenTotalTime?: number;
59        /**
60         * The bundle name of the application.
61         */
62        bundleName?: string;
63        /**
64         * The total duration, in milliseconds.
65         */
66        fgAbilityAccessTotalTime?: number;
67        /**
68         * The last time when the foreground application was accessed, in milliseconds.
69         */
70        fgAbilityPrevAccessTime?: number;
71        /**
72         * The time of the first bundle usage record in this {@code BundleActiveInfo} object,
73         * in milliseconds.
74         */
75        infosBeginTime?: number;
76        /**
77         * The time of the last bundle usage record in this {@code BundleActiveInfo} object,
78         * in milliseconds.
79         */
80        infosEndTime?: number;
81    }
82
83    /**
84     * @interface HapFormInfo
85     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
86     * @systemapi Hide this for inner system use.
87     * @since 9
88     */
89    interface HapFormInfo {
90        /**
91         * The form name.
92         */
93        formName: string;
94        /**
95         * The form dimension.
96         */
97        formDimension: number;
98        /**
99         * The form id.
100         */
101        formId: number;
102        /**
103         * The last time when the form was accessed, in milliseconds..
104         */
105        formLastUsedTime: number;
106        /**
107         * The click count of module.
108         */
109        count: number;
110    }
111
112    /**
113     * @interface HapModuleInfo
114     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
115     * @systemapi Hide this for inner system use.
116     * @since 9
117     */
118    interface HapModuleInfo {
119        /**
120         * The device id of module.
121         */
122        deviceId?: string;
123        /**
124         * The bundle name.
125         */
126        bundleName: string;
127        /**
128         * The module name.
129         */
130        moduleName: string;
131        /**
132         * The main ability name of module.
133         */
134        abilityName?: string;
135        /**
136         * The label id of application.
137         */
138        appLabelId?: number;
139        /**
140         * The label id of module.
141         */
142        labelId?: number;
143        /**
144         * The description id of application.
145         */
146        descriptionId?: number;
147        /**
148         * The ability id of main ability.
149         */
150        abilityLableId?: number;
151        /**
152         * The description id of main ability.
153         */
154        abilityDescriptionId?: number;
155        /**
156         * The icon id of main ability.
157         */
158        abilityIconId?: number;
159        /**
160         * The launch count of module.
161         */
162        launchedCount: number;
163        /**
164         * The last time when the module was accessed, in milliseconds.
165         */
166        lastModuleUsedTime: number;
167        /**
168         * The form usage record list of current module.
169         */
170        formRecords: Array<HapFormInfo>;
171    }
172
173    /**
174     * @interface DeviceEventStats
175     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
176     * @systemapi Hide this for inner system use.
177     * @since 9
178     */
179    interface DeviceEventStats {
180        /**
181         * The bundle name or system event name.
182         */
183        name: string;
184
185        /**
186         * The event id.
187         */
188        eventId: number;
189
190        /**
191         * The the event occurrence number.
192         */
193        count: number;
194    }
195
196    /**
197     * @interface BundleEvents
198     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
199     * @systemapi Hide this for inner system use.
200     * @since 9
201     */
202     interface BundleEvents {
203        /**
204         * The usage group of the application.
205         */
206        appGroup?: number;
207        /**
208         * The bundle name.
209         */
210        bundleName?: string;
211        /**
212         * The shortcut ID.
213         */
214        indexOfLink?: string;
215        /**
216         * The class name.
217         */
218        nameOfClass?: string;
219        /**
220         * The time when this state occurred, in milliseconds.
221         */
222        eventOccurredTime?: number;
223        /**
224         * The event id.
225         */
226        eventId?: number;
227    }
228    /**
229     * @interface AppGroupCallbackInfo
230     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
231     * @systemapi Hide this for inner system use.
232     * @since 9
233     */
234    interface AppGroupCallbackInfo {
235        /*
236         * The usage old group of the application
237         */
238        appOldGroup: number;
239        /*
240         * The usage new group of the application
241         */
242        appNewGroup: number;
243        /*
244         * The use id
245         */
246        userId: number;
247        /*
248         * The change reason
249         */
250        changeReason: number;
251        /*
252         * The bundle name
253         */
254        bundleName: string;
255    }
256
257    /**
258     * Checks whether the application with a specified bundle name is in the idle state.
259     *
260     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
261     * @param { string } bundleName - Indicates the bundle name of the application to query.
262     * @param { AsyncCallback<boolean> } callback - the callback of isIdleState.
263     * <p> boolean value is true mean the application is idle in a particular period; false mean otherwise.
264     * The time range of the particular period is defined by the system, which may be hours or days.</p>
265     * @throws { BusinessError } 201 - Parameter error.
266     * @throws { BusinessError } 401 - Permission denied.
267     * @throws { BusinessError } 801 - Capability not supported.
268     * @throws { BusinessError } 10000001 - Memory operation failed.
269     * @throws { BusinessError } 10000002 - Parcel operation failed.
270     * @throws { BusinessError } 10000003 - System service operation failed.
271     * @throws { BusinessError } 10000004 - IPC failed.
272     * @throws { BusinessError } 10000006 - Failed to get the application information.
273     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
274     * @systemapi Hide this for inner system use.
275     * @since 9
276     */
277    function isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void;
278
279    /**
280     * Checks whether the application with a specified bundle name is in the idle state.
281     *
282     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
283     * @param { string } bundleName - Indicates the bundle name of the application to query.
284     * @returns { Promise<boolean> } the promise returned by queryAppGroup.
285     * <p> boolean value is true mean the application is idle in a particular period; false mean otherwise.
286     * The time range of the particular period is defined by the system, which may be hours or days.</p>
287     * @throws { BusinessError } 201 - Parameter error.
288     * @throws { BusinessError } 401 - Permission denied.
289     * @throws { BusinessError } 801 - Capability not supported.
290     * @throws { BusinessError } 10000001 - Memory operation failed.
291     * @throws { BusinessError } 10000002 - Parcel operation failed.
292     * @throws { BusinessError } 10000003 - System service operation failed.
293     * @throws { BusinessError } 10000004 - IPC failed.
294     * @throws { BusinessError } 10000006 - Failed to get the application information.
295     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
296     * @systemapi Hide this for inner system use.
297     * @since 9
298     */
299    function isIdleState(bundleName: string): Promise<boolean>;
300
301    /**
302     * Queries the app group of the calling application.
303     * <p>The priority defined in a priority group restricts the resource usage of an application,
304     * for example, restricting the running of background tasks. </p>
305     *
306     * @param { AsyncCallback<number> } callback - the callback of queryAppGroup.
307     * <p> Returns the app group of the calling application.</p>
308     * @throws { BusinessError } 201 - Parameter error.
309     * @throws { BusinessError } 202 - Not System App.
310     * @throws { BusinessError } 401 - Permission denied.
311     * @throws { BusinessError } 801 - Capability not supported.
312     * @throws { BusinessError } 10000001 - Memory operation failed.
313     * @throws { BusinessError } 10000002 - Parcel operation failed.
314     * @throws { BusinessError } 10000003 - System service operation failed.
315     * @throws { BusinessError } 10000004 - IPC failed.
316     * @throws { BusinessError } 10000005 - Application is not installed.
317     * @throws { BusinessError } 10000006 - Failed to get the application information.
318     * @throws { BusinessError } 10100002 - Failed to get the application group information.
319     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
320     * @systemapi Hide this for inner system use.
321     * @since 9
322     */
323    function queryAppGroup(callback: AsyncCallback<number>): void;
324
325    /**
326     * Queries the app group of the calling application.
327     * <p>The priority defined in a priority group restricts the resource usage of an application,
328     * for example, restricting the running of background tasks. </p>
329     *
330     * @returns { Promise<number> } the promise returned by queryAppGroup.
331     * <p> Returns the app group of the calling application.</p>
332     * @throws { BusinessError } 201 - Parameter error.
333     * @throws { BusinessError } 202 - Not System App.
334     * @throws { BusinessError } 401 - Permission denied.
335     * @throws { BusinessError } 801 - Capability not supported.
336     * @throws { BusinessError } 10000001 - Memory operation failed.
337     * @throws { BusinessError } 10000002 - Parcel operation failed.
338     * @throws { BusinessError } 10000003 - System service operation failed.
339     * @throws { BusinessError } 10000004 - IPC failed.
340     * @throws { BusinessError } 10000005 - Application is not installed.
341     * @throws { BusinessError } 10000006 - Failed to get the application information.
342     * @throws { BusinessError } 10100002 - Failed to get the application group information.
343     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
344     * @systemapi Hide this for inner system use.
345     * @since 9
346     */
347    function queryAppGroup(): Promise<number>;
348
349    /**
350     * Queries the usage priority group by bundleName.
351     * <p>The priority defined in a priority group restricts the resource usage of an application,
352     * for example, restricting the running of background tasks. </p>
353     *
354     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
355     * @param { string } bundleName - name of the application.
356     * @param { AsyncCallback<number> } callback - the callback of queryAppGroup.
357     * <p> the usage priority group of the calling application.</p>
358     * @throws { BusinessError } 201 - Parameter error.
359     * @throws { BusinessError } 202 - Not System App.
360     * @throws { BusinessError } 401 - Permission denied.
361     * @throws { BusinessError } 801 - Capability not supported.
362     * @throws { BusinessError } 10000001 - Memory operation failed.
363     * @throws { BusinessError } 10000002 - Parcel operation failed.
364     * @throws { BusinessError } 10000003 - System service operation failed.
365     * @throws { BusinessError } 10000004 - IPC failed.
366     * @throws { BusinessError } 10000005 - Application is not installed.
367     * @throws { BusinessError } 10000006 - Failed to get the application information.
368     * @throws { BusinessError } 10100002 - Failed to get the application group information.
369     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
370     * @systemapi Hide this for inner system use.
371     * @since 9
372     */
373     function queryAppGroup(bundleName : string, callback: AsyncCallback<number>): void;
374
375     /**
376     * Queries the usage priority group by bundleName.
377     * <p>The priority defined in a priority group restricts the resource usage of an application,
378     * for example, restricting the running of background tasks. </p>
379     *
380     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
381     * @param { string } bundleName - name of the application.
382     * @returns { Promise<number> } the promise returned by queryAppGroup.
383     * <p> the usage priority group of the calling application.</p>
384     * @throws { BusinessError } 201 - Parameter error.
385     * @throws { BusinessError } 202 - Not System App.
386     * @throws { BusinessError } 401 - Permission denied.
387     * @throws { BusinessError } 801 - Capability not supported.
388     * @throws { BusinessError } 10000001 - Memory operation failed.
389     * @throws { BusinessError } 10000002 - Parcel operation failed.
390     * @throws { BusinessError } 10000003 - System service operation failed.
391     * @throws { BusinessError } 10000004 - IPC failed.
392     * @throws { BusinessError } 10000005 - Application is not installed.
393     * @throws { BusinessError } 10000006 - Failed to get the application information.
394     * @throws { BusinessError } 10100002 - Failed to get the application group information.
395     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
396     * @systemapi Hide this for inner system use.
397     * @since 9
398     */
399     function queryAppGroup(bundleName : string): Promise<number>;
400
401    /**
402     * @interface BundleStatsMap
403     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
404     * @systemapi Hide this for inner system use.
405     * @since 9
406     */
407     interface BundleStatsMap {
408        [key: string]: BundleStatsInfo;
409    }
410
411    /**
412     * Queries usage information about each bundle within a specified period.
413     * <p>This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.</p>
414     *
415     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
416     * @param {number} begin - Indicates the start time of the query period, in milliseconds.
417     * @param {number} end - Indicates the end time of the query period, in milliseconds.
418     * @param { AsyncCallback<BundleStatsMap> } callback - the callback of queryBundleStatsInfos,
419     * <p> the {@link BundleStatsMap} objects containing the usage information about each bundle.</p>
420     * @throws { BusinessError } 201 - Parameter error.
421     * @throws { BusinessError } 202 - Not System App.
422     * @throws { BusinessError } 401 - Permission denied.
423     * @throws { BusinessError } 801 - Capability not supported.
424     * @throws { BusinessError } 10000001 - Memory operation failed.
425     * @throws { BusinessError } 10000002 - Parcel operation failed.
426     * @throws { BusinessError } 10000003 - System service operation failed.
427     * @throws { BusinessError } 10000004 - IPC failed.
428     * @throws { BusinessError } 10000006 - Failed to get the application information.
429     * @throws { BusinessError } 10000007 - Failed to get the system time.
430     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
431     * @systemapi Hide this for inner system use.
432     * @since 9
433     */
434    function queryBundleStatsInfos(begin: number, end: number, callback: AsyncCallback<BundleStatsMap>): void;
435
436    /**
437     * Queries usage information about each bundle within a specified period.
438     * <p>This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.</p>
439     *
440     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
441     * @param {number} begin - Indicates the start time of the query period, in milliseconds.
442     * @param {number} end - Indicates the end time of the query period, in milliseconds.
443     * @returns { Promise<BundleStatsMap> } the promise returned by queryBundleStatsInfos.
444     * <p> the {@link BundleStatsMap} objects containing the usage information about each bundle.</p>
445     * @throws { BusinessError } 201 - Parameter error.
446     * @throws { BusinessError } 202 - Not System App.
447     * @throws { BusinessError } 401 - Permission denied.
448     * @throws { BusinessError } 801 - Capability not supported.
449     * @throws { BusinessError } 10000001 - Memory operation failed.
450     * @throws { BusinessError } 10000002 - Parcel operation failed.
451     * @throws { BusinessError } 10000003 - System service operation failed.
452     * @throws { BusinessError } 10000004 - IPC failed.
453     * @throws { BusinessError } 10000006 - Failed to get the application information.
454     * @throws { BusinessError } 10000007 - Failed to get the system time.
455     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
456     * @systemapi Hide this for inner system use.
457     * @since 9
458     */
459    function queryBundleStatsInfos(begin: number, end: number): Promise<BundleStatsMap>;
460
461    /**
462     * Declares interval type.
463     *
464     * @enum { number }
465     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
466     * @systemapi Hide this for inner system use.
467     * @since 9
468     */
469    export enum IntervalType {
470        /**
471         * Indicates the interval type that will determine the optimal interval based on the start and end time.
472         */
473        BY_OPTIMIZED = 0,
474
475        /**
476         * Indicates the daily interval.
477         */
478        BY_DAILY = 1,
479
480        /**
481         * Indicates the weekly interval.
482         */
483        BY_WEEKLY = 2,
484
485        /**
486         * Indicates the monthly interval.
487         */
488        BY_MONTHLY = 3,
489
490        /**
491         * Indicates the annually interval.
492         */
493        BY_ANNUALLY = 4
494    }
495
496    /**
497     * Queries usage information about each bundle within a specified period at a specified interval.
498     *
499     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
500     * @param { IntervalType } byInterval - Indicates the interval at which the usage statistics are queried.
501     * <p> The value can be {@link #BY_OPTIMIZED}, {@link #BY_DAILY},
502     * {@link #BY_WEEKLY}, {@link #BY_MONTHLY}, or {@link #BY_ANNUALLY}.</p>
503     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
504     * @param { number } end - Indicates the end time of the query period, in milliseconds.
505     * @param { AsyncCallback<Array<BundleStatsInfo>> } callback - the callback of queryBundleStatsInfoByInterval.
506     * <p> the list of {@link BundleStatsInfo} objects containing the usage information about each bundle.</p>
507     * @throws { BusinessError } 201 - Parameter error.
508     * @throws { BusinessError } 202 - Not System App.
509     * @throws { BusinessError } 401 - Permission denied.
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     * @throws { BusinessError } 10000007 - Failed to get the system time.
517     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
518     * @systemapi Hide this for inner system use.
519     * @since 9
520     */
521    function queryBundleStatsInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback<Array<BundleStatsInfo>>): void;
522
523    /**
524     * Queries usage information about each bundle within a specified period at a specified interval.
525     *
526     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
527     * @param { IntervalType } byInterval - Indicates the interval at which the usage statistics are queried.
528     * <p> The value can be {@link #BY_OPTIMIZED}, {@link #BY_DAILY},
529     * {@link #BY_WEEKLY}, {@link #BY_MONTHLY}, or {@link #BY_ANNUALLY}.</p>
530     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
531     * @param { number } end - Indicates the end time of the query period, in milliseconds.
532     * @returns { Promise<Array<BundleStatsInfo>> } the promise returned by queryBundleStatsInfoByInterval.
533     * <p> the list of {@link BundleStatsInfo} objects containing the usage information about each bundle.</p>
534     * @throws { BusinessError } 201 - Parameter error.
535     * @throws { BusinessError } 202 - Not System App.
536     * @throws { BusinessError } 401 - Permission denied.
537     * @throws { BusinessError } 801 - Capability not supported.
538     * @throws { BusinessError } 10000001 - Memory operation failed.
539     * @throws { BusinessError } 10000002 - Parcel operation failed.
540     * @throws { BusinessError } 10000003 - System service operation failed.
541     * @throws { BusinessError } 10000004 - IPC failed.
542     * @throws { BusinessError } 10000006 - Failed to get the application information.
543     * @throws { BusinessError } 10000007 - Failed to get the system time.
544     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
545     * @systemapi Hide this for inner system use.
546     * @since 9
547     */
548    function queryBundleStatsInfoByInterval(byInterval: IntervalType, begin: number, end: number): Promise<Array<BundleStatsInfo>>;
549
550    /**
551     * Queries state data of all bundles within a specified period identified by the start and end time.
552     *
553     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
554     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
555     * @param { number } end - Indicates the end time of the query period, in milliseconds.
556     * @param { AsyncCallback<Array<BundleEvents>> } callback - the promise returned by queryBundleEvents.
557     * <p> the list of {@link BundleEvents} objects containing the state data of all bundles.</p>
558     * @throws { BusinessError } 201 - Parameter error.
559     * @throws { BusinessError } 202 - Not System App.
560     * @throws { BusinessError } 401 - Permission denied.
561     * @throws { BusinessError } 801 - Capability not supported.
562     * @throws { BusinessError } 10000001 - Memory operation failed.
563     * @throws { BusinessError } 10000002 - Parcel operation failed.
564     * @throws { BusinessError } 10000003 - System service operation failed.
565     * @throws { BusinessError } 10000004 - IPC failed.
566     * @throws { BusinessError } 10000006 - Failed to get the application information.
567     * @throws { BusinessError } 10000007 - Failed to get the system time.
568     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
569     * @systemapi Hide this for inner system use.
570     * @since 9
571     */
572    function queryBundleEvents(begin: number, end: number, callback: AsyncCallback<Array<BundleEvents>>): void;
573
574    /**
575     * Queries state data of all bundles within a specified period identified by the start and end time.
576     *
577     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
578     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
579     * @param { number } end - Indicates the end time of the query period, in milliseconds.
580     * @returns { Promise<Array<BundleEvents>> } the promise returned by queryBundleEvents.
581     * <p> the list of {@link BundleEvents} objects containing the state data of all bundles.</p>
582     * @throws { BusinessError } 201 - Parameter error.
583     * @throws { BusinessError } 202 - Not System App.
584     * @throws { BusinessError } 401 - Permission denied.
585     * @throws { BusinessError } 801 - Capability not supported.
586     * @throws { BusinessError } 10000001 - Memory operation failed.
587     * @throws { BusinessError } 10000002 - Parcel operation failed.
588     * @throws { BusinessError } 10000003 - System service operation failed.
589     * @throws { BusinessError } 10000004 - IPC failed.
590     * @throws { BusinessError } 10000006 - Failed to get the application information.
591     * @throws { BusinessError } 10000007 - Failed to get the system time.
592     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
593     * @systemapi Hide this for inner system use.
594     * @since 9
595     */
596    function queryBundleEvents(begin: number, end: number): Promise<Array<BundleEvents>>;
597
598    /**
599     * Queries state data of the current bundle within a specified period.
600     *
601     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
602     * @param { number } end - Indicates the end time of the query period, in milliseconds.
603     * @param { AsyncCallback<Array<BundleEvents>> } callback - the callback of queryCurrentBundleEvents.
604     * <p> the {@link BundleEvents} object Array containing the state data of the current bundle.</p>
605     * @throws { BusinessError } 201 - Parameter error.
606     * @throws { BusinessError } 202 - Not System App.
607     * @throws { BusinessError } 401 - Permission denied.
608     * @throws { BusinessError } 801 - Capability not supported.
609     * @throws { BusinessError } 10000001 - Memory operation failed.
610     * @throws { BusinessError } 10000002 - Parcel operation failed.
611     * @throws { BusinessError } 10000003 - System service operation failed.
612     * @throws { BusinessError } 10000004 - IPC failed.
613     * @throws { BusinessError } 10000006 - Failed to get the application information.
614     * @throws { BusinessError } 10000007 - Failed to get the system time.
615     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
616     * @systemapi Hide this for inner system use.
617     * @since 9
618     */
619    function queryCurrentBundleEvents(begin: number, end: number, callback: AsyncCallback<Array<BundleEvents>>): void;
620
621    /**
622     * Queries state data of the current bundle within a specified period.
623     *
624     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
625     * @param { number } end - Indicates the end time of the query period, in milliseconds.
626     * @returns { Promise<Array<BundleEvents>> } the promise returned by queryCurrentBundleEvents.
627     * <p> the {@link BundleEvents} object Array containing the state data of the current bundle.</p>
628     * @throws { BusinessError } 201 - Parameter error.
629     * @throws { BusinessError } 202 - Not System App.
630     * @throws { BusinessError } 401 - Permission denied.
631     * @throws { BusinessError } 801 - Capability not supported.
632     * @throws { BusinessError } 10000001 - Memory operation failed.
633     * @throws { BusinessError } 10000002 - Parcel operation failed.
634     * @throws { BusinessError } 10000003 - System service operation failed.
635     * @throws { BusinessError } 10000004 - IPC failed.
636     * @throws { BusinessError } 10000006 - Failed to get the application information.
637     * @throws { BusinessError } 10000007 - Failed to get the system time.
638     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
639     * @systemapi Hide this for inner system use.
640     * @since 9
641     */
642    function queryCurrentBundleEvents(begin: number, end: number): Promise<Array<BundleEvents>>;
643
644    /**
645     * Queries recently module usage records with maxNum.
646     *
647     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
648     * @param { number } maxNum - Indicates max record number in result, max value is 1000, default value is 1000.
649     * @param { AsyncCallback<Array<HapModuleInfo>> } callback - the callback of queryModuleUsageRecords.
650     * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p>
651     * @throws { BusinessError } 201 - Parameter error.
652     * @throws { BusinessError } 202 - Not System App.
653     * @throws { BusinessError } 401 - Permission denied.
654     * @throws { BusinessError } 801 - Capability not supported.
655     * @throws { BusinessError } 10000001 - Memory operation failed.
656     * @throws { BusinessError } 10000002 - Parcel operation failed.
657     * @throws { BusinessError } 10000003 - System service operation failed.
658     * @throws { BusinessError } 10000004 - IPC failed.
659     * @throws { BusinessError } 10000006 - Failed to get the application information.
660     * @throws { BusinessError } 10000007 - Failed to get the system time.
661     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
662     * @systemapi Hide this for inner system use.
663     * @since 9
664     */
665    function queryModuleUsageRecords(maxNum: number, callback: AsyncCallback<Array<HapModuleInfo>>): void;
666
667    /**
668     * Queries recently module usage records with maxNum.
669     *
670     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
671     * @param { number } maxNum - Indicates max record number in result, max value is 1000, default value is 1000.
672     * @returns { Promise<Array<HapModuleInfo>> } the promise returned by queryModuleUsageRecords.
673     * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p>
674     * @throws { BusinessError } 201 - Parameter error.
675     * @throws { BusinessError } 202 - Not System App.
676     * @throws { BusinessError } 401 - Permission denied.
677     * @throws { BusinessError } 801 - Capability not supported.
678     * @throws { BusinessError } 10000001 - Memory operation failed.
679     * @throws { BusinessError } 10000002 - Parcel operation failed.
680     * @throws { BusinessError } 10000003 - System service operation failed.
681     * @throws { BusinessError } 10000004 - IPC failed.
682     * @throws { BusinessError } 10000006 - Failed to get the application information.
683     * @throws { BusinessError } 10000007 - Failed to get the system time.
684     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
685     * @systemapi Hide this for inner system use.
686     * @since 9
687     */
688    function queryModuleUsageRecords(maxNum: number): Promise<Array<HapModuleInfo>>;
689
690    /**
691     * Queries recently module usage records.
692     *
693     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
694     * @param { AsyncCallback<Array<HapModuleInfo>> } callback - the callback of queryModuleUsageRecords.
695     * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p>
696     * @throws { BusinessError } 201 - Parameter error.
697     * @throws { BusinessError } 202 - Not System App.
698     * @throws { BusinessError } 401 - Permission denied.
699     * @throws { BusinessError } 801 - Capability not supported.
700     * @throws { BusinessError } 10000001 - Memory operation failed.
701     * @throws { BusinessError } 10000002 - Parcel operation failed.
702     * @throws { BusinessError } 10000003 - System service operation failed.
703     * @throws { BusinessError } 10000004 - IPC failed.
704     * @throws { BusinessError } 10000006 - Failed to get the application information.
705     * @throws { BusinessError } 10000007 - Failed to get the system time.
706     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
707     * @systemapi Hide this for inner system use.
708     * @since 9
709     */
710    function queryModuleUsageRecords(callback: AsyncCallback<Array<HapModuleInfo>>): void;
711
712    /**
713     * Queries recently module usage records.
714     *
715     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
716     * @returns { Promise<Array<HapModuleInfo>> } the promise returned by queryModuleUsageRecords.
717     * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p>
718     * @throws { BusinessError } 201 - Parameter error.
719     * @throws { BusinessError } 202 - Not System App.
720     * @throws { BusinessError } 401 - Permission denied.
721     * @throws { BusinessError } 801 - Capability not supported.
722     * @throws { BusinessError } 10000001 - Memory operation failed.
723     * @throws { BusinessError } 10000002 - Parcel operation failed.
724     * @throws { BusinessError } 10000003 - System service operation failed.
725     * @throws { BusinessError } 10000004 - IPC failed.
726     * @throws { BusinessError } 10000006 - Failed to get the application information.
727     * @throws { BusinessError } 10000007 - Failed to get the system time.
728     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
729     * @systemapi Hide this for inner system use.
730     * @since 9
731     */
732    function queryModuleUsageRecords(): Promise<Array<HapModuleInfo>>;
733
734    /**
735     * Declares group type.
736     *
737     * @enum { number }
738     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
739     * @systemapi Hide this for inner system use.
740     * @since 9
741     */
742      export enum GroupType {
743        /**
744         * Indicates the alive group.
745         */
746        ALIVE_GROUP = 10,
747
748        /**
749         * Indicates the daily group.
750         */
751        DAILY_GROUP = 20,
752
753        /**
754         * Indicates the fixed group.
755         */
756        FIXED_GROUP = 30,
757
758        /**
759         * Indicates the rare group.
760         */
761        RARE_GROUP = 40,
762
763        /**
764         * Indicates the limit group.
765         */
766         LIMITED_GROUP = 50,
767
768         /**
769         * Indicates the never group.
770         */
771         NEVER_GROUP = 60
772    }
773
774    /**
775     * Set app group by bundleName.
776     *
777     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
778     * @param { string } bundleName - name of the application.
779     * @param { GroupType } newGroup - the group of the application whose name is bundleName.
780     * @param { AsyncCallback<void> } callback - the callback of setAppGroup.
781     * @throws { BusinessError } 201 - Parameter error.
782     * @throws { BusinessError } 202 - Not System App.
783     * @throws { BusinessError } 401 - Permission denied.
784     * @throws { BusinessError } 801 - Capability not supported.
785     * @throws { BusinessError } 10000001 - Memory operation failed.
786     * @throws { BusinessError } 10000002 - Parcel operation failed.
787     * @throws { BusinessError } 10000003 - System service operation failed.
788     * @throws { BusinessError } 10000004 - IPC failed.
789     * @throws { BusinessError } 10000006 - Failed to get the application information.
790     * @throws { BusinessError } 10100001 - Repeated operation on the application group.
791     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
792     * @systemapi Hide this for inner system use.
793     * @since 9
794     */
795    function setAppGroup(bundleName: string, newGroup: GroupType, callback: AsyncCallback<void>): void;
796
797    /**
798     * Set app group by bundleName.
799     *
800     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
801     * @param { string } bundleName - name of the application.
802     * @param { GroupType } newGroup - the group of the application whose name is bundleName.
803     * @returns { Promise<void> } the promise returned by setAppGroup.
804     * @throws { BusinessError } 201 - Parameter error.
805     * @throws { BusinessError } 202 - Not System App.
806     * @throws { BusinessError } 401 - Permission denied.
807     * @throws { BusinessError } 801 - Capability not supported.
808     * @throws { BusinessError } 10000001 - Memory operation failed.
809     * @throws { BusinessError } 10000002 - Parcel operation failed.
810     * @throws { BusinessError } 10000003 - System service operation failed.
811     * @throws { BusinessError } 10000004 - IPC failed.
812     * @throws { BusinessError } 10000006 - Failed to get the application information.
813     * @throws { BusinessError } 10100001 - Repeated operation on the application group.
814     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
815     * @systemapi Hide this for inner system use.
816     * @since 9
817     */
818    function setAppGroup(bundleName: string, newGroup: GroupType): Promise<void>;
819
820    /**
821     * Register appGroup change callback to service.
822     *
823     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
824     * @param { Callback<AppGroupCallbackInfo> } groupCallback -
825     * <p> callback when AppGroupCallbackInfo when the group of app changed.</p>
826     * @param { AsyncCallback<void> } callback - the callback of registerAppGroupCallBack.
827     * @throws { BusinessError } 201 - Parameter error.
828     * @throws { BusinessError } 202 - Not System App.
829     * @throws { BusinessError } 401 - Permission denied.
830     * @throws { BusinessError } 801 - Capability not supported.
831     * @throws { BusinessError } 10000001 - Memory operation failed.
832     * @throws { BusinessError } 10000002 - Parcel operation failed.
833     * @throws { BusinessError } 10000003 - System service operation failed.
834     * @throws { BusinessError } 10000004 - IPC failed.
835     * @throws { BusinessError } 10100001 - Repeated operation on the application group.
836     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
837     * @systemapi Hide this for inner system use.
838     * @since 9
839     */
840    function registerAppGroupCallBack(groupCallback: Callback<AppGroupCallbackInfo>, callback: AsyncCallback<void>): void;
841
842    /**
843     * Register appGroup change callback to service.
844     *
845     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
846     * @param { Callback<AppGroupCallbackInfo> } groupCallback -
847     * <p> callback when AppGroupCallbackInfo when the group of app changed.</p>
848     * @returns { Promise<void> } the promise returned by registerAppGroupCallBack.
849     * @throws { BusinessError } 201 - Parameter error.
850     * @throws { BusinessError } 202 - Not System App.
851     * @throws { BusinessError } 401 - Permission denied.
852     * @throws { BusinessError } 801 - Capability not supported.
853     * @throws { BusinessError } 10000001 - Memory operation failed.
854     * @throws { BusinessError } 10000002 - Parcel operation failed.
855     * @throws { BusinessError } 10000003 - System service operation failed.
856     * @throws { BusinessError } 10000004 - IPC failed.
857     * @throws { BusinessError } 10100001 - Repeated operation on the application group.
858     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
859     * @systemapi Hide this for inner system use.
860     * @since 9
861     */
862    function registerAppGroupCallBack(groupCallback: Callback<AppGroupCallbackInfo>): Promise<void>;
863
864    /**
865     * Unregister appGroup change callback from service.
866     *
867     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
868     * @param { AsyncCallback<void> } callback - the callback of unregisterAppGroupCallBack.
869     * @throws { BusinessError } 201 - Parameter error.
870     * @throws { BusinessError } 202 - Not System App.
871     * @throws { BusinessError } 401 - Permission denied.
872     * @throws { BusinessError } 801 - Capability not supported.
873     * @throws { BusinessError } 10000001 - Memory operation failed.
874     * @throws { BusinessError } 10000002 - Parcel operation failed.
875     * @throws { BusinessError } 10000003 - System service operation failed.
876     * @throws { BusinessError } 10000004 - IPC failed.
877     * @throws { BusinessError } 10100001 - Repeated operation on the application group.
878     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
879     * @systemapi Hide this for inner system use.
880     * @since 9
881     */
882    function unregisterAppGroupCallBack(callback: AsyncCallback<void>): void;
883
884    /**
885     * Unregister appGroup change callback from service.
886     *
887     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
888     * @returns { Promise<void> } the promise returned by unregisterAppGroupCallBack.
889     * @throws { BusinessError } 201 - Parameter error.
890     * @throws { BusinessError } 202 - Not System App.
891     * @throws { BusinessError } 401 - Permission denied.
892     * @throws { BusinessError } 801 - Capability not supported.
893     * @throws { BusinessError } 10000001 - Memory operation failed.
894     * @throws { BusinessError } 10000002 - Parcel operation failed.
895     * @throws { BusinessError } 10000003 - System service operation failed.
896     * @throws { BusinessError } 10000004 - IPC failed.
897     * @throws { BusinessError } 10100001 - Repeated operation on the application group.
898     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
899     * @systemapi Hide this for inner system use.
900     * @since 9
901     */
902    function unregisterAppGroupCallBack(): Promise<void>;
903
904    /**
905     * Queries device event states data within a specified period identified by the start and end time.
906     *
907     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
908     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
909     * @param { number } end - Indicates the end time of the query period, in milliseconds.
910     * @param { AsyncCallback<Array<DeviceEventStats>> } callback - the callback of queryDeviceEventStats.
911     * <p> the {@link DeviceEventStats} object Array containing the event states data.</p>
912     * @throws { BusinessError } 201 - Parameter error.
913     * @throws { BusinessError } 202 - Not System App.
914     * @throws { BusinessError } 401 - Permission denied.
915     * @throws { BusinessError } 801 - Capability not supported.
916     * @throws { BusinessError } 10000001 - Memory operation failed.
917     * @throws { BusinessError } 10000002 - Parcel operation failed.
918     * @throws { BusinessError } 10000003 - System service operation failed.
919     * @throws { BusinessError } 10000004 - IPC failed.
920     * @throws { BusinessError } 10000006 - Failed to get the application information.
921     * @throws { BusinessError } 10000007 - Failed to get the system time.
922     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
923     * @systemapi Hide this for inner system use.
924     * @since 9
925     */
926    function queryDeviceEventStats(begin: number, end: number, callback: AsyncCallback<Array<DeviceEventStats>>): void;
927
928    /**
929     * Queries device event states data within a specified period identified by the start and end time.
930     *
931     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
932     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
933     * @param { number } end - Indicates the end time of the query period, in milliseconds.
934     * @returns { Promise<Array<DeviceEventStats>> } the promise returned by queryDeviceEventStats.
935     * <p> the {@link DeviceEventStats} object Array containing the event states data.</p>
936     * @throws { BusinessError } 201 - Parameter error.
937     * @throws { BusinessError } 202 - Not System App.
938     * @throws { BusinessError } 401 - Permission denied.
939     * @throws { BusinessError } 801 - Capability not supported.
940     * @throws { BusinessError } 10000001 - Memory operation failed.
941     * @throws { BusinessError } 10000002 - Parcel operation failed.
942     * @throws { BusinessError } 10000003 - System service operation failed.
943     * @throws { BusinessError } 10000004 - IPC failed.
944     * @throws { BusinessError } 10000006 - Failed to get the application information.
945     * @throws { BusinessError } 10000007 - Failed to get the system time.
946     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
947     * @systemapi Hide this for inner system use.
948     * @since 9
949     */
950    function queryDeviceEventStats(begin: number, end: number): Promise<Array<DeviceEventStats>>;
951
952    /**
953     * Queries app notification number within a specified period identified by the start and end time.
954     *
955     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
956     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
957     * @param { number } end - Indicates the end time of the query period, in milliseconds.
958     * @param { AsyncCallback<Array<DeviceEventStats>> } callback - the callback of queryNotificationEventStats.
959     * <p> the {@link DeviceEventStats} object Array containing the event states data.</p>
960     * @throws { BusinessError } 201 - Parameter error.
961     * @throws { BusinessError } 202 - Not System App.
962     * @throws { BusinessError } 401 - Permission denied.
963     * @throws { BusinessError } 801 - Capability not supported.
964     * @throws { BusinessError } 10000001 - Memory operation failed.
965     * @throws { BusinessError } 10000002 - Parcel operation failed.
966     * @throws { BusinessError } 10000003 - System service operation failed.
967     * @throws { BusinessError } 10000004 - IPC failed.
968     * @throws { BusinessError } 10000006 - Failed to get the application information.
969     * @throws { BusinessError } 10000007 - Failed to get the system time.
970     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
971     * @systemapi Hide this for inner system use.
972     * @since 9
973     */
974    function queryNotificationEventStats(begin: number, end: number, callback: AsyncCallback<Array<DeviceEventStats>>): void;
975
976    /**
977     * Queries app notification number within a specified period identified by the start and end time.
978     *
979     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
980     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
981     * @param { number } end - Indicates the end time of the query period, in milliseconds.
982     * @returns { Promise<Array<DeviceEventStats>> } the promise returned by queryNotificationEventStats.
983     * <p> the {@link DeviceEventStats} object Array containing the event states data.</p>
984     * @throws { BusinessError } 201 - Parameter error.
985     * @throws { BusinessError } 202 - Not System App.
986     * @throws { BusinessError } 401 - Permission denied.
987     * @throws { BusinessError } 801 - Capability not supported.
988     * @throws { BusinessError } 10000001 - Memory operation failed.
989     * @throws { BusinessError } 10000002 - Parcel operation failed.
990     * @throws { BusinessError } 10000003 - System service operation failed.
991     * @throws { BusinessError } 10000004 - IPC failed.
992     * @throws { BusinessError } 10000006 - Failed to get the application information.
993     * @throws { BusinessError } 10000007 - Failed to get the system time.
994     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
995     * @systemapi Hide this for inner system use.
996     * @since 9
997     */
998    function queryNotificationEventStats(begin: number, end: number): Promise<Array<DeviceEventStats>>;
999}
1000
1001export default usageStatistics;