diff --git a/api/@ohos.ability.particleAbility.d.ts b/api/@ohos.ability.particleAbility.d.ts index 74ff1629758d38c4ca40797e4f2dc5c3cf0149ee..5c8a142e5625178c802f323f9039ac520f80aa30 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; + + /** + * Keep this Service ability in the background and display a notification bar. + * + * @since 7 + * @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. + * @FAModelOnly + * @deprecated + */ + function startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback): void; + function startBackgroundRunning(id: number, request: NotificationRequest): Promise; + + /** + * Cancel background running of this ability to free up system memory. + * + * @since 7 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @FAModelOnly + * @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 85bd32ad33e3ee19b783488db1622757c543a006..7a2dabdfaafcbae93b79aa81647168a9893b550e 100644 --- a/api/@ohos.backgroundTaskManager.d.ts +++ b/api/@ohos.backgroundTaskManager.d.ts @@ -14,6 +14,8 @@ */ import { AsyncCallback , Callback} from './basic'; +import { WantAgent } from "./@ohos.wantAgent"; +import { Context } from './app/context'; /** * Manages background tasks. @@ -75,6 +77,113 @@ 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. + * + * @since 8 + * @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 bar. + */ + 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. + * + * @since 8 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @param context app running context. + */ + function stopBackgroundRunning(context: Context, callback: AsyncCallback): void; + function stopBackgroundRunning(context: Context): Promise; + + /** + * supported background mode. + * + * @since 8 + * @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, + + /** + * Voice over Internet Phone mode + * + * @since 8 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @systemapi Hide this for inner system use. + */ + VOIP = 8, + + /** + * background continuous calculate mode, for example 3D render. + * only supported in portable computer device + * + * @since 8 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + TASK_KEEPING = 9, + } } export default backgroundTaskManager; \ No newline at end of file