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