1/* 2 * Copyright (c) 2022-2025 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 { AsyncCallback } from '../@ohos.base'; 22import Context from './Context'; 23import AbilityLifecycleCallback from '../@ohos.app.ability.AbilityLifecycleCallback'; 24import EnvironmentCallback from '../@ohos.app.ability.EnvironmentCallback'; 25import type ApplicationStateChangeCallback from '../@ohos.app.ability.ApplicationStateChangeCallback'; 26import { ProcessInformation } from './ProcessInformation'; 27import type ConfigurationConstant from '../@ohos.app.ability.ConfigurationConstant'; 28import Want from '../@ohos.app.ability.Want'; 29 30/** 31 * The context of an application. It allows access to application-specific resources. 32 * 33 * @extends Context 34 * @syscap SystemCapability.Ability.AbilityRuntime.Core 35 * @stagemodelonly 36 * @since 9 37 */ 38/** 39 * The context of an application. It allows access to application-specific resources. 40 * 41 * @extends Context 42 * @syscap SystemCapability.Ability.AbilityRuntime.Core 43 * @stagemodelonly 44 * @crossplatform 45 * @since 10 46 */ 47/** 48 * The context of an application. It allows access to application-specific resources. 49 * 50 * @extends Context 51 * @syscap SystemCapability.Ability.AbilityRuntime.Core 52 * @stagemodelonly 53 * @crossplatform 54 * @atomicservice 55 * @since 11 56 */ 57export default class ApplicationContext extends Context { 58 /** 59 * Register ability lifecycle callback. 60 * 61 * @param { 'abilityLifecycle' } type - abilityLifecycle. 62 * @param { AbilityLifecycleCallback } callback - The ability lifecycle callback. 63 * @returns { number } Returns the number code of the callback. 64 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 65 * @syscap SystemCapability.Ability.AbilityRuntime.Core 66 * @stagemodelonly 67 * @since 9 68 */ 69 /** 70 * Register ability lifecycle callback. 71 * 72 * @param { 'abilityLifecycle' } type - abilityLifecycle. 73 * @param { AbilityLifecycleCallback } callback - The ability lifecycle callback. 74 * @returns { number } Returns the number code of the callback. 75 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 76 * @syscap SystemCapability.Ability.AbilityRuntime.Core 77 * @stagemodelonly 78 * @crossplatform 79 * @since 10 80 */ 81 /** 82 * Register ability lifecycle callback. 83 * 84 * @param { 'abilityLifecycle' } type - abilityLifecycle. 85 * @param { AbilityLifecycleCallback } callback - The ability lifecycle callback. 86 * @returns { number } Returns the number code of the callback. 87 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 88 * @syscap SystemCapability.Ability.AbilityRuntime.Core 89 * @stagemodelonly 90 * @crossplatform 91 * @atomicservice 92 * @since 11 93 */ 94 on(type: 'abilityLifecycle', callback: AbilityLifecycleCallback): number; 95 96 /** 97 * Unregister ability lifecycle callback. 98 * 99 * @param { 'abilityLifecycle' } type - abilityLifecycle. 100 * @param { number } callbackId - Indicates the number code of the callback. 101 * @param { AsyncCallback<void> } callback - The callback of off. 102 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 103 * @syscap SystemCapability.Ability.AbilityRuntime.Core 104 * @stagemodelonly 105 * @since 9 106 */ 107 /** 108 * Unregister ability lifecycle callback. 109 * 110 * @param { 'abilityLifecycle' } type - abilityLifecycle. 111 * @param { number } callbackId - Indicates the number code of the callback. 112 * @param { AsyncCallback<void> } callback - The callback of off. 113 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 114 * @syscap SystemCapability.Ability.AbilityRuntime.Core 115 * @stagemodelonly 116 * @crossplatform 117 * @since 10 118 */ 119 /** 120 * Unregister ability lifecycle callback. 121 * 122 * @param { 'abilityLifecycle' } type - abilityLifecycle. 123 * @param { number } callbackId - Indicates the number code of the callback. 124 * @param { AsyncCallback<void> } callback - The callback of off. 125 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 126 * @syscap SystemCapability.Ability.AbilityRuntime.Core 127 * @stagemodelonly 128 * @crossplatform 129 * @atomicservice 130 * @since 11 131 */ 132 off(type: 'abilityLifecycle', callbackId: number, callback: AsyncCallback<void>): void; 133 134 /** 135 * Unregister ability lifecycle callback. 136 * 137 * @param { 'abilityLifecycle' } type - abilityLifecycle. 138 * @param { number } callbackId - Indicates the number code of the callback. 139 * @returns { Promise<void> } The promise returned by the function. 140 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 141 * @syscap SystemCapability.Ability.AbilityRuntime.Core 142 * @stagemodelonly 143 * @since 9 144 */ 145 /** 146 * Unregister ability lifecycle callback. 147 * 148 * @param { 'abilityLifecycle' } type - abilityLifecycle. 149 * @param { number } callbackId - Indicates the number code of the callback. 150 * @returns { Promise<void> } The promise returned by the function. 151 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 152 * @syscap SystemCapability.Ability.AbilityRuntime.Core 153 * @stagemodelonly 154 * @atomicservice 155 * @since 11 156 */ 157 /** 158 * Unregister ability lifecycle callback. 159 * 160 * @param { 'abilityLifecycle' } type - abilityLifecycle. 161 * @param { number } callbackId - Indicates the number code of the callback. 162 * @returns { Promise<void> } The promise returned by the function. 163 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 164 * @syscap SystemCapability.Ability.AbilityRuntime.Core 165 * @stagemodelonly 166 * @crossplatform 167 * @atomicservice 168 * @since 12 169 */ 170 off(type: 'abilityLifecycle', callbackId: number): Promise<void>; 171 172 /** 173 * Register environment callback. 174 * 175 * @param { 'environment' } type - environment. 176 * @param { EnvironmentCallback } callback - The environment callback. 177 * @returns { number } Returns the number code of the callback. 178 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 179 * @syscap SystemCapability.Ability.AbilityRuntime.Core 180 * @stagemodelonly 181 * @since 9 182 */ 183 /** 184 * Register environment callback. 185 * 186 * @param { 'environment' } type - environment. 187 * @param { EnvironmentCallback } callback - The environment callback. 188 * @returns { number } Returns the number code of the callback. 189 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 190 * @syscap SystemCapability.Ability.AbilityRuntime.Core 191 * @stagemodelonly 192 * @atomicservice 193 * @since 11 194 */ 195 on(type: 'environment', callback: EnvironmentCallback): number; 196 197 /** 198 * Unregister environment callback. 199 * 200 * @param { 'environment' } type - environment. 201 * @param { number } callbackId - Indicates the number code of the callback. 202 * @param { AsyncCallback<void> } callback - The callback of unregisterEnvironmentCallback. 203 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 204 * @syscap SystemCapability.Ability.AbilityRuntime.Core 205 * @stagemodelonly 206 * @since 9 207 */ 208 /** 209 * Unregister environment callback. 210 * 211 * @param { 'environment' } type - environment. 212 * @param { number } callbackId - Indicates the number code of the callback. 213 * @param { AsyncCallback<void> } callback - The callback of unregisterEnvironmentCallback. 214 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 215 * @syscap SystemCapability.Ability.AbilityRuntime.Core 216 * @stagemodelonly 217 * @atomicservice 218 * @since 11 219 */ 220 off(type: 'environment', callbackId: number, callback: AsyncCallback<void>): void; 221 222 /** 223 * Unregister environment callback. 224 * 225 * @param { 'environment' } type - environment. 226 * @param { number } callbackId - Indicates the number code of the callback. 227 * @returns { Promise<void> } The promise returned by the function. 228 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 229 * @syscap SystemCapability.Ability.AbilityRuntime.Core 230 * @stagemodelonly 231 * @since 9 232 */ 233 /** 234 * Unregister environment callback. 235 * 236 * @param { 'environment' } type - environment. 237 * @param { number } callbackId - Indicates the number code of the callback. 238 * @returns { Promise<void> } The promise returned by the function. 239 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 240 * @syscap SystemCapability.Ability.AbilityRuntime.Core 241 * @stagemodelonly 242 * @atomicservice 243 * @since 11 244 */ 245 off(type: 'environment', callbackId: number): Promise<void>; 246 247 /** 248 * Register applicationStateChange callback. 249 * 250 * @param { 'applicationStateChange' } type - applicationStateChange. 251 * @param { ApplicationStateChangeCallback } callback - The applicationStateChange callback. 252 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 253 * @syscap SystemCapability.Ability.AbilityRuntime.Core 254 * @stagemodelonly 255 * @since 10 256 */ 257 /** 258 * Register applicationStateChange callback. 259 * 260 * @param { 'applicationStateChange' } type - applicationStateChange. 261 * @param { ApplicationStateChangeCallback } callback - The applicationStateChange callback. 262 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 263 * @syscap SystemCapability.Ability.AbilityRuntime.Core 264 * @stagemodelonly 265 * @atomicservice 266 * @since 11 267 */ 268 /** 269 * Register applicationStateChange callback. 270 * 271 * @param { 'applicationStateChange' } type - applicationStateChange. 272 * @param { ApplicationStateChangeCallback } callback - The applicationStateChange callback. 273 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 274 * @syscap SystemCapability.Ability.AbilityRuntime.Core 275 * @stagemodelonly 276 * @crossplatform 277 * @atomicservice 278 * @since 18 279 */ 280 on(type: 'applicationStateChange', callback: ApplicationStateChangeCallback): void; 281 282 /** 283 * Unregister applicationStateChange callback. 284 * 285 * @param { 'applicationStateChange' } type - applicationStateChange. 286 * @param { ApplicationStateChangeCallback } [callback] - The applicationStateChange callback. 287 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 288 * @syscap SystemCapability.Ability.AbilityRuntime.Core 289 * @stagemodelonly 290 * @since 10 291 */ 292 /** 293 * Unregister applicationStateChange callback. 294 * 295 * @param { 'applicationStateChange' } type - applicationStateChange. 296 * @param { ApplicationStateChangeCallback } [callback] - The applicationStateChange callback. 297 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 298 * @syscap SystemCapability.Ability.AbilityRuntime.Core 299 * @stagemodelonly 300 * @atomicservice 301 * @since 11 302 */ 303 /** 304 * Unregister applicationStateChange callback. 305 * 306 * @param { 'applicationStateChange' } type - applicationStateChange. 307 * @param { ApplicationStateChangeCallback } [callback] - The applicationStateChange callback. 308 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 309 * @syscap SystemCapability.Ability.AbilityRuntime.Core 310 * @stagemodelonly 311 * @crossplatform 312 * @atomicservice 313 * @since 18 314 */ 315 off(type: 'applicationStateChange', callback?: ApplicationStateChangeCallback): void; 316 317 /** 318 * Get information about running processes 319 * 320 * @returns { Promise<Array<ProcessInformation>> } Returns the array of {@link ProcessInformation}. 321 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 322 * @throws { BusinessError } 16000011 - The context does not exist. 323 * @throws { BusinessError } 16000050 - Internal error. 324 * @syscap SystemCapability.Ability.AbilityRuntime.Core 325 * @stagemodelonly 326 * @since 9 327 */ 328 /** 329 * Get information about running processes 330 * 331 * @returns { Promise<Array<ProcessInformation>> } Returns the array of {@link ProcessInformation}. 332 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 333 * @throws { BusinessError } 16000011 - The context does not exist. 334 * @throws { BusinessError } 16000050 - Internal error. 335 * @syscap SystemCapability.Ability.AbilityRuntime.Core 336 * @stagemodelonly 337 * @crossplatform 338 * @since 10 339 */ 340 /** 341 * Get information about running processes 342 * 343 * @returns { Promise<Array<ProcessInformation>> } Returns the array of {@link ProcessInformation}. 344 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 345 * @throws { BusinessError } 16000011 - The context does not exist. 346 * @throws { BusinessError } 16000050 - Internal error. 347 * @syscap SystemCapability.Ability.AbilityRuntime.Core 348 * @stagemodelonly 349 * @crossplatform 350 * @atomicservice 351 * @since 11 352 */ 353 getRunningProcessInformation(): Promise<Array<ProcessInformation>>; 354 355 /** 356 * Get information about running processes 357 * 358 * @param { AsyncCallback<Array<ProcessInformation>> } callback - The callback is used to return the array of {@link ProcessInformation}. 359 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 360 * @throws { BusinessError } 16000011 - The context does not exist. 361 * @throws { BusinessError } 16000050 - Internal error. 362 * @syscap SystemCapability.Ability.AbilityRuntime.Core 363 * @stagemodelonly 364 * @since 9 365 */ 366 /** 367 * Get information about running processes 368 * 369 * @param { AsyncCallback<Array<ProcessInformation>> } callback - The callback is used to return the array of {@link ProcessInformation}. 370 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 371 * @throws { BusinessError } 16000011 - The context does not exist. 372 * @throws { BusinessError } 16000050 - Internal error. 373 * @syscap SystemCapability.Ability.AbilityRuntime.Core 374 * @stagemodelonly 375 * @crossplatform 376 * @since 10 377 */ 378 /** 379 * Get information about running processes 380 * 381 * @param { AsyncCallback<Array<ProcessInformation>> } callback - The callback is used to return the array of {@link ProcessInformation}. 382 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 383 * @throws { BusinessError } 16000011 - The context does not exist. 384 * @throws { BusinessError } 16000050 - Internal error. 385 * @syscap SystemCapability.Ability.AbilityRuntime.Core 386 * @stagemodelonly 387 * @crossplatform 388 * @atomicservice 389 * @since 11 390 */ 391 getRunningProcessInformation(callback: AsyncCallback<Array<ProcessInformation>>): void; 392 393 /** 394 * Kill all processes of the application 395 * 396 * @returns { Promise<void> } The promise returned by the function. 397 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 398 * @throws { BusinessError } 16000011 - The context does not exist. 399 * @syscap SystemCapability.Ability.AbilityRuntime.Core 400 * @stagemodelonly 401 * @since 9 402 */ 403 /** 404 * Kill all processes of the application 405 * 406 * @returns { Promise<void> } The promise returned by the function. 407 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 408 * @throws { BusinessError } 16000011 - The context does not exist. 409 * @syscap SystemCapability.Ability.AbilityRuntime.Core 410 * @stagemodelonly 411 * @atomicservice 412 * @since 11 413 */ 414 killAllProcesses(): Promise<void>; 415 416 /** 417 * Kill all processes of the application 418 * 419 * @param { boolean } clearPageStack - The flag that indicates whether the page stack need to be cleared. 420 * @returns { Promise<void> } The promise returned by the function. 421 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 422 * @throws { BusinessError } 16000011 - The context does not exist. 423 * @syscap SystemCapability.Ability.AbilityRuntime.Core 424 * @stagemodelonly 425 * @atomicservice 426 * @since 14 427 */ 428 killAllProcesses(clearPageStack: boolean): Promise<void>; 429 430 /** 431 * Kill all processes of the application 432 * 433 * @param { AsyncCallback<void> } callback - The callback of killAllProcesses. 434 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 435 * @throws { BusinessError } 16000011 - The context does not exist. 436 * @syscap SystemCapability.Ability.AbilityRuntime.Core 437 * @stagemodelonly 438 * @since 9 439 */ 440 /** 441 * Kill all processes of the application 442 * 443 * @param { AsyncCallback<void> } callback - The callback of killAllProcesses. 444 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 445 * @throws { BusinessError } 16000011 - The context does not exist. 446 * @syscap SystemCapability.Ability.AbilityRuntime.Core 447 * @stagemodelonly 448 * @atomicservice 449 * @since 11 450 */ 451 killAllProcesses(callback: AsyncCallback<void>); 452 453 /** 454 * Set colorMode of the application 455 * 456 * @param { ConfigurationConstant.ColorMode } colorMode - Color mode. 457 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 458 * @throws { BusinessError } 16000011 - The context does not exist. 459 * @syscap SystemCapability.Ability.AbilityRuntime.Core 460 * @stagemodelonly 461 * @atomicservice 462 * @since 11 463 */ 464 /** 465 * Set colorMode of the application 466 * 467 * @param { ConfigurationConstant.ColorMode } colorMode - Color mode. 468 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 469 * @throws { BusinessError } 16000011 - The context does not exist. 470 * @syscap SystemCapability.Ability.AbilityRuntime.Core 471 * @stagemodelonly 472 * @crossplatform 473 * @atomicservice 474 * @since 18 475 */ 476 setColorMode(colorMode: ConfigurationConstant.ColorMode): void; 477 478 /** 479 * Set language of the application 480 * 481 * @param { string } language - Language. 482 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 483 * @throws { BusinessError } 16000011 - The context does not exist. 484 * @syscap SystemCapability.Ability.AbilityRuntime.Core 485 * @stagemodelonly 486 * @atomicservice 487 * @since 11 488 */ 489 setLanguage(language: string): void; 490 491 /** 492 * Clear up application data by app self 493 * 494 * @returns { Promise<void> } The promise returned by the function. 495 * @throws { BusinessError } 16000011 - The context does not exist. 496 * @throws { BusinessError } 16000050 - Internal error. 497 * @syscap SystemCapability.Ability.AbilityRuntime.Core 498 * @stagemodelonly 499 * @since 11 500 */ 501 clearUpApplicationData(): Promise<void>; 502 503 /** 504 * Clear up application data by app self 505 * 506 * @param { AsyncCallback<void> } callback - The callback of clearUpApplicationData. 507 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 508 * @throws { BusinessError } 16000011 - The context does not exist. 509 * @throws { BusinessError } 16000050 - Internal error. 510 * @syscap SystemCapability.Ability.AbilityRuntime.Core 511 * @stagemodelonly 512 * @since 11 513 */ 514 clearUpApplicationData(callback: AsyncCallback<void>): void; 515 516 /** 517 * Kill the application and does not call back the onDestroy method, then start UIAbility. 518 * 519 * @param { Want } want - Indicates the want name of the current app, and the ability name is UIAbility. 520 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 521 * @throws { BusinessError } 16000050 - Internal error. 522 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 523 * @throws { BusinessError } 16000063 - The target to restart does not belong to the current application or is not a UIAbility. 524 * @throws { BusinessError } 16000064 - Restart too frequently. Try again at least 3s later. 525 * @syscap SystemCapability.Ability.AbilityRuntime.Core 526 * @stagemodelonly 527 * @atomicservice 528 * @since 12 529 */ 530 restartApp(want: Want): void; 531 532 /** 533 * Preload UIExtensionAbility. 534 * 535 * @permission ohos.permission.PRELOAD_UI_EXTENSION_ABILITY 536 * @param { Want } want - Indicates the want of target UIExtensionAbility. 537 * @returns { Promise<void> } The promise returned by the function. 538 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 539 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 540 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 541 * @throws { BusinessError } 16000001 - The specified ability does not exist. 542 * @throws { BusinessError } 16000002 - Incorrect ability type. 543 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 544 * @throws { BusinessError } 16000011 - The context does not exist. 545 * @throws { BusinessError } 16000050 - Internal error. 546 * @syscap SystemCapability.Ability.AbilityRuntime.Core 547 * @systemapi 548 * @stagemodelonly 549 * @since 12 550 */ 551 preloadUIExtensionAbility(want: Want): Promise<void>; 552 553 /** 554 * Set the state about whether the application supports process cache or not. 555 * 556 * @param { boolean } isSupported - Indicates the process cache support state. 557 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 558 * @throws { BusinessError } 801 - Capability not supported. 559 * @throws { BusinessError } 16000011 - The context does not exist. 560 * @throws { BusinessError } 16000050 - Internal error. 561 * @syscap SystemCapability.Ability.AbilityRuntime.Core 562 * @stagemodelonly 563 * @since 12 564 */ 565 setSupportedProcessCache(isSupported : boolean): void; 566 567 /** 568 * Set font of the application 569 * 570 * @param { string } font - Font. 571 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 572 * @throws { BusinessError } 16000011 - The context does not exist. 573 * @throws { BusinessError } 16000050 - Internal error. 574 * @syscap SystemCapability.Ability.AbilityRuntime.Core 575 * @stagemodelonly 576 * @since 12 577 */ 578 setFont(font: string): void; 579 580 /** 581 * Get current app clone index. 582 * 583 * @returns { number } Returns the app clone index for current app. 584 * @throws { BusinessError } 16000011 - The context does not exist. 585 * @throws { BusinessError } 16000071 - The MultiAppMode is not {@link APP_CLONE}. 586 * @syscap SystemCapability.Ability.AbilityRuntime.Core 587 * @stagemodelonly 588 * @atomicservice 589 * @since 12 590 */ 591 getCurrentAppCloneIndex(): number; 592 593 /** 594 * Set font size scale. 595 * @param {number} fontSizeScale - Font size scale. 596 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 597 * @syscap SystemCapability.Ability.AbilityRuntime.Core 598 * @stagemodelonly 599 * @atomicservice 600 * @since 13 601 */ 602 setFontSizeScale(fontSizeScale: number): void; 603 604 /** 605 * Get current app key of current running app instance. 606 * 607 * @returns { string } Returns the key of current running app instance. 608 * @throws { BusinessError } 16000011 - The context does not exist. 609 * @throws { BusinessError } 16000078 - The multi-instance is not supported. 610 * @syscap SystemCapability.Ability.AbilityRuntime.Core 611 * @stagemodelonly 612 * @since 14 613 */ 614 getCurrentInstanceKey(): string; 615 616 /** 617 * Get all running app instance key for current bundle 618 * 619 * @returns { Promise<Array<string>> } Returns the array of all running app instance keys. 620 * @throws { BusinessError } 16000011 - The context does not exist. 621 * @throws { BusinessError } 16000050 - Internal error. 622 * @throws { BusinessError } 16000078 - The multi-instance is not supported. 623 * @syscap SystemCapability.Ability.AbilityRuntime.Core 624 * @stagemodelonly 625 * @since 14 626 */ 627 getAllRunningInstanceKeys(): Promise<Array<string>>; 628} 629