• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.resourceschedule.usageStatistics (设备使用信息统计)
2
3本模块提供设备使用信息统计能力。
4
5设备使用信息统计,系统应用可调用接口实现如下功能:
6
7- 查询设备上各应用在不同时间段的使用时长、各应用的事件(前台、后台、长时任务开始、长时任务结束)信息及各应用的通知次数信息。
8- 查询系统事件(休眠、唤醒、解锁、锁屏)统计信息。
9- 查询应用分组信息(其他应用和自身应用)。
10- 查询应用空闲状态(其他应用和自身应用)。
11- 设置应用分组信息(其他应用)。
12- 注册和解除注册应用分组变化监听。
13
14三方应用可调用接口实现如下功能:
15
16- 查询应用空闲状态(仅限自身应用)。
17- 查询应用分组信息(仅限自身应用)。
18- 查询应用事件(仅限自身应用)。
19
20> **说明:**
21>
22> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
23>
24
25
26## 导入模块
27
28```
29import usageStatistics from '@ohos.resourceschedule.usageStatistics'
30```
31
32## usageStatistics.isIdleState
33
34isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void
35
36判断指定bundleName的应用当前是否是空闲状态,三方应用只能查询自身的空闲状态,使用Callback形式返回。
37
38**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
39
40**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
41
42**系统API**:此接口为系统接口。
43
44**参数**:
45
46| 参数名        | 类型                           | 必填   | 说明                                       |
47| ---------- | ---------------------------- | ---- | ---------------------------------------- |
48| bundleName | string                       | 是    | 应用的bundleName。                           |
49| callback   | AsyncCallback<boolean> | 是    | 指定的callback回调方法。如果指定的bundleName有效,则返回指定bundleName的应用当前是否是空闲状态;否则返回null。 |
50
51**错误码**:
52
53以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
54
55| 错误码ID        | 错误信息                     |
56| ---------- | ----------------------------     |
57| 10000001   | Memory operation failed.         |
58| 10000002   | Parcel operation failed.         |
59| 10000003   | System service operation failed. |
60| 10000004   | IPC failed.        |
61| 10000006   | Failed to get the application information.    |
62
63**示例**:
64```ts
65import { BusinessError } from '@ohos.base';
66
67usageStatistics.isIdleState("com.ohos.camera", (err: BusinessError, res: boolean) => {
68  if (err) {
69    console.log('BUNDLE_ACTIVE isIdleState callback failed. code is: ' + err.code + ',message is: ' + err.message);
70  } else {
71    console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res));
72  }
73});
74```
75
76## usageStatistics.isIdleState
77
78isIdleState(bundleName: string): Promise<boolean>
79
80判断指定bundleName的应用当前是否是空闲状态,三方应用只能查询自身的空闲状态,使用Promise形式返回。
81
82**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
83
84**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
85
86**系统API**:此接口为系统接口。
87
88**参数**:
89
90| 参数名        | 类型     | 必填   | 说明             |
91| ---------- | ------ | ---- | -------------- |
92| bundleName | string | 是    | 应用的bundleName。 |
93
94**返回值**:
95
96| 类型                     | 说明                                       |
97| ---------------------- | ---------------------------------------- |
98| Promise<boolean> | 指定的Promise回调方法。如果指定的bundleName有效,则返回指定bundleName的应用当前是否是空闲状态;否则返回null。 |
99
100**错误码**:
101
102以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
103
104| 错误码ID        | 错误信息                     |
105| ---------- | ----------------------------     |
106| 10000001   | Memory operation failed.         |
107| 10000002   | Parcel operation failed.         |
108| 10000003   | System service operation failed. |
109| 10000004   | IPC failed.        |
110| 10000006   | Failed to get the application information.     |
111
112**示例**:
113
114```ts
115import { BusinessError } from '@ohos.base';
116
117usageStatistics.isIdleState("com.ohos.camera").then((res: boolean) => {
118  console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res));
119}).catch((err: BusinessError) => {
120  console.log('BUNDLE_ACTIVE isIdleState promise failed. code is: ' + err.code + ',message is: ' + err.message);
121});
122```
123## usageStatistics.isIdleStateSync<sup>10+<sup>
124
125isIdleStateSync(bundleName: string): boolean
126
127判断指定bundleName的应用当前是否是空闲状态,三方应用只能查询自身的空闲状态。
128
129**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
130
131**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
132
133**系统API**:此接口为系统接口。
134
135**参数**:
136
137| 参数名        | 类型                           | 必填   | 说明                                       |
138| ---------- | ---------------------------- | ---- | ---------------------------------------- |
139| bundleName | string                       | 是    | 应用的bundleName。                           |
140
141**返回值**:
142
143| 类型                     | 说明                                       |
144| ---------------------- | ---------------------------------------- |
145| boolean | 如果指定的bundleName有效,返回true则表示空闲状态,false则非空闲。 |
146
147**错误码**:
148
149以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
150
151| 错误码ID        | 错误信息                     |
152| ---------- | ----------------------------     |
153| 10000001   | Memory operation failed.         |
154| 10000002   | Parcel operation failed.         |
155| 10000003   | System service operation failed. |
156| 10000004   | IPC failed.        |
157| 10000006   | Failed to get the application information.    |
158
159**示例**:
160```ts
161let isIdleState: boolean = usageStatistics.isIdleStateSync("com.ohos.camera");
162```
163
164## usageStatistics.queryAppGroup
165
166queryAppGroup(): Promise&lt;number&gt;
167
168查询当前应用的优先级分组。使用Promise形式返回其应用分组。
169
170**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
171
172**系统API**:此接口为系统接口。
173
174**返回值**:
175
176| 类型              | 说明                          |
177| --------------- | --------------------------- |
178| Promise&lt;number&gt; | 指定的Promise回调方法。返回查询的应用分组结果。 |
179
180**错误码**:
181
182以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
183
184| 错误码ID        | 错误信息                       |
185| ---------- | ----------------------------       |
186| 10000001   | Memory operation failed.           |
187| 10000002   | Parcel operation failed.           |
188| 10000003   | System service operation failed.   |
189| 10000004   | IPC failed.          |
190| 10000005   | Application is not installed.      |
191| 10000006   | Failed to get the application information.       |
192| 10100002   | Failed to get the application group information. |
193
194**示例**:
195
196```ts
197import { BusinessError } from '@ohos.base';
198
199usageStatistics.queryAppGroup().then((res: number) => {
200  console.log('BUNDLE_ACTIVE queryAppGroup promise succeeded. result: ' + JSON.stringify(res));
201}).catch((err: BusinessError) => {
202  console.log('BUNDLE_ACTIVE queryAppGroup promise failed. code is: ' + err.code + ',message is: ' + err.message);
203});
204```
205
206## usageStatistics.queryAppGroup
207
208queryAppGroup(callback: AsyncCallback&lt;number&gt;): void
209
210查询当前应用的优先级分组。使用callback形式返回其应用分组。
211
212**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
213
214**系统API**:此接口为系统接口。
215
216**参数**:
217
218| 参数名      | 类型                    | 必填   | 说明                         |
219| -------- | --------------------- | ---- | -------------------------- |
220| callback | AsyncCallback&lt;number&gt; | 是    | 指定的CallBack回调方法。返回查询的应用分组。 |
221
222**错误码**:
223
224以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
225
226| 错误码ID        | 错误信息                       |
227| ---------- | ----------------------------       |
228| 10000001   | Memory operation failed.           |
229| 10000002   | Parcel operation failed.           |
230| 10000003   | System service operation failed.   |
231| 10000004   | IPC failed.          |
232| 10000005   | Application is not installed.      |
233| 10000006   | Failed to get the application information.       |
234| 10100002   | Failed to get the application group information. |
235
236**示例**:
237
238```ts
239import { BusinessError } from '@ohos.base';
240
241usageStatistics.queryAppGroup((err: BusinessError, res: number) => {
242  if(err) {
243    console.log('BUNDLE_ACTIVE queryAppGroup callback failed. code is: ' + err.code + ',message is: ' + err.message);
244  } else {
245    console.log('BUNDLE_ACTIVE queryAppGroup callback succeeded. result: ' + JSON.stringify(res));
246  }
247});
248```
249
250## usageStatistics.queryAppGroupSync<sup>10+<sup>
251
252queryAppGroupSync(): number;
253
254查询当前应用的优先级分组。
255
256**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
257
258**系统API**:此接口为系统接口。
259
260**返回值**:
261
262| 类型              | 说明                          |
263| --------------- | --------------------------- |
264| number | 返回当前应用优先级分组结果。 |
265
266**错误码**:
267
268以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
269
270| 错误码ID        | 错误信息                       |
271| ---------- | ----------------------------       |
272| 10000001   | Memory operation failed.           |
273| 10000002   | Parcel operation failed.           |
274| 10000003   | System service operation failed.   |
275| 10000004   | IPC failed.          |
276| 10000005   | Application is not installed.      |
277| 10000006   | Failed to get the application information.       |
278| 10100002   | Failed to get the application group information. |
279
280**示例**:
281
282```ts
283let priorityGroup: number = usageStatistics.queryAppGroupSync();
284```
285
286## usageStatistics.queryAppGroupSync<sup>10+<sup>
287
288queryAppGroupSync(bundleName: string): number
289
290查询指定bundleName应用的优先级分组。
291
292**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
293
294**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
295
296**系统API**:此接口为系统接口。
297
298**参数**:
299
300| 参数名        | 类型                           | 必填   | 说明                                       |
301| ---------- | ---------------------------- | ---- | ---------------------------------------- |
302| bundleName | string                       | 是    | 应用的bundleName。                           |
303
304**返回值**:
305
306| 类型              | 说明                          |
307| --------------- | --------------------------- |
308| number | 返回指定bundleName应用优先级分组结果。 |
309
310**错误码**:
311
312以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
313
314| 错误码ID        | 错误信息                       |
315| ---------- | ----------------------------       |
316| 10000001   | Memory operation failed.           |
317| 10000002   | Parcel operation failed.           |
318| 10000003   | System service operation failed.   |
319| 10000004   | IPC failed.          |
320| 10000005   | Application is not installed.      |
321| 10000006   | Failed to get the application information.       |
322| 10100002   | Failed to get the application group information. |
323
324**示例**:
325
326```ts
327let priorityGroup: number = usageStatistics.queryAppGroupSync("com.ohos.camera");
328```
329
330## usageStatistics.queryBundleStatsInfos
331
332queryBundleStatsInfos(begin: number, end: number, callback: AsyncCallback&lt;BundleStatsMap&gt;): void
333
334通过指定起始和结束时间查询应用使用时长统计信息,使用Callback形式返回。
335
336**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
337
338**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
339
340**系统API**:此接口为系统接口。
341
342**参数**:
343
344| 参数名      | 类型                                       | 必填   | 说明                                      |
345| -------- | ---------------------------------------- | ---- | --------------------------------------- |
346| begin    | number                                   | 是    | 起始时间,以毫秒为单位。                                   |
347| end      | number                                   | 是    | 结束时间,以毫秒为单位。                                   |
348| callback | AsyncCallback&lt;[BundleStatsMap](#bundlestatsmap)&gt; | 是    | 指定的callback回调方法。返回指定起始和结束时间内应用使用时长统计信息。 |
349
350**错误码**:
351
352以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
353
354| 错误码ID        | 错误信息                       |
355| ---------- | ----------------------------       |
356| 10000001   | Memory operation failed.           |
357| 10000002   | Parcel operation failed.           |
358| 10000003   | System service operation failed.   |
359| 10000004   | IPC failed.          |
360| 10000006   | Failed to get the application information.       |
361| 10000007   | Failed to get the system time.  |
362
363**示例**:
364
365```ts
366import { BusinessError } from '@ohos.base';
367
368usageStatistics.queryBundleStatsInfos(0, 20000000000000, (err: BusinessError, res:usageStatistics.BundleStatsMap) => {
369  if (err) {
370    console.log('BUNDLE_ACTIVE queryBundleStatsInfos callback failed. code is: ' + err.code + ',message is: ' + err.message);
371  } else {
372    console.log('BUNDLE_ACTIVE queryBundleStatsInfos callback success.');
373    console.log('BUNDLE_ACTIVE queryBundleStatsInfos callback result ' + JSON.stringify(res));
374  }
375});
376```
377
378## usageStatistics.queryBundleStatsInfos
379
380queryBundleStatsInfos(begin: number, end: number): Promise&lt;BundleStatsMap&gt;
381
382通过指定起始和结束时间查询应用使用时长统计信息,使用Promise形式返回。
383
384**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
385
386**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
387
388**系统API**:此接口为系统接口。
389
390**参数**:
391
392| 参数名   | 类型     | 必填   | 说明    |
393| ----- | ------ | ---- | ----- |
394| begin | number | 是    | 起始时间,以毫秒为单位。 |
395| end   | number | 是    | 结束时间,以毫秒为单位。 |
396
397**返回值**:
398
399| 类型                                       | 说明                                     |
400| ---------------------------------------- | -------------------------------------- |
401| Promise&lt;[BundleStatsMap](#bundlestatsmap)&gt; | 指定的Promise回调方法。返回指定起始和结束时间内应用使用时长统计信息。 |
402
403**错误码**:
404
405以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
406
407| 错误码ID        | 错误信息                       |
408| ---------- | ----------------------------       |
409| 10000001   | Memory operation failed.           |
410| 10000002   | Parcel operation failed.           |
411| 10000003   | System service operation failed.   |
412| 10000004   | IPC failed.          |
413| 10000006   | Failed to get the application information.       |
414| 10000007   | Failed to get the system time.  |
415
416**示例**:
417
418```ts
419import { BusinessError } from '@ohos.base';
420
421usageStatistics.queryBundleStatsInfos(0, 20000000000000).then((res:usageStatistics.BundleStatsMap) => {
422  console.log('BUNDLE_ACTIVE queryBundleStatsInfos promise success.');
423  console.log('BUNDLE_ACTIVE queryBundleStatsInfos promise result ' + JSON.stringify(res));
424}).catch((err: BusinessError) => {
425  console.log('BUNDLE_ACTIVE queryBundleStatsInfos promise failed. code is: ' + err.code + ',message is: ' + err.message);
426});
427```
428
429## usageStatistics.queryBundleStatsInfoByInterval
430
431queryBundleStatsInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback&lt;Array&lt;BundleStatsInfo&gt;&gt;): void
432
433通过指定时间段间隔(天、周、月、年)查询应用使用时长统计信息,使用Callback形式返回。
434
435**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
436
437**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
438
439**系统API**:此接口为系统接口。
440
441**参数**:
442
443| 参数名        | 类型                                       | 必填   | 说明                                       |
444| ---------- | ---------------------------------------- | ---- | ---------------------------------------- |
445| byInterval | [IntervalType](#intervaltype)            | 是    | 查询类型。                                    |
446| begin      | number                                   | 是    | 起始时间,以毫秒为单位。                                    |
447| end        | number                                   | 是    | 结束时间,以毫秒为单位。                                    |
448| callback   | AsyncCallback&lt;Array&lt;[BundleStatsInfo](#bundlestatsinfo)&gt;&gt; | 是    | 指定的callback回调方法。返回指定时间段间隔(天、周、月、年)查询应用使用时长统计信息。 |
449
450**错误码**:
451
452以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
453
454| 错误码ID        | 错误信息                       |
455| ---------- | ----------------------------       |
456| 10000001   | Memory operation failed.           |
457| 10000002   | Parcel operation failed.           |
458| 10000003   | System service operation failed.   |
459| 10000004   | IPC failed.          |
460| 10000006   | Failed to get the application information.       |
461| 10000007   | Failed to get the system time.  |
462
463**示例**:
464
465```ts
466import { BusinessError } from '@ohos.base';
467
468usageStatistics.queryBundleStatsInfoByInterval(0, 0, 20000000000000, (err: BusinessError, res: Array<usageStatistics.BundleStatsInfo>) => {
469  if (err) {
470    console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval callback failed. code is: ' + err.code + ',message is: ' + err.message);
471  } else {
472    console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval callback success.');
473    for (let i = 0; i < res.length; i++) {
474      console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval callback number : ' + (i + 1));
475      console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval callback result ' + JSON.stringify(res[i]));
476    }
477  }
478});
479```
480
481## usageStatistics.queryBundleStatsInfoByInterval
482
483queryBundleStatsInfoByInterval(byInterval: IntervalType, begin: number, end: number): Promise&lt;Array&lt;BundleStatsInfo&gt;&gt;
484
485通过指定时间段间隔(天、周、月、年)查询应用使用时长统计信息,使用Promise形式返回。
486
487**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
488
489**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
490
491**系统API**:此接口为系统接口。
492
493**参数**:
494
495| 参数名        | 类型                            | 必填   | 说明    |
496| ---------- | ----------------------------- | ---- | ----- |
497| byInterval | [IntervalType](#intervaltype) | 是    | 查询类型。 |
498| begin      | number                        | 是    | 起始时间,以毫秒为单位。 |
499| end        | number                        | 是    | 结束时间,以毫秒为单位。 |
500
501**返回值**:
502
503| 类型                                       | 说明                                       |
504| ---------------------------------------- | ---------------------------------------- |
505| Promise&lt;Array&lt;[BundleStatsInfo](#bundlestatsinfo)&gt;&gt; | 指定的Promise回调方法。返回指定时间段间隔(天、周、月、年)查询应用使用时长统计信息。 |
506
507**错误码**:
508
509以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
510
511| 错误码ID        | 错误信息                       |
512| ---------- | ----------------------------       |
513| 10000001   | Memory operation failed.           |
514| 10000002   | Parcel operation failed.           |
515| 10000003   | System service operation failed.   |
516| 10000004   | IPC failed.          |
517| 10000006   | Failed to get the application information.       |
518| 10000007   | Failed to get the system time.  |
519
520**示例**:
521
522```ts
523import { BusinessError } from '@ohos.base';
524
525usageStatistics.queryBundleStatsInfoByInterval(0, 0, 20000000000000).then((res: Array<usageStatistics.BundleStatsInfo>) => {
526  console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval promise success.');
527  for (let i = 0; i < res.length; i++) {
528    console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval promise number : ' + (i + 1));
529    console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval promise result ' + JSON.stringify(res[i]));
530  }
531}).catch((err: BusinessError) => {
532  console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval promise failed. code is: ' + err.code + ',message is: ' + err.message);
533});
534```
535
536## usageStatistics.queryBundleEvents
537
538queryBundleEvents(begin: number, end: number, callback: AsyncCallback&lt;Array&lt;BundleEvents&gt;&gt;): void
539
540通过指定起始和结束时间查询所有应用的事件集合,使用Callback形式返回。
541
542**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
543
544**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
545
546**系统API**:此接口为系统接口。
547
548**参数**:
549
550| 参数名      | 类型                                       | 必填   | 说明                                      |
551| -------- | ---------------------------------------- | ---- | --------------------------------------- |
552| begin    | number                                   | 是    | 起始时间,以毫秒为单位。                                   |
553| end      | number                                   | 是    | 结束时间,以毫秒为单位。                                   |
554| callback | AsyncCallback&lt;Array&lt;[BundleEvents](#bundleevents)&gt;&gt; | 是    | 指定的callback回调方法。返回指定起始和结束时间查询所有应用的事件集合。 |
555
556**错误码**:
557
558以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
559
560| 错误码ID        | 错误信息                       |
561| ---------- | ----------------------------       |
562| 10000001   | Memory operation failed.           |
563| 10000002   | Parcel operation failed.           |
564| 10000003   | System service operation failed.   |
565| 10000004   | IPC failed.          |
566| 10000006   | Failed to get the application information.       |
567| 10000007   | Failed to get the system time.  |
568
569**示例**:
570
571```ts
572import { BusinessError } from '@ohos.base';
573
574usageStatistics.queryBundleEvents(0, 20000000000000, (err: BusinessError, res: Array<usageStatistics.BundleEvents>) => {
575  if (err) {
576    console.log('BUNDLE_ACTIVE queryBundleEvents callback failed. code is: ' + err.code + ',message is: ' + err.message);
577  } else {
578    console.log('BUNDLE_ACTIVE queryBundleEvents callback success.');
579    for (let i = 0; i < res.length; i++) {
580      console.log('BUNDLE_ACTIVE queryBundleEvents callback number : ' + (i + 1));
581      console.log('BUNDLE_ACTIVE queryBundleEvents callback result ' + JSON.stringify(res[i]));
582    }
583  }
584});
585```
586
587## usageStatistics.queryBundleEvents
588
589queryBundleEvents(begin: number, end: number): Promise&lt;Array&lt;BundleEvents&gt;&gt;
590
591通过指定起始和结束时间查询所有应用的事件集合,使用Promise形式返回。
592
593**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
594
595**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
596
597**系统API**:此接口为系统接口。
598
599**参数**:
600
601| 参数名   | 类型     | 必填   | 说明    |
602| ----- | ------ | ---- | ----- |
603| begin | number | 是    | 起始时间,以毫秒为单位。 |
604| end   | number | 是    | 结束时间,以毫秒为单位。 |
605
606**返回值**:
607
608| 类型                                       | 说明                                     |
609| ---------------------------------------- | -------------------------------------- |
610| Promise&lt;Array&lt;[BundleEvents](#bundleevents)&gt;&gt; | 指定的Promise回调方法。返回指定起始和结束时间查询所有应用的事件集合。 |
611
612**错误码**:
613
614以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
615
616| 错误码ID        | 错误信息                       |
617| ---------- | ----------------------------       |
618| 10000001   | Memory operation failed.           |
619| 10000002   | Parcel operation failed.           |
620| 10000003   | System service operation failed.   |
621| 10000004   | IPC failed.          |
622| 10000006   | Failed to get the application information.       |
623| 10000007   | Failed to get the system time.  |
624
625**示例**:
626
627```ts
628import { BusinessError } from '@ohos.base';
629
630usageStatistics.queryBundleEvents(0, 20000000000000).then((res: Array<usageStatistics.BundleEvents>) => {
631  console.log('BUNDLE_ACTIVE queryBundleEvents promise success.');
632  for (let i = 0; i < res.length; i++) {
633    console.log('BUNDLE_ACTIVE queryBundleEvents promise number : ' + (i + 1));
634    console.log('BUNDLE_ACTIVE queryBundleEvents promise result ' + JSON.stringify(res[i]));
635  }
636}).catch((err: BusinessError) => {
637  console.log('BUNDLE_ACTIVE queryBundleEvents promise failed. code is: ' + err.code + ',message is: ' + err.message);
638});
639```
640
641## usageStatistics.queryCurrentBundleEvents
642
643queryCurrentBundleEvents(begin: number, end: number, callback: AsyncCallback&lt;Array&lt;BundleEvents&gt;&gt;): void
644
645通过指定起始和结束时间查询当前应用的事件集合,使用Callback形式返回。
646
647**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
648
649**系统API**:此接口为系统接口。
650
651**参数**:
652
653| 参数名      | 类型                                       | 必填   | 说明                                      |
654| -------- | ---------------------------------------- | ---- | --------------------------------------- |
655| begin    | number                                   | 是    | 起始时间,以毫秒为单位。                                   |
656| end      | number                                   | 是    | 结束时间,以毫秒为单位。                                   |
657| callback | AsyncCallback&lt;Array&lt;[BundleEvents](#bundleevents)&gt;&gt; | 是    | 指定的callback回调方法。返回指定起始和结束时间查询当前应用的事件集合。 |
658
659**错误码**:
660
661以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
662
663| 错误码ID        | 错误信息                       |
664| ---------- | ----------------------------       |
665| 10000001   | Memory operation failed.           |
666| 10000002   | Parcel operation failed.           |
667| 10000003   | System service operation failed.   |
668| 10000004   | IPC failed.          |
669| 10000006   | Failed to get the application information.       |
670| 10000007   | Failed to get the system time.  |
671
672**示例**:
673
674```ts
675import { BusinessError } from '@ohos.base';
676
677usageStatistics.queryCurrentBundleEvents(0, 20000000000000, (err: BusinessError, res: Array<usageStatistics.BundleEvents>) => {
678  if (err) {
679    console.log('BUNDLE_ACTIVE queryCurrentBundleEvents callback failed. code is: ' + err.code + ',message is: ' + err.message);
680  } else {
681    console.log('BUNDLE_ACTIVE queryCurrentBundleEvents callback success.');
682    for (let i = 0; i < res.length; i++) {
683      console.log('BUNDLE_ACTIVE queryCurrentBundleEvents callback number : ' + (i + 1));
684      console.log('BUNDLE_ACTIVE queryCurrentBundleEvents callback result ' + JSON.stringify(res[i]));
685    }
686  }
687});
688```
689
690## usageStatistics.queryCurrentBundleEvents
691
692queryCurrentBundleEvents(begin: number, end: number): Promise&lt;Array&lt;BundleEvents&gt;&gt;
693
694通过指定起始和结束时间查询当前应用的事件集合,使用Promise形式返回。
695
696**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
697
698**系统API**:此接口为系统接口。
699
700**参数**:
701
702| 参数名   | 类型     | 必填   | 说明    |
703| ----- | ------ | ---- | ----- |
704| begin | number | 是    | 起始时间,以毫秒为单位。 |
705| end   | number | 是    | 结束时间,以毫秒为单位。 |
706
707**返回值**:
708
709| 类型                                       | 说明                                     |
710| ---------------------------------------- | -------------------------------------- |
711| Promise&lt;Array&lt;[BundleEvents](#bundleevents)&gt;&gt; | 指定的Promise回调方法。返回指定起始和结束时间查询当前应用的事件集合。 |
712
713**错误码**:
714
715以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
716
717| 错误码ID        | 错误信息                       |
718| ---------- | ----------------------------       |
719| 10000001   | Memory operation failed.           |
720| 10000002   | Parcel operation failed.           |
721| 10000003   | System service operation failed.   |
722| 10000004   | IPC failed.          |
723| 10000006   | Failed to get the application information.      |
724| 10000007   | Failed to get the system time.  |
725
726**示例**:
727
728```ts
729import { BusinessError } from '@ohos.base';
730
731usageStatistics.queryCurrentBundleEvents(0, 20000000000000).then((res: Array<usageStatistics.BundleEvents>) => {
732  console.log('BUNDLE_ACTIVE queryCurrentBundleEvents promise success.');
733  for (let i = 0; i < res.length; i++) {
734    console.log('BUNDLE_ACTIVE queryCurrentBundleEvents promise number : ' + (i + 1));
735    console.log('BUNDLE_ACTIVE queryCurrentBundleEvents promise result ' + JSON.stringify(res[i]));
736  }
737}).catch((err: BusinessError) => {
738  console.log('BUNDLE_ACTIVE queryCurrentBundleEvents promise failed. code is: ' + err.code + ',message is: ' + err.message);
739});
740```
741
742## usageStatistics.queryModuleUsageRecords
743
744queryModuleUsageRecords(): Promise&lt;Array&lt;HapModuleInfo&gt;&gt;
745
746使用Promise形式返回不超过1000条FA使用记录,FA使用记录由近及远排序。
747
748**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
749
750**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
751
752**系统API**:此接口为系统接口。
753
754**返回值**:
755
756| 类型                                       | 说明                                 |
757| ---------------------------------------- | ---------------------------------- |
758| Promise&lt;Array&lt;[HapModuleInfo](#hapmoduleinfo)&gt;&gt; | 指定的Promise回调方法。返回不超过1000条FA使用记录。 |
759
760**错误码**:
761
762以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
763
764| 错误码ID        | 错误信息                       |
765| ---------- | ----------------------------       |
766| 10000001   | Memory operation failed.           |
767| 10000002   | Parcel operation failed.           |
768| 10000003   | System service operation failed.   |
769| 10000004   | IPC failed.          |
770| 10000006   | Failed to get the application information.       |
771| 10000007   | Failed to get the system time.  |
772
773**示例**:
774
775```ts
776// 无maxNum参数调用方式
777import { BusinessError } from '@ohos.base';
778
779usageStatistics.queryModuleUsageRecords().then((res: Array<usageStatistics.HapModuleInfo>) => {
780  console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise succeeded');
781  for (let i = 0; i < res.length; i++) {
782    console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise number : ' + (i + 1));
783    console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise result ' + JSON.stringify(res[i]));
784  }
785}).catch((err: BusinessError) => {
786  console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise failed. code is: ' + err.code + ',message is: ' + err.message);
787});
788```
789
790## usageStatistics.queryModuleUsageRecords
791
792queryModuleUsageRecords(callback: AsyncCallback&lt;Array&lt;HapModuleInfo&gt;&gt;): void
793
794查询FA使用记录。使用CallBack形式返回数量不超过1000条FA使用记录(FA记录按时间由近及远排序)。
795
796**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
797
798**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
799
800**系统API**:此接口为系统接口。
801
802**参数**:
803
804| 参数名      | 类型                                       | 必填   | 说明                                  |
805| -------- | ---------------------------------------- | ---- | ----------------------------------- |
806| callback | AsyncCallback&lt;Array&lt;[HapModuleInfo](#hapmoduleinfo)&gt;&gt; | 是    | 指定的CallBack回调方法。返回不超过maxNum条FA使用记录。 |
807
808**错误码**:
809
810以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
811
812| 错误码ID        | 错误信息                       |
813| ---------- | ----------------------------       |
814| 10000001   | Memory operation failed.           |
815| 10000002   | Parcel operation failed.           |
816| 10000003   | System service operation failed.   |
817| 10000004   | IPC failed.          |
818| 10000006   | Failed to get the application information.       |
819| 10000007   | Failed to get the system time.  |
820
821**示例**:
822
823```ts
824import { BusinessError } from '@ohos.base';
825
826usageStatistics.queryModuleUsageRecords((err: BusinessError, res: Array<usageStatistics.HapModuleInfo>) => {
827  if(err) {
828    console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback failed. code is: ' + err.code + ',message is: ' + err.message);
829  } else {
830    console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback succeeded.');
831    for (let i = 0; i < res.length; i++) {
832      console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback number : ' + (i + 1));
833      console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback result ' + JSON.stringify(res[i]));
834    }
835  }
836});
837```
838
839## usageStatistics.queryModuleUsageRecords
840
841queryModuleUsageRecords(maxNum: number): Promise&lt;Array&lt;HapModuleInfo&gt;&gt;
842
843据maxNum,查询FA使用记录,使用Promise形式返回不超过maxNum条FA使用记录,FA使用记录由近及远排序,maxNum最大为1000。
844
845**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
846
847**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
848
849**系统API**:此接口为系统接口。
850
851**参数**:
852
853| 参数名    | 类型     | 必填   | 说明                                 |
854| ------ | ------ | ---- | ---------------------------------- |
855| maxNum | number | 是    | 返回条目的最大数量,最多支持1000条。 |
856
857**返回值**:
858
859| 类型                                       | 说明                                 |
860| ---------------------------------------- | ---------------------------------- |
861| Promise&lt;Array&lt;[HapModuleInfo](#hapmoduleinfo)&gt;&gt; | 指定的Promise回调方法。返回不超过maxNum条FA使用记录。 |
862
863**错误码**:
864
865以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
866
867| 错误码ID        | 错误信息                       |
868| ---------- | ----------------------------       |
869| 10000001   | Memory operation failed.           |
870| 10000002   | Parcel operation failed.           |
871| 10000003   | System service operation failed.   |
872| 10000004   | IPC failed.          |
873| 10000006   | Failed to get the application information.       |
874| 10000007   | Failed to get the system time.  |
875
876**示例**:
877
878```ts
879import { BusinessError } from '@ohos.base';
880
881usageStatistics.queryModuleUsageRecords(1000).then((res: Array<usageStatistics.HapModuleInfo>) => {
882  console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise succeeded');
883  for (let i = 0; i < res.length; i++) {
884    console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise number : ' + (i + 1));
885    console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise result ' + JSON.stringify(res[i]));
886  }
887}).catch((err: BusinessError) => {
888  console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise failed. code is: ' + err.code + ',message is: ' + err.message);
889});
890```
891
892## usageStatistics.queryModuleUsageRecords
893
894queryModuleUsageRecords(maxNum: number, callback: AsyncCallback&lt;Array&lt;HapModuleInfo&gt;&gt;): void
895
896查询FA使用记录。使用CallBack形式返回数量最大不超过maxNum设置的值,FA使用记录由近及远排序,maxNum最大为1000。
897
898**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
899
900**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
901
902**系统API**:此接口为系统接口。
903
904**参数**:
905
906| 参数名      | 类型                                       | 必填   | 说明                                  |
907| -------- | ---------------------------------------- | ---- | ----------------------------------- |
908| maxNum   | number                                   | 是    | 返回FA记录的最大数量,maxNum最大为1000。|
909| callback | AsyncCallback&lt;Array&lt;[HapModuleInfo](#hapmoduleinfo)&gt;&gt; | 是    | 指定的CallBack回调方法。返回不超过maxNum条FA使用记录。 |
910
911**错误码**:
912
913以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
914
915| 错误码ID        | 错误信息                       |
916| ---------- | ----------------------------       |
917| 10000001   | Memory operation failed.           |
918| 10000002   | Parcel operation failed.           |
919| 10000003   | System service operation failed.   |
920| 10000004   | IPC failed.          |
921| 10000006   | Failed to get the application information.       |
922| 10000007   | Failed to get the system time.  |
923
924**示例**:
925
926```ts
927import { BusinessError } from '@ohos.base';
928
929usageStatistics.queryModuleUsageRecords(1000, (err: BusinessError, res: Array<usageStatistics.HapModuleInfo>) => {
930  if(err) {
931    console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback failed. code is: ' + err.code + ',message is: ' + err.message);
932  } else {
933    console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback succeeded.');
934    for (let i = 0; i < res.length; i++) {
935      console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback number : ' + (i + 1));
936      console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback result ' + JSON.stringify(res[i]));
937    }
938  }
939});
940```
941
942## usageStatistics.queryAppGroup
943
944queryAppGroup(bundleName : string): Promise&lt;number&gt;
945
946查询指定bundleName的应用的优先级分组。使用Promise形式返回其应用分组结果。
947
948**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
949
950**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
951
952**系统API**:此接口为系统接口。
953
954**参数**:
955
956| 参数名        | 类型     | 必填   | 说明                                       |
957| ---------- | ------ | ---- | ---------------------------------------- |
958| bundleName | string | 是    | 查询指定bundleName的应用的优先级分组。 |
959
960**返回值**:
961
962| 类型              | 说明                          |
963| --------------- | --------------------------- |
964| Promise&lt;number&gt; | 指定的Promise回调方法。返回查询的应用分组结果。 |
965
966**错误码**:
967
968以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
969
970| 错误码ID        | 错误信息                       |
971| ---------- | ----------------------------       |
972| 10000001   | Memory operation failed.           |
973| 10000002   | Parcel operation failed.           |
974| 10000003   | System service operation failed.   |
975| 10000004   | IPC failed.          |
976| 10000005   | Application is not installed.      |
977| 10000006   | Failed to get the application information.       |
978| 10100002   | Failed to get the application group information. |
979
980**示例**:
981
982```javascript
983//有bundleName的promise
984import { BusinessError } from '@ohos.base';
985
986let bundleName: string = "com.ohos.camera";
987usageStatistics.queryAppGroup(bundleName).then((res: number) => {
988  console.log('BUNDLE_ACTIVE queryAppGroup promise succeeded. result: ' + JSON.stringify(res));
989}).catch((err: BusinessError) => {
990  console.log('BUNDLE_ACTIVE queryAppGroup promise failed. code is: ' + err.code + ',message is: ' + err.message);
991});
992```
993
994## usageStatistics.queryAppGroup
995
996queryAppGroup(bundleName : string, callback: AsyncCallback&lt;number&gt;): void
997
998查询指定bundleName对应应用的分组。使用callback形式返回其应用分组。
999
1000**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
1001
1002**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
1003
1004**系统API**:此接口为系统接口。
1005
1006**参数**:
1007
1008| 参数名        | 类型                    | 必填   | 说明                                       |
1009| ---------- | --------------------- | ---- | ---------------------------------------- |
1010| bundleName | string                | 是    | 查询指定bundleName对应应用的分组。 |
1011| callback   | AsyncCallback&lt;number&gt; | 是    | 指定的CallBack回调方法。返回指定bundleName的应用分组。|
1012
1013**错误码**:
1014
1015以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
1016
1017| 错误码ID        | 错误信息                       |
1018| ---------- | ----------------------------       |
1019| 10000001   | Memory operation failed.           |
1020| 10000002   | Parcel operation failed.           |
1021| 10000003   | System service operation failed.   |
1022| 10000004   | IPC failed.          |
1023| 10000005   | Application is not installed.      |
1024| 10000006   | Failed to get the application information.       |
1025| 10100002   | Failed to get the application group information. |
1026
1027**示例**:
1028
1029```ts
1030import { BusinessError } from '@ohos.base';
1031
1032let bundleName: string = "com.ohos.camera";
1033usageStatistics.queryAppGroup(bundleName, (err: BusinessError, res: number) => {
1034  if(err) {
1035    console.log('BUNDLE_ACTIVE queryAppGroup callback failed. code is: ' + err.code + ',message is: ' + err.message);
1036  } else {
1037    console.log('BUNDLE_ACTIVE queryAppGroup callback succeeded. result: ' + JSON.stringify(res));
1038  }
1039});
1040```
1041
1042## usageStatistics.setAppGroup
1043
1044setAppGroup(bundleName: string, newGroup: GroupType): Promise&lt;void&gt;
1045
1046将指定bundleName的应用的分组设置为newGroup,使用Promise形式返回设置是否成功。
1047
1048**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
1049
1050**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
1051
1052**系统API**:此接口为系统接口。
1053
1054**参数**:
1055
1056| 参数名        | 类型        | 必填   | 说明   |
1057| ---------- | --------- | ---- | ---- |
1058| bundleName | string    | 是    | 应用名称 |
1059| newGroup   | [GroupType](#grouptype) | 是    | 应用分组 |
1060
1061**错误码**:
1062
1063以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
1064
1065| 错误码ID        | 错误信息                          |
1066| ---------- | ----------------------------          |
1067| 10000001   | Memory operation failed.              |
1068| 10000002   | Parcel operation failed.              |
1069| 10000003   | System service operation failed.      |
1070| 10000004   | IPC failed.             |
1071| 10000006   | Failed to get the application information.          |
1072| 10100001   | Repeated operation on the application group. |
1073
1074**返回值**:
1075
1076| 类型            | 说明                        |
1077| ------------- | ------------------------- |
1078| Promise&lt;void&gt; | 指定的Promise回调方法。返回本次设置是否成功 |
1079
1080**示例**:
1081
1082```ts
1083import { BusinessError } from '@ohos.base';
1084
1085let bundleName: string = "com.example.deviceUsageStatistics";
1086let newGroup = usageStatistics.GroupType.DAILY_GROUP;
1087
1088usageStatistics.setAppGroup(bundleName, newGroup).then( () => {
1089  console.log('BUNDLE_ACTIVE setAppGroup promise succeeded.');
1090}).catch((err: BusinessError) => {
1091  console.log('BUNDLE_ACTIVE setAppGroup promise failed. code is: ' + err.code + ',message is: ' + err.message);
1092});
1093```
1094
1095## usageStatistics.setAppGroup
1096
1097setAppGroup(bundleName: string, newGroup: GroupType, callback: AsyncCallback&lt;void&gt;): void
1098
1099将指定bundleName的应用的分组设置为newGroup,使用CallBack形式返回设置是否成功。
1100
1101**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
1102
1103**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
1104
1105**系统API**:此接口为系统接口。
1106
1107**参数**:
1108
1109| 参数名        | 类型                  | 必填   | 说明                        |
1110| ---------- | ------------------- | ---- | ------------------------- |
1111| bundleName | string              | 是    | 应用名称                      |
1112| newGroup   | [GroupType](#grouptype)           | 是    | 应用分组                      |
1113| callback   | AsyncCallback&lt;void&gt; | 是    | 指定的CallBack回调方法。返回设置是否成功。 |
1114
1115**错误码**:
1116
1117以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
1118
1119| 错误码ID        | 错误信息                          |
1120| ---------- | ----------------------------          |
1121| 10000001   | Memory operation failed.              |
1122| 10000002   | Parcel operation failed.              |
1123| 10000003   | System service operation failed.      |
1124| 10000004   | IPC failed.             |
1125| 10000006   | Failed to get the application information.          |
1126| 10100001   | Repeated operation on the application group. |
1127
1128**示例**:
1129
1130```ts
1131import { BusinessError } from '@ohos.base';
1132
1133let bundleName: string = "com.example.deviceUsageStatistics";
1134let newGroup = usageStatistics.GroupType.DAILY_GROUP;
1135
1136usageStatistics.setAppGroup(bundleName, newGroup, (err: BusinessError) => {
1137  if(err) {
1138    console.log('BUNDLE_ACTIVE setAppGroup callback failed. code is: ' + err.code + ',message is: ' + err.message);
1139  } else {
1140    console.log('BUNDLE_ACTIVE setAppGroup callback succeeded.');
1141  }
1142});
1143```
1144
1145## usageStatistics.registerAppGroupCallBack
1146
1147registerAppGroupCallBack(groupCallback: Callback&lt;AppGroupCallbackInfo&gt;): Promise&lt;void&gt;
1148
1149应用注册分组变化监听,待用户名下的某个应用分组发生变化时,通过callback形式向所有已注册分组变化监听的应用返回[AppGroupCallbackInfo](#appgroupcallbackinfo)信息。使用Promise形式返回注册是否成功。
1150
1151**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
1152
1153**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
1154
1155**系统API**:此接口为系统接口。
1156
1157**参数**:
1158
1159| 参数名   | 类型                                                         | 必填 | 说明                                       |
1160| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------ |
1161| callback | Callback&lt;[AppGroupCallbackInfo](#appgroupcallbackinfo)&gt; | 是   | 指定的callback函数,返回应用分组变化的信息 |
1162
1163**错误码**:
1164
1165以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
1166
1167| 错误码ID        | 错误信息                          |
1168| ---------- | ----------------------------          |
1169| 10000001   | Memory operation failed.              |
1170| 10000002   | Parcel operation failed.              |
1171| 10000003   | System service operation failed.      |
1172| 10000004   | IPC failed.             |
1173| 10100001   | Repeated operation on the application group. |
1174
1175**返回值**:
1176
1177| 类型            | 说明                      |
1178| ------------- | ----------------------- |
1179| Promise&lt;void&gt; | 指定的Promise回调方法。返回注册监听是否成功 |
1180
1181**示例**:
1182
1183```ts
1184import { BusinessError } from '@ohos.base';
1185
1186function onBundleGroupChanged(res: usageStatistics.AppGroupCallbackInfo) {
1187  console.log('BUNDLE_ACTIVE registerAppGroupCallBack RegisterGroupCallBack callback success.');
1188  console.log('BUNDLE_ACTIVE registerAppGroupCallBack result appOldGroup is : ' + res.appOldGroup);
1189  console.log('BUNDLE_ACTIVE registerAppGroupCallBack result appNewGroup is : ' + res.appNewGroup);
1190  console.log('BUNDLE_ACTIVE registerAppGroupCallBack result changeReason is : ' + res.changeReason);
1191  console.log('BUNDLE_ACTIVE registerAppGroupCallBack result userId is : ' + res.userId);
1192  console.log('BUNDLE_ACTIVE registerAppGroupCallBack result bundleName is : ' + res.bundleName);
1193};
1194usageStatistics.registerAppGroupCallBack(onBundleGroupChanged).then( () => {
1195  console.log('BUNDLE_ACTIVE registerAppGroupCallBack promise succeeded.');
1196}).catch((err: BusinessError) => {
1197  console.log('BUNDLE_ACTIVE registerAppGroupCallBack promise failed. code is: ' + err.code + ',message is: ' + err.message);
1198});
1199```
1200
1201## usageStatistics.registerAppGroupCallBack
1202
1203registerAppGroupCallBack(groupCallback: Callback&lt;AppGroupCallbackInfo&gt;, callback: AsyncCallback&lt;void&gt;): void
1204
1205应用注册分组变化监听,待用户名下的某个应用分组发生变化时,通过callback形式向所有已注册分组变化监听的应用返回[AppGroupCallbackInfo](#appgroupcallbackinfo)信息。使用异步callback形式返回注册监听是否成功。
1206
1207**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
1208
1209**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
1210
1211**系统API**:此接口为系统接口。
1212
1213**参数**:
1214
1215| 参数名   | 类型                                                         | 必填 | 说明                                         |
1216| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------- |
1217| groupCallback | Callback&lt;[AppGroupCallbackInfo](#appgroupcallbackinfo)&gt; | 是   | 指定的callback函数,返回应用分组变化的信息   |
1218| callback | AsyncCallback&lt;void&gt;                                    | 是   | 指定的异步callback函数,返回注册监听是否成功 |
1219
1220**错误码**:
1221
1222以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
1223
1224| 错误码ID        | 错误信息                          |
1225| ---------- | ----------------------------          |
1226| 10000001   | Memory operation failed.              |
1227| 10000002   | Parcel operation failed.              |
1228| 10000003   | System service operation failed.      |
1229| 10000004   | IPC failed.             |
1230| 10100001   | Repeated operation on the application group. |
1231
1232
1233**示例**:
1234
1235```ts
1236import { BusinessError } from '@ohos.base';
1237
1238function onBundleGroupChanged(res: usageStatistics.AppGroupCallbackInfo) {
1239  console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.');
1240  console.log('BUNDLE_ACTIVE registerAppGroupCallBack result appOldGroup is : ' + res.appOldGroup);
1241  console.log('BUNDLE_ACTIVE registerAppGroupCallBack result appNewGroup is : ' + res.appNewGroup);
1242  console.log('BUNDLE_ACTIVE registerAppGroupCallBack result changeReason is : ' + res.changeReason);
1243  console.log('BUNDLE_ACTIVE registerAppGroupCallBack result userId is : ' + res.userId);
1244  console.log('BUNDLE_ACTIVE registerAppGroupCallBack result bundleName is : ' + res.bundleName);
1245};
1246usageStatistics.registerAppGroupCallBack(onBundleGroupChanged, (err: BusinessError) => {
1247  if(err) {
1248    console.log('BUNDLE_ACTIVE registerAppGroupCallBack callback failed. code is: ' + err.code + ',message is: ' + err.message);
1249  } else {
1250    console.log('BUNDLE_ACTIVE registerAppGroupCallBack callback success.');
1251  }
1252});
1253```
1254
1255## usageStatistics.unregisterAppGroupCallBack
1256
1257unregisterAppGroupCallBack(): Promise&lt;void&gt;
1258
1259应用解除分组变化监听,解除通过调用注册接口生成的监听。使用Promise形式返回解除监听是否成功。
1260
1261**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
1262
1263**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
1264
1265**系统API**:此接口为系统接口。
1266
1267**返回值**:
1268
1269| 类型            | 说明                       |
1270| ------------- | ------------------------ |
1271| Promise&lt;void&gt; | 指定的Promise回调方法。返回解除监听是否成功 |
1272
1273**错误码**:
1274
1275以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
1276
1277| 错误码ID        | 错误信息                          |
1278| ---------- | ----------------------------          |
1279| 10000001   | Memory operation failed.              |
1280| 10000002   | Parcel operation failed.              |
1281| 10000003   | System service operation failed.      |
1282| 10000004   | IPC failed.             |
1283| 10100001   | Repeated operation on the application group. |
1284
1285**示例**:
1286
1287```ts
1288import { BusinessError } from '@ohos.base';
1289
1290usageStatistics.unregisterAppGroupCallBack().then( () => {
1291  console.log('BUNDLE_ACTIVE unregisterAppGroupCallBack promise succeeded.');
1292}).catch((err: BusinessError) => {
1293  console.log('BUNDLE_ACTIVE unregisterAppGroupCallBack promise failed. code is: ' + err.code + ',message is: ' + err.message);
1294});
1295```
1296
1297## usageStatistics.unregisterAppGroupCallBack
1298
1299unregisterAppGroupCallBack(callback: AsyncCallback&lt;void&gt;): void;
1300
1301应用解除分组变化监听,解除通过调用注册接口生成的监听。使用异步callback形式返回解除监听是否成功。
1302
1303**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
1304
1305**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
1306
1307**系统API**:此接口为系统接口。
1308
1309**参数**:
1310
1311| 参数名      | 类型                  | 必填   | 说明             |
1312| -------- | ------------------- | ---- | -------------- |
1313| callback | AsyncCallback&lt;void&gt; | 是    | 解除监听是否成功的异步回调函数 |
1314
1315**错误码**:
1316
1317以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
1318
1319| 错误码ID        | 错误信息                          |
1320| ---------- | ----------------------------          |
1321| 10000001   | Memory operation failed.              |
1322| 10000002   | Parcel operation failed.              |
1323| 10000003   | System service operation failed.      |
1324| 10000004   | IPC failed.             |
1325| 10100001   | Repeated operation on the application group. |
1326
1327**示例**:
1328
1329```ts
1330import { BusinessError } from '@ohos.base';
1331
1332usageStatistics.unregisterAppGroupCallBack((err: BusinessError) => {
1333  if(err) {
1334    console.log('BUNDLE_ACTIVE unregisterAppGroupCallBack callback failed. code is: ' + err.code + ',message is: ' + err.message);
1335  } else {
1336    console.log('BUNDLE_ACTIVE unregisterAppGroupCallBack callback success.');
1337  }
1338});
1339```
1340
1341## usageStatistics.queryDeviceEventStats
1342
1343queryDeviceEventStats(begin: number, end: number): Promise&lt;Array&lt;DeviceEventStats&gt;&gt;
1344
1345通过指定起始和结束时间查询系统事件(休眠、唤醒、解锁、锁屏)统计信息,使用Promise形式返回。
1346
1347**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
1348
1349**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
1350
1351**系统API**:此接口为系统接口。
1352
1353**参数**:
1354
1355| 参数名   | 类型     | 必填   | 说明    |
1356| ----- | ------ | ---- | ----- |
1357| begin | number | 是    | 起始时间,以毫秒为单位。 |
1358| end   | number | 是    | 结束时间,以毫秒为单位。 |
1359
1360**返回值**:
1361
1362| 类型                                       | 说明                                       |
1363| ---------------------------------------- | ---------------------------------------- |
1364| Promise&lt;Array&lt;[DeviceEventStats](#deviceeventstats)&gt;&gt; | 指定的Promise回调方法。返回指定起始和结束时间查询系统事件(休眠、唤醒、解锁、锁屏)统计信息。 |
1365
1366**错误码**:
1367
1368以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
1369
1370| 错误码ID        | 错误信息                          |
1371| ---------- | ----------------------------          |
1372| 10000001   | Memory operation failed.              |
1373| 10000002   | Parcel operation failed.              |
1374| 10000003   | System service operation failed.      |
1375| 10000004   | IPC failed.             |
1376| 10000006   | Failed to get the application information.          |
1377| 10000007   | Failed to get the system time.     |
1378
1379**示例**:
1380
1381```ts
1382import { BusinessError } from '@ohos.base';
1383
1384usageStatistics.queryDeviceEventStats(0, 20000000000000).then((res: Array<usageStatistics.DeviceEventStats>) => {
1385  console.log('BUNDLE_ACTIVE queryDeviceEventStates promise success.');
1386  console.log('BUNDLE_ACTIVE queryDeviceEventStates promise result ' + JSON.stringify(res));
1387}).catch((err: BusinessError) => {
1388  console.log('BUNDLE_ACTIVE queryDeviceEventStats promise failed. code is: ' + err.code + ',message is: ' + err.message);
1389});
1390```
1391
1392## usageStatistics.queryDeviceEventStats
1393
1394queryDeviceEventStats(begin: number, end: number, callback: AsyncCallback&lt;Array&lt;DeviceEventStats&gt;&gt;): void
1395
1396通过指定起始和结束时间查询系统事件(休眠、唤醒、解锁、锁屏)统计信息,使用Callback形式返回。
1397
1398**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
1399
1400**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
1401
1402**系统API**:此接口为系统接口。
1403
1404**参数**:
1405
1406| 参数名      | 类型                                       | 必填   | 说明                                       |
1407| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
1408| begin    | number                                   | 是    | 起始时间,以毫秒为单位。                                    |
1409| end      | number                                   | 是    | 结束时间,以毫秒为单位。                                    |
1410| callback | AsyncCallback&lt;Array&lt;[DeviceEventStats](#deviceeventstats)&gt;&gt; | 是    | 指定的callback回调方法。返回指定起始和结束时间查询系统事件(休眠、唤醒、解锁、锁屏)统计信息。 |
1411
1412**错误码**:
1413
1414以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
1415
1416| 错误码ID        | 错误信息                          |
1417| ---------- | ----------------------------          |
1418| 10000001   | Memory operation failed.              |
1419| 10000002   | Parcel operation failed.              |
1420| 10000003   | System service operation failed.      |
1421| 10000004   | IPC failed.             |
1422| 10000006   | Failed to get the application information.           |
1423| 10000007   | Failed to get the system time.     |
1424
1425**示例**:
1426
1427```ts
1428import { BusinessError } from '@ohos.base';
1429
1430usageStatistics.queryDeviceEventStats(0, 20000000000000, (err: BusinessError, res: Array<usageStatistics.DeviceEventStats>) => {
1431  if(err) {
1432    console.log('BUNDLE_ACTIVE queryDeviceEventStats callback failed. code is: ' + err.code + ',message is: ' + err.message);
1433  } else {
1434    console.log('BUNDLE_ACTIVE queryDeviceEventStats callback success.');
1435    console.log('BUNDLE_ACTIVE queryDeviceEventStats callback result ' + JSON.stringify(res));
1436  }
1437});
1438```
1439
1440## usageStatistics.queryNotificationEventStats
1441
1442queryNotificationEventStats(begin: number, end: number): Promise&lt;Array&lt;DeviceEventStats&gt;&gt;
1443
1444通过指定起始和结束时间查询所有应用的通知次数信息,使用Promise形式返回。
1445
1446**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
1447
1448**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
1449
1450**系统API**:此接口为系统接口。
1451
1452**参数**:
1453
1454| 参数名   | 类型     | 必填   | 说明    |
1455| ----- | ------ | ---- | ----- |
1456| begin | number | 是    | 起始时间,以毫秒为单位。 |
1457| end   | number | 是    | 结束时间,以毫秒为单位。 |
1458
1459**返回值**:
1460
1461| 类型                                       | 说明                                       |
1462| ---------------------------------------- | ---------------------------------------- |
1463| Promise&lt;Array&lt;[DeviceEventStats](#deviceeventstats)&gt;&gt; | 指定的Promise回调方法。返回指定起始和结束时间查询所有应用的通知次数信息。 |
1464
1465**错误码**:
1466
1467以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
1468
1469| 错误码ID        | 错误信息                          |
1470| ---------- | ----------------------------          |
1471| 10000001   | Memory operation failed.              |
1472| 10000002   | Parcel operation failed.              |
1473| 10000003   | System service operation failed.      |
1474| 10000004   | IPC failed.             |
1475| 10000006   | Failed to get the application information.          |
1476| 10000007   | Failed to get the system time.     |
1477
1478**示例**:
1479
1480```ts
1481import { BusinessError } from '@ohos.base';
1482
1483usageStatistics.queryNotificationEventStats(0, 20000000000000).then((res: Array<usageStatistics.DeviceEventStats>) => {
1484  console.log('BUNDLE_ACTIVE queryNotificationEventStats promise success.');
1485  console.log('BUNDLE_ACTIVE queryNotificationEventStats promise result ' + JSON.stringify(res));
1486}).catch((err: BusinessError) => {
1487  console.log('BUNDLE_ACTIVE queryNotificationEventStats promise failed. code is: ' + err.code + ',message is: ' + err.message);
1488});
1489```
1490
1491## usageStatistics.queryNotificationEventStats
1492
1493queryNotificationEventStats(begin: number, end: number, callback: AsyncCallback&lt;Array&lt;DeviceEventStats&gt;&gt;): void
1494
1495通过指定起始和结束时间查询所有应用的通知次数信息,使用Callback形式返回。
1496
1497**需要权限**:ohos.permission.BUNDLE_ACTIVE_INFO
1498
1499**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
1500
1501**系统API**:此接口为系统接口。
1502
1503**参数**:
1504
1505| 参数名      | 类型                                       | 必填   | 说明                                       |
1506| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
1507| begin    | number                                   | 是    | 起始时间,以毫秒为单位。                                    |
1508| end      | number                                   | 是    | 结束时间,以毫秒为单位。                                    |
1509| callback | AsyncCallback&lt;Array&lt;[DeviceEventStats](#deviceeventstats)&gt;&gt; | 是    | 指定的callback回调方法。返回通过指定起始和结束时间查询所有应用的通知次数信息。 |
1510
1511**错误码**:
1512
1513以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。
1514
1515| 错误码ID        | 错误信息                          |
1516| ---------- | ----------------------------          |
1517| 10000001   | Memory operation failed.              |
1518| 10000002   | Parcel operation failed.              |
1519| 10000003   | System service operation failed.      |
1520| 10000004   | IPC failed.             |
1521| 10000006   | Failed to get the application information.          |
1522| 10000007   | Failed to get the system time.     |
1523
1524**示例**:
1525
1526```ts
1527import { BusinessError } from '@ohos.base';
1528
1529usageStatistics.queryNotificationEventStats(0, 20000000000000, (err: BusinessError, res: Array<usageStatistics.DeviceEventStats>) => {
1530  if(err) {
1531    console.log('BUNDLE_ACTIVE queryNotificationEventStats callback failed. code is: ' + err.code + ',message is: ' + err.message);
1532  } else {
1533    console.log('BUNDLE_ACTIVE queryNotificationEventStats callback success.');
1534    console.log('BUNDLE_ACTIVE queryNotificationEventStats callback result ' + JSON.stringify(res));
1535  }
1536});
1537```
1538
1539## HapModuleInfo
1540FA的使用信息的属性集合。
1541
1542**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.UsageStatistics.App
1543
1544**系统API**:此接口为系统接口。
1545
1546| 名称                  | 类型                                       | 必填   | 说明                            |
1547| -------------------- | ---------------------------------------- | ---- | ----------------------------- |
1548| deviceId             | string                                   | 否    | FA所属deviceId。                 |
1549| bundleName           | string                                   | 是    | FA所属应用Bundle名称。             |
1550| moduleName           | string                                   | 是    | FA所属module名。                  |
1551| abilityName          | string                                   | 否    | FA的MainAbility名。              |
1552| appLabelId           | number                                   | 否    | FA的应用labelId。                 |
1553| labelId              | number                                   | 否    | FA所属module的labelId。           |
1554| descriptionId        | number                                   | 否    | FA所属的应用descriptionId。         |
1555| abilityLableId       | number                                   | 否    | FA的MainAbility labelId。       |
1556| abilityDescriptionId | number                                   | 否    | FA的MainAbility descriptionId。 |
1557| abilityIconId        | number                                   | 否    | FA的MainAbility iconId。        |
1558| launchedCount        | number                                   | 是    | FA的启动次数。                      |
1559| lastModuleUsedTime   | number                                   | 是    | FA的上一次使用时间。                   |
1560| formRecords          | Array&lt;[HapFormInfo](#hapforminfo)&gt; | 是    | FA中卡片的使用记录。                   |
1561
1562## HapFormInfo
1563FA卡片的使用信息的属性集合。
1564
1565**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.UsageStatistics.App
1566
1567**系统API**:此接口为系统接口。
1568
1569| 名称              | 类型     | 必填   | 说明          |
1570| ---------------- | ------ | ---- | ----------- |
1571| formName         | string | 是    | 卡片名称。       |
1572| formDimension    | number | 是    | 卡片尺寸。       |
1573| formId           | number | 是    | 卡片Id。       |
1574| formLastUsedTime | number | 是    | 卡片的上一次点击时间。 |
1575| count            | number | 是    | 卡片的点击次数。    |
1576
1577## AppGroupCallbackInfo
1578
1579应用分组变化回调返回的属性集合
1580
1581**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
1582
1583**系统API**:此接口为系统接口。
1584
1585| 名称           | 类型   | 必填 | 说明             |
1586| ---------------- | ------ | ---- | ---------------- |
1587| appOldGroup | number | 是   | 变化前的应用分组 |
1588| appNewGroup | number | 是   | 变化后的应用分组 |
1589| userId           | number | 是   | 用户id           |
1590| changeReason     | number | 是   | 分组变化原因     |
1591| bundleName       | string | 是   | 应用名称         |
1592
1593## BundleStatsInfo
1594
1595提供应用使用时长的具体信息。
1596
1597
1598**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.UsageStatistics.App
1599
1600**系统API**:此接口为系统接口。
1601
1602| 名称                      | 类型     | 必填   | 说明                                       |
1603| ------------------------ | ------ | ---- | ---------------------------------------- |
1604| bundleName               | string | 否    | 应用包名。                                    |
1605| abilityPrevAccessTime    | number | 否    | 应用最后一次使用的时间。                             |
1606| abilityInFgTotalTime     | number | 否    | 应用在前台使用的总时间。                             |
1607| id                       | number | 是    | 用户id。 |
1608| abilityPrevSeenTime      | number | 否    | 应用最后一次在前台可见的时间。 |
1609| abilitySeenTotalTime     | number | 否    | 应用在前台可见的总时间。 |
1610| fgAbilityAccessTotalTime | number | 否    | 应用访问前台的总时间。 |
1611| fgAbilityPrevAccessTime  | number | 否    | 应用最后一次访问前台的时间。|
1612| infosBeginTime           | number | 否    | BundleActiveInfo对象中第一条应用使用统计的记录时间。 |
1613| infosEndTime             | number | 否    | BundleActiveInfo对象中最后一条应用使用统计的记录时间。 |
1614
1615## BundleEvents
1616
1617提供应用事件的具体信息。
1618
1619**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.UsageStatistics.App
1620
1621**系统API**:此接口为系统接口。
1622
1623| 名称                   | 类型     | 必填   | 说明                                       |
1624| --------------------- | ------ | ---- | ---------------------------------------- |
1625| bundleName            | string | 否    | 应用包名。                                    |
1626| eventId             | number | 否    | 应用事件类型。                                  |
1627| eventOccurredTime     | number | 否    | 应用事件发生的时间戳。                              |
1628| appGroup | number | 否    | 应用程序的使用优先级组。|
1629| indexOfLink           | string | 否    | 快捷方式id。|
1630| nameOfClass           | string | 否    | 类名。|
1631
1632## BundleStatsMap
1633
1634提供应用使用时长的具体信息。
1635
1636**系统能力**:SystemCapability.ResourceSchedule.UsageStatistics.App
1637
1638**系统API**:此接口为系统接口。
1639
1640|名称                           | 类型                                       | 必填   | 说明             |
1641| ------------------------------ | ---------------------------------------- | ---- | -------------- |
1642| [key: string] | [BundleStatsInfo](#bundlestatsinfo) | 是    | 不同应用的使用时长统计信息。 |
1643
1644## DeviceEventStats
1645
1646提供通知、系统事件的统计信息。
1647
1648**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.UsageStatistics.App
1649
1650**系统API**:此接口为系统接口。
1651
1652| 名称     | 类型     | 必填   | 说明                |
1653| ------- | ------ | ---- | ----------------- |
1654| name    | string | 是    | 通知应用包名或者系统事件名。    |
1655| eventId | number | 是    | 通知、系统事件类型。        |
1656| count   | number | 是    | 应用通知次数或者系统事件触发次数。 |
1657
1658## IntervalType
1659
1660提供应用使用时长的查询类型。
1661
1662**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.UsageStatistics.App
1663
1664**系统API**:此接口为系统接口。
1665
1666| 名称           | 值  | 说明                                       |
1667| ------------ | ---- | ---------------------------------------- |
1668| BY_OPTIMIZED | 0    | 表示系统自行判断最合适的查询类型(天、周、月、年)去查询指定时间段间隔的应用使用时长信息。 |
1669| BY_DAILY     | 1    | 表示系统按照天去查询指定时间段间隔的应用使用时长信息。              |
1670| BY_WEEKLY    | 2    | 表示系统按照周去查询指定时间段间隔的应用使用时长信息。              |
1671| BY_MONTHLY   | 3    | 表示系统按照月去查询指定时间段间隔的应用使用时长信息。              |
1672| BY_ANNUALLY  | 4    | 表示系统按照年去查询指定时间段间隔的应用使用时长信息。              |
1673
1674## GroupType
1675
1676提供应用分组的设置类型。
1677
1678**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
1679
1680**系统API**:此接口为系统接口。
1681
1682| 名称                 | 值  | 说明                |
1683| ------------------ | ---- | ----------------- |
1684| ALIVE_GROUP | 10   | 活跃分组。              |
1685| DAILY_GROUP | 20   | 经常使用,但当前并未在活跃态。    |
1686| FIXED_GROUP | 30   | 常用分组,定期使用,但不是每天使用。 |
1687| RARE_GROUP  | 40   | 极少使用分组,不经常使用。      |
1688| LIMITED_GROUP | 50   | 受限使用分组。            |
1689| NEVER_GROUP | 60   | 从未使用分组,安装但是从未运行过。  |