From 683f340183f9eeb00916b31baafc205fad3019b3 Mon Sep 17 00:00:00 2001 From: zhangxin_T Date: Sun, 23 Jan 2022 15:30:18 +0800 Subject: [PATCH 1/6] add background mode request interface Signed-off-by: zhangxin_T --- api/@ohos.ability.particleAbility.d.ts | 26 +++++++++ api/@ohos.backgroundTaskManager.d.ts | 79 ++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) diff --git a/api/@ohos.ability.particleAbility.d.ts b/api/@ohos.ability.particleAbility.d.ts index 74ff162975..6a241d3c6f 100644 --- a/api/@ohos.ability.particleAbility.d.ts +++ b/api/@ohos.ability.particleAbility.d.ts @@ -16,6 +16,7 @@ import { AsyncCallback } from './basic'; import { StartAbilityParameter } from './ability/startAbilityParameter'; import { DataAbilityHelper } from './ability/dataAbilityHelper'; +import { NotificationRequest } from './notification/notificationRequest'; /** * A Particle Ability represents an ability with service. @@ -59,5 +60,30 @@ declare namespace particleAbility { * @return Returns the dataAbilityHelper. */ function acquireDataAbilityHelper(uri: string): DataAbilityHelper; + + /** + * Service ability uses this method to request keep running in background. + * note this is old api. will be deprecated in furture api version + * + * @devices phone, tablet + * @since 7 + * @sysCap BackgroundTaskMgr + * @param id Identifies the notificaiton bar information + * @param request the notification related to the this service. + * @deprecated + */ + function startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback): void; + function startBackgroundRunning(id: number, request: NotificationRequest): Promise; + + /** + * Service ability uses this method to request cancel running in background. + * + * @devices phone, tablet + * @since 7 + * @sysCap BackgroundTaskMgr + * @deprecated + */ + function cancelBackgroundRunning(callback: AsyncCallback): void; + function cancelBackgroundRunning(): Promise; } export default particleAbility; diff --git a/api/@ohos.backgroundTaskManager.d.ts b/api/@ohos.backgroundTaskManager.d.ts index 85bd32ad33..729a9a689e 100644 --- a/api/@ohos.backgroundTaskManager.d.ts +++ b/api/@ohos.backgroundTaskManager.d.ts @@ -14,6 +14,7 @@ */ import { AsyncCallback , Callback} from './basic'; +import { WantAgent } from "./@ohos.wantAgent"; /** * Manages background tasks. @@ -75,6 +76,84 @@ declare namespace backgroundTaskManager { * @return Info of delay request */ function requestSuspendDelay(reason: string, callback: Callback): DelaySuspendInfo; + + /** + * Service ability uses this method to request start running in background. + * system will publish a notification related to the this service when condition is met. + * each ability will only allowed to request one type background mode. + * + * @devices phone, tablet + * @since 8 + * @param bgMode Indicates which background mode to request. + * @param wantAgent Indicates which ability to start when user click the notification. + */ + function startBackgroundRunning(bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback): void; + function startBackgroundRunning(bgMode: BackgroundMode, wantAgent: WantAgent): Promise; + + /** + * Service ability uses this method to request stop running in background. + * + * @devices phone, tablet + * @since 8 + */ + function stopBackgroundRunning(callback: AsyncCallback): void; + function stopBackgroundRunning(): Promise; + + /** + * supported background mode. + * + * @since 8 + */ + export enum BackgroundMode { + /** + * data transfer mode + */ + DATA_TRANSFER = 1, + + /** + * audio playback mode + */ + AUDIO_PLAYBACK = 2, + + /** + * audio recording mode + */ + AUDIO_RECORDING = 3, + + /** + * location mode + */ + LOCATION = 4, + + /** + * bluetooth interaction mode + */ + BLUETOOTH_INTERACTION = 5, + + /** + * multi-device connection mode + */ + MULTI_DEVICE_CONNECTION = 6, + + /** + * wifi interaction mode + * + * @systemapi Hide this for inner system use. + */ + WIFI_INTERACTION = 7, + + /** + * Voice over Internet Phone mode + * + * @systemapi Hide this for inner system use. + */ + VOIP = 8, + + /** + * backgroud continuous calculate mode, for example 3d render. + */ + TASK_KEEPING = 9, + } } export default backgroundTaskManager; \ No newline at end of file -- Gitee From c808a754a146e2ececaf8a01eafab74a20ddfcc4 Mon Sep 17 00:00:00 2001 From: zhangxin_T Date: Mon, 24 Jan 2022 09:16:56 +0800 Subject: [PATCH 2/6] add context param for new module Signed-off-by: zhangxin_T --- api/@ohos.ability.particleAbility.d.ts | 19 ++++++++++--------- api/@ohos.backgroundTaskManager.d.ts | 23 +++++++++++++++-------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/api/@ohos.ability.particleAbility.d.ts b/api/@ohos.ability.particleAbility.d.ts index 6a241d3c6f..3076931de8 100644 --- a/api/@ohos.ability.particleAbility.d.ts +++ b/api/@ohos.ability.particleAbility.d.ts @@ -62,25 +62,26 @@ declare namespace particleAbility { function acquireDataAbilityHelper(uri: string): DataAbilityHelper; /** - * Service ability uses this method to request keep running in background. - * note this is old api. will be deprecated in furture api version + * Keeps this Service ability in the background and displays a notification bar. * - * @devices phone, tablet + * @devices phone, tablet, tv, wearable, car * @since 7 - * @sysCap BackgroundTaskMgr - * @param id Identifies the notificaiton bar information - * @param request the notification related to the this service. + * @sysCap AAFwk + * @param id Identifies the notification bar information. + * @param request Indicates the notificationRequest instance containing information for displaying a notification bar. + * @return - * @deprecated */ function startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback): void; function startBackgroundRunning(id: number, request: NotificationRequest): Promise; /** - * Service ability uses this method to request cancel running in background. + * Cancels background running of this ability to free up system memory. * - * @devices phone, tablet + * @devices phone, tablet, tv, wearable, car * @since 7 - * @sysCap BackgroundTaskMgr + * @sysCap AAFwk + * @return - * @deprecated */ function cancelBackgroundRunning(callback: AsyncCallback): void; diff --git a/api/@ohos.backgroundTaskManager.d.ts b/api/@ohos.backgroundTaskManager.d.ts index 729a9a689e..380a5a3493 100644 --- a/api/@ohos.backgroundTaskManager.d.ts +++ b/api/@ohos.backgroundTaskManager.d.ts @@ -15,6 +15,7 @@ import { AsyncCallback , Callback} from './basic'; import { WantAgent } from "./@ohos.wantAgent"; +import { Context } from './app/context'; /** * Manages background tasks. @@ -79,30 +80,35 @@ declare namespace backgroundTaskManager { /** * Service ability uses this method to request start running in background. - * system will publish a notification related to the this service when condition is met. - * each ability will only allowed to request one type background mode. + * system will publish a notification related to the this service. * - * @devices phone, tablet * @since 8 + * @sysCap SystemCapability.Ressched.BackgroundTaskMgr + * @devices phone, tv, wearable, tablet, car + * @param context app running context. * @param bgMode Indicates which background mode to request. * @param wantAgent Indicates which ability to start when user click the notification. */ - function startBackgroundRunning(bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback): void; - function startBackgroundRunning(bgMode: BackgroundMode, wantAgent: WantAgent): Promise; + function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback): void; + function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise; /** * Service ability uses this method to request stop running in background. * - * @devices phone, tablet * @since 8 + * @sysCap SystemCapability.Ressched.BackgroundTaskMgr + * @devices phone, tv, wearable, tablet, car + * @param context app running context. */ - function stopBackgroundRunning(callback: AsyncCallback): void; - function stopBackgroundRunning(): Promise; + function stopBackgroundRunning(context: Context, callback: AsyncCallback): void; + function stopBackgroundRunning(context: Context, ): Promise; /** * supported background mode. * * @since 8 + * @sysCap SystemCapability.Ressched.BackgroundTaskMgr + * @devices phone, tv, wearable, tablet, car */ export enum BackgroundMode { /** @@ -151,6 +157,7 @@ declare namespace backgroundTaskManager { /** * backgroud continuous calculate mode, for example 3d render. + * only supported in portable computer */ TASK_KEEPING = 9, } -- Gitee From 85381448904cf6594d8880252e69aad912a47a22 Mon Sep 17 00:00:00 2001 From: zhangxin_T Date: Wed, 9 Feb 2022 22:14:17 +0800 Subject: [PATCH 3/6] modify sysCap label Signed-off-by: zhangxin_T --- api/@ohos.ability.particleAbility.d.ts | 13 ++++----- api/@ohos.backgroundTaskManager.d.ts | 39 ++++++++++++++++++++------ 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/api/@ohos.ability.particleAbility.d.ts b/api/@ohos.ability.particleAbility.d.ts index 3076931de8..942550b5c6 100644 --- a/api/@ohos.ability.particleAbility.d.ts +++ b/api/@ohos.ability.particleAbility.d.ts @@ -62,26 +62,23 @@ declare namespace particleAbility { function acquireDataAbilityHelper(uri: string): DataAbilityHelper; /** - * Keeps this Service ability in the background and displays a notification bar. + * Keep this Service ability in the background and display a notification bar. * - * @devices phone, tablet, tv, wearable, car * @since 7 - * @sysCap AAFwk + * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @permission ohos.permission.KEEP_BACKGROUND_RUNNING * @param id Identifies the notification bar information. * @param request Indicates the notificationRequest instance containing information for displaying a notification bar. - * @return - * @deprecated */ function startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback): void; function startBackgroundRunning(id: number, request: NotificationRequest): Promise; /** - * Cancels background running of this ability to free up system memory. + * Cancel background running of this ability to free up system memory. * - * @devices phone, tablet, tv, wearable, car * @since 7 - * @sysCap AAFwk - * @return - + * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask * @deprecated */ function cancelBackgroundRunning(callback: AsyncCallback): void; diff --git a/api/@ohos.backgroundTaskManager.d.ts b/api/@ohos.backgroundTaskManager.d.ts index 380a5a3493..5b3544c90d 100644 --- a/api/@ohos.backgroundTaskManager.d.ts +++ b/api/@ohos.backgroundTaskManager.d.ts @@ -83,11 +83,11 @@ declare namespace backgroundTaskManager { * system will publish a notification related to the this service. * * @since 8 - * @sysCap SystemCapability.Ressched.BackgroundTaskMgr - * @devices phone, tv, wearable, tablet, car + * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @permission ohos.permission.KEEP_BACKGROUND_RUNNING * @param context app running context. * @param bgMode Indicates which background mode to request. - * @param wantAgent Indicates which ability to start when user click the notification. + * @param wantAgent Indicates which ability to start when user click the notification bar. */ function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback): void; function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise; @@ -96,8 +96,7 @@ declare namespace backgroundTaskManager { * Service ability uses this method to request stop running in background. * * @since 8 - * @sysCap SystemCapability.Ressched.BackgroundTaskMgr - * @devices phone, tv, wearable, tablet, car + * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask * @param context app running context. */ function stopBackgroundRunning(context: Context, callback: AsyncCallback): void; @@ -107,43 +106,62 @@ declare namespace backgroundTaskManager { * supported background mode. * * @since 8 - * @sysCap SystemCapability.Ressched.BackgroundTaskMgr - * @devices phone, tv, wearable, tablet, car + * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ export enum BackgroundMode { /** * data transfer mode + * + * @since 8 + * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ DATA_TRANSFER = 1, /** * audio playback mode + * + * @since 8 + * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ AUDIO_PLAYBACK = 2, /** * audio recording mode + * + * @since 8 + * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ AUDIO_RECORDING = 3, /** * location mode + * + * @since 8 + * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ LOCATION = 4, /** * bluetooth interaction mode + * + * @since 8 + * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ BLUETOOTH_INTERACTION = 5, /** * multi-device connection mode + * + * @since 8 + * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ MULTI_DEVICE_CONNECTION = 6, /** * wifi interaction mode * + * @since 8 + * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask * @systemapi Hide this for inner system use. */ WIFI_INTERACTION = 7, @@ -151,13 +169,18 @@ declare namespace backgroundTaskManager { /** * Voice over Internet Phone mode * + * @since 8 + * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask * @systemapi Hide this for inner system use. */ VOIP = 8, /** * backgroud continuous calculate mode, for example 3d render. - * only supported in portable computer + * only supported in portable computer device + * + * @since 8 + * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ TASK_KEEPING = 9, } -- Gitee From fe6f61008ce168f7c38a5a7bef3c56475aa7ca11 Mon Sep 17 00:00:00 2001 From: zhangxin_T Date: Thu, 10 Feb 2022 02:36:30 +0800 Subject: [PATCH 4/6] bugfix Signed-off-by: zhangxin_T --- api/@ohos.backgroundTaskManager.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/@ohos.backgroundTaskManager.d.ts b/api/@ohos.backgroundTaskManager.d.ts index 5b3544c90d..6ee0265d8c 100644 --- a/api/@ohos.backgroundTaskManager.d.ts +++ b/api/@ohos.backgroundTaskManager.d.ts @@ -100,7 +100,7 @@ declare namespace backgroundTaskManager { * @param context app running context. */ function stopBackgroundRunning(context: Context, callback: AsyncCallback): void; - function stopBackgroundRunning(context: Context, ): Promise; + function stopBackgroundRunning(context: Context): Promise; /** * supported background mode. @@ -176,7 +176,7 @@ declare namespace backgroundTaskManager { VOIP = 8, /** - * backgroud continuous calculate mode, for example 3d render. + * background continuous calculate mode, for example 3D render. * only supported in portable computer device * * @since 8 -- Gitee From 1eb6de46f8f7de06241d33270eb43dd885010a65 Mon Sep 17 00:00:00 2001 From: zhangxin_T Date: Thu, 10 Feb 2022 14:39:36 +0800 Subject: [PATCH 5/6] change sysCap label Signed-off-by: zhangxin_T --- api/@ohos.ability.particleAbility.d.ts | 4 ++-- api/@ohos.backgroundTaskManager.d.ts | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/api/@ohos.ability.particleAbility.d.ts b/api/@ohos.ability.particleAbility.d.ts index 942550b5c6..706c753b9b 100644 --- a/api/@ohos.ability.particleAbility.d.ts +++ b/api/@ohos.ability.particleAbility.d.ts @@ -65,7 +65,7 @@ declare namespace particleAbility { * Keep this Service ability in the background and display a notification bar. * * @since 7 - * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask * @permission ohos.permission.KEEP_BACKGROUND_RUNNING * @param id Identifies the notification bar information. * @param request Indicates the notificationRequest instance containing information for displaying a notification bar. @@ -78,7 +78,7 @@ declare namespace particleAbility { * Cancel background running of this ability to free up system memory. * * @since 7 - * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask * @deprecated */ function cancelBackgroundRunning(callback: AsyncCallback): void; diff --git a/api/@ohos.backgroundTaskManager.d.ts b/api/@ohos.backgroundTaskManager.d.ts index 6ee0265d8c..7a2dabdfaa 100644 --- a/api/@ohos.backgroundTaskManager.d.ts +++ b/api/@ohos.backgroundTaskManager.d.ts @@ -83,7 +83,7 @@ declare namespace backgroundTaskManager { * system will publish a notification related to the this service. * * @since 8 - * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask * @permission ohos.permission.KEEP_BACKGROUND_RUNNING * @param context app running context. * @param bgMode Indicates which background mode to request. @@ -96,7 +96,7 @@ declare namespace backgroundTaskManager { * Service ability uses this method to request stop running in background. * * @since 8 - * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask * @param context app running context. */ function stopBackgroundRunning(context: Context, callback: AsyncCallback): void; @@ -106,14 +106,14 @@ declare namespace backgroundTaskManager { * supported background mode. * * @since 8 - * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ export enum BackgroundMode { /** * data transfer mode * * @since 8 - * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ DATA_TRANSFER = 1, @@ -121,7 +121,7 @@ declare namespace backgroundTaskManager { * audio playback mode * * @since 8 - * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ AUDIO_PLAYBACK = 2, @@ -129,7 +129,7 @@ declare namespace backgroundTaskManager { * audio recording mode * * @since 8 - * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ AUDIO_RECORDING = 3, @@ -137,7 +137,7 @@ declare namespace backgroundTaskManager { * location mode * * @since 8 - * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ LOCATION = 4, @@ -145,7 +145,7 @@ declare namespace backgroundTaskManager { * bluetooth interaction mode * * @since 8 - * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ BLUETOOTH_INTERACTION = 5, @@ -153,7 +153,7 @@ declare namespace backgroundTaskManager { * multi-device connection mode * * @since 8 - * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ MULTI_DEVICE_CONNECTION = 6, @@ -161,7 +161,7 @@ declare namespace backgroundTaskManager { * wifi interaction mode * * @since 8 - * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask * @systemapi Hide this for inner system use. */ WIFI_INTERACTION = 7, @@ -170,7 +170,7 @@ declare namespace backgroundTaskManager { * Voice over Internet Phone mode * * @since 8 - * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask * @systemapi Hide this for inner system use. */ VOIP = 8, @@ -180,7 +180,7 @@ declare namespace backgroundTaskManager { * only supported in portable computer device * * @since 8 - * @sysCap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask */ TASK_KEEPING = 9, } -- Gitee From 4b8ab5f21d2732c0c583c431f142251dc3822838 Mon Sep 17 00:00:00 2001 From: zhangxin_T Date: Mon, 14 Feb 2022 17:35:40 +0800 Subject: [PATCH 6/6] add FAModelOnly label Signed-off-by: zhangxin_T --- api/@ohos.ability.particleAbility.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/@ohos.ability.particleAbility.d.ts b/api/@ohos.ability.particleAbility.d.ts index 706c753b9b..5c8a142e56 100644 --- a/api/@ohos.ability.particleAbility.d.ts +++ b/api/@ohos.ability.particleAbility.d.ts @@ -69,6 +69,7 @@ declare namespace particleAbility { * @permission ohos.permission.KEEP_BACKGROUND_RUNNING * @param id Identifies the notification bar information. * @param request Indicates the notificationRequest instance containing information for displaying a notification bar. + * @FAModelOnly * @deprecated */ function startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback): void; @@ -79,6 +80,7 @@ declare namespace particleAbility { * * @since 7 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @FAModelOnly * @deprecated */ function cancelBackgroundRunning(callback: AsyncCallback): void; -- Gitee