Go to file
openharmony_ci 5477d518fe
!28 TDD用例输出路径更改
Merge pull request !28 from 廖康康/master
2022-02-08 12:14:36 +00:00
figures update 2022-01-12 20:58:44 +08:00
frameworks NAPI check requestId 2022-01-20 11:17:54 +08:00
interfaces change tdd output path 2022-02-08 19:13:13 +08:00
sa_profile update code 2022-01-14 16:23:12 +08:00
services change tdd output path 2022-02-08 19:13:13 +08:00
test/systemtest change tdd output path 2022-02-08 19:13:13 +08:00
utils !16 对应元能力部件化修改 2022-01-19 12:06:20 +00:00
LICENSE add code 2022-01-06 10:32:52 +08:00
OAT.xml update 2022-01-11 09:47:31 +08:00
README.md change readme 2022-01-12 17:00:40 +08:00
README_ZH.md change file name 2022-01-13 16:54:28 +08:00
bgtaskmgr.gni update 2022-01-11 09:47:31 +08:00
bundle.json code check 2022-01-20 09:58:08 +08:00

README.md

Background Task Manager

Introduction

In the resource scheduling subsystem, the background task management is responsible for managing background tasks, and provides interfaces for application, cancellation and query of background tasks.

Directory Structure

/foundation/resourceschedule/background_task_mgr
├── frameworks       # Frameworks
├── interfaces
│   ├── innerkits    # Internal APIs
│   └── kits         # External APIs
├── sa_profile       # SA profile
├── services         # Services
└── utils            # Utilities

Transient Tasks

Available APIs

API Description
function requestSuspendDelay(reason:string, callback:Callback<void>): DelaySuspendInfo; Request a suspend delay
function cancelSuspendDelay(requestId:number): void; Cancel the suspend delay
function getRemainingDelayTime(requestId:number, callback:AsyncCallback<number>):void; Get remaining delay time(callback)
function getRemainingDelayTime(requestId:number): Promise<number>; Get remaining delay time(Promise)

Usage Guidelines

As mentioned above, applications and service modules with transient tasks have their suspension delayed so that their running is not affected by background lifecycle management within the specified time frame.

  • Note: Applications and service modules can request transient tasks only for temporary tasks. The time quota is 3 minutes per time and 10 minutes per day. The system allocates the time frame based on the application scenario and system status.

Restrictions on Using Transient Tasks

  • When to requestAn application can request a transient task only when it is running in the foreground or before it is suspended in the background. Otherwise, the application may be suspended, resulting in request failure. By default, an application has 612 seconds of running time (subject to the application scenario) before it is suspended in the background.
  • TimeoutThe system notifies the application of the suspension delay timeout by using a callback. The application must then cancel the delayed suspension or apply for delayed suspension again. Otherwise, the application will be forcibly suspended.
  • When to cancelThe requesting application shall cancel the request when the transient task is complete. If the request is forcibly canceled by the system, the time frame allowed for the application to run in the background will be affected.
  • Quota mechanismTo prevent abuse of the keepalive, each application has a certain quota every day (dynamically adjusted based on user habits). After using up the quota, an application cannot request transient tasks. Therefore, applications should cancel their request immediately after the transient tasks are complete, to avoid quota consumption. (Note: The quota refers to the requested duration and does not include the time when the application runs in the background.)

Repositories Involved

Resource Schedule subsystem

background_task_mgr

notification_ces_standard

appexecfwk_standard