• 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 './@ohos.base';
17
18/**
19 * Provides methods for managing bundle usage statistics,
20 * including the methods for querying bundle usage information and state data.
21 * <p>You can use the methods defined in this class to query
22 * the usage history and states of bundles in a specified period.
23 * The system stores the query result in a {@link BundleStateInfo} or {@link BundleActiveState} instance and
24 * then returns it to you.
25 *
26 * @namespace bundleState
27 * @since 7
28 * @deprecated since 9
29 * @useinstead ohos.resourceschedule.usageStatistics
30 */
31declare namespace bundleState {
32  /**
33   * @interface BundleStateInfo
34   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
35   * @since 7
36   * @deprecated since 9
37   * @useinstead ohos.resourceschedule.usageStatistics.BundleStatsInfo
38   */
39  interface BundleStateInfo {
40    /**
41     * The identifier of BundleStateInfo.
42     *
43     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
44     * @since 7
45     * @deprecated since 9
46     */
47    id: number;
48    /**
49     * The total duration, in milliseconds.
50     *
51     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
52     * @since 7
53     * @deprecated since 9
54     */
55    abilityInFgTotalTime?: number;
56    /**
57     * The last time when the application was accessed, in milliseconds.
58     *
59     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
60     * @since 7
61     * @deprecated since 9
62     */
63    abilityPrevAccessTime?: number;
64    /**
65     * The last time when the application was visible in the foreground, in milliseconds.
66     *
67     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
68     * @since 7
69     * @deprecated since 9
70     */
71    abilityPrevSeenTime?: number;
72    /**
73     * The total duration, in milliseconds.
74     *
75     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
76     * @since 7
77     * @deprecated since 9
78     */
79    abilitySeenTotalTime?: number;
80    /**
81     * The bundle name of the application.
82     *
83     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
84     * @since 7
85     * @deprecated since 9
86     */
87    bundleName?: string;
88    /**
89     * The total duration, in milliseconds.
90     *
91     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
92     * @since 7
93     * @deprecated since 9
94     */
95    fgAbilityAccessTotalTime?: number;
96    /**
97     * The last time when the foreground application was accessed, in milliseconds.
98     *
99     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
100     * @since 7
101     * @deprecated since 9
102     */
103    fgAbilityPrevAccessTime?: number;
104    /**
105     * The time of the first bundle usage record in this {@code BundleActiveInfo} object,
106     * in milliseconds.
107     *
108     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
109     * @since 7
110     * @deprecated since 9
111     */
112    infosBeginTime?: number;
113    /**
114     * The time of the last bundle usage record in this {@code BundleActiveInfo} object,
115     * in milliseconds.
116     *
117     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
118     * @since 7
119     * @deprecated since 9
120     */
121    infosEndTime?: number;
122
123    /**
124     * Merges a specified {@link BundleActiveInfo} object with this {@link BundleActiveInfo} object.
125     * The bundle name of both objects must be the same.
126     *
127     * @param { BundleStateInfo } toMerge Indicates the {@link BundleActiveInfo} object to merge.
128     * If the bundle names of the two {@link BundleActiveInfo} objects are different.
129     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
130     * @since 7
131     * @deprecated since 9
132     */
133    merge(toMerge: BundleStateInfo): void;
134  }
135
136  /**
137   * @typedef BundleActiveState
138   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
139   * @since 7
140   * @deprecated since 9
141   * @useinstead ohos.resourceschedule.usageStatistics.BundleEvents
142   */
143  interface BundleActiveState {
144    /**
145     * The usage priority group of the application.
146     *
147     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
148     * @since 7
149     * @deprecated since 9
150     */
151    appUsagePriorityGroup?: number;
152    /**
153     * The bundle name.
154     *
155     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
156     * @since 7
157     * @deprecated since 9
158     */
159    bundleName?: string;
160    /**
161     * The shortcut ID.
162     *
163     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
164     * @since 7
165     * @deprecated since 9
166     */
167    indexOfLink?: string;
168    /**
169     * The class name.
170     *
171     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
172     * @since 7
173     * @deprecated since 9
174     */
175    nameOfClass?: string;
176    /**
177     * The time when this state occurred, in milliseconds.
178     *
179     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
180     * @since 7
181     * @deprecated since 9
182     */
183    stateOccurredTime?: number;
184    /**
185     * The state type.
186     *
187     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
188     * @since 7
189     * @deprecated since 9
190     */
191    stateType?: number;
192  }
193
194  /**
195   * Checks whether the application with a specified bundle name is in the idle state.
196   *
197   * @param { string } bundleName Indicates the bundle name of the application to query.
198   * @param { AsyncCallback<boolean> } callback - the callback of isIdleState.
199   * <p> boolean value is true mean the application is idle in a particular period; false mean otherwise.
200   * The time range of the particular period is defined by the system, which may be hours or days.</p>
201   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
202   * @since 7
203   * @deprecated since 9
204   * @useinstead ohos.resourceschedule.usageStatistics.isIdleState
205   */
206  function isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void;
207
208  /**
209   * Checks whether the application with a specified bundle name is in the idle state.
210   *
211   * @param { string } bundleName Indicates the bundle name of the application to query.
212   * @returns { Promise<boolean> } the promise returned by isIdleState.
213   * <p> boolean value is true mean the application is idle in a particular period; false mean otherwise.
214   * The time range of the particular period is defined by the system, which may be hours or days.</p>
215   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
216   * @since 7
217   * @deprecated since 9
218   * @useinstead ohos.resourceschedule.usageStatistics.isIdleState
219   */
220  function isIdleState(bundleName: string): Promise<boolean>;
221
222  /**
223   * Queries the usage priority group of the calling application.
224   * <p>The priority defined in a priority group restricts the resource usage of an application,
225   * for example, restricting the running of background tasks. </p>
226   *
227   * @param { AsyncCallback<number> } callback - the callback of queryAppUsagePriorityGroup.
228   * <p> Returns the app group of the calling application.</p>
229   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
230   * @since 7
231   * @deprecated since 9
232   * @useinstead ohos.resourceschedule.usageStatistics.queryAppGroup
233   */
234  function queryAppUsagePriorityGroup(callback: AsyncCallback<number>): void;
235
236  /**
237   * Queries the usage priority group of the calling application.
238   * <p>The priority defined in a priority group restricts the resource usage of an application,
239   * for example, restricting the running of background tasks. </p>
240   *
241   * @returns { Promise<number> } the promise returned by queryAppUsagePriorityGroup.
242   * <p> Returns the app group of the calling application.</p>
243   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
244   * @since 7
245   * @deprecated since 9
246   * @useinstead ohos.resourceschedule.usageStatistics.queryAppGroup
247   */
248  function queryAppUsagePriorityGroup(): Promise<number>;
249
250  /**
251   * @typedef BundleActiveInfoResponse
252   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
253   * @since 7
254   * @deprecated since 9
255   * @useinstead ohos.resourceschedule.usageStatistics.BundleStatsMap
256   */
257  interface BundleActiveInfoResponse {
258    [key: string]: BundleStateInfo;
259  }
260
261  /**
262   * Queries usage information about each bundle within a specified period.
263   * <p>This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.</p>
264   *
265   * @permission ohos.permission.BUNDLE_ACTIVE_INFO
266   * @param { number } begin Indicates the start time of the query period, in milliseconds.
267   * @param { number } end Indicates the end time of the query period, in milliseconds.
268   * @param { AsyncCallback<BundleActiveInfoResponse> } callback - the callback of queryBundleStateInfos.
269   * <p> the {@link BundleActiveInfoResponse} objects containing the usage information about each bundle.</p>
270   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
271   * @systemapi Hide this for inner system use.
272   * @since 7
273   * @deprecated since 9
274   * @useinstead ohos.resourceschedule.usageStatistics.queryBundleStatsInfos
275   */
276  function queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback<BundleActiveInfoResponse>): void;
277
278  /**
279   * Queries usage information about each bundle within a specified period.
280   * <p>This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.</p>
281   *
282   * @permission ohos.permission.BUNDLE_ACTIVE_INFO
283   * @param { number } begin Indicates the start time of the query period, in milliseconds.
284   * @param { number } end Indicates the end time of the query period, in milliseconds.
285   * @returns { Promise<BundleActiveInfoResponse> } the promise returned by queryBundleStatsInfos.
286   * <p> the {@link BundleActiveInfoResponse} objects containing the usage information about each bundle.</p>
287   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
288   * @systemapi Hide this for inner system use.
289   * @since 7
290   * @deprecated since 9
291   * @useinstead ohos.resourceschedule.usageStatistics.queryBundleStatsInfos
292   */
293  function queryBundleStateInfos(begin: number, end: number): Promise<BundleActiveInfoResponse>;
294
295  /**
296   * Declares interval type.
297   *
298   * @enum { number }
299   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
300   * @since 7
301   * @deprecated since 9
302   * @useinstead ohos.resourceschedule.usageStatistics.IntervalType
303   */
304  export enum IntervalType {
305    /**
306     * Indicates the interval type that will determine the optimal interval based on the start and end time.
307     *
308     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
309     * @since 7
310     * @deprecated since 9
311     */
312    BY_OPTIMIZED = 0,
313
314    /**
315     * Indicates the daily interval.
316     *
317     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
318     * @since 7
319     * @deprecated since 9
320     */
321    BY_DAILY = 1,
322
323    /**
324     * Indicates the weekly interval.
325     *
326     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
327     * @since 7
328     * @deprecated since 9
329     */
330    BY_WEEKLY = 2,
331
332    /**
333     * Indicates the monthly interval.
334     *
335     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
336     * @since 7
337     * @deprecated since 9
338     */
339    BY_MONTHLY = 3,
340
341    /**
342     * Indicates the annually interval.
343     *
344     * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
345     * @since 7
346     * @deprecated since 9
347     */
348    BY_ANNUALLY = 4
349  }
350
351  /**
352   * Queries usage information about each bundle within a specified period at a specified interval.
353   *
354   * @permission ohos.permission.BUNDLE_ACTIVE_INFO
355   * @param { IntervalType } byInterval Indicates the interval at which the usage statistics are queried.
356   * <p>The value can be {@link #BY_OPTIMIZED}, {@link #BY_DAILY},
357   * {@link #BY_WEEKLY}, {@link #BY_MONTHLY}, or {@link #BY_ANNUALLY}.</p>
358   * @param { number } begin Indicates the start time of the query period, in milliseconds.
359   * @param { number } end Indicates the end time of the query period, in milliseconds.
360   * @param { AsyncCallback<Array<BundleStateInfo>> } callback - the callback of usage information about each bundle.
361   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
362   * @systemapi Hide this for inner system use.
363   * @since 7
364   * @deprecated since 9
365   * @useinstead ohos.resourceschedule.usageStatistics.queryBundleStatsInfoByInterval
366   */
367  function queryBundleStateInfoByInterval(
368    byInterval: IntervalType,
369    begin: number,
370    end: number,
371    callback: AsyncCallback<Array<BundleStateInfo>>
372  ): void;
373
374  /**
375   * Queries usage information about each bundle within a specified period at a specified interval.
376   *
377   * @permission ohos.permission.BUNDLE_ACTIVE_INFO
378   * @param { IntervalType } byInterval Indicates the interval at which the usage statistics are queried.
379   * <p>The value can be {@link #BY_OPTIMIZED}, {@link #BY_DAILY},
380   * {@link #BY_WEEKLY}, {@link #BY_MONTHLY}, or {@link #BY_ANNUALLY}.</p>
381   * @param { number } begin Indicates the start time of the query period, in milliseconds.
382   * @param { number } end Indicates the end time of the query period, in milliseconds.
383   * @returns { Promise<Array<BundleStateInfo>> } the usage information about each bundle.
384   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
385   * @systemapi Hide this for inner system use.
386   * @since 7
387   * @deprecated since 9
388   * @useinstead ohos.resourceschedule.usageStatistics.queryBundleStatsInfoByInterval
389   */
390  function queryBundleStateInfoByInterval(
391    byInterval: IntervalType,
392    begin: number,
393    end: number
394  ): Promise<Array<BundleStateInfo>>;
395
396  /**
397   * Queries state data of all bundles within a specified period identified by the start and end time.
398   *
399   * @permission ohos.permission.BUNDLE_ACTIVE_INFO
400   * @param { number } begin Indicates the start time of the query period, in milliseconds.
401   * @param { number } end Indicates the end time of the query period, in milliseconds.
402   * @param { AsyncCallback<Array<BundleActiveState>> } callback - the state data of all bundles.
403   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
404   * @systemapi Hide this for inner system use.
405   * @since 7
406   * @deprecated since 9
407   * @useinstead ohos.resourceschedule.usageStatistics.queryBundleEvents
408   */
409  function queryBundleActiveStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveState>>): void;
410
411  /**
412   * Queries state data of all bundles within a specified period identified by the start and end time.
413   *
414   * @permission ohos.permission.BUNDLE_ACTIVE_INFO
415   * @param { number } begin Indicates the start time of the query period, in milliseconds.
416   * @param { number } end Indicates the end time of the query period, in milliseconds.
417   * @returns { Promise<Array<BundleActiveState>> } the state data of all bundles.
418   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
419   * @systemapi Hide this for inner system use.
420   * @since 7
421   * @deprecated since 9
422   * @useinstead ohos.resourceschedule.usageStatistics.queryBundleEvents
423   */
424  function queryBundleActiveStates(begin: number, end: number): Promise<Array<BundleActiveState>>;
425
426  /**
427   * Queries state data of the current bundle within a specified period.
428   *
429   * @param { number } begin Indicates the start time of the query period, in milliseconds.
430   * @param { number } end Indicates the end time of the query period, in milliseconds.
431   * @param { AsyncCallback<Array<BundleActiveState>> } callback - the state data of the current bundle.
432   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
433   * @since 7
434   * @deprecated since 9
435   * @useinstead ohos.resourceschedule.usageStatistics.queryCurrentBundleEvents
436   */
437  function queryCurrentBundleActiveStates(
438    begin: number,
439    end: number,
440    callback: AsyncCallback<Array<BundleActiveState>>
441  ): void;
442
443  /**
444   * Queries state data of the current bundle within a specified period.
445   *
446   * @param { number } begin Indicates the start time of the query period, in milliseconds.
447   * @param { number } end Indicates the end time of the query period, in milliseconds.
448   * @returns { Promise<Array<BundleActiveState>> } the state data of the current bundle.
449   * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App
450   * @since 7
451   * @deprecated since 9
452   * @useinstead ohos.resourceschedule.usageStatistics.queryCurrentBundleEvents
453   */
454  function queryCurrentBundleActiveStates(begin: number, end: number): Promise<Array<BundleActiveState>>;
455}
456
457export default bundleState;
458