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