!14805 长时任务on接口

Merge pull request !14805 from lipengfei/cherry-pick-1732073494
This commit is contained in:
openharmony_ci 2024-11-21 09:38:49 +00:00 committed by Gitee
commit 7ca07f3680
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -101,6 +101,40 @@ declare namespace backgroundTaskManager {
* @since 12
*/
notificationId: number;
/**
* The continuous task id.
* @type { ?number }
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
continuousTaskId?: number;
}
/**
* The continuous task cancel info.
*
* @interface ContinuousTaskCancelInfo
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
interface ContinuousTaskCancelInfo {
/**
* The cancel reason of continuous task.
*
* @type { ContinuousTaskCancelReason }
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
reason: ContinuousTaskCancelReason;
/**
* The id of cancelled continuous task.
*
* @type { number }
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
id: number;
}
/**
@ -431,6 +465,34 @@ declare namespace backgroundTaskManager {
*/
function resetAllEfficiencyResources(): void;
/**
* Register continuous task cancel callback.
*
* @permission ohos.permission.KEEP_BACKGROUND_RUNNING
* @param { 'continuousTaskCancel' } type - The type of continuous task cancel.
* @param { Callback<ContinuousTaskCancelInfo> } callback - the callback of continuous task cancel.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Callback parameter error;
* <br> 2. Register a exist callback type; 3. Parameter verification failed.
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
function on(type: 'continuousTaskCancel', callback: Callback<ContinuousTaskCancelInfo>): void;
/**
* Unregister continuous task cancel callback.
*
* @permission ohos.permission.KEEP_BACKGROUND_RUNNING
* @param { 'continuousTaskCancel' } type - The type of continuous task cancel.
* @param { Callback<ContinuousTaskCancelInfo> } callback - the callback of continuous task cancel.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Callback parameter error;
* <br> 2. Unregister type has not register; 3. Parameter verification failed.
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
function off(type: 'continuousTaskCancel', callback?: Callback<ContinuousTaskCancelInfo>): void;
/**
* Supported background mode.
*
@ -696,6 +758,101 @@ declare namespace backgroundTaskManager {
*/
reason: string;
}
/**
* The type of continuous task cancel reason.
*
* @enum { number }
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
export enum ContinuousTaskCancelReason {
/**
* User cancel.
*
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
USER_CANCEL = 1,
/**
* System cancel.
*
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
SYSTEM_CANCEL = 2,
/**
* User remove notification.
*
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
USER_CANCEL_REMOVE_NOTIFICATION = 3,
/**
* Low network speed when request data transfer mode.
*
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
SYSTEM_CANCEL_DATA_TRANSFER_LOW_SPEED = 4,
/**
* Not use avsession when request audio playback mode.
*
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
SYSTEM_CANCEL_AUDIO_PLAYBACK_NOT_USE_AVSESSION = 5,
/**
* Audio is not running when request audio playback mode.
*
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
SYSTEM_CANCEL_AUDIO_PLAYBACK_NOT_RUNNING = 6,
/**
* Audio is not running when request audio recording mode.
*
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
SYSTEM_CANCEL_AUDIO_RECORDING_NOT_RUNNING = 7,
/**
* Not use location when request location mode.
*
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
SYSTEM_CANCEL_NOT_USE_LOCATION = 8,
/**
* Not use bluetooth when request bluetooth interaction mode.
*
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
SYSTEM_CANCEL_NOT_USE_BLUETOOTH = 9,
/**
* Not use multi device when request multi-device connection mode.
*
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
SYSTEM_CANCEL_NOT_USE_MULTI_DEVICE = 10,
/**
* Use some mode illegally.
*
* @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
* @since 16
*/
SYSTEM_CANCEL_USE_ILLEGALLY = 11,
}
}
export default backgroundTaskManager;