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'; 29 30/** 31 * The context of UI extension. It allows access to UIExtension-specific resources. 32 * 33 * @extends ExtensionContext 34 * @syscap SystemCapability.Ability.AbilityRuntime.Core 35 * @stagemodelonly 36 * @since 10 37 */ 38export default class UIExtensionContext extends ExtensionContext { 39 /** 40 * UI extension uses this method to start a specific ability.If the caller application is in foreground, 41 * you can use this method to start ability; If the caller application is in the background, 42 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 43 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 44 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 45 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 46 * 47 * @param { Want } want - Indicates the ability to start. 48 * @param { AsyncCallback<void> } callback - The callback of startAbility. 49 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 50 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 51 * @throws { BusinessError } 16000001 - The specified ability does not exist. 52 * @throws { BusinessError } 16000002 - Incorrect ability type. 53 * @throws { BusinessError } 16000004 - Can not start invisible component. 54 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 55 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 56 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 57 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 58 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 59 * @throws { BusinessError } 16000011 - The context does not exist. 60 * @throws { BusinessError } 16000012 - The application is controlled. 61 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 62 * @throws { BusinessError } 16000050 - Internal error. 63 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 64 * @throws { BusinessError } 16000055 - Installation-free timed out. 65 * @throws { BusinessError } 16200001 - The caller has been released. 66 * @syscap SystemCapability.Ability.AbilityRuntime.Core 67 * @stagemodelonly 68 * @since 10 69 */ 70 /** 71 * UI extension uses this method to start a specific ability.If the caller application is in foreground, 72 * you can use this method to start ability; If the caller application is in the background, 73 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 74 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 75 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 76 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 77 * 78 * @param { Want } want - Indicates the ability to start. 79 * @param { AsyncCallback<void> } callback - The callback of startAbility. 80 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 81 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 82 * @throws { BusinessError } 16000001 - The specified ability does not exist. 83 * @throws { BusinessError } 16000002 - Incorrect ability type. 84 * @throws { BusinessError } 16000004 - Can not start invisible component. 85 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 86 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 87 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 88 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 89 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 90 * @throws { BusinessError } 16000011 - The context does not exist. 91 * @throws { BusinessError } 16000012 - The application is controlled. 92 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 93 * @throws { BusinessError } 16000018 - The application is not allow jumping to other applications. 94 * @throws { BusinessError } 16000019 - Can not match any component. 95 * @throws { BusinessError } 16000050 - Internal error. 96 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 97 * @throws { BusinessError } 16000055 - Installation-free timed out. 98 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 99 * @throws { BusinessError } 16000070 - The extension cannot start the service. 100 * @throws { BusinessError } 16000073 - The app clone index is invalid. 101 * @throws { BusinessError } 16200001 - The caller has been released. 102 * @syscap SystemCapability.Ability.AbilityRuntime.Core 103 * @stagemodelonly 104 * @since 12 105 */ 106 startAbility(want: Want, callback: AsyncCallback<void>): void; 107 108 /** 109 * UI extension uses this method to start a specific ability.If the caller application is in foreground, 110 * you can use this method to start ability; If the caller application is in the background, 111 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 112 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 113 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 114 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 115 * 116 * @param { Want } want - Indicates the ability to start. 117 * @param { StartOptions } options - Indicates the start options. 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 } 16000004 - Can not start invisible component. 123 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 124 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 125 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 126 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 127 * @throws { BusinessError } 16000011 - The context does not exist. 128 * @throws { BusinessError } 16000012 - The application is controlled. 129 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 130 * @throws { BusinessError } 16000050 - Internal error. 131 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 132 * @throws { BusinessError } 16000055 - Installation-free timed out. 133 * @throws { BusinessError } 16200001 - The caller has been released. 134 * @syscap SystemCapability.Ability.AbilityRuntime.Core 135 * @stagemodelonly 136 * @since 10 137 */ 138 /** 139 * UI extension uses this method to start a specific ability.If the caller application is in foreground, 140 * you can use this method to start ability; If the caller application is in the background, 141 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 142 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 143 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 144 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 145 * 146 * @param { Want } want - Indicates the ability to start. 147 * @param { StartOptions } options - Indicates the start options. 148 * @param { AsyncCallback<void> } callback - The callback of startAbility. 149 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 150 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 151 * @throws { BusinessError } 16000001 - The specified ability does not exist. 152 * @throws { BusinessError } 16000004 - Can not start invisible component. 153 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 154 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 155 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 156 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 157 * @throws { BusinessError } 16000011 - The context does not exist. 158 * @throws { BusinessError } 16000012 - The application is controlled. 159 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 160 * @throws { BusinessError } 16000018 - The application is not allow jumping to other applications. 161 * @throws { BusinessError } 16000019 - Can not match any component. 162 * @throws { BusinessError } 16000050 - Internal error. 163 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 164 * @throws { BusinessError } 16000055 - Installation-free timed out. 165 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 166 * @throws { BusinessError } 16000070 - The extension cannot start the service. 167 * @throws { BusinessError } 16000073 - The app clone index is invalid. 168 * @throws { BusinessError } 16200001 - The caller has been released. 169 * @syscap SystemCapability.Ability.AbilityRuntime.Core 170 * @stagemodelonly 171 * @since 12 172 */ 173 startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void; 174 175 /** 176 * UI extension uses this method to start a specific ability.If the caller application is in foreground, 177 * you can use this method to start ability; If the caller application is in the background, 178 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 179 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 180 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 181 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 182 * 183 * @param { Want } want - Indicates the ability to start. 184 * @param { StartOptions } [options] - Indicates the start options. 185 * @returns { Promise<void> } The promise returned by the function. 186 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 187 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 188 * @throws { BusinessError } 16000001 - The specified ability does not exist. 189 * @throws { BusinessError } 16000002 - Incorrect ability type. 190 * @throws { BusinessError } 16000004 - Can not start invisible component. 191 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 192 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 193 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 194 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 195 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 196 * @throws { BusinessError } 16000011 - The context does not exist. 197 * @throws { BusinessError } 16000012 - The application is controlled. 198 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 199 * @throws { BusinessError } 16000050 - Internal error. 200 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 201 * @throws { BusinessError } 16000055 - Installation-free timed out. 202 * @throws { BusinessError } 16200001 - The caller has been released. 203 * @syscap SystemCapability.Ability.AbilityRuntime.Core 204 * @stagemodelonly 205 * @since 10 206 */ 207 /** 208 * UI extension uses this method to start a specific ability.If the caller application is in foreground, 209 * you can use this method to start ability; If the caller application is in the background, 210 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 211 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 212 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 213 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 214 * 215 * @param { Want } want - Indicates the ability to start. 216 * @param { StartOptions } [options] - Indicates the start options. 217 * @returns { Promise<void> } The promise returned by the function. 218 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 219 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 220 * @throws { BusinessError } 16000001 - The specified ability does not exist. 221 * @throws { BusinessError } 16000002 - Incorrect ability type. 222 * @throws { BusinessError } 16000004 - Can not start invisible component. 223 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 224 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 225 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 226 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 227 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 228 * @throws { BusinessError } 16000011 - The context does not exist. 229 * @throws { BusinessError } 16000012 - The application is controlled. 230 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 231 * @throws { BusinessError } 16000018 - The application is not allow jumping to other applications. 232 * @throws { BusinessError } 16000019 - Can not match any component. 233 * @throws { BusinessError } 16000050 - Internal error. 234 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 235 * @throws { BusinessError } 16000055 - Installation-free timed out. 236 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 237 * @throws { BusinessError } 16000070 - The extension cannot start the service. 238 * @throws { BusinessError } 16000073 - The app clone index is invalid. 239 * @throws { BusinessError } 16200001 - The caller has been released. 240 * @syscap SystemCapability.Ability.AbilityRuntime.Core 241 * @stagemodelonly 242 * @since 12 243 */ 244 startAbility(want: Want, options?: StartOptions): Promise<void>; 245 246 /** 247 * UI extension uses this method to start a specific ability by implicit want.If the caller application is in foreground, 248 * you can use this method to start ability; If the caller application is in the background, 249 * you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 250 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 251 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 252 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 253 * 254 * @param { string } link - Indicates the ability to start. 255 * @param { OpenLinkOptions } [options] - Indicates the open link options. 256 * @param { AsyncCallback<AbilityResult> } [callback] - The callback is used to return the ability result. 257 * @returns { Promise<void> } The promise returned by the function. 258 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 259 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 260 * @throws { BusinessError } 16000001 - The specified ability does not exist. 261 * @throws { BusinessError } 16000002 - Incorrect ability type. 262 * @throws { BusinessError } 16000004 - Can not start invisible component. 263 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 264 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 265 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 266 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 267 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 268 * @throws { BusinessError } 16000011 - The context does not exist. 269 * @throws { BusinessError } 16000012 - The application is controlled. 270 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 271 * @throws { BusinessError } 16000019 - Can not match any component. 272 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 273 * @throws { BusinessError } 16200001 - The caller has been released. 274 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 275 * @syscap SystemCapability.Ability.AbilityRuntime.Core 276 * @stagemodelonly 277 * @since 12 278 */ 279 openLink(link: string, options?: OpenLinkOptions, callback?: AsyncCallback<AbilityResult>): Promise<void>; 280 281 /** 282 * Starts an ability and returns the execution result when the ability is destroyed. 283 * If the caller application is in foreground, you can use this method to start ability; If the caller application 284 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 285 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 286 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 287 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 288 * 289 * @param { Want } want - Indicates the ability to start. 290 * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility. 291 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 292 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 293 * @throws { BusinessError } 16000001 - The specified ability does not exist. 294 * @throws { BusinessError } 16000002 - Incorrect ability type. 295 * @throws { BusinessError } 16000004 - Can not start invisible component. 296 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 297 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 298 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 299 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 300 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 301 * @throws { BusinessError } 16000011 - The context does not exist. 302 * @throws { BusinessError } 16000012 - The application is controlled. 303 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 304 * @throws { BusinessError } 16000050 - Internal error. 305 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 306 * @throws { BusinessError } 16000055 - Installation-free timed out. 307 * @throws { BusinessError } 16200001 - The caller has been released. 308 * @syscap SystemCapability.Ability.AbilityRuntime.Core 309 * @stagemodelonly 310 * @since 10 311 */ 312 /** 313 * Starts an ability and returns the execution result when the ability is destroyed. 314 * If the caller application is in foreground, you can use this method to start ability; If the caller application 315 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 316 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 317 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 318 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 319 * 320 * @param { Want } want - Indicates the ability to start. 321 * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility. 322 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 323 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 324 * @throws { BusinessError } 16000001 - The specified ability does not exist. 325 * @throws { BusinessError } 16000002 - Incorrect ability type. 326 * @throws { BusinessError } 16000004 - Can not start invisible component. 327 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 328 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 329 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 330 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 331 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 332 * @throws { BusinessError } 16000011 - The context does not exist. 333 * @throws { BusinessError } 16000012 - The application is controlled. 334 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 335 * @throws { BusinessError } 16000018 - The application is not allow jumping to other applications. 336 * @throws { BusinessError } 16000019 - Can not match any component. 337 * @throws { BusinessError } 16000050 - Internal error. 338 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 339 * @throws { BusinessError } 16000055 - Installation-free timed out. 340 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 341 * @throws { BusinessError } 16000070 - The extension cannot start the service. 342 * @throws { BusinessError } 16000073 - The app clone index is invalid. 343 * @throws { BusinessError } 16200001 - The caller has been released. 344 * @syscap SystemCapability.Ability.AbilityRuntime.Core 345 * @stagemodelonly 346 * @since 12 347 */ 348 startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): void; 349 350 /** 351 * Starts an ability and returns the execution result when the ability is destroyed. 352 * If the caller application is in foreground, you can use this method to start ability; If the caller application 353 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 354 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 355 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 356 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 357 * 358 * @param { Want } want - Indicates the ability to start. 359 * @param { StartOptions } options - Indicates the start options. 360 * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility. 361 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 362 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 363 * @throws { BusinessError } 16000001 - The specified ability does not exist. 364 * @throws { BusinessError } 16000004 - Can not start invisible component. 365 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 366 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 367 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 368 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 369 * @throws { BusinessError } 16000011 - The context does not exist. 370 * @throws { BusinessError } 16000012 - The application is controlled. 371 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 372 * @throws { BusinessError } 16000050 - Internal error. 373 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 374 * @throws { BusinessError } 16000055 - Installation-free timed out. 375 * @throws { BusinessError } 16200001 - The caller has been released. 376 * @syscap SystemCapability.Ability.AbilityRuntime.Core 377 * @stagemodelonly 378 * @since 10 379 */ 380 /** 381 * Starts an ability and returns the execution result when the ability is destroyed. 382 * If the caller application is in foreground, you can use this method to start ability; If the caller application 383 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 384 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 385 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 386 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 387 * 388 * @param { Want } want - Indicates the ability to start. 389 * @param { StartOptions } options - Indicates the start options. 390 * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility. 391 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 392 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 393 * @throws { BusinessError } 16000001 - The specified ability does not exist. 394 * @throws { BusinessError } 16000004 - Can not start invisible component. 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 } 16000011 - The context does not exist. 400 * @throws { BusinessError } 16000012 - The application is controlled. 401 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 402 * @throws { BusinessError } 16000018 - The application is not allow jumping to other applications. 403 * @throws { BusinessError } 16000019 - Can not match any component. 404 * @throws { BusinessError } 16000050 - Internal error. 405 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 406 * @throws { BusinessError } 16000055 - Installation-free timed out. 407 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 408 * @throws { BusinessError } 16000070 - The extension cannot start the service. 409 * @throws { BusinessError } 16000073 - The app clone index is invalid. 410 * @throws { BusinessError } 16200001 - The caller has been released. 411 * @syscap SystemCapability.Ability.AbilityRuntime.Core 412 * @stagemodelonly 413 * @since 12 414 */ 415 startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>): void; 416 417 /** 418 * Starts an ability and returns the execution result when the ability is destroyed. 419 * If the caller application is in foreground, you can use this method to start ability; If the caller application 420 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 421 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 422 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 423 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 424 * 425 * @param { Want } want - Indicates the ability to start. 426 * @param { StartOptions } [options] - Indicates the start options. 427 * @returns { Promise<AbilityResult> } Returns the result of startAbility. 428 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 429 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 430 * @throws { BusinessError } 16000001 - The specified ability does not exist. 431 * @throws { BusinessError } 16000002 - Incorrect ability type. 432 * @throws { BusinessError } 16000004 - Can not start invisible component. 433 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 434 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 435 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 436 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 437 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 438 * @throws { BusinessError } 16000011 - The context does not exist. 439 * @throws { BusinessError } 16000012 - The application is controlled. 440 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 441 * @throws { BusinessError } 16000050 - Internal error. 442 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 443 * @throws { BusinessError } 16000055 - Installation-free timed out. 444 * @throws { BusinessError } 16200001 - The caller has been released. 445 * @syscap SystemCapability.Ability.AbilityRuntime.Core 446 * @stagemodelonly 447 * @since 10 448 */ 449 /** 450 * Starts an ability and returns the execution result when the ability is destroyed. 451 * If the caller application is in foreground, you can use this method to start ability; If the caller application 452 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 453 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 454 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 455 * If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 456 * 457 * @param { Want } want - Indicates the ability to start. 458 * @param { StartOptions } [options] - Indicates the start options. 459 * @returns { Promise<AbilityResult> } Returns the result of startAbility. 460 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 461 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 462 * @throws { BusinessError } 16000001 - The specified ability does not exist. 463 * @throws { BusinessError } 16000002 - Incorrect ability type. 464 * @throws { BusinessError } 16000004 - Can not start invisible component. 465 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 466 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 467 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 468 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 469 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 470 * @throws { BusinessError } 16000011 - The context does not exist. 471 * @throws { BusinessError } 16000012 - The application is controlled. 472 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 473 * @throws { BusinessError } 16000018 - The application is not allow jumping to other applications. 474 * @throws { BusinessError } 16000019 - Can not match any component. 475 * @throws { BusinessError } 16000050 - Internal error. 476 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 477 * @throws { BusinessError } 16000055 - Installation-free timed out. 478 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 479 * @throws { BusinessError } 16000070 - The extension cannot start the service. 480 * @throws { BusinessError } 16000073 - The app clone index is invalid. 481 * @throws { BusinessError } 16200001 - The caller has been released. 482 * @syscap SystemCapability.Ability.AbilityRuntime.Core 483 * @stagemodelonly 484 * @since 12 485 */ 486 startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityResult>; 487 488 /** 489 * Starts a new ability using the original caller information, and returns the execution result when the ability 490 * is destroyed. 491 * If the caller application is in foreground, you can use this method to start ability; If the caller application 492 * is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND. 493 * If the target ability is visible, you can start the target ability; If the target ability is invisible, 494 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability. 495 * 496 * @param { Want } want - Indicates the ability to start. 497 * @param { StartOptions } [options] - Indicates the start options. 498 * @returns { Promise<AbilityResult> } Returns the result of startAbility. 499 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 500 * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app. 501 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 502 * @throws { BusinessError } 16000001 - The specified ability does not exist. 503 * @throws { BusinessError } 16000004 - Can not start invisible component. 504 * @throws { BusinessError } 16000050 - Internal error. 505 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 506 * @throws { BusinessError } 16000070 - The extension cannot start the service. 507 * @throws { BusinessError } 16000073 - The app clone index is invalid. 508 * @syscap SystemCapability.Ability.AbilityRuntime.Core 509 * @systemapi 510 * @stagemodelonly 511 * @since 12 512 */ 513 startAbilityForResultAsCaller(want: Want, options?: StartOptions): Promise<AbilityResult>; 514 515 /** 516 * Connects the current ability to an service extension ability. 517 * If the target service extension ability is visible, you can connect the target service extension ability; 518 * If the target service extension ability is invisible, 519 * you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to connect target invisible service extension ability. 520 * If the target service extension ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC. 521 * 522 * @param { Want } want - The element name of the service ability 523 * @param { ConnectOptions } options - The remote object instance 524 * @returns { number } Returns the number code of the ability connected 525 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 526 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 527 * @throws { BusinessError } 16000001 - The specified ability does not exist. 528 * @throws { BusinessError } 16000002 - Incorrect ability type. 529 * @throws { BusinessError } 16000004 - Can not start invisible component. 530 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 531 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 532 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 533 * @throws { BusinessError } 16000011 - The context does not exist. 534 * @throws { BusinessError } 16000050 - Internal error. 535 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 536 * @throws { BusinessError } 16000055 - Installation-free timed out. 537 * @throws { BusinessError } 16000070 - The extension cannot start the service. 538 * @syscap SystemCapability.Ability.AbilityRuntime.Core 539 * @stagemodelonly 540 * @since 10 541 */ 542 connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; 543 544 /** 545 * Disconnect an ability from a service extension, in contrast to {@link connectAbility}. 546 * 547 * @param { number } connection - The number code of the ability connected 548 * @param { AsyncCallback<void> } callback - The callback of disconnectAbility. 549 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 550 * @throws { BusinessError } 16000011 - The context does not exist. 551 * @throws { BusinessError } 16000050 - Internal error. 552 * @syscap SystemCapability.Ability.AbilityRuntime.Core 553 * @stagemodelonly 554 * @since 10 555 */ 556 disconnectServiceExtensionAbility(connection: number, callback: AsyncCallback<void>): void; 557 558 /** 559 * Disconnect an ability from a service extension, in contrast to {@link connectAbility}. 560 * 561 * @param { number } connection - The number code of the ability connected 562 * @returns { Promise<void> } The promise returned by the function. 563 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 564 * @throws { BusinessError } 16000011 - The context does not exist. 565 * @throws { BusinessError } 16000050 - Internal error. 566 * @syscap SystemCapability.Ability.AbilityRuntime.Core 567 * @stagemodelonly 568 * @since 10 569 */ 570 disconnectServiceExtensionAbility(connection: number): Promise<void>; 571 572 /** 573 * Report to system when the extension is drawn completed. 574 * 575 * @param { AsyncCallback<void> } callback - The callback of startUIExtensionAbility. 576 * @throws { BusinessError } 16000011 - The context does not exist. 577 * @throws { BusinessError } 16000050 - Internal error. 578 * @syscap SystemCapability.Ability.AbilityRuntime.Core 579 * @stagemodelonly 580 * @since 12 581 */ 582 reportDrawnCompleted(callback: AsyncCallback<void>): void; 583 584 /** 585 * Destroys the UI extension. 586 * 587 * @param { AsyncCallback<void> } callback - The callback of terminateSelf. 588 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 589 * @syscap SystemCapability.Ability.AbilityRuntime.Core 590 * @stagemodelonly 591 * @since 12 592 */ 593 terminateSelf(callback: AsyncCallback<void>): void; 594 595 /** 596 * Destroys the UI extension. 597 * 598 * @returns { Promise<void> } The promise returned by the function. 599 * @syscap SystemCapability.Ability.AbilityRuntime.Core 600 * @stagemodelonly 601 * @since 12 602 */ 603 terminateSelf(): Promise<void>; 604 605 /** 606 * Destroys the UI extension while returning the specified result code and data to the caller. 607 * 608 * @param { AbilityResult } parameter - Indicates the result to return. 609 * @param { AsyncCallback<void> } callback - The callback of terminateSelfWithResult. 610 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 611 * @syscap SystemCapability.Ability.AbilityRuntime.Core 612 * @stagemodelonly 613 * @since 12 614 */ 615 terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>): void; 616 617 /** 618 * Destroys the UI extension while returning the specified result code and data to the caller. 619 * 620 * @param { AbilityResult } parameter - Indicates the result to return. 621 * @returns { Promise<void> } The promise returned by the function. 622 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 623 * @syscap SystemCapability.Ability.AbilityRuntime.Core 624 * @stagemodelonly 625 * @since 12 626 */ 627 terminateSelfWithResult(parameter: AbilityResult): Promise<void>; 628 629 /** 630 * Full-screen pop-us startup atomic service. 631 * 632 * @param { string } appId - Globally unique identifier of an application, which is allocated by the cloud. 633 * @param { AtomicServiceOptions } [options] - Indicates the atomic service start options. 634 * @returns { Promise<AbilityResult> } Returns the result of openAtomicService. 635 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 636 * @throws { BusinessError } 16000002 - Incorrect ability type. 637 * @throws { BusinessError } 16000003 - The appId does not exist. 638 * @throws { BusinessError } 16000004 - Can not start invisible component 639 * @throws { BusinessError } 16000011 - The context does not exist. 640 * @throws { BusinessError } 16000012 - The application is controlled. 641 * @throws { BusinessError } 16000050 - Internal error. 642 * @throws { BusinessError } 16000069 - The extension cannot start the third party application. 643 * @throws { BusinessError } 16200001 - The caller has been released. 644 * @syscap SystemCapability.Ability.AbilityRuntime.Core 645 * @stagemodelonly 646 * @since 12 647 */ 648 openAtomicService(appId: string, options?: AtomicServiceOptions): Promise<AbilityResult>; 649} 650