1/* 2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit BackgroundTasksKit 19 */ 20 21import workScheduler from './@ohos.resourceschedule.workScheduler'; 22import { WorkSchedulerExtensionContext as _WorkSchedulerExtensionContext } from './application/WorkSchedulerExtensionContext'; 23 24/** 25 * The context of work scheduler extension. It allows access to 26 * WorkSchedulerExtensionContext-specific resources. 27 * 28 * @typedef { _WorkSchedulerExtensionContext } 29 * @syscap SystemCapability.ResourceSchedule.WorkScheduler 30 * @StageModelOnly 31 * @since 10 32 */ 33export type WorkSchedulerExtensionContext = _WorkSchedulerExtensionContext; 34 35/** 36 * Class of the work scheduler extension ability. 37 * 38 * @syscap SystemCapability.ResourceSchedule.WorkScheduler 39 * @StageModelOnly 40 * @since 9 41 */ 42export default class WorkSchedulerExtensionAbility { 43 /** 44 * Indicates work scheduler extension ability context. 45 * 46 * @type { WorkSchedulerExtensionContext } 47 * @syscap SystemCapability.ResourceSchedule.WorkScheduler 48 * @StageModelOnly 49 * @since 10 50 */ 51 context: WorkSchedulerExtensionContext; 52 53 /** 54 * Called back when a work is started. 55 * 56 * @param {workScheduler.WorkInfo} work - The info of work. 57 * @syscap SystemCapability.ResourceSchedule.WorkScheduler 58 * @StageModelOnly 59 * @since 9 60 */ 61 onWorkStart(work: workScheduler.WorkInfo): void; 62 63 /** 64 * Called back when a work is stopped. 65 * 66 * @param {workScheduler.WorkInfo} work - The info of work. 67 * @syscap SystemCapability.ResourceSchedule.WorkScheduler 68 * @StageModelOnly 69 * @since 9 70 */ 71 onWorkStop(work: workScheduler.WorkInfo): void; 72} 73