• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.resourceschedule.backgroundTaskManager (Background Task Management)
2
3The **BackgroundTaskManager** module provides APIs to manage background tasks.
4
5If a service needs to be continued when the application or service module is running in the background (not visible to users), the application or service module can request a transient task to delay the suspension or a continuous task to prevent the suspension.
6
7If an application has a task that needs to be continued when the application is switched to the background and can be completed within a short period of time, the application can request a transient task. For example, if a user chooses to clear junk files in the **Files** application and exits the application, the application can request a transient task to complete the cleanup.
8
9If an application has a service that can be intuitively perceived by users and needs to run in the background for a long period of time (for example, music playback in the background), the application can request a continuous task.
10
11If a privileged system application needs to use certain system resources (for example, it wants to receive common events when suspended), it can request efficiency resources.
12
13>  **NOTE**
14>
15>  The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
16
17
18## Modules to Import
19
20```js
21import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager';
22```
23
24## backgroundTaskManager.requestSuspendDelay
25
26requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspendInfo
27
28Requests delayed suspension after the application switches to the background.
29
30The default duration of delayed suspension is 3 minutes when the battery level is higher than or equal to the broadcast low battery level and 1 minute when the battery level is lower than the broadcast low battery level.
31
32**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
33
34**Parameters**
35
36| Name     | Type                  | Mandatory  | Description                            |
37| -------- | -------------------- | ---- | ------------------------------ |
38| reason   | string               | Yes   | Reason for delayed transition to the suspended state.                    |
39| callback | Callback<void> | Yes   | Invoked when a delay is about to time out. Generally, this callback is used to notify the application 6 seconds before the delay times out.|
40
41**Return value**
42
43| Type                                   | Description       |
44| ------------------------------------- | --------- |
45| [DelaySuspendInfo](#delaysuspendinfo) | Information about the suspension delay.|
46
47**Error codes**
48
49For details about the error codes, see [backgroundTaskManager Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
50
51| ID | Error Message            |
52| ---- | --------------------- |
53| 9800001 | Memory operation failed. |
54| 9800002 | Parcel operation failed. |
55| 9800003 | Inner transact failed. | |
56| 9800004 | System service operation failed. |
57| 9900001 | Caller information verification failed. |
58| 9900002 | Background task verification failed. |
59
60**Example**
61
62  ```js
63  import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager';
64
65  let myReason = 'test requestSuspendDelay';
66  try {
67    let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => {
68        console.info("Request suspension delay will time out.");
69    })
70    var id = delayInfo.requestId;
71    var time = delayInfo.actualDelayTime;
72    console.info("The requestId is: " + id);
73    console.info("The actualDelayTime is: " + time);
74  } catch (error) {
75    console.error(`requestSuspendDelay failed. code is ${error.code} message is ${error.message}`);
76  }
77  ```
78
79
80## backgroundTaskManager.getRemainingDelayTime:callback
81
82getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>): void
83
84Obtains the remaining duration before the application is suspended. This API uses an asynchronous callback to return the result.
85
86**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
87
88**Parameters**
89
90| Name      | Type                         | Mandatory  | Description                                      |
91| --------- | --------------------------- | ---- | ---------------------------------------- |
92| requestId | number                      | Yes   | ID of the suspension delay request.                              |
93| callback  | AsyncCallback<number> | Yes   | Callback used to return the remaining duration before the application is suspended, in milliseconds.|
94
95**Error codes**
96
97For details about the error codes, see [backgroundTaskManager Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
98
99| ID | Error Message            |
100| ---- | --------------------- |
101| 9800001 | Memory operation failed. |
102| 9800002 | Parcel operation failed. |
103| 9800003 | Inner transact failed. | |
104| 9800004 | System service operation failed. |
105| 9900001 | Caller information verification failed. |
106| 9900002 | Background task verification failed. |
107
108
109**Example**
110
111  ```js
112  import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager';
113
114  let id = 1;
115  try {
116    backgroundTaskManager.getRemainingDelayTime(id, (error, res) => {
117        if(error) {
118            console.error(`callback => Operation getRemainingDelayTime failed. code is ${error.code} message is ${error.message}`);
119        } else {
120            console.log('callback => Operation getRemainingDelayTime succeeded. Data: ' + JSON.stringify(res));
121        }
122    })
123  } catch (error) {
124    console.error(`callback => Operation getRemainingDelayTime failed. code is ${error.code} message is ${error.message}`);
125  }
126  ```
127
128
129## backgroundTaskManager.getRemainingDelayTime:promise
130
131getRemainingDelayTime(requestId: number): Promise<number>
132
133Obtains the remaining duration before the application is suspended. This API uses a promise to return the result.
134
135
136
137**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
138
139**Parameters**
140
141| Name      | Type    | Mandatory  | Description        |
142| --------- | ------ | ---- | ---------- |
143| requestId | number | Yes   | ID of the suspension delay request.|
144
145**Return value**
146
147| Type                   | Description                                      |
148| --------------------- | ---------------------------------------- |
149| Promise<number> | Promise used to return the remaining duration before the application is suspended, in milliseconds.|
150
151**Error codes**
152
153For details about the error codes, see [backgroundTaskManager Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
154
155| ID | Error Message            |
156| ---- | --------------------- |
157| 9800001 | Memory operation failed. |
158| 9800002 | Parcel operation failed. |
159| 9800003 | Inner transact failed. | |
160| 9800004 | System service operation failed. |
161| 9900001 | Caller information verification failed. |
162| 9900002 | Background task verification failed. |
163
164**Example**
165
166  ```js
167  import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager';
168
169  let id = 1;
170  try {
171    backgroundTaskManager.getRemainingDelayTime(id).then( res => {
172        console.log('promise => Operation getRemainingDelayTime succeeded. Data: ' + JSON.stringify(res));
173    }).catch( error => {
174        console.error(`promise => Operation getRemainingDelayTime failed. code is ${error.code} message is ${error.message}`);
175    })
176  } catch (error) {
177    console.error(`promise => Operation getRemainingDelayTime failed. code is ${error.code} message is ${error.message}`);
178  }
179  ```
180
181
182## backgroundTaskManager.cancelSuspendDelay
183
184cancelSuspendDelay(requestId: number): void
185
186Cancels the suspension delay.
187
188**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
189
190**Parameters**
191
192| Name      | Type    | Mandatory  | Description        |
193| --------- | ------ | ---- | ---------- |
194| requestId | number | Yes   | ID of the suspension delay request.|
195
196**Error codes**
197
198For details about the error codes, see [backgroundTaskManager Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
199
200| ID | Error Message            |
201| ---- | --------------------- |
202| 9800001 | Memory operation failed. |
203| 9800002 | Parcel operation failed. |
204| 9800003 | Inner transact failed. | |
205| 9800004 | System service operation failed. |
206| 9900001 | Caller information verification failed. |
207| 9900002 | Background task verification failed. |
208
209**Example**
210
211  ```js
212  import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager';
213
214  let id = 1;
215  try {
216    backgroundTaskManager.cancelSuspendDelay(id);
217  } catch (error) {
218    console.error(`cancelSuspendDelay failed. code is ${error.code} message is ${error.message}`);
219  }
220  ```
221
222
223## backgroundTaskManager.startBackgroundRunning:callback
224
225startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback<void>): void
226
227Requests a continuous task from the system. This API uses an asynchronous callback to return the result.
228
229**Required permissions**: ohos.permission.KEEP_BACKGROUND_RUNNING
230
231**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
232
233**Parameters**
234
235| Name      | Type                                | Mandatory  | Description                                      |
236| --------- | ---------------------------------- | ---- | ---------------------------------------- |
237| context   | Context                            | Yes   | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
238| bgMode    | [BackgroundMode](#backgroundmode) | Yes   | Background mode requested.                             |
239| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes   | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked.                |
240| callback  | AsyncCallback&lt;void&gt;          | Yes   | Callback used to return the result.                  |
241
242**Error codes**
243
244For details about the error codes, see [backgroundTaskManager Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
245
246| ID | Error Message            |
247| ---- | --------------------- |
248| 9800001 | Memory operation failed. |
249| 9800002 | Parcel operation failed. |
250| 9800003 | Inner transact failed. | |
251| 9800004 | System service operation failed. |
252| 9800005 | Background task verification failed. |
253| 9800006 | Notification verification failed. |
254| 9800007 | Task storage failed. |
255
256**Example**
257
258```js
259import UIAbility from '@ohos.app.ability.UIAbility';
260import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager';
261import wantAgent from '@ohos.app.ability.wantAgent';
262
263function callback(error, data) {
264    if (error) {
265        console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`);
266    } else {
267        console.info("Operation startBackgroundRunning succeeded");
268    }
269}
270
271export default class EntryAbility extends UIAbility {
272    onCreate(want, launchParam) {
273        let wantAgentInfo = {
274            wants: [
275                {
276                    bundleName: "com.example.myapplication",
277                    abilityName: "EntryAbility"
278                }
279            ],
280            operationType: wantAgent.OperationType.START_ABILITY,
281            requestCode: 0,
282            wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
283        };
284
285        try {
286            wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
287                try {
288                    backgroundTaskManager.startBackgroundRunning(this.context,
289                        backgroundTaskManager.BackgroundMode.LOCATION, wantAgentObj, callback)
290                } catch (error) {
291                    console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`);
292                }
293            });
294        } catch (error) {
295            console.error(`Operation getWantAgent failed. code is ${error.code} message is ${error.message}`);
296        }
297    }
298};
299```
300
301## backgroundTaskManager.startBackgroundRunning:promise
302
303startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise&lt;void&gt;
304
305Requests a continuous task from the system. This API uses a promise to return the result.
306
307**Required permissions**: ohos.permission.KEEP_BACKGROUND_RUNNING
308
309**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
310
311**Parameters**
312
313| Name      | Type                                | Mandatory  | Description                                      |
314| --------- | ---------------------------------- | ---- | ---------------------------------------- |
315| context   | Context                            | Yes   | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
316| bgMode    | [BackgroundMode](#backgroundmode) | Yes   | Background mode requested.                             |
317| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes   | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked.                 |
318
319**Return value**
320
321| Type            | Description              |
322| -------------- | ---------------- |
323| Promise\<void> | Promise used to return the result.|
324
325**Error codes**
326
327For details about the error codes, see [backgroundTaskManager Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
328
329| ID | Error Message            |
330| ---- | --------------------- |
331| 9800001 | Memory operation failed. |
332| 9800002 | Parcel operation failed. |
333| 9800003 | Inner transact failed. | |
334| 9800004 | System service operation failed. |
335| 9800005 | Background task verification failed. |
336| 9800006 | Notification verification failed. |
337| 9800007 | Task storage failed. |
338
339**Example**
340
341```js
342import UIAbility from '@ohos.app.ability.UIAbility';
343import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager';
344import wantAgent from '@ohos.app.ability.wantAgent';
345
346export default class EntryAbility extends UIAbility {
347    onCreate(want, launchParam) {
348        let wantAgentInfo = {
349            wants: [
350                {
351                    bundleName: "com.example.myapplication",
352                    abilityName: "EntryAbility"
353                }
354            ],
355            operationType: wantAgent.OperationType.START_ABILITY,
356            requestCode: 0,
357            wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
358        };
359
360        try {
361            wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
362                try {
363                    backgroundTaskManager.startBackgroundRunning(this.context,
364                        backgroundTaskManager.BackgroundMode.LOCATION, wantAgentObj).then(() => {
365                        console.info("Operation startBackgroundRunning succeeded");
366                    }).catch((error) => {
367                        console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`);
368                    });
369                } catch (error) {
370                    console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`);
371                }
372            });
373        } catch (error) {
374            console.error(`Operation getWantAgent failed. code is ${error.code} message is ${error.message}`);
375        }
376    }
377};
378```
379
380## backgroundTaskManager.stopBackgroundRunning:callback
381
382stopBackgroundRunning(context: Context, callback: AsyncCallback&lt;void&gt;): void
383
384Requests to cancel a continuous task. This API uses an asynchronous callback to return the result.
385
386**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
387
388**Parameters**
389
390| Name     | Type                       | Mandatory  | Description                                      |
391| -------- | ------------------------- | ---- | ---------------------------------------- |
392| context  | Context                   | Yes   | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
393| callback | AsyncCallback&lt;void&gt; | Yes   | Callback used to return the result.                  |
394
395**Error codes**
396
397For details about the error codes, see [backgroundTaskManager Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
398
399| ID | Error Message            |
400| ---- | --------------------- |
401| 9800001 | Memory operation failed. |
402| 9800002 | Parcel operation failed. |
403| 9800003 | Inner transact failed. | |
404| 9800004 | System service operation failed. |
405| 9800005 | Background task verification failed. |
406| 9800006 | Notification verification failed. |
407| 9800007 | Task storage failed. |
408
409**Example**
410
411```js
412import UIAbility from '@ohos.app.ability.UIAbility';
413import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager';
414
415function callback(error, data) {
416    if (error) {
417        console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`);
418    } else {
419        console.info("Operation stopBackgroundRunning succeeded");
420    }
421}
422
423export default class EntryAbility extends UIAbility {
424    onCreate(want, launchParam) {
425        try {
426            backgroundTaskManager.stopBackgroundRunning(this.context, callback);
427        } catch (error) {
428            console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`);
429        }
430    }
431};
432```
433
434## backgroundTaskManager.stopBackgroundRunning:promise
435
436stopBackgroundRunning(context: Context): Promise&lt;void&gt;
437
438Requests to cancel a continuous task. This API uses a promise to return the result.
439
440
441
442**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
443
444**Parameters**
445
446| Name    | Type     | Mandatory  | Description                                      |
447| ------- | ------- | ---- | ---------------------------------------- |
448| context | Context | Yes   | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
449
450**Return value**
451
452| Type            | Description              |
453| -------------- | ---------------- |
454| Promise\<void> | Promise used to return the result.|
455
456**Error codes**
457
458For details about the error codes, see [backgroundTaskManager Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
459
460| ID | Error Message            |
461| ---- | --------------------- |
462| 9800001 | Memory operation failed. |
463| 9800002 | Parcel operation failed. |
464| 9800003 | Inner transact failed. | |
465| 9800004 | System service operation failed. |
466| 9800005 | Background task verification failed. |
467| 9800006 | Notification verification failed. |
468| 9800007 | Task storage failed. |
469
470**Example**
471
472```js
473import UIAbility from '@ohos.app.ability.UIAbility';
474import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager';
475
476export default class EntryAbility extends UIAbility {
477    onCreate(want, launchParam) {
478        try {
479            backgroundTaskManager.stopBackgroundRunning(this.context).then(() => {
480                console.info("Operation stopBackgroundRunning succeeded");
481            }).catch((error) => {
482                console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`);
483            });
484        } catch (error) {
485            console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`);
486        }
487    }
488};
489```
490
491## backgroundTaskManager.applyEfficiencyResources
492
493applyEfficiencyResources(request: [EfficiencyResourcesRequest](#efficiencyresourcesrequest)): void
494
495Requests efficiency resources from the system.
496A process and its application can request the same type of resources at the same time, for example, CPU resources. When the application releases the resources, the same type of resources requested by the process are also released.
497
498**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
499
500**System API**: This is a system API.
501
502**Parameters**
503
504| Name    | Type     | Mandatory  | Description                                      |
505| ------- | ------- | ---- | ---------------------------------------- |
506| request | [EfficiencyResourcesRequest](#efficiencyresourcesrequest) | Yes   | Necessary information carried in the request, including the resource type and timeout interval. For details, see [EfficiencyResourcesRequest](#efficiencyresourcesrequest).|
507
508
509**Error codes**
510
511For details about the error codes, see [backgroundTaskManager Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
512
513| ID | Error Message            |
514| ---- | --------------------- |
515| 9800001 | Memory operation failed. |
516| 9800002 | Parcel operation failed. |
517| 9800003 | Inner transact failed. | |
518| 9800004 | System service operation failed. |
519| 18700001 | Caller information verification failed. |
520
521**Example**
522
523```js
524import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager';
525
526let request = {
527    resourceTypes: backgroundTaskManager.ResourceType.CPU,
528    isApply: true,
529    timeOut: 0,
530    reason: "apply",
531    isPersist: true,
532    isProcess: false,
533};
534try {
535    backgroundTaskManager.applyEfficiencyResources(request);
536    console.info("applyEfficiencyResources success. ");
537} catch (error) {
538    console.error(`applyEfficiencyResources failed. code is ${error.code} message is ${error.message}`);
539}
540```
541
542## backgroundTaskManager.resetAllEfficiencyResources
543
544resetAllEfficiencyResources(): void
545
546Releases all resources that have been requested.
547
548**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
549
550**System API**: This is a system API.
551
552**Error codes**
553
554For details about the error codes, see [backgroundTaskManager Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
555
556| ID | Error Message            |
557| ---- | --------------------- |
558| 9800001 | Memory operation failed. |
559| 9800002 | Parcel operation failed. |
560| 9800003 | Inner transact failed. | |
561| 9800004 | System service operation failed. |
562| 18700001 | Caller information verification failed. |
563
564**Example**
565
566```js
567import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager';
568
569try {
570    backgroundTaskManager.resetAllEfficiencyResources();
571} catch (error) {
572    console.error(`resetAllEfficiencyResources failed. code is ${error.code} message is ${error.message}`);
573}
574```
575
576## DelaySuspendInfo
577
578Provides the information about the suspension delay.
579
580**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
581
582| Name            | Type    | Mandatory  | Description                                      |
583| --------------- | ------ | ---- | ---------------------------------------- |
584| requestId       | number | Yes   | ID of the suspension delay request.                              |
585| actualDelayTime | number | Yes   | Actual suspension delay duration of the application, in milliseconds.<br>The default duration is 180000 when the battery level is higher than or equal to the broadcast low battery level and 60000 when the battery level is lower than the broadcast low battery level.|
586
587
588## BackgroundMode
589
590**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
591
592| Name                    | Value | Description                   |
593| ----------------------- | ---- | --------------------- |
594| DATA_TRANSFER           | 1    | Data transfer.                 |
595| AUDIO_PLAYBACK          | 2    | Audio playback.                 |
596| AUDIO_RECORDING         | 3    | Audio recording.                   |
597| LOCATION                | 4    | Positioning and navigation.                 |
598| BLUETOOTH_INTERACTION   | 5    | Bluetooth-related task.                 |
599| MULTI_DEVICE_CONNECTION | 6    | Multi-device connection.                |
600| WIFI_INTERACTION        | 7    | WLAN-related (system API).|
601| VOIP                    | 8    | Audio and video calls (system API). |
602| TASK_KEEPING            | 9    | Computing task (effective only for specific devices).       |
603
604## EfficiencyResourcesRequest
605
606Describes the parameters for requesting efficiency resources.
607
608**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
609
610**System API**: This is a system API.
611
612| Name            | Type    | Mandatory  | Description                                      |
613| --------------- | ------ | ---- | ---------------------------------------- |
614| resourceTypes   | number  | Yes   | Type of the resource to request.                              |
615| isApply         | boolean | Yes   | Whether the request is used to apply for resources. The value **true** means that the request is used to apply for resources, and **false** means that the request is used to release resources.         |
616| timeOut         | number  | Yes   | Duration for which the resource will be used, in milliseconds.               |
617| isPersist       | boolean | No   | Whether the resource is permanently held. If the value is **true**, **timeOut** is invalid.   |
618| isProcess       | boolean | No   | Whether the request is initiated by a process. The value **true** means that the request is initiated by a process, and **false** means that the request is initiated by an application.         |
619| reason          | string  | Yes   | Reason for requesting the resource.               |
620
621## ResourceType
622
623Enumerates the efficiency resource types.
624
625**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
626
627**System API**: This is a system API.
628
629| Name                    | Value | Description                   |
630| ----------------------- | ---- | --------------------- |
631| CPU                     | 1    | CPU resources, which prevent the application from being suspended.            |
632| COMMON_EVENT            | 2    | A type of software resources, which prevent common events from being proxied when the application is suspended. |
633| TIMER                   | 4    | A type of software resources, which prevent timers from being proxied when the application is suspended.   |
634| WORK_SCHEDULER          | 8    | WORK_SCHEDULER resources, which ensure that the application has more time to execute the task.     |
635| BLUETOOTH               | 16   | A type of hardware resources, which prevent Bluetooth resources from being proxied when the application is suspended. |
636| GPS                     | 32   | A type of hardware resources, which prevent GPS resources from being proxied when the application is suspended. |
637| AUDIO                   | 64   | A type of hardware resources, which prevent audio resources from being proxied when the application is suspended.|
638