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 AbilityKit 19 */ 20 21import type { AbilityResult } from '../ability/abilityResult'; 22import type { AsyncCallback } from '../@ohos.base'; 23import type { ConnectOptions } from '../ability/connectOptions'; 24import ExtensionContext from './ExtensionContext'; 25import type Want from '../@ohos.app.ability.Want'; 26import type StartOptions from '../@ohos.app.ability.StartOptions'; 27import type AtomicServiceOptions from '../@ohos.app.ability.AtomicServiceOptions'; 28import OpenLinkOptions from '../@ohos.app.ability.OpenLinkOptions'; 29import type ConfigurationConstant from '../@ohos.app.ability.ConfigurationConstant'; 30import type UIServiceProxy from './UIServiceProxy'; 31import type UIServiceExtensionConnectCallback from './UIServiceExtensionConnectCallback'; 32 33/** 34 * The context of UI extension. It allows access to UIExtension-specific resources. 35 * 36 * @extends ExtensionContext 37 * @syscap SystemCapability.Ability.AbilityRuntime.Core 38 * @stagemodelonly 39 * @since 10 40 */ 41export default class UIExtensionContext extends ExtensionContext { 42 /** 43 * UI extension uses this method to start a specific ability.If the caller application is in foreground, 44 * you can use this method to start ability; If the caller application is in the background, 45 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 46 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 47 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 48 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 49 * 50 * @param { Want } want - Indicates the ability to start. 51 * @param { AsyncCallback<void> } callback - The callback of startAbility. 52 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 53 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 54 * @throws { BusinessError } 16000001 - The specified ability does not exist. 55 * @throws { BusinessError } 16000002 - Incorrect ability type. 56 * @throws { BusinessError } 16000004 - Can not start invisible component. 57 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 58 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 59 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 60 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 61 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 62 * @throws { BusinessError } 16000011 - The context does not exist. 63 * @throws { BusinessError } 16000012 - The application is controlled. 64 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 65 * @throws { BusinessError } 16000050 - Internal error. 66 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 67 * @throws { BusinessError } 16000055 - Installation-free timed out. 68 * @throws { BusinessError } 16200001 - The caller has been released. 69 * @syscap SystemCapability.Ability.AbilityRuntime.Core 70 * @stagemodelonly 71 * @since 10 72 */ 73 /** 74 * UI extension uses this method to start a specific ability.If the caller application is in foreground, 75 * you can use this method to start ability; If the caller application is in the background, 76 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 77 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 78 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 79 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 80 * 81 * @param { Want } want - Indicates the ability to start. 82 * @param { AsyncCallback<void> } callback - The callback of startAbility. 83 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 84 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 85 * @throws { BusinessError } 16000001 - The specified ability does not exist. 86 * @throws { BusinessError } 16000002 - Incorrect ability type. 87 * @throws { BusinessError } 16000004 - Can not start invisible component. 88 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 89 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 90 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 91 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 92 * @throws { BusinessError } 16000010 - The call with the continuation and prepare continuation flag is forbidden. 93 * @throws { BusinessError } 16000011 - The context does not exist. 94 * @throws { BusinessError } 16000012 - The application is controlled. 95 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 96 * @throws { BusinessError } 16000018 - The application is not allow jumping to other applications. 97 * @throws { BusinessError } 16000019 - Can not match any component. 98 * @throws { BusinessError } 16000050 - Internal error. 99 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 100 * @throws { BusinessError } 16000055 - Installation-free timed out. 101 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 102 * @throws { BusinessError } 16000070 - The extension cannot start the service. 103 * @throws { BusinessError } 16000073 - The app clone index is invalid. 104 * @throws { BusinessError } 16200001 - The caller has been released. 105 * @syscap SystemCapability.Ability.AbilityRuntime.Core 106 * @stagemodelonly 107 * @since 12 108 */ 109 /** 110 * UI extension uses this method to start a specific ability.If the caller application is in foreground, 111 * you can use this method to start ability; If the caller application is in the background, 112 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 113 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 114 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 115 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 116 * 117 * @param { Want } want - Indicates the ability to start. 118 * @param { AsyncCallback<void> } callback - The callback of startAbility. 119 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 120 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 121 * @throws { BusinessError } 16000001 - The specified ability does not exist. 122 * @throws { BusinessError } 16000002 - Incorrect ability type. 123 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 124 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 125 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 126 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 127 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 128 * @throws { BusinessError } 16000010 - The call with the continuation and prepare continuation flag is forbidden. 129 * @throws { BusinessError } 16000011 - The context does not exist. 130 * @throws { BusinessError } 16000012 - The application is controlled. 131 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 132 * @throws { BusinessError } 16000018 - Redirection to a third-party application is not allowed in API version 11 or later. 133 * @throws { BusinessError } 16000019 - No matching ability is found. 134 * @throws { BusinessError } 16000050 - Internal error. 135 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 136 * @throws { BusinessError } 16000055 - Installation-free timed out. 137 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 138 * @throws { BusinessError } 16000070 - The extension cannot start the service. 139 * @throws { BusinessError } 16000071 - App clone is not supported. 140 * @throws { BusinessError } 16000072 - App clone or multi-instance is not supported. 141 * @throws { BusinessError } 16000073 - The app clone index is invalid. 142 * @throws { BusinessError } 16000076 - The app instance key is invalid. 143 * @throws { BusinessError } 16000077 - The number of app instances reaches the limit. 144 * @throws { BusinessError } 16000078 - The multi-instance is not supported. 145 * @throws { BusinessError } 16000079 - The APP_INSTANCE_KEY cannot be specified. 146 * @throws { BusinessError } 16000080 - Creating a new instance is not supported. 147 * @throws { BusinessError } 16200001 - The caller has been released. 148 * @syscap SystemCapability.Ability.AbilityRuntime.Core 149 * @stagemodelonly 150 * @since 14 151 */ 152 startAbility(want: Want, callback: AsyncCallback<void>): void; 153 154 /** 155 * UI extension uses this method to start a specific ability.If the caller application is in foreground, 156 * you can use this method to start ability; If the caller application is in the background, 157 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 158 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 159 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 160 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 161 * 162 * @param { Want } want - Indicates the ability to start. 163 * @param { StartOptions } options - Indicates the start options. 164 * @param { AsyncCallback<void> } callback - The callback of startAbility. 165 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 166 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 167 * @throws { BusinessError } 16000001 - The specified ability does not exist. 168 * @throws { BusinessError } 16000004 - Can not start invisible component. 169 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 170 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 171 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 172 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 173 * @throws { BusinessError } 16000011 - The context does not exist. 174 * @throws { BusinessError } 16000012 - The application is controlled. 175 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 176 * @throws { BusinessError } 16000050 - Internal error. 177 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 178 * @throws { BusinessError } 16000055 - Installation-free timed out. 179 * @throws { BusinessError } 16200001 - The caller has been released. 180 * @syscap SystemCapability.Ability.AbilityRuntime.Core 181 * @stagemodelonly 182 * @since 10 183 */ 184 /** 185 * UI extension uses this method to start a specific ability.If the caller application is in foreground, 186 * you can use this method to start ability; If the caller application is in the background, 187 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 188 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 189 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 190 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 191 * 192 * @param { Want } want - Indicates the ability to start. 193 * @param { StartOptions } options - Indicates the start options. 194 * @param { AsyncCallback<void> } callback - The callback of startAbility. 195 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 196 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 197 * @throws { BusinessError } 16000001 - The specified ability does not exist. 198 * @throws { BusinessError } 16000004 - Can not start invisible component. 199 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 200 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 201 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 202 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 203 * @throws { BusinessError } 16000011 - The context does not exist. 204 * @throws { BusinessError } 16000012 - The application is controlled. 205 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 206 * @throws { BusinessError } 16000018 - The application is not allow jumping to other applications. 207 * @throws { BusinessError } 16000019 - Can not match any component. 208 * @throws { BusinessError } 16000050 - Internal error. 209 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 210 * @throws { BusinessError } 16000055 - Installation-free timed out. 211 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 212 * @throws { BusinessError } 16000070 - The extension cannot start the service. 213 * @throws { BusinessError } 16000073 - The app clone index is invalid. 214 * @throws { BusinessError } 16200001 - The caller has been released. 215 * @syscap SystemCapability.Ability.AbilityRuntime.Core 216 * @stagemodelonly 217 * @since 12 218 */ 219 /** 220 * UI extension uses this method to start a specific ability.If the caller application is in foreground, 221 * you can use this method to start ability; If the caller application is in the background, 222 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 223 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 224 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 225 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 226 * 227 * @param { Want } want - Indicates the ability to start. 228 * @param { StartOptions } options - Indicates the start options. 229 * @param { AsyncCallback<void> } callback - The callback of startAbility. 230 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 231 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 232 * @throws { BusinessError } 16000001 - The specified ability does not exist. 233 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 234 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 235 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 236 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 237 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 238 * @throws { BusinessError } 16000011 - The context does not exist. 239 * @throws { BusinessError } 16000012 - The application is controlled. 240 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 241 * @throws { BusinessError } 16000018 - Redirection to a third-party application is not allowed in API version 11 or later. 242 * @throws { BusinessError } 16000019 - No matching ability is found. 243 * @throws { BusinessError } 16000050 - Internal error. 244 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 245 * @throws { BusinessError } 16000055 - Installation-free timed out. 246 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 247 * @throws { BusinessError } 16000070 - The extension cannot start the service. 248 * @throws { BusinessError } 16000071 - App clone is not supported. 249 * @throws { BusinessError } 16000072 - App clone or multi-instance is not supported. 250 * @throws { BusinessError } 16000073 - The app clone index is invalid. 251 * @throws { BusinessError } 16000076 - The app instance key is invalid. 252 * @throws { BusinessError } 16000077 - The number of app instances reaches the limit. 253 * @throws { BusinessError } 16000078 - The multi-instance is not supported. 254 * @throws { BusinessError } 16000079 - The APP_INSTANCE_KEY cannot be specified. 255 * @throws { BusinessError } 16000080 - Creating a new instance is not supported. 256 * @throws { BusinessError } 16200001 - The caller has been released. 257 * @syscap SystemCapability.Ability.AbilityRuntime.Core 258 * @stagemodelonly 259 * @since 14 260 */ 261 startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void; 262 263 /** 264 * UI extension uses this method to start a specific ability.If the caller application is in foreground, 265 * you can use this method to start ability; If the caller application is in the background, 266 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 267 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 268 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 269 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 270 * 271 * @param { Want } want - Indicates the ability to start. 272 * @param { StartOptions } [options] - Indicates the start options. 273 * @returns { Promise<void> } The promise returned by the function. 274 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 275 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 276 * @throws { BusinessError } 16000001 - The specified ability does not exist. 277 * @throws { BusinessError } 16000002 - Incorrect ability type. 278 * @throws { BusinessError } 16000004 - Can not start invisible component. 279 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 280 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 281 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 282 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 283 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 284 * @throws { BusinessError } 16000011 - The context does not exist. 285 * @throws { BusinessError } 16000012 - The application is controlled. 286 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 287 * @throws { BusinessError } 16000050 - Internal error. 288 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 289 * @throws { BusinessError } 16000055 - Installation-free timed out. 290 * @throws { BusinessError } 16200001 - The caller has been released. 291 * @syscap SystemCapability.Ability.AbilityRuntime.Core 292 * @stagemodelonly 293 * @since 10 294 */ 295 /** 296 * UI extension uses this method to start a specific ability.If the caller application is in foreground, 297 * you can use this method to start ability; If the caller application is in the background, 298 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 299 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 300 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 301 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 302 * 303 * @param { Want } want - Indicates the ability to start. 304 * @param { StartOptions } [options] - Indicates the start options. 305 * @returns { Promise<void> } The promise returned by the function. 306 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 307 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 308 * @throws { BusinessError } 16000001 - The specified ability does not exist. 309 * @throws { BusinessError } 16000002 - Incorrect ability type. 310 * @throws { BusinessError } 16000004 - Can not start invisible component. 311 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 312 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 313 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 314 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 315 * @throws { BusinessError } 16000010 - The call with the continuation and prepare continuation flag is forbidden. 316 * @throws { BusinessError } 16000011 - The context does not exist. 317 * @throws { BusinessError } 16000012 - The application is controlled. 318 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 319 * @throws { BusinessError } 16000018 - The application is not allow jumping to other applications. 320 * @throws { BusinessError } 16000019 - Can not match any component. 321 * @throws { BusinessError } 16000050 - Internal error. 322 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 323 * @throws { BusinessError } 16000055 - Installation-free timed out. 324 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 325 * @throws { BusinessError } 16000070 - The extension cannot start the service. 326 * @throws { BusinessError } 16000073 - The app clone index is invalid. 327 * @throws { BusinessError } 16200001 - The caller has been released. 328 * @syscap SystemCapability.Ability.AbilityRuntime.Core 329 * @stagemodelonly 330 * @since 12 331 */ 332 /** 333 * UI extension uses this method to start a specific ability.If the caller application is in foreground, 334 * you can use this method to start ability; If the caller application is in the background, 335 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 336 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 337 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 338 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 339 * 340 * @param { Want } want - Indicates the ability to start. 341 * @param { StartOptions } [options] - Indicates the start options. 342 * @returns { Promise<void> } The promise returned by the function. 343 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 344 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 345 * @throws { BusinessError } 16000001 - The specified ability does not exist. 346 * @throws { BusinessError } 16000002 - Incorrect ability type. 347 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 348 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 349 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 350 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 351 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 352 * @throws { BusinessError } 16000010 - The call with the continuation and prepare continuation flag is forbidden. 353 * @throws { BusinessError } 16000011 - The context does not exist. 354 * @throws { BusinessError } 16000012 - The application is controlled. 355 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 356 * @throws { BusinessError } 16000018 - Redirection to a third-party application is not allowed in API version 11 or later. 357 * @throws { BusinessError } 16000019 - No matching ability is found. 358 * @throws { BusinessError } 16000050 - Internal error. 359 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 360 * @throws { BusinessError } 16000055 - Installation-free timed out. 361 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 362 * @throws { BusinessError } 16000070 - The extension cannot start the service. 363 * @throws { BusinessError } 16000071 - App clone is not supported. 364 * @throws { BusinessError } 16000072 - App clone or multi-instance is not supported. 365 * @throws { BusinessError } 16000073 - The app clone index is invalid. 366 * @throws { BusinessError } 16000076 - The app instance key is invalid. 367 * @throws { BusinessError } 16000077 - The number of app instances reaches the limit. 368 * @throws { BusinessError } 16000078 - The multi-instance is not supported. 369 * @throws { BusinessError } 16000079 - The APP_INSTANCE_KEY cannot be specified. 370 * @throws { BusinessError } 16000080 - Creating a new instance is not supported. 371 * @throws { BusinessError } 16200001 - The caller has been released. 372 * @syscap SystemCapability.Ability.AbilityRuntime.Core 373 * @stagemodelonly 374 * @since 14 375 */ 376 startAbility(want: Want, options?: StartOptions): Promise<void>; 377 378 /** 379 * UI extension uses this method to start a specific ability by implicit want.If the caller application is in foreground, 380 * you can use this method to start ability; If the caller application is in the background, 381 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 382 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 383 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 384 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 385 * 386 * @param { string } link - Indicates the ability to start. 387 * @param { OpenLinkOptions } [options] - Indicates the open link options. 388 * @param { AsyncCallback<AbilityResult> } [callback] - The callback is used to return the ability result. 389 * @returns { Promise<void> } The promise returned by the function. 390 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 391 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 392 * @throws { BusinessError } 16000001 - The specified ability does not exist. 393 * @throws { BusinessError } 16000002 - Incorrect ability type. 394 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 395 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 396 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 397 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 398 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 399 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 400 * @throws { BusinessError } 16000011 - The context does not exist. 401 * @throws { BusinessError } 16000012 - The application is controlled. 402 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 403 * @throws { BusinessError } 16000019 - No matching ability is found. 404 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 405 * @throws { BusinessError } 16200001 - The caller has been released. 406 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 407 * @syscap SystemCapability.Ability.AbilityRuntime.Core 408 * @stagemodelonly 409 * @since 12 410 */ 411 openLink(link: string, options?: OpenLinkOptions, callback?: AsyncCallback<AbilityResult>): Promise<void>; 412 413 /** 414 * Starts an ability and returns the execution result when the ability is destroyed. 415 * If the caller application is in foreground, you can use this method to start ability; If the caller application 416 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 417 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 418 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 419 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 420 * 421 * @param { Want } want - Indicates the ability to start. 422 * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility. 423 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 424 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 425 * @throws { BusinessError } 16000001 - The specified ability does not exist. 426 * @throws { BusinessError } 16000002 - Incorrect ability type. 427 * @throws { BusinessError } 16000004 - Can not start invisible component. 428 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 429 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 430 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 431 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 432 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 433 * @throws { BusinessError } 16000011 - The context does not exist. 434 * @throws { BusinessError } 16000012 - The application is controlled. 435 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 436 * @throws { BusinessError } 16000050 - Internal error. 437 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 438 * @throws { BusinessError } 16000055 - Installation-free timed out. 439 * @throws { BusinessError } 16200001 - The caller has been released. 440 * @syscap SystemCapability.Ability.AbilityRuntime.Core 441 * @stagemodelonly 442 * @since 10 443 */ 444 /** 445 * Starts an ability and returns the execution result when the ability is destroyed. 446 * If the caller application is in foreground, you can use this method to start ability; If the caller application 447 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 448 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 449 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 450 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 451 * 452 * @param { Want } want - Indicates the ability to start. 453 * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility. 454 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 455 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 456 * @throws { BusinessError } 16000001 - The specified ability does not exist. 457 * @throws { BusinessError } 16000002 - Incorrect ability type. 458 * @throws { BusinessError } 16000004 - Can not start invisible component. 459 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 460 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 461 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 462 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 463 * @throws { BusinessError } 16000010 - The call with the continuation and prepare continuation flag is forbidden. 464 * @throws { BusinessError } 16000011 - The context does not exist. 465 * @throws { BusinessError } 16000012 - The application is controlled. 466 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 467 * @throws { BusinessError } 16000018 - The application is not allow jumping to other applications. 468 * @throws { BusinessError } 16000019 - Can not match any component. 469 * @throws { BusinessError } 16000050 - Internal error. 470 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 471 * @throws { BusinessError } 16000055 - Installation-free timed out. 472 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 473 * @throws { BusinessError } 16000070 - The extension cannot start the service. 474 * @throws { BusinessError } 16000073 - The app clone index is invalid. 475 * @throws { BusinessError } 16200001 - The caller has been released. 476 * @syscap SystemCapability.Ability.AbilityRuntime.Core 477 * @stagemodelonly 478 * @since 12 479 */ 480 /** 481 * Starts an ability and returns the execution result when the ability is destroyed. 482 * If the caller application is in foreground, you can use this method to start ability; If the caller application 483 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 484 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 485 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 486 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 487 * 488 * @param { Want } want - Indicates the ability to start. 489 * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility. 490 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 491 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 492 * @throws { BusinessError } 16000001 - The specified ability does not exist. 493 * @throws { BusinessError } 16000002 - Incorrect ability type. 494 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 495 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 496 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 497 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 498 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 499 * @throws { BusinessError } 16000010 - The call with the continuation and prepare continuation flag is forbidden. 500 * @throws { BusinessError } 16000011 - The context does not exist. 501 * @throws { BusinessError } 16000012 - The application is controlled. 502 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 503 * @throws { BusinessError } 16000018 - Redirection to a third-party application is not allowed in API version 11 or later. 504 * @throws { BusinessError } 16000019 - No matching ability is found. 505 * @throws { BusinessError } 16000050 - Internal error. 506 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 507 * @throws { BusinessError } 16000055 - Installation-free timed out. 508 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 509 * @throws { BusinessError } 16000070 - The extension cannot start the service. 510 * @throws { BusinessError } 16000071 - App clone is not supported. 511 * @throws { BusinessError } 16000072 - App clone or multi-instance is not supported. 512 * @throws { BusinessError } 16000073 - The app clone index is invalid. 513 * @throws { BusinessError } 16000076 - The app instance key is invalid. 514 * @throws { BusinessError } 16000077 - The number of app instances reaches the limit. 515 * @throws { BusinessError } 16000078 - The multi-instance is not supported. 516 * @throws { BusinessError } 16000079 - The APP_INSTANCE_KEY cannot be specified. 517 * @throws { BusinessError } 16000080 - Creating a new instance is not supported. 518 * @throws { BusinessError } 16200001 - The caller has been released. 519 * @syscap SystemCapability.Ability.AbilityRuntime.Core 520 * @stagemodelonly 521 * @since 14 522 */ 523 startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): void; 524 525 /** 526 * Starts an ability and returns the execution result when the ability is destroyed. 527 * If the caller application is in foreground, you can use this method to start ability; If the caller application 528 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 529 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 530 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 531 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 532 * 533 * @param { Want } want - Indicates the ability to start. 534 * @param { StartOptions } options - Indicates the start options. 535 * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility. 536 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 537 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 538 * @throws { BusinessError } 16000001 - The specified ability does not exist. 539 * @throws { BusinessError } 16000004 - Can not start invisible component. 540 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 541 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 542 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 543 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 544 * @throws { BusinessError } 16000011 - The context does not exist. 545 * @throws { BusinessError } 16000012 - The application is controlled. 546 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 547 * @throws { BusinessError } 16000050 - Internal error. 548 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 549 * @throws { BusinessError } 16000055 - Installation-free timed out. 550 * @throws { BusinessError } 16200001 - The caller has been released. 551 * @syscap SystemCapability.Ability.AbilityRuntime.Core 552 * @stagemodelonly 553 * @since 10 554 */ 555 /** 556 * Starts an ability and returns the execution result when the ability is destroyed. 557 * If the caller application is in foreground, you can use this method to start ability; If the caller application 558 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 559 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 560 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 561 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 562 * 563 * @param { Want } want - Indicates the ability to start. 564 * @param { StartOptions } options - Indicates the start options. 565 * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility. 566 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 567 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 568 * @throws { BusinessError } 16000001 - The specified ability does not exist. 569 * @throws { BusinessError } 16000004 - Can not start invisible component. 570 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 571 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 572 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 573 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 574 * @throws { BusinessError } 16000011 - The context does not exist. 575 * @throws { BusinessError } 16000012 - The application is controlled. 576 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 577 * @throws { BusinessError } 16000018 - The application is not allow jumping to other applications. 578 * @throws { BusinessError } 16000019 - Can not match any component. 579 * @throws { BusinessError } 16000050 - Internal error. 580 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 581 * @throws { BusinessError } 16000055 - Installation-free timed out. 582 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 583 * @throws { BusinessError } 16000070 - The extension cannot start the service. 584 * @throws { BusinessError } 16000073 - The app clone index is invalid. 585 * @throws { BusinessError } 16200001 - The caller has been released. 586 * @syscap SystemCapability.Ability.AbilityRuntime.Core 587 * @stagemodelonly 588 * @since 12 589 */ 590 /** 591 * Starts an ability and returns the execution result when the ability is destroyed. 592 * If the caller application is in foreground, you can use this method to start ability; If the caller application 593 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 594 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 595 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 596 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 597 * 598 * @param { Want } want - Indicates the ability to start. 599 * @param { StartOptions } options - Indicates the start options. 600 * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility. 601 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 602 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 603 * @throws { BusinessError } 16000001 - The specified ability does not exist. 604 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 605 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 606 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 607 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 608 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 609 * @throws { BusinessError } 16000011 - The context does not exist. 610 * @throws { BusinessError } 16000012 - The application is controlled. 611 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 612 * @throws { BusinessError } 16000018 - Redirection to a third-party application is not allowed in API version 11 or later. 613 * @throws { BusinessError } 16000019 - No matching ability is found. 614 * @throws { BusinessError } 16000050 - Internal error. 615 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 616 * @throws { BusinessError } 16000055 - Installation-free timed out. 617 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 618 * @throws { BusinessError } 16000070 - The extension cannot start the service. 619 * @throws { BusinessError } 16000071 - App clone is not supported. 620 * @throws { BusinessError } 16000072 - App clone or multi-instance is not supported. 621 * @throws { BusinessError } 16000073 - The app clone index is invalid. 622 * @throws { BusinessError } 16000076 - The app instance key is invalid. 623 * @throws { BusinessError } 16000077 - The number of app instances reaches the limit. 624 * @throws { BusinessError } 16000078 - The multi-instance is not supported. 625 * @throws { BusinessError } 16000079 - The APP_INSTANCE_KEY cannot be specified. 626 * @throws { BusinessError } 16000080 - Creating a new instance is not supported. 627 * @throws { BusinessError } 16200001 - The caller has been released. 628 * @syscap SystemCapability.Ability.AbilityRuntime.Core 629 * @stagemodelonly 630 * @since 14 631 */ 632 startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>): void; 633 634 /** 635 * Starts an ability and returns the execution result when the ability is destroyed. 636 * If the caller application is in foreground, you can use this method to start ability; If the caller application 637 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 638 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 639 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 640 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 641 * 642 * @param { Want } want - Indicates the ability to start. 643 * @param { StartOptions } [options] - Indicates the start options. 644 * @returns { Promise<AbilityResult> } Returns the result of startAbility. 645 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 646 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 647 * @throws { BusinessError } 16000001 - The specified ability does not exist. 648 * @throws { BusinessError } 16000002 - Incorrect ability type. 649 * @throws { BusinessError } 16000004 - Can not start invisible component. 650 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 651 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 652 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 653 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 654 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 655 * @throws { BusinessError } 16000011 - The context does not exist. 656 * @throws { BusinessError } 16000012 - The application is controlled. 657 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 658 * @throws { BusinessError } 16000050 - Internal error. 659 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 660 * @throws { BusinessError } 16000055 - Installation-free timed out. 661 * @throws { BusinessError } 16200001 - The caller has been released. 662 * @syscap SystemCapability.Ability.AbilityRuntime.Core 663 * @stagemodelonly 664 * @since 10 665 */ 666 /** 667 * Starts an ability and returns the execution result when the ability is destroyed. 668 * If the caller application is in foreground, you can use this method to start ability; If the caller application 669 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 670 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 671 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 672 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 673 * 674 * @param { Want } want - Indicates the ability to start. 675 * @param { StartOptions } [options] - Indicates the start options. 676 * @returns { Promise<AbilityResult> } Returns the result of startAbility. 677 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 678 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 679 * @throws { BusinessError } 16000001 - The specified ability does not exist. 680 * @throws { BusinessError } 16000002 - Incorrect ability type. 681 * @throws { BusinessError } 16000004 - Can not start invisible component. 682 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 683 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 684 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 685 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 686 * @throws { BusinessError } 16000010 - The call with the continuation and prepare continuation flag is forbidden. 687 * @throws { BusinessError } 16000011 - The context does not exist. 688 * @throws { BusinessError } 16000012 - The application is controlled. 689 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 690 * @throws { BusinessError } 16000018 - The application is not allow jumping to other applications. 691 * @throws { BusinessError } 16000019 - Can not match any component. 692 * @throws { BusinessError } 16000050 - Internal error. 693 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 694 * @throws { BusinessError } 16000055 - Installation-free timed out. 695 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 696 * @throws { BusinessError } 16000070 - The extension cannot start the service. 697 * @throws { BusinessError } 16000073 - The app clone index is invalid. 698 * @throws { BusinessError } 16200001 - The caller has been released. 699 * @syscap SystemCapability.Ability.AbilityRuntime.Core 700 * @stagemodelonly 701 * @since 12 702 */ 703 /** 704 * Starts an ability and returns the execution result when the ability is destroyed. 705 * If the caller application is in foreground, you can use this method to start ability; If the caller application 706 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 707 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 708 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 709 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 710 * 711 * @param { Want } want - Indicates the ability to start. 712 * @param { StartOptions } [options] - Indicates the start options. 713 * @returns { Promise<AbilityResult> } Returns the result of startAbility. 714 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 715 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 716 * @throws { BusinessError } 16000001 - The specified ability does not exist. 717 * @throws { BusinessError } 16000002 - Incorrect ability type. 718 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 719 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 720 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 721 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 722 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 723 * @throws { BusinessError } 16000010 - The call with the continuation and prepare continuation flag is forbidden. 724 * @throws { BusinessError } 16000011 - The context does not exist. 725 * @throws { BusinessError } 16000012 - The application is controlled. 726 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 727 * @throws { BusinessError } 16000018 - Redirection to a third-party application is not allowed in API version 11 or later. 728 * @throws { BusinessError } 16000019 - No matching ability is found. 729 * @throws { BusinessError } 16000050 - Internal error. 730 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 731 * @throws { BusinessError } 16000055 - Installation-free timed out. 732 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 733 * @throws { BusinessError } 16000070 - The extension cannot start the service. 734 * @throws { BusinessError } 16000071 - App clone is not supported. 735 * @throws { BusinessError } 16000072 - App clone or multi-instance is not supported. 736 * @throws { BusinessError } 16000073 - The app clone index is invalid. 737 * @throws { BusinessError } 16000076 - The app instance key is invalid. 738 * @throws { BusinessError } 16000077 - The number of app instances reaches the limit. 739 * @throws { BusinessError } 16000078 - The multi-instance is not supported. 740 * @throws { BusinessError } 16000079 - The APP_INSTANCE_KEY cannot be specified. 741 * @throws { BusinessError } 16000080 - Creating a new instance is not supported. 742 * @throws { BusinessError } 16200001 - The caller has been released. 743 * @syscap SystemCapability.Ability.AbilityRuntime.Core 744 * @stagemodelonly 745 * @since 14 746 */ 747 startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityResult>; 748 749 /** 750 * Starts a new ability using the original caller information, and returns the execution result when the ability 751 * is destroyed. 752 * If the caller application is in foreground, you can use this method to start ability; If the caller application 753 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 754 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 755 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 756 * 757 * @param { Want } want - Indicates the ability to start. 758 * @param { StartOptions } [options] - Indicates the start options. 759 * @returns { Promise<AbilityResult> } Returns the result of startAbility. 760 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 761 * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app. 762 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 763 * @throws { BusinessError } 16000001 - The specified ability does not exist. 764 * @throws { BusinessError } 16000004 - Can not start invisible component. 765 * @throws { BusinessError } 16000050 - Internal error. 766 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 767 * @throws { BusinessError } 16000070 - The extension cannot start the service. 768 * @throws { BusinessError } 16000073 - The app clone index is invalid. 769 * @syscap SystemCapability.Ability.AbilityRuntime.Core 770 * @systemapi 771 * @stagemodelonly 772 * @since 12 773 */ 774 /** 775 * Starts a new ability using the original caller information, and returns the execution result when the ability 776 * is destroyed. 777 * If the caller application is in foreground, you can use this method to start ability; If the caller application 778 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 779 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 780 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 781 * 782 * @param { Want } want - Indicates the ability to start. 783 * @param { StartOptions } [options] - Indicates the start options. 784 * @returns { Promise<AbilityResult> } Returns the result of startAbility. 785 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 786 * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app. 787 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 788 * @throws { BusinessError } 16000001 - The specified ability does not exist. 789 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 790 * @throws { BusinessError } 16000050 - Internal error. 791 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 792 * @throws { BusinessError } 16000070 - The extension cannot start the service. 793 * @throws { BusinessError } 16000071 - App clone is not supported. 794 * @throws { BusinessError } 16000072 - App clone or multi-instance is not supported. 795 * @throws { BusinessError } 16000073 - The app clone index is invalid. 796 * @throws { BusinessError } 16000076 - The app instance key is invalid. 797 * @throws { BusinessError } 16000077 - The number of app instances reaches the limit. 798 * @throws { BusinessError } 16000078 - The multi-instance is not supported. 799 * @throws { BusinessError } 16000079 - The APP_INSTANCE_KEY cannot be specified. 800 * @throws { BusinessError } 16000080 - Creating a new instance is not supported. 801 * @syscap SystemCapability.Ability.AbilityRuntime.Core 802 * @systemapi 803 * @stagemodelonly 804 * @since 14 805 */ 806 startAbilityForResultAsCaller(want: Want, options?: StartOptions): Promise<AbilityResult>; 807 808 /** 809 * Connects the current ability to an service extension ability. 810 * If the target service extension ability is visible, you can connect the target service extension ability; 811 * If the target service extension ability is invisible, 812 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to connect target invisible service extension ability. 813 * If the target service extension ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 814 * 815 * @param { Want } want - The element name of the service ability 816 * @param { ConnectOptions } options - The remote object instance 817 * @returns { number } Returns the number code of the ability connected 818 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 819 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 820 * @throws { BusinessError } 16000001 - The specified ability does not exist. 821 * @throws { BusinessError } 16000002 - Incorrect ability type. 822 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 823 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 824 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 825 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 826 * @throws { BusinessError } 16000011 - The context does not exist. 827 * @throws { BusinessError } 16000050 - Internal error. 828 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 829 * @throws { BusinessError } 16000055 - Installation-free timed out. 830 * @throws { BusinessError } 16000070 - The extension cannot start the service. 831 * @syscap SystemCapability.Ability.AbilityRuntime.Core 832 * @stagemodelonly 833 * @since 10 834 */ 835 connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; 836 837 /** 838 * Disconnect an ability from a service extension, in contrast to {@link connectAbility}. 839 * 840 * @param { number } connection - The number code of the ability connected 841 * @param { AsyncCallback<void> } callback - The callback of disconnectAbility. 842 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 843 * @throws { BusinessError } 16000011 - The context does not exist. 844 * @throws { BusinessError } 16000050 - Internal error. 845 * @syscap SystemCapability.Ability.AbilityRuntime.Core 846 * @stagemodelonly 847 * @since 10 848 */ 849 disconnectServiceExtensionAbility(connection: number, callback: AsyncCallback<void>): void; 850 851 /** 852 * Disconnect an ability from a service extension, in contrast to {@link connectAbility}. 853 * 854 * @param { number } connection - The number code of the ability connected 855 * @returns { Promise<void> } The promise returned by the function. 856 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 857 * @throws { BusinessError } 16000011 - The context does not exist. 858 * @throws { BusinessError } 16000050 - Internal error. 859 * @syscap SystemCapability.Ability.AbilityRuntime.Core 860 * @stagemodelonly 861 * @since 10 862 */ 863 disconnectServiceExtensionAbility(connection: number): Promise<void>; 864 865 /** 866 * Report to system when the extension is drawn completed. 867 * 868 * @param { AsyncCallback<void> } callback - The callback of startUIExtensionAbility. 869 * @throws { BusinessError } 16000011 - The context does not exist. 870 * @throws { BusinessError } 16000050 - Internal error. 871 * @syscap SystemCapability.Ability.AbilityRuntime.Core 872 * @stagemodelonly 873 * @since 12 874 */ 875 reportDrawnCompleted(callback: AsyncCallback<void>): void; 876 877 /** 878 * Destroys the UI extension. 879 * 880 * @param { AsyncCallback<void> } callback - The callback of terminateSelf. 881 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 882 * @syscap SystemCapability.Ability.AbilityRuntime.Core 883 * @stagemodelonly 884 * @since 12 885 */ 886 terminateSelf(callback: AsyncCallback<void>): void; 887 888 /** 889 * Destroys the UI extension. 890 * 891 * @returns { Promise<void> } The promise returned by the function. 892 * @syscap SystemCapability.Ability.AbilityRuntime.Core 893 * @stagemodelonly 894 * @since 12 895 */ 896 terminateSelf(): Promise<void>; 897 898 /** 899 * Destroys the UI extension while returning the specified result code and data to the caller. 900 * 901 * @param { AbilityResult } parameter - Indicates the result to return. 902 * @param { AsyncCallback<void> } callback - The callback of terminateSelfWithResult. 903 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 904 * @syscap SystemCapability.Ability.AbilityRuntime.Core 905 * @stagemodelonly 906 * @since 12 907 */ 908 terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>): void; 909 910 /** 911 * Destroys the UI extension while returning the specified result code and data to the caller. 912 * 913 * @param { AbilityResult } parameter - Indicates the result to return. 914 * @returns { Promise<void> } The promise returned by the function. 915 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 916 * @syscap SystemCapability.Ability.AbilityRuntime.Core 917 * @stagemodelonly 918 * @since 12 919 */ 920 terminateSelfWithResult(parameter: AbilityResult): Promise<void>; 921 922 /** 923 * Full-screen pop-us startup atomic service. 924 * 925 * @param { string } appId - Globally unique identifier of an application, which is allocated by the cloud. 926 * @param { AtomicServiceOptions } [options] - Indicates the atomic service start options. 927 * @returns { Promise<AbilityResult> } Returns the result of openAtomicService. 928 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 929 * @throws { BusinessError } 16000002 - Incorrect ability type. 930 * @throws { BusinessError } 16000003 - The specified ID does not exist. 931 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 932 * @throws { BusinessError } 16000011 - The context does not exist. 933 * @throws { BusinessError } 16000012 - The application is controlled. 934 * @throws { BusinessError } 16000050 - Internal error. 935 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 936 * @throws { BusinessError } 16200001 - The caller has been released. 937 * @syscap SystemCapability.Ability.AbilityRuntime.Core 938 * @stagemodelonly 939 * @since 12 940 */ 941 openAtomicService(appId: string, options?: AtomicServiceOptions): Promise<AbilityResult>; 942 943 /** 944 * Starts a UI service extension ability. 945 * If the target UI service extension ability is visible, you can start the target UI service extension ability; 946 * If the target UI service extension ability is invisible, 947 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible UI service extension ability. 948 * 949 * @param { Want } want - Indicates the want info to start. 950 * @returns { Promise<void> } The promise returned by the function. 951 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 952 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 953 * 2. Incorrect parameter types; 3. Parameter verification failed. 954 * @throws { BusinessError } 801 - Capability not supported. 955 * @throws { BusinessError } 16000001 - The specified ability does not exist. 956 * @throws { BusinessError } 16000002 - Incorrect ability type. 957 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 958 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 959 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 960 * @throws { BusinessError } 16000011 - The context does not exist. 961 * @throws { BusinessError } 16000012 - The application is controlled. 962 * @throws { BusinessError } 16000013 - The EDM prohibits the application from launching. 963 * @throws { BusinessError } 16000019 - No matching ability is found. 964 * @throws { BusinessError } 16000050 - Internal error. 965 * @throws { BusinessError } 16200001 - The caller has been released. 966 * @syscap SystemCapability.Ability.AbilityRuntime.Core 967 * @stagemodelonly 968 * @since 14 969 */ 970 startUIServiceExtensionAbility(want: Want): Promise<void>; 971 972 /** 973 * Connects to a UI service extension ability. 974 * If the target UI service extension ability is visible, you can connect the target UI service extension ability; 975 * If the target UI service extension ability is invisible, 976 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to connect target invisible UI service extension ability. 977 * 978 * @param { Want } want - Indicates the want info to connect. 979 * @param { UIServiceExtensionConnectCallback } callback - The callback of connection. 980 * @returns { Promise<UIServiceProxy> } The promise to get UIServiceProxy. 981 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 982 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 983 * 2. Incorrect parameter types; 3. Parameter verification failed. 984 * @throws { BusinessError } 801 - Capability not supported. 985 * @throws { BusinessError } 16000001 - The specified ability does not exist. 986 * @throws { BusinessError } 16000002 - Incorrect ability type. 987 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 988 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 989 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 990 * @throws { BusinessError } 16000011 - The context does not exist. 991 * @throws { BusinessError } 16000013 - The EDM prohibits the application from launching. 992 * @throws { BusinessError } 16000050 - Internal error. 993 * @throws { BusinessError } 16000055 - Installation-free timed out. 994 * @syscap SystemCapability.Ability.AbilityRuntime.Core 995 * @stagemodelonly 996 * @since 14 997 */ 998 connectUIServiceExtensionAbility(want: Want, callback: UIServiceExtensionConnectCallback) : Promise<UIServiceProxy>; 999 1000 /** 1001 * Disconnects from a UI service extension, in contrast to {@link connectUIServiceExtensionAbility}. 1002 * 1003 * @param { UIServiceProxy } proxy - The UI service proxy return by connectUIServiceExtensionAbility. 1004 * @returns { Promise<void> } The promise returned by the function. 1005 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1006 * 2. Incorrect parameter types; 3. Parameter verification failed. 1007 * @throws { BusinessError } 16000011 - The context does not exist. 1008 * @throws { BusinessError } 16000050 - Internal error. 1009 * @syscap SystemCapability.Ability.AbilityRuntime.Core 1010 * @stagemodelonly 1011 * @since 14 1012 */ 1013 disconnectUIServiceExtensionAbility(proxy: UIServiceProxy): Promise<void>; 1014 1015 /** 1016 * Starts a new service extension ability. 1017 * If the target service extension ability is visible, you can start the target service extension ability; 1018 * If the target service extension ability is invisible, 1019 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible service extension ability. 1020 * If the target service extension ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 1021 * 1022 * @param { Want } want - Indicates the want info to start. 1023 * @returns { Promise<void> } The promise returned by the function. 1024 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 1025 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 1026 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 1027 * @throws { BusinessError } 16000001 - The specified ability does not exist. 1028 * @throws { BusinessError } 16000002 - Incorrect ability type. 1029 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 1030 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 1031 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 1032 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 1033 * @throws { BusinessError } 16000011 - The context does not exist. 1034 * @throws { BusinessError } 16000012 - The application is controlled. 1035 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 1036 * @throws { BusinessError } 16000019 - No matching ability is found. 1037 * @throws { BusinessError } 16000050 - Internal error. 1038 * @throws { BusinessError } 16200001 - The caller has been released. 1039 * @syscap SystemCapability.Ability.AbilityRuntime.Core 1040 * @systemapi 1041 * @stagemodelonly 1042 * @since 18 1043 */ 1044 startServiceExtensionAbility(want: Want): Promise<void>; 1045 1046 /** 1047 * Starts a new service extension ability with account. 1048 * If the target service extension ability is visible, you can start the target service extension ability; 1049 * If the target service extension ability is invisible, 1050 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible service extension ability. 1051 * If the target service extension ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 1052 * 1053 * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS 1054 * @param { Want } want - Indicates the want info to start. 1055 * @param { number } accountId - Indicates the account to start. 1056 * @returns { Promise<void> } The promise returned by the function. 1057 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 1058 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 1059 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 1060 * @throws { BusinessError } 16000001 - The specified ability does not exist. 1061 * @throws { BusinessError } 16000002 - Incorrect ability type. 1062 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 1063 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 1064 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 1065 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 1066 * @throws { BusinessError } 16000011 - The context does not exist. 1067 * @throws { BusinessError } 16000012 - The application is controlled. 1068 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 1069 * @throws { BusinessError } 16000019 - No matching ability is found. 1070 * @throws { BusinessError } 16000050 - Internal error. 1071 * @throws { BusinessError } 16200001 - The caller has been released. 1072 * @syscap SystemCapability.Ability.AbilityRuntime.Core 1073 * @systemapi 1074 * @stagemodelonly 1075 * @since 18 1076 */ 1077 startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise<void>; 1078 1079 /** 1080 * Set the uiextension to either not allow being covered by the host page or allow it. 1081 * 1082 * @param { boolean } isForbidden - Indicates the bool value of uiextension can be covered by host page. 1083 * True indicates not allowing. 1084 * False indicates allowing. 1085 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 1086 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 1087 * @syscap SystemCapability.Ability.AbilityRuntime.Core 1088 * @systemapi 1089 * @stagemodelonly 1090 * @since 15 1091 */ 1092 setHostPageOverlayForbidden(isForbidden: boolean) : void; 1093 1094 /** 1095 * Set colorMode of uiextension. 1096 * 1097 * @param { ConfigurationConstant.ColorMode } colorMode - Color mode. 1098 * @throws { BusinessError } 16000011 - The context does not exist. 1099 * @syscap SystemCapability.Ability.AbilityRuntime.Core 1100 * @stagemodelonly 1101 * @since 18 1102 */ 1103 setColorMode(colorMode: ConfigurationConstant.ColorMode): void; 1104} 1105