1/* 2 * Copyright (c) 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 BasicServicesKit 19 */ 20 21import { AsyncCallback } from './@ohos.base'; 22import Want from './@ohos.app.ability.Want'; 23import ExtensionContext from './application/ExtensionContext'; 24 25/** 26 * class of static subscriber extension context. 27 * 28 * @extends ExtensionContext 29 * @syscap SystemCapability.Ability.AbilityRuntime.Core 30 * @systemapi 31 * @StageModelOnly 32 * @since 10 33 */ 34export default class StaticSubscriberExtensionContext extends ExtensionContext { 35 /** 36 * Starts a new ability. If the caller application is in foreground, you can use this method to start ability; 37 * If the caller application is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 38 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 39 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 40 * 41 * @permission ohos.permission.START_ABILITIES_FROM_BACKGROUND 42 * @param { Want } want - Indicates the ability to start. 43 * @param { AsyncCallback<void> } callback - The callback of startAbility. 44 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 45 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 46 * @throws { BusinessError } 401 - Params error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 47 * @throws { BusinessError } 16000001 - The specified ability does not exist. 48 * @throws { BusinessError } 16000002 - Incorrect ability type. 49 * @throws { BusinessError } 16000004 - Can not start 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 } 16000009 - An ability cannot be started or stopped in Wukong mode. 54 * @throws { BusinessError } 16000011 - The context does not exist. 55 * @throws { BusinessError } 16000050 - Internal error. 56 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 57 * @throws { BusinessError } 16000055 - Installation-free timed out. 58 * @throws { BusinessError } 16200001 - The caller has been released. 59 * @throws { BusinessError } 16300003 - The target application is not self application. 60 * @syscap SystemCapability.Ability.AbilityRuntime.Core 61 * @systemapi 62 * @StageModelOnly 63 * @since 10 64 */ 65 startAbility(want: Want, callback: AsyncCallback<void>): void; 66 67 /** 68 * Starts a new ability. If the caller application is in foreground, you can use this method to start ability; 69 * If the caller application is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 70 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 71 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 72 * 73 * @permission ohos.permission.START_ABILITIES_FROM_BACKGROUND 74 * @param { Want } want - Indicates the ability to start. 75 * @returns { Promise<void> } The promise returned by the function. 76 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 77 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 78 * @throws { BusinessError } 401 - Params error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 79 * @throws { BusinessError } 16000001 - The specified ability does not exist. 80 * @throws { BusinessError } 16000002 - Incorrect ability type. 81 * @throws { BusinessError } 16000004 - Can not start invisible component. 82 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 83 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 84 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 85 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 86 * @throws { BusinessError } 16000011 - The context does not exist. 87 * @throws { BusinessError } 16000050 - Internal error. 88 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 89 * @throws { BusinessError } 16000055 - Installation-free timed out. 90 * @throws { BusinessError } 16200001 - The caller has been released. 91 * @throws { BusinessError } 16300003 - The target application is not self application. 92 * @syscap SystemCapability.Ability.AbilityRuntime.Core 93 * @systemapi 94 * @StageModelOnly 95 * @since 10 96 */ 97 startAbility(want: Want): Promise<void>; 98} 99