• 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 info of continuous task notification.
70   *
71   * @interface ContinuousTaskNotification
72   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
73   * @atomicservice
74   * @since 12
75   */
76  interface ContinuousTaskNotification {
77    /**
78     * The notification slot type.
79     *
80     * @type { notificationManager.SlotType }
81     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
82     * @atomicservice
83     * @since 12
84     */
85    slotType: notificationManager.SlotType;
86    /**
87     * The notification content type.
88     *
89     * @type { notificationManager.ContentType }
90     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
91     * @atomicservice
92     * @since 12
93     */
94    contentType: notificationManager.ContentType;
95    /**
96     * The notification id.
97     *
98     * @type { number }
99     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
100     * @atomicservice
101     * @since 12
102     */
103    notificationId: number;
104    /**
105     * The continuous task id.
106     * @type { ?number }
107     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
108     * @since 15
109     */
110    continuousTaskId?: number;
111  }
112
113  /**
114   * The continuous task cancel info.
115   *
116   * @interface ContinuousTaskCancelInfo
117   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
118   * @since 15
119   */
120  interface ContinuousTaskCancelInfo {
121    /**
122     * The cancel reason of continuous task.
123     *
124     * @type { ContinuousTaskCancelReason }
125     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
126     * @since 15
127     */
128    reason: ContinuousTaskCancelReason;
129
130    /**
131     * The id of cancelled continuous task.
132     *
133     * @type { number }
134     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
135     * @since 15
136     */
137    id: number;
138  }
139
140  /**
141   * Cancels delayed transition to the suspended state.
142   *
143   * @param { number } requestId - The identifier of the delay request.
144   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
145   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
146   * @throws { BusinessError } 9800001 - Memory operation failed.
147   * @throws { BusinessError } 9800002 - Parcel operation failed.
148   * @throws { BusinessError } 9800003 - Internal transaction failed.
149   * @throws { BusinessError } 9800004 - System service operation failed.
150   * @throws { BusinessError } 9900001 - Caller information verification failed for a transient task.
151   * @throws { BusinessError } 9900002 - Transient task verification failed.
152   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
153   * @since 9
154   */
155  function cancelSuspendDelay(requestId: number): void;
156
157  /**
158   * Obtains the remaining time before an application enters the suspended state.
159   *
160   * @param { number } requestId - The identifier of the delay request.
161   * @param { AsyncCallback<number> } callback - The callback of the remaining delay time.
162   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
163   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
164   * @throws { BusinessError } 9800001 - Memory operation failed.
165   * @throws { BusinessError } 9800002 - Parcel operation failed.
166   * @throws { BusinessError } 9800003 - Internal transaction failed.
167   * @throws { BusinessError } 9800004 - System service operation failed.
168   * @throws { BusinessError } 9900001 - Caller information verification failed for a transient task.
169   * @throws { BusinessError } 9900002 - Transient task verification failed.
170   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
171   * @since 9
172   */
173  function getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>): void;
174
175  /**
176   * Obtains the remaining time before an application enters the suspended state.
177   *
178   * @param { number } requestId - The identifier of the delay request.
179   * @returns { Promise<number> } The promise returns the remaining delay time.
180   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
181   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
182   * @throws { BusinessError } 9800001 - Memory operation failed.
183   * @throws { BusinessError } 9800002 - Parcel operation failed.
184   * @throws { BusinessError } 9800003 - Internal transaction failed.
185   * @throws { BusinessError } 9800004 - System service operation failed.
186   * @throws { BusinessError } 9900001 - Caller information verification failed for a transient task.
187   * @throws { BusinessError } 9900002 - Transient task verification failed.
188   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
189   * @since 9
190   */
191  function getRemainingDelayTime(requestId: number): Promise<number>;
192
193  /**
194   * Requests delayed transition to the suspended state.
195   *
196   * @param { string } reason - Indicates the reason for delayed transition to the suspended state.
197   * @param { Callback<void> } callback - The callback delay time expired.
198   * @returns { DelaySuspendInfo } Info of delay request.
199   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
200   * <br> 2. Incorrect parameters types.
201   * @throws { BusinessError } 9800001 - Memory operation failed.
202   * @throws { BusinessError } 9800002 - Parcel operation failed.
203   * @throws { BusinessError } 9800003 - Internal transaction failed.
204   * @throws { BusinessError } 9800004 - System service operation failed.
205   * @throws { BusinessError } 9900001 - Caller information verification failed for a transient task.
206   * @throws { BusinessError } 9900002 - Transient task verification failed.
207   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
208   * @since 9
209   */
210  function requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspendInfo;
211
212  /**
213   * Service ability uses this method to request start running in background.
214   * <p> System will publish a notification related to the this service. </p>
215   *
216   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
217   * @param { Context } context - App running context.
218   * @param { BackgroundMode } bgMode - Indicates which background mode to request.
219   * @param { WantAgent } wantAgent - Indicates which ability to start when user click the notification bar.
220   * @param { AsyncCallback<void> } callback - The callback of the function.
221   * @throws { BusinessError } 201 - Permission denied.
222   * @throws { BusinessError } 202 - Not System App.
223   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
224   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
225   * @throws { BusinessError } 9800001 - Memory operation failed.
226   * @throws { BusinessError } 9800002 - Parcel operation failed.
227   * @throws { BusinessError } 9800003 - Internal transaction failed.
228   * @throws { BusinessError } 9800004 - System service operation failed.
229   * @throws { BusinessError } 9800005 - Continuous task verification failed.
230   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
231   * @throws { BusinessError } 9800007 - Continuous task storage failed.
232   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
233   * @since 9
234   */
235  /**
236   * Service ability uses this method to request start running in background.
237   * <p> System will publish a notification related to the this service. </p>
238   *
239   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
240   * @param { Context } context - App running context.
241   * @param { BackgroundMode } bgMode - Indicates which background mode to request.
242   * @param { WantAgent } wantAgent - Indicates which ability to start when user click the notification bar.
243   * @param { AsyncCallback<void> } callback - The callback of the function.
244   * @throws { BusinessError } 201 - Permission denied.
245   * @throws { BusinessError } 202 - Not System App.
246   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
247   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
248   * @throws { BusinessError } 9800001 - Memory operation failed.
249   * @throws { BusinessError } 9800002 - Parcel operation failed.
250   * @throws { BusinessError } 9800003 - Internal transaction failed.
251   * @throws { BusinessError } 9800004 - System service operation failed.
252   * @throws { BusinessError } 9800005 - Continuous task verification failed.
253   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
254   * @throws { BusinessError } 9800007 - Continuous task storage failed.
255   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
256   * @atomicservice
257   * @since 12
258   */
259  function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback<void>): void;
260
261  /**
262   * Service ability uses this method to request start running in background.
263   * <p> System will publish a notification related to the this service. </p>
264   *
265   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
266   * @param { Context } context - App running context.
267   * @param { BackgroundMode } bgMode - Indicates which background mode to request.
268   * @param { WantAgent } wantAgent - Indicates which ability to start when user click the notification bar.
269   * @returns { Promise<void> } The promise returned by the function.
270   * @throws { BusinessError } 201 - Permission denied.
271   * @throws { BusinessError } 202 - Not System App.
272   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
273   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
274   * @throws { BusinessError } 9800001 - Memory operation failed.
275   * @throws { BusinessError } 9800002 - Parcel operation failed.
276   * @throws { BusinessError } 9800003 - Internal transaction failed.
277   * @throws { BusinessError } 9800004 - System service operation failed.
278   * @throws { BusinessError } 9800005 - Continuous task verification failed.
279   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
280   * @throws { BusinessError } 9800007 - Continuous task storage failed.
281   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
282   * @since 9
283   */
284  /**
285   * Service ability uses this method to request start running in background.
286   * <p> System will publish a notification related to the this service. </p>
287   *
288   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
289   * @param { Context } context - App running context.
290   * @param { BackgroundMode } bgMode - Indicates which background mode to request.
291   * @param { WantAgent } wantAgent - Indicates which ability to start when user click the notification bar.
292   * @returns { Promise<void> } The promise returned by the function.
293   * @throws { BusinessError } 201 - Permission denied.
294   * @throws { BusinessError } 202 - Not System App.
295   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
296   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
297   * @throws { BusinessError } 9800001 - Memory operation failed.
298   * @throws { BusinessError } 9800002 - Parcel operation failed.
299   * @throws { BusinessError } 9800003 - Internal transaction failed.
300   * @throws { BusinessError } 9800004 - System service operation failed.
301   * @throws { BusinessError } 9800005 - Continuous task verification failed.
302   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
303   * @throws { BusinessError } 9800007 - Continuous task storage failed.
304   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
305   * @atomicservice
306   * @since 12
307   */
308  function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise<void>;
309
310  /**
311   * UIAbility uses this method to request start running in background.
312   * <p> System will publish a notification related to the UIAbility. </p>
313   *
314   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
315   * @param { Context } context - App running context.
316   * @param { string[] } bgModes - Indicates which background mode to request.
317   * @param { WantAgent } wantAgent - Indicates which ability to start when user click the notification bar.
318   * @returns { Promise<ContinuousTaskNotification> } The The continuous task notification.
319   * @throws { BusinessError } 201 - Permission denied.
320   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
321   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
322   * @throws { BusinessError } 9800001 - Memory operation failed.
323   * @throws { BusinessError } 9800002 - Parcel operation failed.
324   * @throws { BusinessError } 9800003 - Internal transaction failed.
325   * @throws { BusinessError } 9800004 - System service operation failed.
326   * @throws { BusinessError } 9800005 - Continuous task verification failed.
327   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
328   * @throws { BusinessError } 9800007 - Continuous task storage failed.
329   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
330   * @atomicservice
331   * @since 12
332   */
333  function startBackgroundRunning(context: Context, bgModes: string[], wantAgent: WantAgent): Promise<ContinuousTaskNotification>;
334
335  /**
336   * UIAbility uses this method to update background mode.
337   *
338   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
339   * @param { Context } context - App running context.
340   * @param { string[] } bgModes - Indicates which background mode to request.
341   * @returns { Promise<ContinuousTaskNotification> } The continuous task notification.
342   * @throws { BusinessError } 201 - Permission denied.
343   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
344   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
345   * @throws { BusinessError } 9800001 - Memory operation failed.
346   * @throws { BusinessError } 9800002 - Parcel operation failed.
347   * @throws { BusinessError } 9800003 - Internal transaction failed.
348   * @throws { BusinessError } 9800004 - System service operation failed.
349   * @throws { BusinessError } 9800005 - Continuous task verification failed.
350   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
351   * @throws { BusinessError } 9800007 - Continuous task storage failed.
352   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
353   * @atomicservice
354   * @since 12
355   */
356  function updateBackgroundRunning(context: Context, bgModes: string[]): Promise<ContinuousTaskNotification>;
357
358  /**
359   * Service ability uses this method to request stop running in background.
360   *
361   * @param { Context } context - App running context.
362   * @param { AsyncCallback<void> } callback - The callback of the function.
363   * @throws { BusinessError } 201 - Permission denied.
364   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
365   * @throws { BusinessError } 9800001 - Memory operation failed.
366   * @throws { BusinessError } 9800002 - Parcel operation failed.
367   * @throws { BusinessError } 9800003 - Internal transaction failed.
368   * @throws { BusinessError } 9800004 - System service operation failed.
369   * @throws { BusinessError } 9800005 - Continuous task verification failed.
370   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
371   * @throws { BusinessError } 9800007 - Continuous task storage failed.
372   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
373   * @since 9
374   */
375  /**
376   * Service ability uses this method to request stop running in background.
377   *
378   * @param { Context } context - App running context.
379   * @param { AsyncCallback<void> } callback - The callback of the function.
380   * @throws { BusinessError } 201 - Permission denied.
381   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
382   * @throws { BusinessError } 9800001 - Memory operation failed.
383   * @throws { BusinessError } 9800002 - Parcel operation failed.
384   * @throws { BusinessError } 9800003 - Internal transaction failed.
385   * @throws { BusinessError } 9800004 - System service operation failed.
386   * @throws { BusinessError } 9800005 - Continuous task verification failed.
387   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
388   * @throws { BusinessError } 9800007 - Continuous task storage failed.
389   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
390   * @atomicservice
391   * @since 12
392   */
393  function stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): void;
394
395  /**
396   * Service ability uses this method to request stop running in background.
397   *
398   * @param { Context } context - App running context.
399   * @returns { Promise<void> } The promise returned by the function.
400   * @throws { BusinessError } 201 - Permission denied.
401   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
402   * @throws { BusinessError } 9800001 - Memory operation failed.
403   * @throws { BusinessError } 9800002 - Parcel operation failed.
404   * @throws { BusinessError } 9800003 - Internal transaction failed.
405   * @throws { BusinessError } 9800004 - System service operation failed.
406   * @throws { BusinessError } 9800005 - Continuous task verification failed.
407   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
408   * @throws { BusinessError } 9800007 - Continuous task storage failed.
409   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
410   * @since 9
411   */
412  /**
413   * Service ability uses this method to request stop running in background.
414   *
415   * @param { Context } context - App running context.
416   * @returns { Promise<void> } The promise returned by the function.
417   * @throws { BusinessError } 201 - Permission denied.
418   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
419   * @throws { BusinessError } 9800001 - Memory operation failed.
420   * @throws { BusinessError } 9800002 - Parcel operation failed.
421   * @throws { BusinessError } 9800003 - Internal transaction failed.
422   * @throws { BusinessError } 9800004 - System service operation failed.
423   * @throws { BusinessError } 9800005 - Continuous task verification failed.
424   * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task.
425   * @throws { BusinessError } 9800007 - Continuous task storage failed.
426   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
427   * @atomicservice
428   * @since 12
429   */
430  function stopBackgroundRunning(context: Context): Promise<void>;
431
432  /**
433   * Apply or unapply efficiency resources.
434   *
435   * @param { EfficiencyResourcesRequest } request - The request of apply or unapply efficiency resources.
436   * @throws { BusinessError } 201 - Permission denied.
437   * @throws { BusinessError } 202 - Not System App.
438   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
439   * <br> 2. Incorrect parameters types; 3. Parameter verification failed.
440   * @throws { BusinessError } 9800001 - Memory operation failed.
441   * @throws { BusinessError } 9800002 - Parcel operation failed.
442   * @throws { BusinessError } 9800003 - Internal transaction failed.
443   * @throws { BusinessError } 9800004 - System service operation failed.
444   * @throws { BusinessError } 18700001 - Caller information verification failed for an energy resource request.
445   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
446   * @systemapi Hide this for inner system use.
447   * @since 9
448   */
449  function applyEfficiencyResources(request: EfficiencyResourcesRequest): void;
450
451  /**
452   * Reset all efficiency resources apply.
453   *
454   * @throws { BusinessError } 201 - Permission denied.
455   * @throws { BusinessError } 202 - Not System App.
456   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Parameter verification failed.
457   * @throws { BusinessError } 9800001 - Memory operation failed.
458   * @throws { BusinessError } 9800002 - Parcel operation failed.
459   * @throws { BusinessError } 9800003 - Internal transaction failed.
460   * @throws { BusinessError } 9800004 - System service operation failed.
461   * @throws { BusinessError } 18700001 - Caller information verification failed for an energy resource request.
462   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
463   * @systemapi Hide this for inner system use.
464   * @since 9
465   */
466  function resetAllEfficiencyResources(): void;
467
468  /**
469   * Register continuous task cancel callback.
470   *
471   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
472   * @param { 'continuousTaskCancel' } type - The type of continuous task cancel.
473   * @param { Callback<ContinuousTaskCancelInfo> } callback - the callback of continuous task cancel.
474   * @throws { BusinessError } 201 - Permission denied.
475   * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Callback parameter error;
476   * <br> 2. Register a exist callback type; 3. Parameter verification failed.
477   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
478   * @since 15
479   */
480  function on(type: 'continuousTaskCancel', callback: Callback<ContinuousTaskCancelInfo>): void;
481
482  /**
483   * Unregister continuous task cancel callback.
484   *
485   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
486   * @param { 'continuousTaskCancel' } type - The type of continuous task cancel.
487   * @param { Callback<ContinuousTaskCancelInfo> } callback - the callback of continuous task cancel.
488   * @throws { BusinessError } 201 - Permission denied.
489   * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Callback parameter error;
490   * <br> 2. Unregister type has not register; 3. Parameter verification failed.
491   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
492   * @since 15
493   */
494  function off(type: 'continuousTaskCancel', callback?: Callback<ContinuousTaskCancelInfo>): void;
495
496  /**
497   * Supported background mode.
498   *
499   * @enum { number }
500   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
501   * @since 9
502   */
503  /**
504   * Supported background mode.
505   *
506   * @enum { number }
507   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
508   * @atomicservice
509   * @since 12
510   */
511  export enum BackgroundMode {
512    /**
513     * data transfer mode
514     *
515     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
516     * @since 9
517     */
518    DATA_TRANSFER = 1,
519
520    /**
521     * audio playback mode
522     *
523     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
524     * @since 9
525     */
526    /**
527     * audio playback mode
528     *
529     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
530     * @atomicservice
531     * @since 12
532     */
533    AUDIO_PLAYBACK = 2,
534
535    /**
536     * audio recording mode
537     *
538     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
539     * @since 9
540     */
541    AUDIO_RECORDING = 3,
542
543    /**
544     * location mode
545     *
546     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
547     * @since 9
548     */
549    LOCATION = 4,
550
551    /**
552     * bluetooth interaction mode
553     *
554     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
555     * @since 9
556     */
557    BLUETOOTH_INTERACTION = 5,
558
559    /**
560     * multi-device connection mode
561     *
562     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
563     * @since 9
564     */
565    /**
566     * multi-device connection mode
567     *
568     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
569     * @atomicservice
570     * @since 12
571     */
572    MULTI_DEVICE_CONNECTION = 6,
573
574    /**
575     * wifi interaction mode
576     *
577     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
578     * @systemapi Hide this for inner system use.
579     * @since 9
580     */
581    WIFI_INTERACTION = 7,
582
583    /**
584     * Voice over Internet Phone mode
585     *
586     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
587     * @since 13
588     */
589    VOIP = 8,
590
591    /**
592     * background continuous calculate mode, for example 3D render.
593     * only supported in particular device
594     *
595     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
596     * @since 9
597     */
598    TASK_KEEPING = 9,
599  }
600
601  /**
602   * The type of resource.
603   *
604   * @enum { number }
605   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
606   * @systemapi Hide this for inner system use.
607   * @since 9
608   */
609  export enum ResourceType {
610    /**
611     * The cpu resource for not being suspended.
612     *
613     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
614     * @systemapi Hide this for inner system use.
615     * @since 9
616     */
617    CPU = 1,
618
619    /**
620     * The resource for not being proxyed common_event.
621     *
622     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
623     * @systemapi Hide this for inner system use.
624     * @since 9
625     */
626    COMMON_EVENT = 1 << 1,
627
628    /**
629     * The resource for not being proxyed timer.
630     *
631     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
632     * @systemapi Hide this for inner system use.
633     * @since 9
634     */
635    TIMER = 1 << 2,
636
637    /**
638     * The resource for not being proxyed workscheduler.
639     *
640     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
641     * @systemapi Hide this for inner system use.
642     * @since 9
643     */
644    WORK_SCHEDULER = 1 << 3,
645
646    /**
647     * The resource for not being proxyed bluetooth.
648     *
649     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
650     * @systemapi Hide this for inner system use.
651     * @since 9
652     */
653    BLUETOOTH = 1 << 4,
654
655    /**
656     * The resource for not being proxyed gps.
657     *
658     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
659     * @systemapi Hide this for inner system use.
660     * @since 9
661     */
662    GPS = 1 << 5,
663
664    /**
665     * The resource for not being proxyed audio.
666     *
667     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
668     * @systemapi Hide this for inner system use.
669     * @since 9
670     */
671    AUDIO = 1 << 6,
672
673    /**
674     * The resource for not being proxyed running lock.
675     *
676     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
677     * @systemapi Hide this for inner system use.
678     * @since 10
679     */
680    RUNNING_LOCK = 1 << 7,
681
682    /**
683     * The resource for not being proxyed sensor.
684     *
685     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
686     * @systemapi Hide this for inner system use.
687     * @since 10
688     */
689    SENSOR = 1 << 8
690  }
691
692  /**
693   * The request of efficiency resources.
694   *
695   * @interface EfficiencyResourcesRequest
696   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
697   * @systemapi Hide this for inner system use.
698   * @since 9
699   */
700  export interface EfficiencyResourcesRequest {
701    /**
702     * The set of resource types that app wants to apply.
703     *
704     * @type { number }
705     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
706     * @systemapi Hide this for inner system use.
707     * @since 9
708     */
709    resourceTypes: number;
710
711    /**
712     * True if the app begin to use, else false.
713     *
714     * @type { boolean }
715     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
716     * @systemapi Hide this for inner system use.
717     * @since 9
718     */
719    isApply: boolean;
720
721    /**
722     * The duration that the resource can be used most.
723     *
724     * @type { number }
725     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
726     * @systemapi Hide this for inner system use.
727     * @since 9
728     */
729    timeOut: number;
730
731    /**
732     * True if the apply action is persist, else false. Default value is false.
733     *
734     * @type { ?boolean }
735     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
736     * @systemapi Hide this for inner system use.
737     * @since 9
738     */
739    isPersist?: boolean;
740
741    /**
742     * True if apply action is for process, false is for package. Default value is false.
743     *
744     * @type { ?boolean }
745     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
746     * @systemapi Hide this for inner system use.
747     * @since 9
748     */
749    isProcess?: boolean;
750
751    /**
752     * The apply reason.
753     *
754     * @type { string }
755     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
756     * @systemapi Hide this for inner system use.
757     * @since 9
758     */
759    reason: string;
760  }
761
762  /**
763   * The type of continuous task cancel reason.
764   *
765   * @enum { number }
766   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
767   * @since 15
768   */
769  export enum ContinuousTaskCancelReason {
770    /**
771     * User cancel.
772     *
773     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
774     * @since 15
775     */
776    USER_CANCEL = 1,
777    /**
778     * System cancel.
779     *
780     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
781     * @since 15
782     */
783    SYSTEM_CANCEL = 2,
784    /**
785     * User remove notification.
786     *
787     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
788     * @since 15
789     */
790    USER_CANCEL_REMOVE_NOTIFICATION = 3,
791
792    /**
793     * Low network speed when request data transfer mode.
794     *
795     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
796     * @since 15
797     */
798    SYSTEM_CANCEL_DATA_TRANSFER_LOW_SPEED = 4,
799
800    /**
801     *  Not use avsession when request audio playback mode.
802     *
803     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
804     * @since 15
805     */
806    SYSTEM_CANCEL_AUDIO_PLAYBACK_NOT_USE_AVSESSION = 5,
807
808    /**
809     * Audio is not running when request audio playback mode.
810     *
811     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
812     * @since 15
813     */
814    SYSTEM_CANCEL_AUDIO_PLAYBACK_NOT_RUNNING = 6,
815
816    /**
817     * Audio is not running when request audio recording mode.
818     *
819     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
820     * @since 15
821     */
822    SYSTEM_CANCEL_AUDIO_RECORDING_NOT_RUNNING = 7,
823
824    /**
825     * Not use location when request location mode.
826     *
827     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
828     * @since 15
829     */
830    SYSTEM_CANCEL_NOT_USE_LOCATION = 8,
831
832    /**
833     * Not use bluetooth when request bluetooth interaction mode.
834     *
835     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
836     * @since 15
837     */
838    SYSTEM_CANCEL_NOT_USE_BLUETOOTH = 9,
839
840    /**
841     * Not use multi device when request multi-device connection mode.
842     *
843     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
844     * @since 15
845     */
846    SYSTEM_CANCEL_NOT_USE_MULTI_DEVICE = 10,
847
848    /**
849     * Use some mode illegally.
850     *
851     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
852     * @since 15
853     */
854    SYSTEM_CANCEL_USE_ILLEGALLY = 11,
855  }
856
857  /**
858   * Supported background submode.
859   *
860   * @enum { number }
861   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
862   * @since 16
863   */
864  export enum BackgroundSubMode {
865    /**
866     * bluetooth car key mode
867     *
868     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
869     * @since 16
870     */
871    CAR_KEY = 1
872  }
873
874  /**
875   * Supported background mode type.
876   *
877   * @enum { string }
878   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
879   * @since 16
880   */
881  export enum BackgroundModeType {
882    /**
883     * subMode type
884     *
885     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
886     * @since 16
887     */
888    SUB_MODE = 'subMode'
889  }
890}
891
892export default backgroundTaskManager;
893