1/* 2 * Copyright (c) 2021-2022 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/// <reference path="../../component/common_ts_ets_api.d.ts"/> 17 18import { AbilityInfo } from "../bundleManager/AbilityInfo"; 19import { AbilityResult } from "../ability/abilityResult"; 20import { AsyncCallback } from "../basic"; 21import { ConnectOptions } from "../ability/connectOptions"; 22import { HapModuleInfo } from "../bundleManager/HapModuleInfo"; 23import Context from "./Context"; 24import Want from "../@ohos.app.ability.Want"; 25import StartOptions from "../@ohos.app.ability.StartOptions"; 26import { Configuration } from '../@ohos.app.ability.Configuration'; 27import { Caller } from '../@ohos.app.ability.UIAbility'; 28import { LocalStorage } from 'StateManagement'; 29import image from '../@ohos.multimedia.image'; 30import dialogRequest from "../@ohos.app.ability.dialogRequest"; 31 32/** 33 * The context of an ability. It allows access to ability-specific resources. 34 * @syscap SystemCapability.Ability.AbilityRuntime.Core 35 * @StageModelOnly 36 * @since 9 37 */ 38export default class UIAbilityContext extends Context { 39 /** 40 * Indicates configuration information about an ability. 41 * @type { AbilityInfo } 42 * @syscap SystemCapability.Ability.AbilityRuntime.Core 43 * @StageModelOnly 44 * @since 9 45 */ 46 abilityInfo: AbilityInfo; 47 48 /** 49 * Indicates configuration information about the module. 50 * @type { HapModuleInfo } 51 * @syscap SystemCapability.Ability.AbilityRuntime.Core 52 * @StageModelOnly 53 * @since 9 54 */ 55 currentHapModuleInfo: HapModuleInfo; 56 57 /** 58 * Indicates configuration information. 59 * @type { Configuration } 60 * @syscap SystemCapability.Ability.AbilityRuntime.Core 61 * @StageModelOnly 62 * @since 9 63 */ 64 config: Configuration; 65 66 /** 67 * Starts a new ability. 68 * @param want { Want } - Indicates the ability to start. 69 * @param { AsyncCallback<void> } callback - The callback of startAbility. 70 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 71 * @throws { BusinessError } 16000001 - The specified ability does not exist. 72 * @throws { BusinessError } 16000002 - Incorrect ability type. 73 * @throws { BusinessError } 16000004 - Can not start invisible component. 74 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 75 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 76 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 77 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 78 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 79 * @throws { BusinessError } 16000011 - The context does not exist. 80 * @throws { BusinessError } 16000050 - Internal error. 81 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 82 * @throws { BusinessError } 16000055 - Installation-free timed out. 83 * @throws { BusinessError } 16200001 - The caller has been released. 84 * @syscap SystemCapability.Ability.AbilityRuntime.Core 85 * @StageModelOnly 86 * @since 9 87 */ 88 startAbility(want: Want, callback: AsyncCallback<void>): void; 89 90 /** 91 * Starts a new ability. 92 * @param { Want } want - Indicates the ability to start. 93 * @param { StartOptions } options - Indicates the start options. 94 * @param { AsyncCallback<void> } callback - The callback of startAbility. 95 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 96 * @throws { BusinessError } 16000001 - The specified ability does not exist. 97 * @throws { BusinessError } 16000002 - Incorrect ability type. 98 * @throws { BusinessError } 16000004 - Can not start invisible component. 99 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 100 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 101 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 102 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 103 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 104 * @throws { BusinessError } 16000011 - The context does not exist. 105 * @throws { BusinessError } 16000050 - Internal error. 106 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 107 * @throws { BusinessError } 16000055 - Installation-free timed out. 108 * @throws { BusinessError } 16200001 - The caller has been released. 109 * @syscap SystemCapability.Ability.AbilityRuntime.Core 110 * @StageModelOnly 111 * @since 9 112 */ 113 startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void; 114 115 /** 116 * Starts a new ability. 117 * @param { Want } want - Indicates the ability to start. 118 * @param { StartOptions } options - Indicates the start options. 119 * @returns { Promise<void> } The promise returned by the function. 120 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 121 * @throws { BusinessError } 16000001 - The specified ability does not exist. 122 * @throws { BusinessError } 16000002 - Incorrect ability type. 123 * @throws { BusinessError } 16000004 - Can not start invisible component. 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 flag is forbidden. 129 * @throws { BusinessError } 16000011 - The context does not exist. 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 9 137 */ 138 startAbility(want: Want, options?: StartOptions): Promise<void>; 139 140 /** 141 * Get the caller object of the startup capability 142 * @permission ohos.permission.ABILITY_BACKGROUND_COMMUNICATION 143 * @param { Want } want - Indicates the ability to start. 144 * @returns { Promise<Caller> } Returns the Caller interface. 145 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 146 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 147 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 148 * @throws { BusinessError } 16000001 - The specified ability does not exist. 149 * @throws { BusinessError } 16000002 - Incorrect ability type. 150 * @throws { BusinessError } 16000004 - Can not start invisible component. 151 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 152 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 153 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 154 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 155 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 156 * @throws { BusinessError } 16000011 - The context does not exist. 157 * @throws { BusinessError } 16000050 - Internal error. 158 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 159 * @throws { BusinessError } 16000055 - Installation-free timed out. 160 * @throws { BusinessError } 16200001 - The caller has been released. 161 * @syscap SystemCapability.Ability.AbilityRuntime.Core 162 * @StageModelOnly 163 * @since 9 164 */ 165 startAbilityByCall(want: Want): Promise<Caller>; 166 167 /** 168 * Starts a new ability with account. 169 * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS 170 * @param { Want } want - Indicates the want info to start. 171 * @param { number } accountId - Indicates the account to start. 172 * @param { AsyncCallback<void> } callback - The callback of startAbilityWithAccount. 173 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 174 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 175 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 176 * @throws { BusinessError } 16000001 - The specified ability does not exist. 177 * @throws { BusinessError } 16000002 - Incorrect ability type. 178 * @throws { BusinessError } 16000004 - Can not start invisible component. 179 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 180 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 181 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 182 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 183 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 184 * @throws { BusinessError } 16000011 - The context does not exist. 185 * @throws { BusinessError } 16000050 - Internal error. 186 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 187 * @throws { BusinessError } 16000055 - Installation-free timed out. 188 * @throws { BusinessError } 16200001 - The caller has been released. 189 * @syscap SystemCapability.Ability.AbilityRuntime.Core 190 * @systemapi 191 * @StageModelOnly 192 * @since 9 193 */ 194 startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback<void>): void; 195 196 /** 197 * Starts a new ability with account. 198 * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS 199 * @param { Want } want - Indicates the want info to start. 200 * @param { number } accountId - Indicates the account to start. 201 * @param { StartOptions } options - Indicates the start options. 202 * @param { AsyncCallback<void> } callback - The callback of startAbilityWithAccount. 203 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 204 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 205 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 206 * @throws { BusinessError } 16000001 - The specified ability does not exist. 207 * @throws { BusinessError } 16000002 - Incorrect ability type. 208 * @throws { BusinessError } 16000004 - Can not start invisible component. 209 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 210 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 211 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 212 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 213 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 214 * @throws { BusinessError } 16000011 - The context does not exist. 215 * @throws { BusinessError } 16000050 - Internal error. 216 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 217 * @throws { BusinessError } 16000055 - Installation-free timed out. 218 * @throws { BusinessError } 16200001 - The caller has been released. 219 * @syscap SystemCapability.Ability.AbilityRuntime.Core 220 * @systemapi 221 * @StageModelOnly 222 * @since 9 223 */ 224 startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback<void>): void; 225 226 /** 227 * Starts a new ability with account. 228 * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS 229 * @param { Want } want - Indicates the want info to start. 230 * @param { number } accountId - Indicates the account to start. 231 * @param { StartOptions } options - Indicates the start options. 232 * @returns { Promise<void> } The promise returned by the function. 233 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 234 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 235 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 236 * @throws { BusinessError } 16000001 - The specified ability does not exist. 237 * @throws { BusinessError } 16000002 - Incorrect ability type. 238 * @throws { BusinessError } 16000004 - Can not start invisible component. 239 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 240 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 241 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 242 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 243 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 244 * @throws { BusinessError } 16000011 - The context does not exist. 245 * @throws { BusinessError } 16000050 - Internal error. 246 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 247 * @throws { BusinessError } 16000055 - Installation-free timed out. 248 * @throws { BusinessError } 16200001 - The caller has been released. 249 * @syscap SystemCapability.Ability.AbilityRuntime.Core 250 * @systemapi 251 * @StageModelOnly 252 * @since 9 253 */ 254 startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise<void>; 255 256 /** 257 * Starts an ability and returns the execution result when the ability is destroyed. 258 * @param { Want } want - Indicates the ability to start. 259 * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility. 260 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 261 * @throws { BusinessError } 16000001 - The specified ability does not exist. 262 * @throws { BusinessError } 16000002 - Incorrect ability type. 263 * @throws { BusinessError } 16000004 - Can not start invisible component. 264 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 265 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 266 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 267 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 268 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 269 * @throws { BusinessError } 16000011 - The context does not exist. 270 * @throws { BusinessError } 16000050 - Internal error. 271 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 272 * @throws { BusinessError } 16000055 - Installation-free timed out. 273 * @throws { BusinessError } 16200001 - The caller has been released. 274 * @syscap SystemCapability.Ability.AbilityRuntime.Core 275 * @StageModelOnly 276 * @since 9 277 */ 278 startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): void; 279 280 /** 281 * Starts an ability and returns the execution result when the ability is destroyed. 282 * @param { Want } want - Indicates the ability to start. 283 * @param { StartOptions } options - Indicates the start options. 284 * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility. 285 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 286 * @throws { BusinessError } 16000001 - The specified ability does not exist. 287 * @throws { BusinessError } 16000002 - Incorrect ability type. 288 * @throws { BusinessError } 16000004 - Can not start invisible component. 289 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 290 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 291 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 292 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 293 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 294 * @throws { BusinessError } 16000011 - The context does not exist. 295 * @throws { BusinessError } 16000050 - Internal error. 296 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 297 * @throws { BusinessError } 16000055 - Installation-free timed out. 298 * @throws { BusinessError } 16200001 - The caller has been released. 299 * @syscap SystemCapability.Ability.AbilityRuntime.Core 300 * @StageModelOnly 301 * @since 9 302 */ 303 startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>): void; 304 305 /** 306 * Starts an ability and returns the execution result when the ability is destroyed. 307 * @param { Want } want - Indicates the ability to start. 308 * @param { StartOptions } options - Indicates the start options. 309 * @returns { Promise<AbilityResult> } Returns the result of startAbility. 310 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 311 * @throws { BusinessError } 16000001 - The specified ability does not exist. 312 * @throws { BusinessError } 16000002 - Incorrect ability type. 313 * @throws { BusinessError } 16000004 - Can not start invisible component. 314 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 315 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 316 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 317 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 318 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 319 * @throws { BusinessError } 16000011 - The context does not exist. 320 * @throws { BusinessError } 16000050 - Internal error. 321 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 322 * @throws { BusinessError } 16000055 - Installation-free timed out. 323 * @throws { BusinessError } 16200001 - The caller has been released. 324 * @syscap SystemCapability.Ability.AbilityRuntime.Core 325 * @StageModelOnly 326 * @since 9 327 */ 328 startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityResult>; 329 330 /** 331 * Starts an ability and returns the execution result when the ability is destroyed with account. 332 * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS 333 * @param { Want } want - Indicates the want info to start. 334 * @param { number } accountId - Indicates the account to start. 335 * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility. 336 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 337 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 338 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 339 * @throws { BusinessError } 16000001 - The specified ability does not exist. 340 * @throws { BusinessError } 16000002 - Incorrect ability type. 341 * @throws { BusinessError } 16000004 - Can not start invisible component. 342 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 343 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 344 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 345 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 346 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 347 * @throws { BusinessError } 16000011 - The context does not exist. 348 * @throws { BusinessError } 16000050 - Internal error. 349 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 350 * @throws { BusinessError } 16000055 - Installation-free timed out. 351 * @throws { BusinessError } 16200001 - The caller has been released. 352 * @syscap SystemCapability.Ability.AbilityRuntime.Core 353 * @systemapi 354 * @StageModelOnly 355 * @since 9 356 */ 357 startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback<AbilityResult>): void; 358 359 /** 360 * Starts an ability and returns the execution result when the ability is destroyed with account. 361 * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS 362 * @param { Want } want - Indicates the want info to start. 363 * @param { number } accountId - Indicates the account to start. 364 * @param { StartOptions } options - Indicates the start options. 365 * @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility. 366 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 367 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 368 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 369 * @throws { BusinessError } 16000001 - The specified ability does not exist. 370 * @throws { BusinessError } 16000002 - Incorrect ability type. 371 * @throws { BusinessError } 16000004 - Can not start invisible component. 372 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 373 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 374 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 375 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 376 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 377 * @throws { BusinessError } 16000011 - The context does not exist. 378 * @throws { BusinessError } 16000050 - Internal error. 379 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 380 * @throws { BusinessError } 16000055 - Installation-free timed out. 381 * @throws { BusinessError } 16200001 - The caller has been released. 382 * @syscap SystemCapability.Ability.AbilityRuntime.Core 383 * @systemapi 384 * @StageModelOnly 385 * @since 9 386 */ 387 startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback<void>): void; 388 389 /** 390 * Starts an ability and returns the execution result when the ability is destroyed with account. 391 * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS 392 * @param { Want } want - Indicates the want info to start. 393 * @param { number } accountId - Indicates the account to start. 394 * @param { StartOptions } options - Indicates the start options. 395 * @returns { Promise<AbilityResult> } Returns the result of startAbility. 396 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 397 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 398 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 399 * @throws { BusinessError } 16000001 - The specified ability does not exist. 400 * @throws { BusinessError } 16000002 - Incorrect ability type. 401 * @throws { BusinessError } 16000004 - Can not start invisible component. 402 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 403 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 404 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 405 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 406 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 407 * @throws { BusinessError } 16000011 - The context does not exist. 408 * @throws { BusinessError } 16000050 - Internal error. 409 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 410 * @throws { BusinessError } 16000055 - Installation-free timed out. 411 * @throws { BusinessError } 16200001 - The caller has been released. 412 * @syscap SystemCapability.Ability.AbilityRuntime.Core 413 * @systemapi 414 * @StageModelOnly 415 * @since 9 416 */ 417 startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise<AbilityResult>; 418 419 /** 420 * Starts a new service extension ability. 421 * @param { Want } want - Indicates the want info to start. 422 * @param { AsyncCallback<void> } callback - The callback of startServiceExtensionAbility. 423 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 424 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 425 * @throws { BusinessError } 16000001 - The specified ability does not exist. 426 * @throws { BusinessError } 16000002 - Incorrect ability type. 427 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 428 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 429 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 430 * @throws { BusinessError } 16000011 - The context does not exist. 431 * @throws { BusinessError } 16000050 - Internal error. 432 * @throws { BusinessError } 16200001 - The caller has been released. 433 * @syscap SystemCapability.Ability.AbilityRuntime.Core 434 * @systemapi 435 * @StageModelOnly 436 * @since 9 437 */ 438 startServiceExtensionAbility(want: Want, callback: AsyncCallback<void>): void; 439 440 /** 441 * Starts a new service extension ability. 442 * @param { Want } want - Indicates the want info to start. 443 * @returns { Promise<void> } The promise returned by the function. 444 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 445 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 446 * @throws { BusinessError } 16000001 - The specified ability does not exist. 447 * @throws { BusinessError } 16000002 - Incorrect ability type. 448 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 449 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 450 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 451 * @throws { BusinessError } 16000011 - The context does not exist. 452 * @throws { BusinessError } 16000050 - Internal error. 453 * @throws { BusinessError } 16200001 - The caller has been released. 454 * @syscap SystemCapability.Ability.AbilityRuntime.Core 455 * @systemapi 456 * @StageModelOnly 457 * @since 9 458 */ 459 startServiceExtensionAbility(want: Want): Promise<void>; 460 461 /** 462 * Starts a new service extension ability with account. 463 * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS 464 * @param { Want } want - Indicates the want info to start. 465 * @param { number } accountId - Indicates the account to start. 466 * @param { AsyncCallback<void> } callback - The callback of startServiceExtensionAbilityWithAccount. 467 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 468 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 469 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 470 * @throws { BusinessError } 16000001 - The specified ability does not exist. 471 * @throws { BusinessError } 16000002 - Incorrect ability type. 472 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 473 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 474 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 475 * @throws { BusinessError } 16000011 - The context does not exist. 476 * @throws { BusinessError } 16000050 - Internal error. 477 * @throws { BusinessError } 16200001 - The caller has been released. 478 * @syscap SystemCapability.Ability.AbilityRuntime.Core 479 * @systemapi 480 * @StageModelOnly 481 * @since 9 482 */ 483 startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback<void>): void; 484 485 /** 486 * Starts a new service extension ability with account. 487 * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS 488 * @param { Want } want - Indicates the want info to start. 489 * @param { number } accountId - Indicates the account to start. 490 * @returns { Promise<void> } The promise returned by the function. 491 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 492 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 493 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 494 * @throws { BusinessError } 16000001 - The specified ability does not exist. 495 * @throws { BusinessError } 16000002 - Incorrect ability type. 496 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 497 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 498 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 499 * @throws { BusinessError } 16000011 - The context does not exist. 500 * @throws { BusinessError } 16000050 - Internal error. 501 * @throws { BusinessError } 16200001 - The caller has been released. 502 * @syscap SystemCapability.Ability.AbilityRuntime.Core 503 * @systemapi 504 * @StageModelOnly 505 * @since 9 506 */ 507 startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise<void>; 508 509 /** 510 * Stops a service within the same application. 511 * @param { Want } want - Indicates the want info to start. 512 * @param { AsyncCallback<void> } callback - The callback of stopServiceExtensionAbility. 513 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 514 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 515 * @throws { BusinessError } 16000001 - The specified ability does not exist. 516 * @throws { BusinessError } 16000002 - Incorrect ability type. 517 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 518 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 519 * @throws { BusinessError } 16000011 - The context does not exist. 520 * @throws { BusinessError } 16000050 - Internal error. 521 * @throws { BusinessError } 16200001 - The caller has been released. 522 * @syscap SystemCapability.Ability.AbilityRuntime.Core 523 * @systemapi 524 * @StageModelOnly 525 * @since 9 526 */ 527 stopServiceExtensionAbility(want: Want, callback: AsyncCallback<void>): void; 528 529 /** 530 * Stops a service within the same application. 531 * @param { Want } want - Indicates the want info to start. 532 * @returns { Promise<void> } The promise returned by the function. 533 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 534 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 535 * @throws { BusinessError } 16000001 - The specified ability does not exist. 536 * @throws { BusinessError } 16000002 - Incorrect ability type. 537 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 538 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 539 * @throws { BusinessError } 16000011 - The context does not exist. 540 * @throws { BusinessError } 16000050 - Internal error. 541 * @throws { BusinessError } 16200001 - The caller has been released. 542 * @syscap SystemCapability.Ability.AbilityRuntime.Core 543 * @systemapi 544 * @StageModelOnly 545 * @since 9 546 */ 547 stopServiceExtensionAbility(want: Want): Promise<void>; 548 549 /** 550 * Stops a service within the same application with account. 551 * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS 552 * @param { Want } want - Indicates the want info to start. 553 * @param { number } accountId - Indicates the accountId to start. 554 * @param { AsyncCallback<void> } callback - The callback of stopServiceExtensionAbilityWithAccount. 555 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 556 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 557 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 558 * @throws { BusinessError } 16000001 - The specified ability does not exist. 559 * @throws { BusinessError } 16000002 - Incorrect ability type. 560 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 561 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 562 * @throws { BusinessError } 16000011 - The context does not exist. 563 * @throws { BusinessError } 16000050 - Internal error. 564 * @throws { BusinessError } 16200001 - The caller has been released. 565 * @syscap SystemCapability.Ability.AbilityRuntime.Core 566 * @systemapi 567 * @StageModelOnly 568 * @since 9 569 */ 570 stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback<void>): void; 571 572 /** 573 * Stops a service within the same application with account. 574 * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS 575 * @param { Want } want - Indicates the want info to start. 576 * @param { number } accountId - Indicates the accountId to start. 577 * @returns { Promise<void> } The promise returned by the function. 578 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 579 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 580 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 581 * @throws { BusinessError } 16000001 - The specified ability does not exist. 582 * @throws { BusinessError } 16000002 - Incorrect ability type. 583 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 584 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 585 * @throws { BusinessError } 16000011 - The context does not exist. 586 * @throws { BusinessError } 16000050 - Internal error. 587 * @throws { BusinessError } 16200001 - The caller has been released. 588 * @syscap SystemCapability.Ability.AbilityRuntime.Core 589 * @systemapi 590 * @StageModelOnly 591 * @since 9 592 */ 593 stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise<void>; 594 595 /** 596 * Destroys this Page ability. 597 * @param { AsyncCallback<void> } callback - The callback of terminateSelf. 598 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 599 * @throws { BusinessError } 16000001 - The specified ability does not exist. 600 * @throws { BusinessError } 16000004 - Can not start invisible component. 601 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 602 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 603 * @throws { BusinessError } 16000011 - The context does not exist. 604 * @throws { BusinessError } 16000050 - Internal error. 605 * @syscap SystemCapability.Ability.AbilityRuntime.Core 606 * @StageModelOnly 607 * @since 9 608 */ 609 terminateSelf(callback: AsyncCallback<void>): void; 610 611 /** 612 * Destroys this Page ability. 613 * @returns { Promise<void> } The promise returned by the function. 614 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 615 * @throws { BusinessError } 16000001 - The specified ability does not exist. 616 * @throws { BusinessError } 16000004 - Can not start invisible component. 617 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 618 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 619 * @throws { BusinessError } 16000011 - The context does not exist. 620 * @throws { BusinessError } 16000050 - Internal error. 621 * @syscap SystemCapability.Ability.AbilityRuntime.Core 622 * @StageModelOnly 623 * @since 9 624 */ 625 terminateSelf(): Promise<void>; 626 627 /** 628 * Sets the result code and data to be returned by this Page ability to the caller 629 * and destroys this Page ability. 630 * @param { AbilityResult } parameter - Indicates the result to return. 631 * @param { AsyncCallback<void> } callback - The callback of terminateSelfWithResult. 632 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 633 * @throws { BusinessError } 16000001 - The specified ability does not exist. 634 * @throws { BusinessError } 16000004 - Can not start invisible component. 635 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 636 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 637 * @throws { BusinessError } 16000011 - The context does not exist. 638 * @throws { BusinessError } 16000050 - Internal error. 639 * @syscap SystemCapability.Ability.AbilityRuntime.Core 640 * @StageModelOnly 641 * @since 9 642 */ 643 terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>): void; 644 645 /** 646 * Sets the result code and data to be returned by this Page ability to the caller 647 * and destroys this Page ability. 648 * @param { AbilityResult } parameter - Indicates the result to return. 649 * @returns { Promise<void> } The promise returned by the function. 650 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 651 * @throws { BusinessError } 16000001 - The specified ability does not exist. 652 * @throws { BusinessError } 16000004 - Can not start invisible component. 653 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 654 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 655 * @throws { BusinessError } 16000011 - The context does not exist. 656 * @throws { BusinessError } 16000050 - Internal error. 657 * @syscap SystemCapability.Ability.AbilityRuntime.Core 658 * @StageModelOnly 659 * @since 9 660 */ 661 terminateSelfWithResult(parameter: AbilityResult): Promise<void>; 662 663 /** 664 * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template. 665 * @param { Want } want - The element name of the service ability 666 * @param { ConnectOptions } options - The remote object instance 667 * @returns { number } Returns the number code of the ability connected 668 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 669 * @throws { BusinessError } 16000001 - The specified ability does not exist. 670 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 671 * @throws { BusinessError } 16000011 - The context does not exist. 672 * @throws { BusinessError } 16000050 - Internal error. 673 * @syscap SystemCapability.Ability.AbilityRuntime.Core 674 * @StageModelOnly 675 * @since 9 676 */ 677 connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; 678 679 /** 680 * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template with account. 681 * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS 682 * @param { Want } want - The element name of the service ability 683 * @param { number } accountId - The account to connect 684 * @param { ConnectOptions } options - The remote object instance 685 * @returns { number } Returns the number code of the ability connected 686 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 687 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 688 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 689 * @throws { BusinessError } 16000001 - The specified ability does not exist. 690 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 691 * @throws { BusinessError } 16000011 - The context does not exist. 692 * @throws { BusinessError } 16000050 - Internal error. 693 * @syscap SystemCapability.Ability.AbilityRuntime.Core 694 * @systemapi 695 * @StageModelOnly 696 * @since 9 697 */ 698 connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; 699 700 /** 701 * The callback interface is connected successfully. 702 * @param { number } connection - The number code of the ability connected 703 * @param { AsyncCallback<void> } callback - The callback of disconnectAbility. 704 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 705 * @throws { BusinessError } 16000001 - The specified ability does not exist. 706 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 707 * @throws { BusinessError } 16000011 - The context does not exist. 708 * @throws { BusinessError } 16000050 - Internal error. 709 * @syscap SystemCapability.Ability.AbilityRuntime.Core 710 * @StageModelOnly 711 * @since 9 712 */ 713 disconnectServiceExtensionAbility(connection: number, callback: AsyncCallback<void>): void; 714 715 /** 716 * The callback interface is connected successfully. 717 * @param { number } connection - The number code of the ability connected 718 * @returns { Promise<void> } The promise returned by the function. 719 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 720 * @throws { BusinessError } 16000001 - The specified ability does not exist. 721 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 722 * @throws { BusinessError } 16000011 - The context does not exist. 723 * @throws { BusinessError } 16000050 - Internal error. 724 * @syscap SystemCapability.Ability.AbilityRuntime.Core 725 * @StageModelOnly 726 * @since 9 727 */ 728 disconnectServiceExtensionAbility(connection: number): Promise<void>; 729 730 /** 731 * Set mission label of current ability. 732 * @param { string } label - The label of ability that showed in recent missions. 733 * @param { AsyncCallback<void> } callback - The callback of setMissionLabel. 734 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 735 * @throws { BusinessError } 16000011 - The context does not exist. 736 * @throws { BusinessError } 16000050 - Internal error. 737 * @syscap SystemCapability.Ability.AbilityRuntime.Core 738 * @StageModelOnly 739 * @since 9 740 */ 741 setMissionLabel(label: string, callback: AsyncCallback<void>): void; 742 743 /** 744 * Set mission label of current ability. 745 * @param { string } label - The label of ability that showed in recent missions. 746 * @returns { Promise<void> } The promise returned by the function. 747 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 748 * @throws { BusinessError } 16000011 - The context does not exist. 749 * @throws { BusinessError } 16000050 - Internal error. 750 * @syscap SystemCapability.Ability.AbilityRuntime.Core 751 * @StageModelOnly 752 * @since 9 753 */ 754 setMissionLabel(label: string): Promise<void>; 755 756 /** 757 * Set mission icon of current ability. 758 * @param { image.PixelMap } icon - The icon of ability that showed in recent missions. 759 * @param { AsyncCallback<void> } callback - The callback of setMissionIcon. 760 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 761 * @throws { BusinessError } 16000011 - The context does not exist. 762 * @throws { BusinessError } 16000050 - Internal error. 763 * @syscap SystemCapability.Ability.AbilityRuntime.Core 764 * @systemapi 765 * @StageModelOnly 766 * @since 9 767 */ 768 setMissionIcon(icon: image.PixelMap, callback: AsyncCallback<void>): void; 769 770 /** 771 * Set mission icon of current ability. 772 * @param { image.PixelMap } icon - The icon of ability that showed in recent missions. 773 * @returns { Promise<void> } The promise returned by the function. 774 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 775 * @throws { BusinessError } 16000011 - The context does not exist. 776 * @throws { BusinessError } 16000050 - Internal error. 777 * @syscap SystemCapability.Ability.AbilityRuntime.Core 778 * @systemapi 779 * @StageModelOnly 780 * @since 9 781 */ 782 setMissionIcon(icon: image.PixelMap): Promise<void>; 783 784 /** 785 * Restore window stage data in ability continuation 786 * @param { LocalStorage } localStorage - the storage data used to restore window stage 787 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 788 * @syscap SystemCapability.Ability.AbilityRuntime.Core 789 * @StageModelOnly 790 * @since 9 791 */ 792 restoreWindowStage(localStorage: LocalStorage): void; 793 794 /** 795 * Check to see ability is in terminating state. 796 * @returns { boolean } Returns true when ability is in terminating state, else returns false. 797 * @syscap SystemCapability.Ability.AbilityRuntime.Core 798 * @StageModelOnly 799 * @since 9 800 */ 801 isTerminating(): boolean; 802 803 /** 804 * Service extension uses this method to start a specific ability, 805 * if ability is multi instance, will start a recent instance. 806 * @param { Want } want - Indicates the ability to start. 807 * @param { AsyncCallback<void> } callback - The callback of startAbility. 808 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 809 * @syscap SystemCapability.Ability.AbilityRuntime.Core 810 * @systemapi 811 * @StageModelOnly 812 * @since 9 813 */ 814 startRecentAbility(want: Want, callback: AsyncCallback<void>): void; 815 816 /** 817 * Service extension uses this method to start a specific ability, 818 * if ability is multi instance, will start a recent instance. 819 * @param { Want } want - Indicates the ability to start. 820 * @param { StartOptions } options - Indicates the start options. 821 * @param { AsyncCallback<void> } callback - The callback of startAbility. 822 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 823 * @throws { BusinessError } 16000011 - The context does not exist. 824 * @throws { BusinessError } 16000050 - Internal error. 825 * @syscap SystemCapability.Ability.AbilityRuntime.Core 826 * @systemapi 827 * @StageModelOnly 828 * @since 9 829 */ 830 startRecentAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void; 831 832 /** 833 * Service extension uses this method to start a specific ability, 834 * if ability is multi instance, will start a recent instance. 835 * @param { Want } want - Indicates the ability to start. 836 * @param { StartOptions } options - Indicates the start options. 837 * @returns { Promise<void> } The promise returned by the function. 838 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 839 * @syscap SystemCapability.Ability.AbilityRuntime.Core 840 * @systemapi 841 * @throws { BusinessError } 16000011 - The context does not exist. 842 * @throws { BusinessError } 16000050 - Internal error. 843 * @StageModelOnly 844 * @since 9 845 */ 846 startRecentAbility(want: Want, options?: StartOptions): Promise<void>; 847 848 /** 849 * Requests certain permissions from the system. 850 * @param want { Want } - Indicates the dialog service to start. 851 * @param { AsyncCallback<RequestResult> } result - The callback is used to return the request result. 852 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 853 * @syscap SystemCapability.Ability.AbilityRuntime.Core 854 * @StageModelOnly 855 * @since 9 856 */ 857 requestDialogService(want: Want, result: AsyncCallback<dialogRequest.RequestResult>): void; 858 859 /** 860 * Requests certain permissions from the system. 861 * @param want { Want } - Indicates the dialog service to start. 862 * @returns { Promise<request.RequestResult> } Returns the request result. 863 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 864 * @syscap SystemCapability.Ability.AbilityRuntime.Core 865 * @StageModelOnly 866 * @since 9 867 */ 868 requestDialogService(want: Want): Promise<dialogRequest.RequestResult>; 869} 870