• 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
16/**
17 * @file
18 * @kit BackgroundTasksKit
19 */
20
21import { AsyncCallback, Callback } from './@ohos.base';
22import { WantAgent } from './@ohos.wantAgent';
23import Context from './application/BaseContext';
24import type notificationManager from './@ohos.notificationManager';
25
26/**
27 * Manages background tasks.
28 *
29 * @namespace backgroundTaskManager
30 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.Core
31 * @since 9
32 */
33/**
34 * Manages background tasks.
35 *
36 * @namespace backgroundTaskManager
37 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.Core
38 * @atomicservice
39 * @since 12
40 */
41declare namespace backgroundTaskManager {
42  /**
43   * The info of delay suspend.
44   *
45   * @interface DelaySuspendInfo
46   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
47   * @since 9
48   */
49  interface DelaySuspendInfo {
50    /**
51     * The unique identifier of the delay request.
52     *
53     * @type { number }
54     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
55     * @since 9
56     */
57    requestId: number;
58    /**
59     * The actual delay duration (ms).
60     *
61     * @type { number }
62     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
63     * @since 9
64     */
65    actualDelayTime: number;
66  }
67
68  /**
69   * The callback info of transient task.
70   *
71   * @interface TransientTaskInfo
72   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
73   * @since 20
74   */
75  interface TransientTaskInfo {
76    /**
77     * Total remaining quota of an application in one day.
78     *
79     * @type { number }
80     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
81     * @since 20
82     */
83    remainingQuota: number;
84    /**
85     * The info list of delay suspend.
86     *
87     * @type { DelaySuspendInfo[] }
88     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
89     * @since 20
90     */
91    transientTasks: DelaySuspendInfo[];
92  }
93
94  /**
95   * The info of continuous task notification.
96   *
97   * @interface ContinuousTaskNotification
98   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
99   * @atomicservice
100   * @since 12
101   */
102  interface ContinuousTaskNotification {
103    /**
104     * The notification slot type.
105     *
106     * @type { notificationManager.SlotType }
107     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
108     * @atomicservice
109     * @since 12
110     */
111    slotType: notificationManager.SlotType;
112    /**
113     * The notification content type.
114     *
115     * @type { notificationManager.ContentType }
116     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
117     * @atomicservice
118     * @since 12
119     */
120    contentType: notificationManager.ContentType;
121    /**
122     * The notification id.
123     *
124     * @type { number }
125     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
126     * @atomicservice
127     * @since 12
128     */
129    notificationId: number;
130    /**
131     * The continuous task id.
132     * @type { ?number }
133     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
134     * @since 15
135     */
136    continuousTaskId?: number;
137  }
138
139  /**
140   * The continuous task cancel info.
141   *
142   * @interface ContinuousTaskCancelInfo
143   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
144   * @since 15
145   */
146  interface ContinuousTaskCancelInfo {
147    /**
148     * The cancel reason of continuous task.
149     *
150     * @type { ContinuousTaskCancelReason }
151     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
152     * @since 15
153     */
154    reason: ContinuousTaskCancelReason;
155
156    /**
157     * The id of cancelled continuous task.
158     *
159     * @type { number }
160     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
161     * @since 15
162     */
163    id: number;
164  }
165
166  /**
167   * The continuous task active info.
168   *
169   * @interface ContinuousTaskActiveInfo
170   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
171   * @since 20
172   */
173  interface ContinuousTaskActiveInfo {
174    /**
175     * The id of active continuous task.
176     *
177     * @type { number }
178     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
179     * @since 20
180     */
181    id: number;
182  }
183
184  /**
185   * The continuous task info.
186   *
187   * @interface ContinuousTaskInfo
188   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
189   * @since 20
190   */
191  interface ContinuousTaskInfo {
192    /**
193     * The ability name of apply continuous task.
194     *
195     * @type { string }
196     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
197     * @since 20
198     */
199    abilityName: string;
200   /**
201     * The uid of apply continuous task.
202     *
203     * @type { number}
204     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
205     * @since 20
206     */
207    uid: number;
208   /**
209     * The pid of apply continuous task.
210     *
211     * @type { number}
212     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
213     * @since 20
214     */
215    pid: number;
216    /**
217     * Is apply continuous task from webview.
218     *
219     * @type { boolean }
220     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
221     * @since 20
222     */
223    isFromWebView: boolean;
224    /**
225     * Background modes of apply continuous task.
226     *
227     * @type { string[] }
228     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
229     * @since 20
230     */
231    backgroundModes: string[];
232    /**
233     * Background sub modes of apply continuous task.
234     *
235     * @type { string[] }
236     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
237     * @since 20
238     */
239    backgroundSubModes: string[];
240    /**
241     * The notification id of apply continuous task.
242     *
243     * @type { number }
244     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
245     * @since 20
246     */
247    notificationId: number;
248    /**
249     * The continuous task id of apply continuous task.
250     * @type { number }
251     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
252     * @since 20
253     */
254    continuousTaskId: number;
255   /**
256     * The ability id of apply continuous task.
257     * @type { number }
258     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
259     * @since 20
260     */
261    abilityId: number;
262    /**
263     * The wantAgent bundle name of apply continuous task.
264     * @type { string }
265     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
266     * @since 20
267     */
268    wantAgentBundleName: string;
269    /**
270     * The wantAgent ability name of apply continuous task.
271     * @type { string }
272     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
273     * @since 20
274     */
275    wantAgentAbilityName: string;
276    /**
277     * The suspend state of apply continuous task.
278     * @type { boolean }
279     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
280     * @since 20
281     */
282    suspendState: boolean;
283  }
284
285  /**
286   * The continuous task suspend info.
287   *
288   * @interface ContinuousTaskSuspendInfo
289   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
290   * @since 20
291   */
292  interface ContinuousTaskSuspendInfo {
293    /**
294     * The id of suspended continuous task.
295     *
296     * @type { number }
297     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
298     * @since 20
299     */
300    continuousTaskId: number;
301
302    /**
303     * The suspend state of continuous task.
304     *
305     * @type { boolean }
306     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
307     * @since 20
308     */
309    suspendState: boolean;
310
311    /**
312     * The suspend reason of continuous task.
313     *
314     * @type { ContinuousTaskSuspendReason }
315     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
316     * @since 20
317     */
318    suspendReason: ContinuousTaskSuspendReason;
319  }
320
321  /**
322   * Efficiency Resources information.
323   *
324   * @interface EfficiencyResourcesInfo
325   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
326   * @systemapi Hide this for inner system use.
327   * @since 20
328   */
329  interface EfficiencyResourcesInfo {
330    /**
331     * The set of resource types that app wants to apply.
332     *
333     * @type { number }
334     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
335     * @systemapi Hide this for inner system use.
336     * @since 20
337     */
338    resourceTypes: number;
339    /**
340     * The duration that the resource can be used most.
341     *
342     * @type { number }
343     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
344     * @systemapi Hide this for inner system use.
345     * @since 20
346     */
347    timeout: number;
348    /**
349     * True if the apply action is persistent, else false. Default value is false.
350     *
351     * @type { boolean }
352     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
353     * @systemapi Hide this for inner system use.
354     * @since 20
355     */
356    isPersistent: boolean;
357    /**
358     * True if apply action is for process, false is for package. Default value is false.
359     *
360     * @type { boolean }
361     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
362     * @systemapi Hide this for inner system use.
363     * @since 20
364     */
365    isForProcess: boolean;
366    /**
367     * The apply reason.
368     *
369     * @type { string }
370     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
371     * @systemapi Hide this for inner system use.
372     * @since 20
373     */
374    reason: string;
375   /**
376     * The uid of apply efficiency resources.
377     *
378     * @type { number }
379     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
380     * @systemapi Hide this for inner system use.
381     * @since 20
382     */
383    uid: number;
384   /**
385     * The pid of apply efficiency resources.
386     *
387     * @type { number }
388     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
389     * @systemapi Hide this for inner system use.
390     * @since 20
391     */
392    pid: number;
393  }
394
395  /**
396   * Cancels delayed transition to the suspended state.
397   *
398   * @param { number } requestId - The identifier of the delay request.
399   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
400   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
401   * @throws { BusinessError } 9800001 - Memory operation failed.
402   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
403   * <br> 2. Failed to apply for memory.
404   * @throws { BusinessError } 9800003 - Internal transaction failed.
405   * @throws { BusinessError } 9800004 - System service operation failed.
406   * @throws { BusinessError } 9900001 - Caller information verification failed for a transient task.
407   * @throws { BusinessError } 9900002 - Transient task verification failed.
408   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
409   * @since 9
410   */
411  function cancelSuspendDelay(requestId: number): void;
412
413  /**
414   * Obtains the remaining time before an application enters the suspended state.
415   *
416   * @param { number } requestId - The identifier of the delay request.
417   * @param { AsyncCallback<number> } callback - The callback of the remaining delay time.
418   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
419   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
420   * @throws { BusinessError } 9800001 - Memory operation failed.
421   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
422   * <br> 2. Failed to apply for memory.
423   * @throws { BusinessError } 9800003 - Internal transaction failed.
424   * @throws { BusinessError } 9800004 - System service operation failed.
425   * @throws { BusinessError } 9900001 - Caller information verification failed for a transient task.
426   * @throws { BusinessError } 9900002 - Transient task verification failed.
427   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
428   * @since 9
429   */
430  function getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>): void;
431
432  /**
433   * Obtains the remaining time before an application enters the suspended state.
434   *
435   * @param { number } requestId - The identifier of the delay request.
436   * @returns { Promise<number> } The promise returns the remaining delay time.
437   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
438   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
439   * @throws { BusinessError } 9800001 - Memory operation failed.
440   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
441   * <br> 2. Failed to apply for memory.
442   * @throws { BusinessError } 9800003 - Internal transaction failed.
443   * @throws { BusinessError } 9800004 - System service operation failed.
444   * @throws { BusinessError } 9900001 - Caller information verification failed for a transient task.
445   * @throws { BusinessError } 9900002 - Transient task verification failed.
446   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
447   * @since 9
448   */
449  function getRemainingDelayTime(requestId: number): Promise<number>;
450
451  /**
452   * Requests delayed transition to the suspended state.
453   *
454   * @param { string } reason - Indicates the reason for delayed transition to the suspended state.
455   * @param { Callback<void> } callback - The callback delay time expired.
456   * @returns { DelaySuspendInfo } Info of delay request.
457   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
458   * <br> 2. Incorrect parameters types.
459   * @throws { BusinessError } 9800001 - Memory operation failed.
460   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
461   * <br> 2. Failed to apply for memory.
462   * @throws { BusinessError } 9800003 - Internal transaction failed.
463   * @throws { BusinessError } 9800004 - System service operation failed.
464   * @throws { BusinessError } 9900001 - Caller information verification failed for a transient task.
465   * @throws { BusinessError } 9900002 - Transient task verification failed.
466   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
467   * @since 9
468   */
469  function requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspendInfo;
470
471  /**
472   * Obtains transient task info before an application enters the suspended state.
473   *
474   * @returns { Promise<TransientTaskInfo> } The promise returns the transient task info.
475   * @throws { BusinessError } 9900001 - Caller information verification failed for a transient task.
476   * @throws { BusinessError } 9900003 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
477   * <br> 2. Failed to apply for memory.
478   * @throws { BusinessError } 9900004 - System service operation failed.
479   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
480   * @since 20
481   */
482  function getTransientTaskInfo(): Promise<TransientTaskInfo>;
483
484  /**
485   * Service ability uses this method to request start running in background.
486   * <p> System will publish a notification related to the this service. </p>
487   *
488   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
489   * @param { Context } context - App running context.
490   * @param { BackgroundMode } bgMode - Indicates which background mode to request.
491   * @param { WantAgent } wantAgent - Indicates which ability to start when user click the notification bar.
492   * @param { AsyncCallback<void> } callback - The callback of the function.
493   * @throws { BusinessError } 201 - Permission denied.
494   * @throws { BusinessError } 202 - Not System App.
495   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
496   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
497   * @throws { BusinessError } 9800001 - Memory operation failed.
498   * @throws { BusinessError } 9800002 - Parcel operation failed.
499   * @throws { BusinessError } 9800003 - Internal transaction failed.
500   * @throws { BusinessError } 9800004 - System service operation failed.
501   * @throws { BusinessError } 9800005 - Continuous task verification failed.
502   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
503   * @throws { BusinessError } 9800007 - Continuous task storage failed.
504   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
505   * @since 9
506   */
507  /**
508   * Service ability uses this method to request start running in background.
509   * <p> System will publish a notification related to the this service. </p>
510   *
511   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
512   * @param { Context } context - App running context.
513   * @param { BackgroundMode } bgMode - Indicates which background mode to request.
514   * @param { WantAgent } wantAgent - Indicates which ability to start when user click the notification bar.
515   * @param { AsyncCallback<void> } callback - The callback of the function.
516   * @throws { BusinessError } 201 - Permission denied.
517   * @throws { BusinessError } 202 - Not System App.
518   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
519   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
520   * @throws { BusinessError } 9800001 - Memory operation failed.
521   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
522   * <br> 2. Failed to apply for memory.
523   * @throws { BusinessError } 9800003 - Internal transaction failed.
524   * @throws { BusinessError } 9800004 - System service operation failed.
525   * @throws { BusinessError } 9800005 - Continuous task verification failed.
526   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
527   * @throws { BusinessError } 9800007 - Continuous task storage failed.
528   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
529   * @atomicservice
530   * @since 12
531   */
532  function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback<void>): void;
533
534  /**
535   * Service ability uses this method to request start running in background.
536   * <p> System will publish a notification related to the this service. </p>
537   *
538   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
539   * @param { Context } context - App running context.
540   * @param { BackgroundMode } bgMode - Indicates which background mode to request.
541   * @param { WantAgent } wantAgent - Indicates which ability to start when user click the notification bar.
542   * @returns { Promise<void> } The promise returned by the function.
543   * @throws { BusinessError } 201 - Permission denied.
544   * @throws { BusinessError } 202 - Not System App.
545   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
546   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
547   * @throws { BusinessError } 9800001 - Memory operation failed.
548   * @throws { BusinessError } 9800002 - Parcel operation failed.
549   * @throws { BusinessError } 9800003 - Internal transaction failed.
550   * @throws { BusinessError } 9800004 - System service operation failed.
551   * @throws { BusinessError } 9800005 - Continuous task verification failed.
552   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
553   * @throws { BusinessError } 9800007 - Continuous task storage failed.
554   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
555   * @since 9
556   */
557  /**
558   * Service ability uses this method to request start running in background.
559   * <p> System will publish a notification related to the this service. </p>
560   *
561   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
562   * @param { Context } context - App running context.
563   * @param { BackgroundMode } bgMode - Indicates which background mode to request.
564   * @param { WantAgent } wantAgent - Indicates which ability to start when user click the notification bar.
565   * @returns { Promise<void> } The promise returned by the function.
566   * @throws { BusinessError } 201 - Permission denied.
567   * @throws { BusinessError } 202 - Not System App.
568   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
569   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
570   * @throws { BusinessError } 9800001 - Memory operation failed.
571   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
572   * <br> 2. Failed to apply for memory.
573   * @throws { BusinessError } 9800003 - Internal transaction failed.
574   * @throws { BusinessError } 9800004 - System service operation failed.
575   * @throws { BusinessError } 9800005 - Continuous task verification failed.
576   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
577   * @throws { BusinessError } 9800007 - Continuous task storage failed.
578   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
579   * @atomicservice
580   * @since 12
581   */
582  function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise<void>;
583
584  /**
585   * UIAbility uses this method to request start running in background.
586   * <p> System will publish a notification related to the UIAbility. </p>
587   *
588   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
589   * @param { Context } context - App running context.
590   * @param { string[] } bgModes - Indicates which background mode to request.
591   * @param { WantAgent } wantAgent - Indicates which ability to start when user click the notification bar.
592   * @returns { Promise<ContinuousTaskNotification> } The The continuous task notification.
593   * @throws { BusinessError } 201 - Permission denied.
594   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
595   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
596   * @throws { BusinessError } 9800001 - Memory operation failed.
597   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
598   * <br> 2. Failed to apply for memory.
599   * @throws { BusinessError } 9800003 - Internal transaction failed.
600   * @throws { BusinessError } 9800004 - System service operation failed.
601   * @throws { BusinessError } 9800005 - Continuous task verification failed.
602   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
603   * @throws { BusinessError } 9800007 - Continuous task storage failed.
604   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
605   * @atomicservice
606   * @since 12
607   */
608  function startBackgroundRunning(context: Context, bgModes: string[], wantAgent: WantAgent): Promise<ContinuousTaskNotification>;
609
610  /**
611   * UIAbility uses this method to update background mode.
612   *
613   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
614   * @param { Context } context - App running context.
615   * @param { string[] } bgModes - Indicates which background mode to request.
616   * @returns { Promise<ContinuousTaskNotification> } The continuous task notification.
617   * @throws { BusinessError } 201 - Permission denied.
618   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
619   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
620   * @throws { BusinessError } 9800001 - Memory operation failed.
621   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
622   * <br> 2. Failed to apply for memory.
623   * @throws { BusinessError } 9800003 - Internal transaction failed.
624   * @throws { BusinessError } 9800004 - System service operation failed.
625   * @throws { BusinessError } 9800005 - Continuous task verification failed.
626   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
627   * @throws { BusinessError } 9800007 - Continuous task storage failed.
628   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
629   * @atomicservice
630   * @since 12
631   */
632  function updateBackgroundRunning(context: Context, bgModes: string[]): Promise<ContinuousTaskNotification>;
633
634  /**
635   * Service ability uses this method to request stop running in background.
636   *
637   * @param { Context } context - App running context.
638   * @param { AsyncCallback<void> } callback - The callback of the function.
639   * @throws { BusinessError } 201 - Permission denied.
640   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
641   * @throws { BusinessError } 9800001 - Memory operation failed.
642   * @throws { BusinessError } 9800002 - Parcel operation failed.
643   * @throws { BusinessError } 9800003 - Internal transaction failed.
644   * @throws { BusinessError } 9800004 - System service operation failed.
645   * @throws { BusinessError } 9800005 - Continuous task verification failed.
646   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
647   * @throws { BusinessError } 9800007 - Continuous task storage failed.
648   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
649   * @since 9
650   */
651  /**
652   * Service ability uses this method to request stop running in background.
653   *
654   * @param { Context } context - App running context.
655   * @param { AsyncCallback<void> } callback - The callback of the function.
656   * @throws { BusinessError } 201 - Permission denied.
657   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
658   * @throws { BusinessError } 9800001 - Memory operation failed.
659   * @throws { BusinessError } 9800002 - Parcel operation failed.
660   * @throws { BusinessError } 9800003 - Internal transaction failed.
661   * @throws { BusinessError } 9800004 - System service operation failed.
662   * @throws { BusinessError } 9800005 - Continuous task verification failed.
663   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
664   * @throws { BusinessError } 9800007 - Continuous task storage failed.
665   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
666   * @atomicservice
667   * @since 12
668   */
669  /**
670   * Service ability uses this method to request stop running in background.
671   *
672   * @param { Context } context - App running context.
673   * @param { AsyncCallback<void> } callback - The callback of the function.
674   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
675   * @throws { BusinessError } 9800001 - Memory operation failed.
676   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
677   * <br> 2. Failed to apply for memory.
678   * @throws { BusinessError } 9800003 - Internal transaction failed.
679   * @throws { BusinessError } 9800004 - System service operation failed.
680   * @throws { BusinessError } 9800005 - Continuous task verification failed.
681   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
682   * @throws { BusinessError } 9800007 - Continuous task storage failed.
683   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
684   * @atomicservice
685   * @since 19
686   */
687  function stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): void;
688
689  /**
690   * Service ability uses this method to request stop running in background.
691   *
692   * @param { Context } context - App running context.
693   * @returns { Promise<void> } The promise returned by the function.
694   * @throws { BusinessError } 201 - Permission denied.
695   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
696   * @throws { BusinessError } 9800001 - Memory operation failed.
697   * @throws { BusinessError } 9800002 - Parcel operation failed.
698   * @throws { BusinessError } 9800003 - Internal transaction failed.
699   * @throws { BusinessError } 9800004 - System service operation failed.
700   * @throws { BusinessError } 9800005 - Continuous task verification failed.
701   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
702   * @throws { BusinessError } 9800007 - Continuous task storage failed.
703   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
704   * @since 9
705   */
706  /**
707   * Service ability uses this method to request stop running in background.
708   *
709   * @param { Context } context - App running context.
710   * @returns { Promise<void> } The promise returned by the function.
711   * @throws { BusinessError } 201 - Permission denied.
712   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
713   * @throws { BusinessError } 9800001 - Memory operation failed.
714   * @throws { BusinessError } 9800002 - Parcel operation failed.
715   * @throws { BusinessError } 9800003 - Internal transaction failed.
716   * @throws { BusinessError } 9800004 - System service operation failed.
717   * @throws { BusinessError } 9800005 - Continuous task verification failed.
718   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
719   * @throws { BusinessError } 9800007 - Continuous task storage failed.
720   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
721   * @atomicservice
722   * @since 12
723   */
724  /**
725   * Service ability uses this method to request stop running in background.
726   *
727   * @param { Context } context - App running context.
728   * @returns { Promise<void> } The promise returned by the function.
729   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
730   * @throws { BusinessError } 9800001 - Memory operation failed.
731   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
732   * <br> 2. Failed to apply for memory.
733   * @throws { BusinessError } 9800003 - Internal transaction failed.
734   * @throws { BusinessError } 9800004 - System service operation failed.
735   * @throws { BusinessError } 9800005 - Continuous task verification failed.
736   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
737   * @throws { BusinessError } 9800007 - Continuous task storage failed.
738   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
739   * @atomicservice
740   * @since 19
741   */
742  function stopBackgroundRunning(context: Context): Promise<void>;
743
744  /**
745   * Obtains all the continuous tasks before an application enters the suspended state,
746   *     including continuous tasks in suspended state.
747   *
748   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
749   * @param { Context } context - App running context.
750   * @returns { Promise<ContinuousTaskInfo[]> } The promise returns the continuous task info.
751   * @throws { BusinessError } 201 - Permission denied.
752   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
753   * <br> 2. Failed to apply for memory.
754   * @throws { BusinessError } 9800004 - System service operation failed.
755   * @throws { BusinessError } 9800005 - Continuous task verification failed.
756   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
757   * @since 20
758   */
759  function getAllContinuousTasks(context: Context): Promise<ContinuousTaskInfo[]>;
760
761  /**
762   * Obtains all the continuous tasks before an application enters the suspended state.
763   *
764   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
765   * @param { Context } context - App running context.
766   * @param { boolean } includeSuspended - Return the suspended continuous tasks.
767   * @returns { Promise<ContinuousTaskInfo[]> } The promise returns the continuous task info.
768   * @throws { BusinessError } 201 - Permission denied.
769   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
770   * <br> 2. Failed to apply for memory.
771   * @throws { BusinessError } 9800004 - System service operation failed.
772   * @throws { BusinessError } 9800005 - Continuous task verification failed.
773   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
774   * @since 20
775   */
776  function getAllContinuousTasks(context: Context, includeSuspended: boolean): Promise<ContinuousTaskInfo[]>;
777
778  /**
779   * Apply or unapply efficiency resources.
780   *
781   * @param { EfficiencyResourcesRequest } request - The request of apply or unapply efficiency resources.
782   * @throws { BusinessError } 201 - Permission denied.
783   * @throws { BusinessError } 202 - Not System App.
784   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
785   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
786   * @throws { BusinessError } 9800001 - Memory operation failed.
787   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
788   * <br> 2. Failed to apply for memory.
789   * @throws { BusinessError } 9800003 - Internal transaction failed.
790   * @throws { BusinessError } 9800004 - System service operation failed.
791   * @throws { BusinessError } 18700001 - Caller information verification failed for an energy resource request.
792   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
793   * @systemapi Hide this for inner system use.
794   * @since 9
795   */
796  function applyEfficiencyResources(request: EfficiencyResourcesRequest): void;
797
798  /**
799   * Reset all efficiency resources apply.
800   *
801   * @throws { BusinessError } 201 - Permission denied.
802   * @throws { BusinessError } 202 - Not System App.
803   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Parameter verification failed.
804   * @throws { BusinessError } 9800001 - Memory operation failed.
805   * @throws { BusinessError } 9800002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
806   * <br> 2. Failed to apply for memory.
807   * @throws { BusinessError } 9800003 - Internal transaction failed.
808   * @throws { BusinessError } 9800004 - System service operation failed.
809   * @throws { BusinessError } 18700001 - Caller information verification failed for an energy resource request.
810   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
811   * @systemapi Hide this for inner system use.
812   * @since 9
813   */
814  function resetAllEfficiencyResources(): void;
815
816  /**
817   * Obtains all the efficiency resources of current application.
818   *
819   * @returns { Promise<EfficiencyResourcesInfo[]> } The promise returns the efficiency resources info.
820   * @throws { BusinessError } 202 - Not System App.
821   * @throws { BusinessError } 18700001 - Caller information verification failed for an energy resource request.
822   * @throws { BusinessError } 18700002 - Failed to write data into parcel. Possible reasons: 1. Invalid parameters;
823   * <br> 2. Failed to apply for memory.
824   * @throws { BusinessError } 18700004 - System service operation failed.
825   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
826   * @systemapi
827   * @since 20
828   */
829  function getAllEfficiencyResources(): Promise<EfficiencyResourcesInfo[]>;
830
831  /**
832   * Register continuous task cancel callback.
833   *
834   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
835   * @param { 'continuousTaskCancel' } type - The type of continuous task cancel.
836   * @param { Callback<ContinuousTaskCancelInfo> } callback - the callback of continuous task cancel.
837   * @throws { BusinessError } 201 - Permission denied.
838   * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Callback parameter error;
839   * <br> 2. Register a exist callback type; 3. Parameter verification failed.
840   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
841   * @since 15
842   */
843  function on(type: 'continuousTaskCancel', callback: Callback<ContinuousTaskCancelInfo>): void;
844
845  /**
846   * Unregister continuous task cancel callback.
847   *
848   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
849   * @param { 'continuousTaskCancel' } type - The type of continuous task cancel.
850   * @param { Callback<ContinuousTaskCancelInfo> } callback - the callback of continuous task cancel.
851   * @throws { BusinessError } 201 - Permission denied.
852   * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Callback parameter error;
853   * <br> 2. Unregister type has not register; 3. Parameter verification failed.
854   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
855   * @since 15
856   */
857  function off(type: 'continuousTaskCancel', callback?: Callback<ContinuousTaskCancelInfo>): void;
858
859  /**
860   * Register continuous task suspend callback.
861   *
862   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
863   * @param { 'continuousTaskSuspend' } type - The type of continuous task suspend.
864   * @param { Callback<ContinuousTaskSuspendInfo> } callback - the callback of continuous task suspend.
865   * @throws { BusinessError } 201 - Permission denied.
866   * @throws { BusinessError } 9800005 - Continuous task verification failed.
867   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
868   * @since 20
869   */
870  function on(type: 'continuousTaskSuspend', callback: Callback<ContinuousTaskSuspendInfo>): void;
871
872  /**
873   * Unregister continuous task suspend callback.
874   *
875   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
876   * @param { 'continuousTaskSuspend' } type - The type of continuous task suspend.
877   * @param { Callback<ContinuousTaskSuspendInfo> } [callback] - the callback of continuous task suspend.
878   * @throws { BusinessError } 201 - Permission denied.
879   * @throws { BusinessError } 9800005 - Continuous task verification failed.
880   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
881   * @since 20
882   */
883  function off(type: 'continuousTaskSuspend', callback?: Callback<ContinuousTaskSuspendInfo>): void;
884
885  /**
886   * Register continuous task active callback.
887   *
888   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
889   * @param { 'continuousTaskActive' } type - The type of continuous task active.
890   * @param { Callback<ContinuousTaskActiveInfo> } callback - the callback of continuous task active.
891   * @throws { BusinessError } 201 - Permission denied.
892   * @throws { BusinessError } 9800005 - Continuous task verification failed.
893   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
894   * @since 20
895   */
896  function on(type: 'continuousTaskActive', callback: Callback<ContinuousTaskActiveInfo>): void;
897
898  /**
899   * Unregister continuous task suspend callback.
900   *
901   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
902   * @param { 'continuousTaskActive' } type - The type of continuous task active.
903   * @param { Callback<ContinuousTaskActiveInfo> } [callback] - the callback of continuous task active.
904   * @throws { BusinessError } 201 - Permission denied.
905   * @throws { BusinessError } 9800005 - Continuous task verification failed.
906   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
907   * @since 20
908   */
909  function off(type: 'continuousTaskActive', callback?: Callback<ContinuousTaskActiveInfo>): void;
910
911  /**
912   * Supported background mode.
913   *
914   * @enum { number }
915   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
916   * @since 9
917   */
918  /**
919   * Supported background mode.
920   *
921   * @enum { number }
922   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
923   * @atomicservice
924   * @since 12
925   */
926  export enum BackgroundMode {
927    /**
928     * data transfer mode
929     *
930     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
931     * @since 9
932     */
933    DATA_TRANSFER = 1,
934
935    /**
936     * audio playback mode
937     *
938     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
939     * @since 9
940     */
941    /**
942     * audio playback mode
943     *
944     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
945     * @atomicservice
946     * @since 12
947     */
948    AUDIO_PLAYBACK = 2,
949
950    /**
951     * audio recording mode
952     *
953     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
954     * @since 9
955     */
956    AUDIO_RECORDING = 3,
957
958    /**
959     * location mode
960     *
961     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
962     * @since 9
963     */
964    LOCATION = 4,
965
966    /**
967     * bluetooth interaction mode
968     *
969     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
970     * @since 9
971     */
972    BLUETOOTH_INTERACTION = 5,
973
974    /**
975     * multi-device connection mode
976     *
977     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
978     * @since 9
979     */
980    /**
981     * multi-device connection mode
982     *
983     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
984     * @atomicservice
985     * @since 12
986     */
987    MULTI_DEVICE_CONNECTION = 6,
988
989    /**
990     * wifi interaction mode
991     *
992     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
993     * @systemapi Hide this for inner system use.
994     * @since 9
995     */
996    WIFI_INTERACTION = 7,
997
998    /**
999     * Voice over Internet Phone mode
1000     *
1001     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1002     * @since 13
1003     */
1004    VOIP = 8,
1005
1006    /**
1007     * background continuous calculate mode, for example 3D render.
1008     * only supported in particular device
1009     *
1010     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1011     * @since 9
1012     */
1013    TASK_KEEPING = 9,
1014  }
1015
1016  /**
1017   * The type of resource.
1018   *
1019   * @enum { number }
1020   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1021   * @systemapi Hide this for inner system use.
1022   * @since 9
1023   */
1024  export enum ResourceType {
1025    /**
1026     * The cpu resource for not being suspended.
1027     *
1028     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1029     * @systemapi Hide this for inner system use.
1030     * @since 9
1031     */
1032    CPU = 1,
1033
1034    /**
1035     * The resource for not being proxyed common_event.
1036     *
1037     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1038     * @systemapi Hide this for inner system use.
1039     * @since 9
1040     */
1041    COMMON_EVENT = 1 << 1,
1042
1043    /**
1044     * The resource for not being proxyed timer.
1045     *
1046     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1047     * @systemapi Hide this for inner system use.
1048     * @since 9
1049     */
1050    TIMER = 1 << 2,
1051
1052    /**
1053     * The resource for not being proxyed workscheduler.
1054     *
1055     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1056     * @systemapi Hide this for inner system use.
1057     * @since 9
1058     */
1059    WORK_SCHEDULER = 1 << 3,
1060
1061    /**
1062     * The resource for not being proxyed bluetooth.
1063     *
1064     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1065     * @systemapi Hide this for inner system use.
1066     * @since 9
1067     */
1068    BLUETOOTH = 1 << 4,
1069
1070    /**
1071     * The resource for not being proxyed gps.
1072     *
1073     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1074     * @systemapi Hide this for inner system use.
1075     * @since 9
1076     */
1077    GPS = 1 << 5,
1078
1079    /**
1080     * The resource for not being proxyed audio.
1081     *
1082     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1083     * @systemapi Hide this for inner system use.
1084     * @since 9
1085     */
1086    AUDIO = 1 << 6,
1087
1088    /**
1089     * The resource for not being proxyed running lock.
1090     *
1091     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1092     * @systemapi Hide this for inner system use.
1093     * @since 10
1094     */
1095    RUNNING_LOCK = 1 << 7,
1096
1097    /**
1098     * The resource for not being proxyed sensor.
1099     *
1100     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1101     * @systemapi Hide this for inner system use.
1102     * @since 10
1103     */
1104    SENSOR = 1 << 8
1105  }
1106
1107  /**
1108   * The request of efficiency resources.
1109   *
1110   * @interface EfficiencyResourcesRequest
1111   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1112   * @systemapi Hide this for inner system use.
1113   * @since 9
1114   */
1115  export interface EfficiencyResourcesRequest {
1116    /**
1117     * The set of resource types that app wants to apply.
1118     *
1119     * @type { number }
1120     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1121     * @systemapi Hide this for inner system use.
1122     * @since 9
1123     */
1124    resourceTypes: number;
1125
1126    /**
1127     * True if the app begin to use, else false.
1128     *
1129     * @type { boolean }
1130     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1131     * @systemapi Hide this for inner system use.
1132     * @since 9
1133     */
1134    isApply: boolean;
1135
1136    /**
1137     * The duration that the resource can be used most.
1138     *
1139     * @type { number }
1140     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1141     * @systemapi Hide this for inner system use.
1142     * @since 9
1143     */
1144    timeOut: number;
1145
1146    /**
1147     * True if the apply action is persist, else false. Default value is false.
1148     *
1149     * @type { ?boolean }
1150     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1151     * @systemapi Hide this for inner system use.
1152     * @since 9
1153     */
1154    isPersist?: boolean;
1155
1156    /**
1157     * True if apply action is for process, false is for package. Default value is false.
1158     *
1159     * @type { ?boolean }
1160     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1161     * @systemapi Hide this for inner system use.
1162     * @since 9
1163     */
1164    isProcess?: boolean;
1165
1166    /**
1167     * The apply reason.
1168     *
1169     * @type { string }
1170     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
1171     * @systemapi Hide this for inner system use.
1172     * @since 9
1173     */
1174    reason: string;
1175  }
1176
1177  /**
1178   * The type of continuous task cancel reason.
1179   *
1180   * @enum { number }
1181   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1182   * @since 15
1183   */
1184  export enum ContinuousTaskCancelReason {
1185    /**
1186     * User cancel.
1187     *
1188     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1189     * @since 15
1190     */
1191    USER_CANCEL = 1,
1192    /**
1193     * System cancel.
1194     *
1195     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1196     * @since 15
1197     */
1198    SYSTEM_CANCEL = 2,
1199    /**
1200     * User remove notification.
1201     *
1202     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1203     * @since 15
1204     */
1205    USER_CANCEL_REMOVE_NOTIFICATION = 3,
1206
1207    /**
1208     * Low network speed when request data transfer mode.
1209     *
1210     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1211     * @since 15
1212     */
1213    SYSTEM_CANCEL_DATA_TRANSFER_LOW_SPEED = 4,
1214
1215    /**
1216     *  Not use avsession when request audio playback mode.
1217     *
1218     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1219     * @since 15
1220     */
1221    SYSTEM_CANCEL_AUDIO_PLAYBACK_NOT_USE_AVSESSION = 5,
1222
1223    /**
1224     * Audio is not running when request audio playback mode.
1225     *
1226     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1227     * @since 15
1228     */
1229    SYSTEM_CANCEL_AUDIO_PLAYBACK_NOT_RUNNING = 6,
1230
1231    /**
1232     * Audio is not running when request audio recording mode.
1233     *
1234     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1235     * @since 15
1236     */
1237    SYSTEM_CANCEL_AUDIO_RECORDING_NOT_RUNNING = 7,
1238
1239    /**
1240     * Not use location when request location mode.
1241     *
1242     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1243     * @since 15
1244     */
1245    SYSTEM_CANCEL_NOT_USE_LOCATION = 8,
1246
1247    /**
1248     * Not use bluetooth when request bluetooth interaction mode.
1249     *
1250     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1251     * @since 15
1252     */
1253    SYSTEM_CANCEL_NOT_USE_BLUETOOTH = 9,
1254
1255    /**
1256     * Not use multi device when request multi-device connection mode.
1257     *
1258     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1259     * @since 15
1260     */
1261    SYSTEM_CANCEL_NOT_USE_MULTI_DEVICE = 10,
1262
1263    /**
1264     * Use some mode illegally.
1265     *
1266     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1267     * @since 15
1268     */
1269    SYSTEM_CANCEL_USE_ILLEGALLY = 11,
1270  }
1271
1272  /**
1273   * Supported background submode.
1274   *
1275   * @enum { number }
1276   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1277   * @since 16
1278   */
1279  export enum BackgroundSubMode {
1280    /**
1281     * bluetooth car key mode
1282     *
1283     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1284     * @since 16
1285     */
1286    CAR_KEY = 1
1287  }
1288
1289  /**
1290   * Supported background mode type.
1291   *
1292   * @enum { string }
1293   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1294   * @since 16
1295   */
1296  export enum BackgroundModeType {
1297    /**
1298     * subMode type
1299     *
1300     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1301     * @since 16
1302     */
1303    SUB_MODE = 'subMode'
1304  }
1305
1306  /**
1307   * Type of continuous task suspend reason.
1308   *
1309   * @enum { number }
1310   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1311   * @since 20
1312   */
1313  export enum ContinuousTaskSuspendReason {
1314    /**
1315     * Low network speed when request data transfer mode.
1316     *
1317     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1318     * @since 20
1319     */
1320    SYSTEM_SUSPEND_DATA_TRANSFER_LOW_SPEED = 4,
1321
1322    /**
1323     *  Not use avsession when request audio playback mode.
1324     *
1325     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1326     * @since 20
1327     */
1328    SYSTEM_SUSPEND_AUDIO_PLAYBACK_NOT_USE_AVSESSION = 5,
1329
1330    /**
1331     * Audio is not running when request audio playback mode.
1332     *
1333     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1334     * @since 20
1335     */
1336    SYSTEM_SUSPEND_AUDIO_PLAYBACK_NOT_RUNNING = 6,
1337
1338    /**
1339     * Audio is not running when request audio recording mode.
1340     *
1341     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1342     * @since 20
1343     */
1344    SYSTEM_SUSPEND_AUDIO_RECORDING_NOT_RUNNING = 7,
1345
1346    /**
1347     * Not use location when request location mode.
1348     *
1349     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1350     * @since 20
1351     */
1352    SYSTEM_SUSPEND_LOCATION_NOT_USED = 8,
1353
1354    /**
1355     * Not use bluetooth when request bluetooth interaction mode.
1356     *
1357     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1358     * @since 20
1359     */
1360    SYSTEM_SUSPEND_BLUETOOTH_NOT_USED = 9,
1361
1362    /**
1363     * Not use multi device when request multi-device connection mode.
1364     *
1365     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1366     * @since 20
1367     */
1368    SYSTEM_SUSPEND_MULTI_DEVICE_NOT_USED = 10,
1369
1370    /**
1371     * Use some mode illegally.
1372     *
1373     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1374     * @since 20
1375     */
1376    SYSTEM_SUSPEND_USED_ILLEGALLY = 11,
1377
1378    /**
1379     * System load warning.
1380     *
1381     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
1382     * @since 20
1383     */
1384    SYSTEM_SUSPEND_SYSTEM_LOAD_WARNING = 12,
1385  }
1386}
1387
1388export default backgroundTaskManager;
1389