From cbc5fdf08d1ff97fa5456a232bd4a756387f276c Mon Sep 17 00:00:00 2001 From: zhangxin_T Date: Fri, 21 Jan 2022 18:22:08 +0800 Subject: [PATCH 1/3] add continuous task interface. --- api/@ohos.ability.particleAbility.d.ts | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/api/@ohos.ability.particleAbility.d.ts b/api/@ohos.ability.particleAbility.d.ts index 74ff162975..c8cc24d1a3 100644 --- a/api/@ohos.ability.particleAbility.d.ts +++ b/api/@ohos.ability.particleAbility.d.ts @@ -16,6 +16,8 @@ import { AsyncCallback } from './basic'; import { StartAbilityParameter } from './ability/startAbilityParameter'; import { DataAbilityHelper } from './ability/dataAbilityHelper'; +import { NotificationRequest } from './notification/notificationRequest'; +import { WantAgent } from "./@ohos.wantAgent"; /** * A Particle Ability represents an ability with service. @@ -59,5 +61,45 @@ 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 AAFwk + * @param id Indicates the declared background mode + * @param request the notification related to the this service. + * @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 keep running in background. + * system will publish a notification related to the this service when condition is met. + * each ability will only allowed to declare one type background mode. + * + * @devices phone, tablet + * @since 8 + * @sysCap AAFwk + * @param wantAgent Indicates which ability to start when user click the notification. + * @return - + */ + function startBackgroundRunning(wantAgent: WantAgent, callback: AsyncCallback): void; + function startBackgroundRunning(wantAgent: WantAgent): Promise; + + /** + * Service ability uses this method to request cancel running in background. + * + * @devices phone, tablet + * @since 7 + * @sysCap AAFwk + * @return - + */ + function cancelBackgroundRunning(callback: AsyncCallback): void; + function cancelBackgroundRunning(): Promise; } export default particleAbility; -- Gitee From 8f3aa4f35c6c8919e56f7e45845a161f6714bc65 Mon Sep 17 00:00:00 2001 From: zhangxin_T Date: Sun, 23 Jan 2022 14:49:30 +0800 Subject: [PATCH 2/3] add api 8 interface to backgroundTaskManager module. --- api/@ohos.ability.particleAbility.d.ts | 18 +----- api/@ohos.backgroundTaskManager.d.ts | 79 ++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 17 deletions(-) diff --git a/api/@ohos.ability.particleAbility.d.ts b/api/@ohos.ability.particleAbility.d.ts index c8cc24d1a3..a116c66ed2 100644 --- a/api/@ohos.ability.particleAbility.d.ts +++ b/api/@ohos.ability.particleAbility.d.ts @@ -17,7 +17,6 @@ import { AsyncCallback } from './basic'; import { StartAbilityParameter } from './ability/startAbilityParameter'; import { DataAbilityHelper } from './ability/dataAbilityHelper'; import { NotificationRequest } from './notification/notificationRequest'; -import { WantAgent } from "./@ohos.wantAgent"; /** * A Particle Ability represents an ability with service. @@ -71,33 +70,18 @@ declare namespace particleAbility { * @sysCap AAFwk * @param id Indicates the declared background mode * @param request the notification related to the this service. - * @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 keep running in background. - * system will publish a notification related to the this service when condition is met. - * each ability will only allowed to declare one type background mode. - * - * @devices phone, tablet - * @since 8 - * @sysCap AAFwk - * @param wantAgent Indicates which ability to start when user click the notification. - * @return - - */ - function startBackgroundRunning(wantAgent: WantAgent, callback: AsyncCallback): void; - function startBackgroundRunning(wantAgent: WantAgent): Promise; - /** * Service ability uses this method to request cancel running in background. * * @devices phone, tablet * @since 7 * @sysCap AAFwk - * @return - + * @deprecated */ function cancelBackgroundRunning(callback: AsyncCallback): void; function cancelBackgroundRunning(): Promise; 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 fb290786618fe2fb8f862908e73baac084bc5dbd Mon Sep 17 00:00:00 2001 From: zhangxin_T Date: Sun, 23 Jan 2022 14:49:30 +0800 Subject: [PATCH 3/3] add api 8 interface to backgroundTaskManager module. Signed-off-by: zhangxin_T --- api/@ohos.ability.particleAbility.d.ts | 18 +----- api/@ohos.backgroundTaskManager.d.ts | 79 ++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 17 deletions(-) diff --git a/api/@ohos.ability.particleAbility.d.ts b/api/@ohos.ability.particleAbility.d.ts index c8cc24d1a3..a116c66ed2 100644 --- a/api/@ohos.ability.particleAbility.d.ts +++ b/api/@ohos.ability.particleAbility.d.ts @@ -17,7 +17,6 @@ import { AsyncCallback } from './basic'; import { StartAbilityParameter } from './ability/startAbilityParameter'; import { DataAbilityHelper } from './ability/dataAbilityHelper'; import { NotificationRequest } from './notification/notificationRequest'; -import { WantAgent } from "./@ohos.wantAgent"; /** * A Particle Ability represents an ability with service. @@ -71,33 +70,18 @@ declare namespace particleAbility { * @sysCap AAFwk * @param id Indicates the declared background mode * @param request the notification related to the this service. - * @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 keep running in background. - * system will publish a notification related to the this service when condition is met. - * each ability will only allowed to declare one type background mode. - * - * @devices phone, tablet - * @since 8 - * @sysCap AAFwk - * @param wantAgent Indicates which ability to start when user click the notification. - * @return - - */ - function startBackgroundRunning(wantAgent: WantAgent, callback: AsyncCallback): void; - function startBackgroundRunning(wantAgent: WantAgent): Promise; - /** * Service ability uses this method to request cancel running in background. * * @devices phone, tablet * @since 7 * @sysCap AAFwk - * @return - + * @deprecated */ function cancelBackgroundRunning(callback: AsyncCallback): void; function cancelBackgroundRunning(): Promise; 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