diff --git a/api/@ohos.ability.particleAbility.d.ts b/api/@ohos.ability.particleAbility.d.ts index 74ff1629758d38c4ca40797e4f2dc5c3cf0149ee..a116c66ed283b05659ea92dcd6b31d14751908ee 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 AAFwk + * @param id Indicates the declared background mode + * @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 AAFwk + * @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..729a9a689ee4a92dbd2c8fc355f3c113ab9b31a5 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