• 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 } 401 - Permission denied.
360     * @throws { BusinessError } 801 - Capability not supported.
361     * @throws { BusinessError } 10000001 - Memory operation failed.
362     * @throws { BusinessError } 10000002 - Parcel operation failed.
363     * @throws { BusinessError } 10000003 - System service operation failed.
364     * @throws { BusinessError } 10000004 - IPC failed.
365     * @throws { BusinessError } 10000005 - Application is not installed.
366     * @throws { BusinessError } 10000006 - Failed to get the application information.
367     * @throws { BusinessError } 10100002 - Failed to get the application group information.
368     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
369     * @systemapi Hide this for inner system use.
370     * @since 9
371     */
372     function queryAppGroup(bundleName : string, callback: AsyncCallback<number>): void;
373
374     /**
375     * Queries the usage priority group by bundleName.
376     * <p>The priority defined in a priority group restricts the resource usage of an application,
377     * for example, restricting the running of background tasks. </p>
378     *
379     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
380     * @param { string } bundleName - name of the application.
381     * @returns { Promise<number> } the promise returned by queryAppGroup.
382     * <p> the usage priority group of the calling application.</p>
383     * @throws { BusinessError } 201 - Parameter error.
384     * @throws { BusinessError } 401 - Permission denied.
385     * @throws { BusinessError } 801 - Capability not supported.
386     * @throws { BusinessError } 10000001 - Memory operation failed.
387     * @throws { BusinessError } 10000002 - Parcel operation failed.
388     * @throws { BusinessError } 10000003 - System service operation failed.
389     * @throws { BusinessError } 10000004 - IPC failed.
390     * @throws { BusinessError } 10000005 - Application is not installed.
391     * @throws { BusinessError } 10000006 - Failed to get the application information.
392     * @throws { BusinessError } 10100002 - Failed to get the application group information.
393     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
394     * @systemapi Hide this for inner system use.
395     * @since 9
396     */
397     function queryAppGroup(bundleName : string): Promise<number>;
398
399    /**
400     * @interface BundleStatsMap
401     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
402     * @systemapi Hide this for inner system use.
403     * @since 9
404     */
405     interface BundleStatsMap {
406        [key: string]: BundleStatsInfo;
407    }
408
409    /**
410     * Queries usage information about each bundle within a specified period.
411     * <p>This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.</p>
412     *
413     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
414     * @param {number} begin - Indicates the start time of the query period, in milliseconds.
415     * @param {number} end - Indicates the end time of the query period, in milliseconds.
416     * @param { AsyncCallback<BundleStatsMap> } callback - the callback of queryBundleStatsInfos,
417     * <p> the {@link BundleStatsMap} objects containing the usage information about each bundle.</p>
418     * @throws { BusinessError } 201 - Parameter error.
419     * @throws { BusinessError } 401 - Permission denied.
420     * @throws { BusinessError } 801 - Capability not supported.
421     * @throws { BusinessError } 10000001 - Memory operation failed.
422     * @throws { BusinessError } 10000002 - Parcel operation failed.
423     * @throws { BusinessError } 10000003 - System service operation failed.
424     * @throws { BusinessError } 10000004 - IPC failed.
425     * @throws { BusinessError } 10000006 - Failed to get the application information.
426     * @throws { BusinessError } 10000007 - Failed to get the system time.
427     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
428     * @systemapi Hide this for inner system use.
429     * @since 9
430     */
431    function queryBundleStatsInfos(begin: number, end: number, callback: AsyncCallback<BundleStatsMap>): void;
432
433    /**
434     * Queries usage information about each bundle within a specified period.
435     * <p>This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.</p>
436     *
437     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
438     * @param {number} begin - Indicates the start time of the query period, in milliseconds.
439     * @param {number} end - Indicates the end time of the query period, in milliseconds.
440     * @returns { Promise<BundleStatsMap> } the promise returned by queryBundleStatsInfos.
441     * <p> the {@link BundleStatsMap} objects containing the usage information about each bundle.</p>
442     * @throws { BusinessError } 201 - Parameter error.
443     * @throws { BusinessError } 202 - Not System App.
444     * @throws { BusinessError } 401 - Permission denied.
445     * @throws { BusinessError } 801 - Capability not supported.
446     * @throws { BusinessError } 10000001 - Memory operation failed.
447     * @throws { BusinessError } 10000002 - Parcel operation failed.
448     * @throws { BusinessError } 10000003 - System service operation failed.
449     * @throws { BusinessError } 10000004 - IPC failed.
450     * @throws { BusinessError } 10000006 - Failed to get the application information.
451     * @throws { BusinessError } 10000007 - Failed to get the system time.
452     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
453     * @systemapi Hide this for inner system use.
454     * @since 9
455     */
456    function queryBundleStatsInfos(begin: number, end: number): Promise<BundleStatsMap>;
457
458    /**
459     * Declares interval type.
460     *
461     * @enum { number }
462     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
463     * @systemapi Hide this for inner system use.
464     * @since 9
465     */
466    export enum IntervalType {
467        /**
468         * Indicates the interval type that will determine the optimal interval based on the start and end time.
469         */
470        BY_OPTIMIZED = 0,
471
472        /**
473         * Indicates the daily interval.
474         */
475        BY_DAILY = 1,
476
477        /**
478         * Indicates the weekly interval.
479         */
480        BY_WEEKLY = 2,
481
482        /**
483         * Indicates the monthly interval.
484         */
485        BY_MONTHLY = 3,
486
487        /**
488         * Indicates the annually interval.
489         */
490        BY_ANNUALLY = 4
491    }
492
493    /**
494     * Queries usage information about each bundle within a specified period at a specified interval.
495     *
496     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
497     * @param { IntervalType } byInterval - Indicates the interval at which the usage statistics are queried.
498     * <p> The value can be {@link #BY_OPTIMIZED}, {@link #BY_DAILY},
499     * {@link #BY_WEEKLY}, {@link #BY_MONTHLY}, or {@link #BY_ANNUALLY}.</p>
500     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
501     * @param { number } end - Indicates the end time of the query period, in milliseconds.
502     * @param { AsyncCallback<Array<BundleStatsInfo>> } callback - the callback of queryBundleStatsInfoByInterval.
503     * <p> the list of {@link BundleStatsInfo} objects containing the usage information about each bundle.</p>
504     * @throws { BusinessError } 201 - Parameter error.
505     * @throws { BusinessError } 401 - Permission denied.
506     * @throws { BusinessError } 801 - Capability not supported.
507     * @throws { BusinessError } 10000001 - Memory operation failed.
508     * @throws { BusinessError } 10000002 - Parcel operation failed.
509     * @throws { BusinessError } 10000003 - System service operation failed.
510     * @throws { BusinessError } 10000004 - IPC failed.
511     * @throws { BusinessError } 10000006 - Failed to get the application information.
512     * @throws { BusinessError } 10000007 - Failed to get the system time.
513     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
514     * @systemapi Hide this for inner system use.
515     * @since 9
516     */
517    function queryBundleStatsInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback<Array<BundleStatsInfo>>): void;
518
519    /**
520     * Queries usage information about each bundle within a specified period at a specified interval.
521     *
522     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
523     * @param { IntervalType } byInterval - Indicates the interval at which the usage statistics are queried.
524     * <p> The value can be {@link #BY_OPTIMIZED}, {@link #BY_DAILY},
525     * {@link #BY_WEEKLY}, {@link #BY_MONTHLY}, or {@link #BY_ANNUALLY}.</p>
526     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
527     * @param { number } end - Indicates the end time of the query period, in milliseconds.
528     * @returns { Promise<Array<BundleStatsInfo>> } the promise returned by queryBundleStatsInfoByInterval.
529     * <p> the list of {@link BundleStatsInfo} objects containing the usage information about each bundle.</p>
530     * @throws { BusinessError } 201 - Parameter error.
531     * @throws { BusinessError } 202 - Not System App.
532     * @throws { BusinessError } 401 - Permission denied.
533     * @throws { BusinessError } 801 - Capability not supported.
534     * @throws { BusinessError } 10000001 - Memory operation failed.
535     * @throws { BusinessError } 10000002 - Parcel operation failed.
536     * @throws { BusinessError } 10000003 - System service operation failed.
537     * @throws { BusinessError } 10000004 - IPC failed.
538     * @throws { BusinessError } 10000006 - Failed to get the application information.
539     * @throws { BusinessError } 10000007 - Failed to get the system time.
540     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
541     * @systemapi Hide this for inner system use.
542     * @since 9
543     */
544    function queryBundleStatsInfoByInterval(byInterval: IntervalType, begin: number, end: number): Promise<Array<BundleStatsInfo>>;
545
546    /**
547     * Queries state data of all bundles within a specified period identified by the start and end time.
548     *
549     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
550     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
551     * @param { number } end - Indicates the end time of the query period, in milliseconds.
552     * @param { AsyncCallback<Array<BundleEvents>> } callback - the promise returned by queryBundleEvents.
553     * <p> the list of {@link BundleEvents} objects containing the state data of all bundles.</p>
554     * @throws { BusinessError } 201 - Parameter error.
555     * @throws { BusinessError } 401 - Permission denied.
556     * @throws { BusinessError } 801 - Capability not supported.
557     * @throws { BusinessError } 10000001 - Memory operation failed.
558     * @throws { BusinessError } 10000002 - Parcel operation failed.
559     * @throws { BusinessError } 10000003 - System service operation failed.
560     * @throws { BusinessError } 10000004 - IPC failed.
561     * @throws { BusinessError } 10000006 - Failed to get the application information.
562     * @throws { BusinessError } 10000007 - Failed to get the system time.
563     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
564     * @systemapi Hide this for inner system use.
565     * @since 9
566     */
567    function queryBundleEvents(begin: number, end: number, callback: AsyncCallback<Array<BundleEvents>>): void;
568
569    /**
570     * Queries state data of all bundles within a specified period identified by the start and end time.
571     *
572     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
573     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
574     * @param { number } end - Indicates the end time of the query period, in milliseconds.
575     * @returns { Promise<Array<BundleEvents>> } the promise returned by queryBundleEvents.
576     * <p> the list of {@link BundleEvents} objects containing the state data of all bundles.</p>
577     * @throws { BusinessError } 201 - Parameter error.
578     * @throws { BusinessError } 202 - Not System App.
579     * @throws { BusinessError } 401 - Permission denied.
580     * @throws { BusinessError } 801 - Capability not supported.
581     * @throws { BusinessError } 10000001 - Memory operation failed.
582     * @throws { BusinessError } 10000002 - Parcel operation failed.
583     * @throws { BusinessError } 10000003 - System service operation failed.
584     * @throws { BusinessError } 10000004 - IPC failed.
585     * @throws { BusinessError } 10000006 - Failed to get the application information.
586     * @throws { BusinessError } 10000007 - Failed to get the system time.
587     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
588     * @systemapi Hide this for inner system use.
589     * @since 9
590     */
591    function queryBundleEvents(begin: number, end: number): Promise<Array<BundleEvents>>;
592
593    /**
594     * Queries state data of the current bundle within a specified period.
595     *
596     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
597     * @param { number } end - Indicates the end time of the query period, in milliseconds.
598     * @param { AsyncCallback<Array<BundleEvents>> } callback - the callback of queryCurrentBundleEvents.
599     * <p> the {@link BundleEvents} object Array containing the state data of the current bundle.</p>
600     * @throws { BusinessError } 201 - Parameter error.
601     * @throws { BusinessError } 202 - Not System App.
602     * @throws { BusinessError } 401 - Permission denied.
603     * @throws { BusinessError } 801 - Capability not supported.
604     * @throws { BusinessError } 10000001 - Memory operation failed.
605     * @throws { BusinessError } 10000002 - Parcel operation failed.
606     * @throws { BusinessError } 10000003 - System service operation failed.
607     * @throws { BusinessError } 10000004 - IPC failed.
608     * @throws { BusinessError } 10000006 - Failed to get the application information.
609     * @throws { BusinessError } 10000007 - Failed to get the system time.
610     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
611     * @systemapi Hide this for inner system use.
612     * @since 9
613     */
614    function queryCurrentBundleEvents(begin: number, end: number, callback: AsyncCallback<Array<BundleEvents>>): void;
615
616    /**
617     * Queries state data of the current bundle within a specified period.
618     *
619     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
620     * @param { number } end - Indicates the end time of the query period, in milliseconds.
621     * @returns { Promise<Array<BundleEvents>> } the promise returned by queryCurrentBundleEvents.
622     * <p> the {@link BundleEvents} object Array containing the state data of the current bundle.</p>
623     * @throws { BusinessError } 201 - Parameter error.
624     * @throws { BusinessError } 202 - Not System App.
625     * @throws { BusinessError } 401 - Permission denied.
626     * @throws { BusinessError } 801 - Capability not supported.
627     * @throws { BusinessError } 10000001 - Memory operation failed.
628     * @throws { BusinessError } 10000002 - Parcel operation failed.
629     * @throws { BusinessError } 10000003 - System service operation failed.
630     * @throws { BusinessError } 10000004 - IPC failed.
631     * @throws { BusinessError } 10000006 - Failed to get the application information.
632     * @throws { BusinessError } 10000007 - Failed to get the system time.
633     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
634     * @systemapi Hide this for inner system use.
635     * @since 9
636     */
637    function queryCurrentBundleEvents(begin: number, end: number): Promise<Array<BundleEvents>>;
638
639    /**
640     * Queries recently module usage records with maxNum.
641     *
642     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
643     * @param { number } maxNum - Indicates max record number in result, max value is 1000, default value is 1000.
644     * @param { AsyncCallback<Array<HapModuleInfo>> } callback - the callback of queryModuleUsageRecords.
645     * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p>
646     * @throws { BusinessError } 201 - Parameter error.
647     * @throws { BusinessError } 401 - Permission denied.
648     * @throws { BusinessError } 801 - Capability not supported.
649     * @throws { BusinessError } 10000001 - Memory operation failed.
650     * @throws { BusinessError } 10000002 - Parcel operation failed.
651     * @throws { BusinessError } 10000003 - System service operation failed.
652     * @throws { BusinessError } 10000004 - IPC failed.
653     * @throws { BusinessError } 10000006 - Failed to get the application information.
654     * @throws { BusinessError } 10000007 - Failed to get the system time.
655     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
656     * @systemapi Hide this for inner system use.
657     * @since 9
658     */
659    function queryModuleUsageRecords(maxNum: number, callback: AsyncCallback<Array<HapModuleInfo>>): void;
660
661    /**
662     * Queries recently module usage records with maxNum.
663     *
664     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
665     * @param { number } maxNum - Indicates max record number in result, max value is 1000, default value is 1000.
666     * @returns { Promise<Array<HapModuleInfo>> } the promise returned by queryModuleUsageRecords.
667     * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p>
668     * @throws { BusinessError } 201 - Parameter error.
669     * @throws { BusinessError } 202 - Not System App.
670     * @throws { BusinessError } 401 - Permission denied.
671     * @throws { BusinessError } 801 - Capability not supported.
672     * @throws { BusinessError } 10000001 - Memory operation failed.
673     * @throws { BusinessError } 10000002 - Parcel operation failed.
674     * @throws { BusinessError } 10000003 - System service operation failed.
675     * @throws { BusinessError } 10000004 - IPC failed.
676     * @throws { BusinessError } 10000006 - Failed to get the application information.
677     * @throws { BusinessError } 10000007 - Failed to get the system time.
678     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
679     * @systemapi Hide this for inner system use.
680     * @since 9
681     */
682    function queryModuleUsageRecords(maxNum: number): Promise<Array<HapModuleInfo>>;
683
684    /**
685     * Queries recently module usage records.
686     *
687     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
688     * @param { AsyncCallback<Array<HapModuleInfo>> } callback - the callback of queryModuleUsageRecords.
689     * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p>
690     * @throws { BusinessError } 201 - Parameter error.
691     * @throws { BusinessError } 401 - Permission denied.
692     * @throws { BusinessError } 801 - Capability not supported.
693     * @throws { BusinessError } 10000001 - Memory operation failed.
694     * @throws { BusinessError } 10000002 - Parcel operation failed.
695     * @throws { BusinessError } 10000003 - System service operation failed.
696     * @throws { BusinessError } 10000004 - IPC failed.
697     * @throws { BusinessError } 10000006 - Failed to get the application information.
698     * @throws { BusinessError } 10000007 - Failed to get the system time.
699     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
700     * @systemapi Hide this for inner system use.
701     * @since 9
702     */
703    function queryModuleUsageRecords(callback: AsyncCallback<Array<HapModuleInfo>>): void;
704
705    /**
706     * Queries recently module usage records.
707     *
708     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
709     * @returns { Promise<Array<HapModuleInfo>> } the promise returned by queryModuleUsageRecords.
710     * <p> the {@link HapModuleInfo} object Array containing the usage data of the modules.</p>
711     * @throws { BusinessError } 201 - Parameter error.
712     * @throws { BusinessError } 202 - Not System App.
713     * @throws { BusinessError } 401 - Permission denied.
714     * @throws { BusinessError } 801 - Capability not supported.
715     * @throws { BusinessError } 10000001 - Memory operation failed.
716     * @throws { BusinessError } 10000002 - Parcel operation failed.
717     * @throws { BusinessError } 10000003 - System service operation failed.
718     * @throws { BusinessError } 10000004 - IPC failed.
719     * @throws { BusinessError } 10000006 - Failed to get the application information.
720     * @throws { BusinessError } 10000007 - Failed to get the system time.
721     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
722     * @systemapi Hide this for inner system use.
723     * @since 9
724     */
725    function queryModuleUsageRecords(): Promise<Array<HapModuleInfo>>;
726
727    /**
728     * Declares group type.
729     *
730     * @enum { number }
731     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
732     * @systemapi Hide this for inner system use.
733     * @since 9
734     */
735      export enum GroupType {
736        /**
737         * Indicates the alive group.
738         */
739        ALIVE_GROUP = 10,
740
741        /**
742         * Indicates the daily group.
743         */
744        DAILY_GROUP = 20,
745
746        /**
747         * Indicates the fixed group.
748         */
749        FIXED_GROUP = 30,
750
751        /**
752         * Indicates the rare group.
753         */
754        RARE_GROUP = 40,
755
756        /**
757         * Indicates the limit group.
758         */
759         LIMITED_GROUP = 50,
760
761         /**
762         * Indicates the never group.
763         */
764         NEVER_GROUP = 60
765    }
766
767    /**
768     * Set app group by bundleName.
769     *
770     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
771     * @param { string } bundleName - name of the application.
772     * @param { GroupType } newGroup - the group of the application whose name is bundleName.
773     * @param { AsyncCallback<void> } callback - the callback of setAppGroup.
774     * @throws { BusinessError } 201 - Parameter error.
775     * @throws { BusinessError } 401 - Permission denied.
776     * @throws { BusinessError } 801 - Capability not supported.
777     * @throws { BusinessError } 10000001 - Memory operation failed.
778     * @throws { BusinessError } 10000002 - Parcel operation failed.
779     * @throws { BusinessError } 10000003 - System service operation failed.
780     * @throws { BusinessError } 10000004 - IPC failed.
781     * @throws { BusinessError } 10000006 - Failed to get the application information.
782     * @throws { BusinessError } 10100001 - Repeated operation on the application group.
783     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
784     * @systemapi Hide this for inner system use.
785     * @since 9
786     */
787    function setAppGroup(bundleName: string, newGroup: GroupType, callback: AsyncCallback<void>): void;
788
789    /**
790     * Set app group by bundleName.
791     *
792     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
793     * @param { string } bundleName - name of the application.
794     * @param { GroupType } newGroup - the group of the application whose name is bundleName.
795     * @returns { Promise<void> } the promise returned by setAppGroup.
796     * @throws { BusinessError } 201 - Parameter error.
797     * @throws { BusinessError } 202 - Not System App.
798     * @throws { BusinessError } 401 - Permission denied.
799     * @throws { BusinessError } 801 - Capability not supported.
800     * @throws { BusinessError } 10000001 - Memory operation failed.
801     * @throws { BusinessError } 10000002 - Parcel operation failed.
802     * @throws { BusinessError } 10000003 - System service operation failed.
803     * @throws { BusinessError } 10000004 - IPC failed.
804     * @throws { BusinessError } 10000006 - Failed to get the application information.
805     * @throws { BusinessError } 10100001 - Repeated operation on the application group.
806     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
807     * @systemapi Hide this for inner system use.
808     * @since 9
809     */
810    function setAppGroup(bundleName: string, newGroup: GroupType): Promise<void>;
811
812    /**
813     * Register appGroup change callback to service.
814     *
815     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
816     * @param { Callback<AppGroupCallbackInfo> } groupCallback -
817     * <p> callback when AppGroupCallbackInfo when the group of app changed.</p>
818     * @param { AsyncCallback<void> } callback - the callback of registerAppGroupCallBack.
819     * @throws { BusinessError } 201 - Parameter error.
820     * @throws { BusinessError } 401 - Permission denied.
821     * @throws { BusinessError } 801 - Capability not supported.
822     * @throws { BusinessError } 10000001 - Memory operation failed.
823     * @throws { BusinessError } 10000002 - Parcel operation failed.
824     * @throws { BusinessError } 10000003 - System service operation failed.
825     * @throws { BusinessError } 10000004 - IPC failed.
826     * @throws { BusinessError } 10100001 - Repeated operation on the application group.
827     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
828     * @systemapi Hide this for inner system use.
829     * @since 9
830     */
831    function registerAppGroupCallBack(groupCallback: Callback<AppGroupCallbackInfo>, callback: AsyncCallback<void>): void;
832
833    /**
834     * Register appGroup change callback to service.
835     *
836     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
837     * @param { Callback<AppGroupCallbackInfo> } groupCallback -
838     * <p> callback when AppGroupCallbackInfo when the group of app changed.</p>
839     * @returns { Promise<void> } the promise returned by registerAppGroupCallBack.
840     * @throws { BusinessError } 201 - Parameter error.
841     * @throws { BusinessError } 202 - Not System App.
842     * @throws { BusinessError } 401 - Permission denied.
843     * @throws { BusinessError } 801 - Capability not supported.
844     * @throws { BusinessError } 10000001 - Memory operation failed.
845     * @throws { BusinessError } 10000002 - Parcel operation failed.
846     * @throws { BusinessError } 10000003 - System service operation failed.
847     * @throws { BusinessError } 10000004 - IPC failed.
848     * @throws { BusinessError } 10100001 - Repeated operation on the application group.
849     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
850     * @systemapi Hide this for inner system use.
851     * @since 9
852     */
853    function registerAppGroupCallBack(groupCallback: Callback<AppGroupCallbackInfo>): Promise<void>;
854
855    /**
856     * Unregister appGroup change callback from service.
857     *
858     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
859     * @param { AsyncCallback<void> } callback - the callback of unregisterAppGroupCallBack.
860     * @throws { BusinessError } 201 - Parameter error.
861     * @throws { BusinessError } 401 - Permission denied.
862     * @throws { BusinessError } 801 - Capability not supported.
863     * @throws { BusinessError } 10000001 - Memory operation failed.
864     * @throws { BusinessError } 10000002 - Parcel operation failed.
865     * @throws { BusinessError } 10000003 - System service operation failed.
866     * @throws { BusinessError } 10000004 - IPC failed.
867     * @throws { BusinessError } 10100001 - Repeated operation on the application group.
868     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
869     * @systemapi Hide this for inner system use.
870     * @since 9
871     */
872    function unregisterAppGroupCallBack(callback: AsyncCallback<void>): void;
873
874    /**
875     * Unregister appGroup change callback from service.
876     *
877     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
878     * @returns { Promise<void> } the promise returned by unregisterAppGroupCallBack.
879     * @throws { BusinessError } 201 - Parameter error.
880     * @throws { BusinessError } 202 - Not System App.
881     * @throws { BusinessError } 401 - Permission denied.
882     * @throws { BusinessError } 801 - Capability not supported.
883     * @throws { BusinessError } 10000001 - Memory operation failed.
884     * @throws { BusinessError } 10000002 - Parcel operation failed.
885     * @throws { BusinessError } 10000003 - System service operation failed.
886     * @throws { BusinessError } 10000004 - IPC failed.
887     * @throws { BusinessError } 10100001 - Repeated operation on the application group.
888     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
889     * @systemapi Hide this for inner system use.
890     * @since 9
891     */
892    function unregisterAppGroupCallBack(): Promise<void>;
893
894    /**
895     * Queries device event states data within a specified period identified by the start and end time.
896     *
897     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
898     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
899     * @param { number } end - Indicates the end time of the query period, in milliseconds.
900     * @param { AsyncCallback<Array<DeviceEventStats>> } callback - the callback of queryDeviceEventStats.
901     * <p> the {@link DeviceEventStats} object Array containing the event states data.</p>
902     * @throws { BusinessError } 201 - Parameter error.
903     * @throws { BusinessError } 401 - Permission denied.
904     * @throws { BusinessError } 801 - Capability not supported.
905     * @throws { BusinessError } 10000001 - Memory operation failed.
906     * @throws { BusinessError } 10000002 - Parcel operation failed.
907     * @throws { BusinessError } 10000003 - System service operation failed.
908     * @throws { BusinessError } 10000004 - IPC failed.
909     * @throws { BusinessError } 10000006 - Failed to get the application information.
910     * @throws { BusinessError } 10000007 - Failed to get the system time.
911     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
912     * @systemapi Hide this for inner system use.
913     * @since 9
914     */
915    function queryDeviceEventStats(begin: number, end: number, callback: AsyncCallback<Array<DeviceEventStats>>): void;
916
917    /**
918     * Queries device event states data within a specified period identified by the start and end time.
919     *
920     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
921     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
922     * @param { number } end - Indicates the end time of the query period, in milliseconds.
923     * @returns { Promise<Array<DeviceEventStats>> } the promise returned by queryDeviceEventStats.
924     * <p> the {@link DeviceEventStats} object Array containing the event states data.</p>
925     * @throws { BusinessError } 201 - Parameter error.
926     * @throws { BusinessError } 202 - Not System App.
927     * @throws { BusinessError } 401 - Permission denied.
928     * @throws { BusinessError } 801 - Capability not supported.
929     * @throws { BusinessError } 10000001 - Memory operation failed.
930     * @throws { BusinessError } 10000002 - Parcel operation failed.
931     * @throws { BusinessError } 10000003 - System service operation failed.
932     * @throws { BusinessError } 10000004 - IPC failed.
933     * @throws { BusinessError } 10000006 - Failed to get the application information.
934     * @throws { BusinessError } 10000007 - Failed to get the system time.
935     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
936     * @systemapi Hide this for inner system use.
937     * @since 9
938     */
939    function queryDeviceEventStats(begin: number, end: number): Promise<Array<DeviceEventStats>>;
940
941    /**
942     * Queries app notification number within a specified period identified by the start and end time.
943     *
944     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
945     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
946     * @param { number } end - Indicates the end time of the query period, in milliseconds.
947     * @param { AsyncCallback<Array<DeviceEventStats>> } callback - the callback of queryNotificationEventStats.
948     * <p> the {@link DeviceEventStats} object Array containing the event states data.</p>
949     * @throws { BusinessError } 201 - Parameter error.
950     * @throws { BusinessError } 401 - Permission denied.
951     * @throws { BusinessError } 801 - Capability not supported.
952     * @throws { BusinessError } 10000001 - Memory operation failed.
953     * @throws { BusinessError } 10000002 - Parcel operation failed.
954     * @throws { BusinessError } 10000003 - System service operation failed.
955     * @throws { BusinessError } 10000004 - IPC failed.
956     * @throws { BusinessError } 10000006 - Failed to get the application information.
957     * @throws { BusinessError } 10000007 - Failed to get the system time.
958     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
959     * @systemapi Hide this for inner system use.
960     * @since 9
961     */
962    function queryNotificationEventStats(begin: number, end: number, callback: AsyncCallback<Array<DeviceEventStats>>): void;
963
964    /**
965     * Queries app notification number within a specified period identified by the start and end time.
966     *
967     * @permission ohos.permission.BUNDLE_ACTIVE_INFO
968     * @param { number } begin - Indicates the start time of the query period, in milliseconds.
969     * @param { number } end - Indicates the end time of the query period, in milliseconds.
970     * @returns { Promise<Array<DeviceEventStats>> } the promise returned by queryNotificationEventStats.
971     * <p> the {@link DeviceEventStats} object Array containing the event states data.</p>
972     * @throws { BusinessError } 201 - Parameter error.
973     * @throws { BusinessError } 202 - Not System App.
974     * @throws { BusinessError } 401 - Permission denied.
975     * @throws { BusinessError } 801 - Capability not supported.
976     * @throws { BusinessError } 10000001 - Memory operation failed.
977     * @throws { BusinessError } 10000002 - Parcel operation failed.
978     * @throws { BusinessError } 10000003 - System service operation failed.
979     * @throws { BusinessError } 10000004 - IPC failed.
980     * @throws { BusinessError } 10000006 - Failed to get the application information.
981     * @throws { BusinessError } 10000007 - Failed to get the system time.
982     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
983     * @systemapi Hide this for inner system use.
984     * @since 9
985     */
986    function queryNotificationEventStats(begin: number, end: number): Promise<Array<DeviceEventStats>>;
987}
988
989export default usageStatistics;