1/* 2 * Copyright (c) 2023-2024 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 ExtensionContext from './ExtensionContext'; 22import type Want from '../@ohos.app.ability.Want'; 23 24/** 25 * The context of work scheduler extension. It allows access to 26 * WorkSchedulerExtensionContext-specific resources. 27 * 28 * @extends ExtensionContext 29 * @syscap SystemCapability.ResourceSchedule.WorkScheduler 30 * @StageModelOnly 31 * @since 10 32 */ 33declare class WorkSchedulerExtensionContext extends ExtensionContext { 34 /** 35 * Starts a new service extension ability. 36 * If the target service extension ability is visible, you can start the target service extension ability; 37 * If the target service extension ability is invisible, 38 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible service extension ability. 39 * If the target service extension ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 40 * 41 * @param { Want } want - Indicates the want info to start. 42 * @returns { Promise<void> } The promise returned by the function. 43 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 44 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 45 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 46 * 2. Incorrect parameter types; 3. Parameter verification failed. 47 * @throws { BusinessError } 16000001 - The specified ability does not exist. 48 * @throws { BusinessError } 16000002 - Incorrect ability type. 49 * @throws { BusinessError } 16000004 - Cannot start an invisible component. 50 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 51 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 52 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 53 * @throws { BusinessError } 16000011 - The context does not exist. 54 * @throws { BusinessError } 16000012 - The application is controlled. 55 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 56 * @throws { BusinessError } 16000050 - Internal error. 57 * @throws { BusinessError } 16200001 - The caller has been released. 58 * @syscap SystemCapability.ResourceSchedule.WorkScheduler 59 * @systemapi 60 * @stagemodelonly 61 * @since 13 62 */ 63 startServiceExtensionAbility(want: Want): Promise<void>; 64 65 /** 66 * Stops other service extension ability. 67 * If the target service extension ability is visible, you can stop the target service extension ability; 68 * If the target service extension ability is invisible, 69 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to stop target invisible service extension ability. 70 * If the target service extension ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 71 * 72 * @param { Want } want - Indicates the want info to stop. 73 * @returns { Promise<void> } The promise returned by the function. 74 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 75 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 76 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 77 * 2. Incorrect parameter types; 3. Parameter verification failed. 78 * @throws { BusinessError } 16000001 - The specified ability does not exist. 79 * @throws { BusinessError } 16000002 - Incorrect ability type. 80 * @throws { BusinessError } 16000004 - Cannot start an invisible component. 81 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 82 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 83 * @throws { BusinessError } 16000011 - The context does not exist. 84 * @throws { BusinessError } 16000050 - Internal error. 85 * @throws { BusinessError } 16200001 - The caller has been released. 86 * @syscap SystemCapability.ResourceSchedule.WorkScheduler 87 * @systemapi 88 * @stagemodelonly 89 * @since 13 90 */ 91 stopServiceExtensionAbility(want: Want): Promise<void>; 92} 93/** 94 * Define a WorkSchedulerExtensionContext. 95 * 96 * @typedef { WorkSchedulerExtensionContext } 97 * @syscap SystemCapability.ResourceSchedule.WorkScheduler 98 * @stagemodelonly 99 * @since 10 100 */ 101export default WorkSchedulerExtensionContext;