1/* 2 * Copyright (c) 2022-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 { AsyncCallback } from './@ohos.base'; 22import * as _ApplicationStateObserver from './application/ApplicationStateObserver'; 23import type * as _AppForegroundStateObserver from './application/AppForegroundStateObserver'; 24import * as _AbilityStateData from './application/AbilityStateData'; 25import * as _AppStateData from './application/AppStateData'; 26import type * as _ProcessData from './application/ProcessData'; 27import { ProcessInformation as _ProcessInformation } from './application/ProcessInformation'; 28import * as _AbilityFirstFrameStateObserver from './application/AbilityFirstFrameStateObserver'; 29import * as _AbilityFirstFrameStateData from './application/AbilityFirstFrameStateData'; 30import bundleManager from './@ohos.bundle.bundleManager'; 31import { RunningMultiAppInfo as _RunningMultiAppInfo } from './application/RunningMultiAppInfo'; 32 33/** 34 * This module provides the function of app manager service. 35 * 36 * @namespace appManager 37 * @syscap SystemCapability.Ability.AbilityRuntime.Core 38 * @since 9 39 */ 40/** 41 * This module provides the function of app manager service. 42 * 43 * @namespace appManager 44 * @syscap SystemCapability.Ability.AbilityRuntime.Core 45 * @atomicservice 46 * @since 11 47 */ 48declare namespace appManager { 49 /** 50 * Enum for the application state 51 * 52 * @enum { number } 53 * @syscap SystemCapability.Ability.AbilityRuntime.Core 54 * @systemapi 55 * @since 9 56 */ 57 export enum ApplicationState { 58 /** 59 * The state in which the application is being created. 60 * 61 * @syscap SystemCapability.Ability.AbilityRuntime.Core 62 * @systemapi 63 * @since 9 64 */ 65 STATE_CREATE, 66 67 /** 68 * The state that the application is in when it switches to the foreground. 69 * 70 * @syscap SystemCapability.Ability.AbilityRuntime.Core 71 * @systemapi 72 * @since 9 73 */ 74 STATE_FOREGROUND, 75 76 /** 77 * The state in which the application is in focus. 78 * 79 * @syscap SystemCapability.Ability.AbilityRuntime.Core 80 * @systemapi 81 * @since 9 82 */ 83 STATE_ACTIVE, 84 85 /** 86 * The state in which the application is invisible in the background. 87 * 88 * @syscap SystemCapability.Ability.AbilityRuntime.Core 89 * @systemapi 90 * @since 9 91 */ 92 STATE_BACKGROUND, 93 94 /** 95 * The state that the application is in when it is destroyed. 96 * 97 * @syscap SystemCapability.Ability.AbilityRuntime.Core 98 * @systemapi 99 * @since 9 100 */ 101 STATE_DESTROY 102 } 103 104 /** 105 * Enum for the process state 106 * 107 * @enum { number } 108 * @syscap SystemCapability.Ability.AbilityRuntime.Core 109 * @since 10 110 */ 111 /** 112 * Enum for the process state 113 * 114 * @enum { number } 115 * @syscap SystemCapability.Ability.AbilityRuntime.Core 116 * @atomicservice 117 * @since 11 118 */ 119 export enum ProcessState { 120 /** 121 * The state that the process is in when it is being created. 122 * 123 * @syscap SystemCapability.Ability.AbilityRuntime.Core 124 * @since 10 125 */ 126 /** 127 * The state that the process is in when it is being created. 128 * 129 * @syscap SystemCapability.Ability.AbilityRuntime.Core 130 * @atomicservice 131 * @since 11 132 */ 133 STATE_CREATE, 134 135 /** 136 * The state in which the process is in when it switches to the foreground. 137 * 138 * @syscap SystemCapability.Ability.AbilityRuntime.Core 139 * @since 10 140 */ 141 /** 142 * The state in which the process is in when it switches to the foreground. 143 * 144 * @syscap SystemCapability.Ability.AbilityRuntime.Core 145 * @atomicservice 146 * @since 11 147 */ 148 STATE_FOREGROUND, 149 150 /** 151 * The state in which the process is in focus. 152 * 153 * @syscap SystemCapability.Ability.AbilityRuntime.Core 154 * @since 10 155 */ 156 /** 157 * The state in which the process is in focus. 158 * 159 * @syscap SystemCapability.Ability.AbilityRuntime.Core 160 * @atomicservice 161 * @since 11 162 */ 163 STATE_ACTIVE, 164 165 /** 166 * The state in which a process is invisible in the background. 167 * 168 * @syscap SystemCapability.Ability.AbilityRuntime.Core 169 * @since 10 170 */ 171 /** 172 * The state in which a process is invisible in the background. 173 * 174 * @syscap SystemCapability.Ability.AbilityRuntime.Core 175 * @atomicservice 176 * @since 11 177 */ 178 STATE_BACKGROUND, 179 180 /** 181 * The state that the process is in when it is destroyed. 182 * 183 * @syscap SystemCapability.Ability.AbilityRuntime.Core 184 * @since 10 185 */ 186 /** 187 * The state that the process is in when it is destroyed. 188 * 189 * @syscap SystemCapability.Ability.AbilityRuntime.Core 190 * @atomicservice 191 * @since 11 192 */ 193 STATE_DESTROY 194 } 195 196 /** 197 * Enum for the preload mode 198 * 199 * @enum { number } 200 * @syscap SystemCapability.Ability.AbilityRuntime.Core 201 * @systemapi 202 * @stagemodelonly 203 * @since 12 204 */ 205 export enum PreloadMode { 206 /** 207 * Preload application when press the app icon down. 208 * 209 * @syscap SystemCapability.Ability.AbilityRuntime.Core 210 * @systemapi 211 * @stagemodelonly 212 * @since 12 213 */ 214 PRESS_DOWN 215 } 216 217 /** 218 * Register application state observer. 219 * 220 * @permission ohos.permission.RUNNING_STATE_OBSERVER 221 * @param { 'applicationState' } type - applicationState. 222 * @param { ApplicationStateObserver } observer - The application state observer. 223 * @returns { number } Returns the number code of the observer. 224 * @throws { BusinessError } 201 - Permission denied. 225 * @throws { BusinessError } 202 - Not system application. 226 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 227 * 2. Incorrect parameter types; 3. Parameter verification failed. 228 * @throws { BusinessError } 16000050 - Internal error. 229 * @syscap SystemCapability.Ability.AbilityRuntime.Core 230 * @systemapi 231 * @since 9 232 */ 233 function on(type: 'applicationState', observer: ApplicationStateObserver): number; 234 235 /** 236 * Register application state observer. 237 * 238 * @permission ohos.permission.RUNNING_STATE_OBSERVER 239 * @param { 'applicationState' } type - applicationState. 240 * @param { ApplicationStateObserver } observer - The application state observer. 241 * @param { Array<string> } bundleNameList - The list of bundleName. The max length is 128. 242 * @returns { number } Returns the number code of the observer. 243 * @throws { BusinessError } 201 - Permission denied. 244 * @throws { BusinessError } 202 - Not system application. 245 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 246 * 2. Incorrect parameter types; 3. Parameter verification failed. 247 * @throws { BusinessError } 16000050 - Internal error. 248 * @syscap SystemCapability.Ability.AbilityRuntime.Core 249 * @systemapi 250 * @since 9 251 */ 252 function on(type: 'applicationState', observer: ApplicationStateObserver, bundleNameList: Array<string>): number; 253 254 /** 255 * Register app foreground or background state observer. 256 * 257 * @permission ohos.permission.RUNNING_STATE_OBSERVER 258 * @param { 'appForegroundState' } type - app foreground or background state. 259 * @param { AppForegroundStateObserver } observer - The app foreground state observer. 260 * @throws { BusinessError } 201 - Permission denied. 261 * @throws { BusinessError } 202 - Not system application. 262 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 263 * 2. Incorrect parameter types; 3. Parameter verification failed. 264 * @throws { BusinessError } 16000050 - Internal error. 265 * @syscap SystemCapability.Ability.AbilityRuntime.Core 266 * @systemapi 267 * @since 11 268 */ 269 function on(type: 'appForegroundState', observer: AppForegroundStateObserver): void; 270 271 /** 272 * Register ability first frame state observe. 273 * 274 * @permission ohos.permission.RUNNING_STATE_OBSERVER 275 * @param { 'abilityFirstFrameState' } type - The ability first frame drawing state. 276 * @param { AbilityFirstFrameStateObserver } observer - The ability first frame state observer. 277 * @param { string } [bundleName] - The target bundle name. 278 * @throws { BusinessError } 201 - Permission denied. 279 * @throws { BusinessError } 202 - Not system application. 280 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 281 * 2. Incorrect parameter types; 3. Parameter verification failed. 282 * @throws { BusinessError } 16000050 - Internal error. 283 * @syscap SystemCapability.Ability.AbilityRuntime.Core 284 * @systemapi 285 * @since 12 286 */ 287 function on(type: 'abilityFirstFrameState', observer: AbilityFirstFrameStateObserver, bundleName?: string): void; 288 289 /** 290 * Unregister application state observer. 291 * 292 * @permission ohos.permission.RUNNING_STATE_OBSERVER 293 * @param { 'applicationState' } type - applicationState. 294 * @param { number } observerId - Indicates the number code of the observer. 295 * @param { AsyncCallback<void> } callback - The callback of off. 296 * @throws { BusinessError } 201 - Permission denied. 297 * @throws { BusinessError } 202 - Not system application. 298 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 299 * 2. Incorrect parameter types; 3. Parameter verification failed. 300 * @throws { BusinessError } 16000050 - Internal error. 301 * @syscap SystemCapability.Ability.AbilityRuntime.Core 302 * @systemapi 303 * @since 9 304 */ 305 function off(type: 'applicationState', observerId: number, callback: AsyncCallback<void>): void; 306 307 /** 308 * Unregister application state observer. 309 * 310 * @permission ohos.permission.RUNNING_STATE_OBSERVER 311 * @param { 'applicationState' } type - applicationState. 312 * @param { number } observerId - Indicates the number code of the observer. 313 * @returns { Promise<void> } The promise returned by the function. 314 * @throws { BusinessError } 201 - Permission denied. 315 * @throws { BusinessError } 202 - Not system application. 316 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 317 * 2. Incorrect parameter types; 3. Parameter verification failed. 318 * @throws { BusinessError } 16000050 - Internal error. 319 * @syscap SystemCapability.Ability.AbilityRuntime.Core 320 * @systemapi 321 * @since 9 322 */ 323 function off(type: 'applicationState', observerId: number): Promise<void>; 324 325 /** 326 * Unregister app foreground or background state observer. 327 * 328 * @permission ohos.permission.RUNNING_STATE_OBSERVER 329 * @param { 'appForegroundState' } type - app foreground or background state. 330 * @param { AppForegroundStateObserver } [observer] - The app foreground state observer. 331 * @throws { BusinessError } 201 - Permission denied. 332 * @throws { BusinessError } 202 - Not system application. 333 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 334 * 2. Incorrect parameter types; 3. Parameter verification failed. 335 * @throws { BusinessError } 16000050 - Internal error. 336 * @syscap SystemCapability.Ability.AbilityRuntime.Core 337 * @systemapi 338 * @since 11 339 */ 340 function off(type: 'appForegroundState', observer?: AppForegroundStateObserver): void; 341 342 /** 343 * Unregister ability first frame state observer. 344 * 345 * @permission ohos.permission.RUNNING_STATE_OBSERVER 346 * @param { 'abilityFirstFrameState' } type - The ability first frame drawing state. 347 * @param { AbilityFirstFrameStateObserver } [observer] - The ability first frame state observer. 348 * @throws { BusinessError } 201 - Permission denied. 349 * @throws { BusinessError } 202 - Not system application. 350 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 351 * 2. Incorrect parameter types; 3. Parameter verification failed. 352 * @throws { BusinessError } 16000050 - Internal error. 353 * @syscap SystemCapability.Ability.AbilityRuntime.Core 354 * @systemapi 355 * @since 12 356 */ 357 function off(type: 'abilityFirstFrameState', observer?: AbilityFirstFrameStateObserver): void; 358 359 /** 360 * getForegroundApplications. 361 * 362 * @permission ohos.permission.GET_RUNNING_INFO 363 * @param { AsyncCallback<Array<AppStateData>> } callback - The callback is used to return the list of AppStateData. 364 * @throws { BusinessError } 201 - Permission denied. 365 * @throws { BusinessError } 202 - Not system application. 366 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 367 * 2. Incorrect parameter types; 3. Parameter verification failed. 368 * @throws { BusinessError } 16000050 - Internal error. 369 * @syscap SystemCapability.Ability.AbilityRuntime.Core 370 * @systemapi 371 * @since 9 372 */ 373 function getForegroundApplications(callback: AsyncCallback<Array<AppStateData>>): void; 374 375 /** 376 * getForegroundApplications. 377 * 378 * @permission ohos.permission.GET_RUNNING_INFO 379 * @returns { Promise<Array<AppStateData>> } Returns the list of AppStateData. 380 * @throws { BusinessError } 201 - Permission denied. 381 * @throws { BusinessError } 202 - Not system application. 382 * @throws { BusinessError } 16000050 - Internal error. 383 * @syscap SystemCapability.Ability.AbilityRuntime.Core 384 * @systemapi 385 * @since 9 386 */ 387 function getForegroundApplications(): Promise<Array<AppStateData>>; 388 389 /** 390 * Kill process with account. 391 * 392 * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES 393 * @param { string } bundleName - The process bundle name. 394 * @param { number } accountId - The account id. 395 * @returns { Promise<void> } The promise returned by the function. 396 * @throws { BusinessError } 201 - Permission denied. 397 * @throws { BusinessError } 202 - Not system application. 398 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 399 * 2. Incorrect parameter types; 3. Parameter verification failed. 400 * @throws { BusinessError } 16000050 - Internal error. 401 * @syscap SystemCapability.Ability.AbilityRuntime.Core 402 * @systemapi 403 * @since 9 404 */ 405 function killProcessWithAccount(bundleName: string, accountId: number): Promise<void>; 406 407 /** 408 * Kill process with account. 409 * 410 * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES 411 * @param { string } bundleName - The process bundle name. 412 * @param { number } accountId - The account id. 413 * @param { AsyncCallback<void> } callback - The callback of killProcessWithAccount. 414 * @throws { BusinessError } 201 - Permission denied. 415 * @throws { BusinessError } 202 - Not system application. 416 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 417 * 2. Incorrect parameter types; 3. Parameter verification failed. 418 * @throws { BusinessError } 16000050 - Internal error. 419 * @syscap SystemCapability.Ability.AbilityRuntime.Core 420 * @systemapi 421 * @since 9 422 */ 423 function killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCallback<void>): void; 424 425 /** 426 * Is user running in stability test. 427 * 428 * @param { AsyncCallback<boolean> } callback - The callback is used to return true if user is running stability test. 429 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 430 * 2. Incorrect parameter types; 3. Parameter verification failed. 431 * @throws { BusinessError } 16000050 - Internal error. 432 * @syscap SystemCapability.Ability.AbilityRuntime.Core 433 * @since 9 434 */ 435 /** 436 * Is user running in stability test. 437 * 438 * @param { AsyncCallback<boolean> } callback - The callback is used to return true if user is running stability test. 439 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 440 * 2. Incorrect parameter types; 3. Parameter verification failed. 441 * @throws { BusinessError } 16000050 - Internal error. 442 * @syscap SystemCapability.Ability.AbilityRuntime.Core 443 * @atomicservice 444 * @since 11 445 */ 446 function isRunningInStabilityTest(callback: AsyncCallback<boolean>): void; 447 448 /** 449 * Is user running in stability test. 450 * 451 * @returns { Promise<boolean> } Returns true if user is running stability test. 452 * @throws { BusinessError } 16000050 - Internal error. 453 * @syscap SystemCapability.Ability.AbilityRuntime.Core 454 * @since 9 455 */ 456 /** 457 * Is user running in stability test. 458 * 459 * @returns { Promise<boolean> } Returns true if user is running stability test. 460 * @throws { BusinessError } 16000050 - Internal error. 461 * @syscap SystemCapability.Ability.AbilityRuntime.Core 462 * @atomicservice 463 * @since 11 464 */ 465 function isRunningInStabilityTest(): Promise<boolean>; 466 467 /** 468 * Kill processes by bundle name 469 * 470 * @permission ohos.permission.CLEAN_BACKGROUND_PROCESSES 471 * @param { string } bundleName - bundle name. 472 * @returns { Promise<void> } The promise returned by the function. 473 * @throws { BusinessError } 201 - Permission denied. 474 * @throws { BusinessError } 202 - Not system application. 475 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 476 * 2. Incorrect parameter types; 3. Parameter verification failed. 477 * @throws { BusinessError } 16000050 - Internal error. 478 * @syscap SystemCapability.Ability.AbilityRuntime.Core 479 * @systemapi 480 * @since 9 481 */ 482 function killProcessesByBundleName(bundleName: string): Promise<void>; 483 484 /** 485 * Kill processes by bundle name 486 * 487 * @permission ohos.permission.CLEAN_BACKGROUND_PROCESSES 488 * @param { string } bundleName - bundle name. 489 * @param { AsyncCallback<void> } callback - The callback of killProcessesByBundleName. 490 * @throws { BusinessError } 201 - Permission denied. 491 * @throws { BusinessError } 202 - Not system application. 492 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 493 * 2. Incorrect parameter types; 3. Parameter verification failed. 494 * @throws { BusinessError } 16000050 - Internal error. 495 * @syscap SystemCapability.Ability.AbilityRuntime.Core 496 * @systemapi 497 * @since 9 498 */ 499 function killProcessesByBundleName(bundleName: string, callback: AsyncCallback<void>); 500 501 /** 502 * Clear up application data by bundle name 503 * 504 * @permission ohos.permission.CLEAN_APPLICATION_DATA 505 * @param { string } bundleName - bundle name. 506 * @returns { Promise<void> } The promise returned by the function. 507 * @throws { BusinessError } 201 - Permission denied. 508 * @throws { BusinessError } 202 - Not system application. 509 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 510 * 2. Incorrect parameter types; 3. Parameter verification failed. 511 * @throws { BusinessError } 16000050 - Internal error. 512 * @syscap SystemCapability.Ability.AbilityRuntime.Core 513 * @systemapi 514 * @since 9 515 */ 516 function clearUpApplicationData(bundleName: string): Promise<void>; 517 518 /** 519 * Clear up application data by bundle name 520 * 521 * @permission ohos.permission.CLEAN_APPLICATION_DATA 522 * @param { string } bundleName - bundle name. 523 * @param { AsyncCallback<void> } callback - The callback of clearUpApplicationData. 524 * @throws { BusinessError } 201 - Permission denied. 525 * @throws { BusinessError } 202 - Not system application. 526 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 527 * 2. Incorrect parameter types; 3. Parameter verification failed. 528 * @throws { BusinessError } 16000050 - Internal error. 529 * @syscap SystemCapability.Ability.AbilityRuntime.Core 530 * @systemapi 531 * @since 9 532 */ 533 function clearUpApplicationData(bundleName: string, callback: AsyncCallback<void>); 534 535 /** 536 * Is it a ram-constrained device 537 * 538 * @returns { Promise<boolean> } Returns true if the device is ram-constrained. 539 * @throws { BusinessError } 16000050 - Internal error. 540 * @syscap SystemCapability.Ability.AbilityRuntime.Core 541 * @since 9 542 */ 543 /** 544 * Is it a ram-constrained device 545 * 546 * @returns { Promise<boolean> } Returns true if the device is ram-constrained. 547 * @throws { BusinessError } 16000050 - Internal error. 548 * @syscap SystemCapability.Ability.AbilityRuntime.Core 549 * @atomicservice 550 * @since 11 551 */ 552 function isRamConstrainedDevice(): Promise<boolean>; 553 554 /** 555 * Is it a ram-constrained device 556 * 557 * @param { AsyncCallback<boolean> } callback - The callback is used to return true if the device is ram-constrained. 558 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 559 * 2. Incorrect parameter types; 3. Parameter verification failed. 560 * @throws { BusinessError } 16000050 - Internal error. 561 * @syscap SystemCapability.Ability.AbilityRuntime.Core 562 * @since 9 563 */ 564 /** 565 * Is it a ram-constrained device 566 * 567 * @param { AsyncCallback<boolean> } callback - The callback is used to return true if the device is ram-constrained. 568 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 569 * 2. Incorrect parameter types; 3. Parameter verification failed. 570 * @throws { BusinessError } 16000050 - Internal error. 571 * @syscap SystemCapability.Ability.AbilityRuntime.Core 572 * @atomicservice 573 * @since 11 574 */ 575 function isRamConstrainedDevice(callback: AsyncCallback<boolean>): void; 576 577 /** 578 * Get the memory size of the application 579 * 580 * @returns { Promise<number> } Returns the application memory size. 581 * @throws { BusinessError } 16000050 - Internal error. 582 * @syscap SystemCapability.Ability.AbilityRuntime.Core 583 * @since 9 584 */ 585 /** 586 * Get the memory size of the application 587 * 588 * @returns { Promise<number> } Returns the application memory size. 589 * @throws { BusinessError } 16000050 - Internal error. 590 * @syscap SystemCapability.Ability.AbilityRuntime.Core 591 * @atomicservice 592 * @since 11 593 */ 594 function getAppMemorySize(): Promise<number>; 595 596 /** 597 * Get the memory size of the application 598 * 599 * @param { AsyncCallback<number> } callback - The callback is used to return the application memory size. 600 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 601 * 2. Incorrect parameter types; 3. Parameter verification failed. 602 * @throws { BusinessError } 16000050 - Internal error. 603 * @syscap SystemCapability.Ability.AbilityRuntime.Core 604 * @since 9 605 */ 606 /** 607 * Get the memory size of the application 608 * 609 * @param { AsyncCallback<number> } callback - The callback is used to return the application memory size. 610 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 611 * 2. Incorrect parameter types; 3. Parameter verification failed. 612 * @throws { BusinessError } 16000050 - Internal error. 613 * @syscap SystemCapability.Ability.AbilityRuntime.Core 614 * @atomicservice 615 * @since 11 616 */ 617 function getAppMemorySize(callback: AsyncCallback<number>): void; 618 619 /** 620 * If you apply for permission, you can obtain information about all running processes. 621 * If you do not apply, you can only obtain information about the current process. 622 * 623 * @permission ohos.permission.GET_RUNNING_INFO 624 * @returns { Promise<Array<ProcessInformation>> } Returns the array of {@link ProcessInformation}. 625 * @throws { BusinessError } 16000050 - Internal error. 626 * @syscap SystemCapability.Ability.AbilityRuntime.Core 627 * @since 9 628 */ 629 /** 630 * Get information about the current process. 631 * 632 * @returns { Promise<Array<ProcessInformation>> } Returns the array of {@link ProcessInformation}. 633 * @throws { BusinessError } 16000050 - Internal error. 634 * @syscap SystemCapability.Ability.AbilityRuntime.Core 635 * @atomicservice 636 * @since 11 637 */ 638 function getRunningProcessInformation(): Promise<Array<ProcessInformation>>; 639 640 /** 641 * Get running process information by bundle type. 642 * 643 * @permission ohos.permission.GET_RUNNING_INFO 644 * @param { bundleManager.BundleType } bundleType - the bundle type of the process 645 * @returns { Promise<Array<ProcessInformation>> } Returns the array of {@link ProcessInformation}. 646 * @throws { BusinessError } 201 - Permission denied. 647 * @throws { BusinessError } 202 - Not system application. 648 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 649 * 2. Incorrect parameter types; 3. Parameter verification failed. 650 * @throws { BusinessError } 16000050 - Internal error. 651 * @syscap SystemCapability.Ability.AbilityRuntime.Core 652 * @systemapi 653 * @since 12 654 */ 655 function getRunningProcessInformationByBundleType( 656 bundleType: bundleManager.BundleType): Promise<Array<ProcessInformation>>; 657 658 /** 659 * If you apply for permission, you can obtain information about all running processes. 660 * If you do not apply, you can only obtain information about the current process. 661 * 662 * @permission ohos.permission.GET_RUNNING_INFO 663 * @param { AsyncCallback<Array<ProcessInformation>> } callback - The callback is used to return the array of {@link ProcessInformation}. 664 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 665 * 2. Incorrect parameter types; 3. Parameter verification failed. 666 * @throws { BusinessError } 16000050 - Internal error. 667 * @syscap SystemCapability.Ability.AbilityRuntime.Core 668 * @since 9 669 */ 670 /** 671 * Get information about the current process. 672 * 673 * @param { AsyncCallback<Array<ProcessInformation>> } callback - The callback is used to return the array of {@link ProcessInformation}. 674 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 675 * 2. Incorrect parameter types; 3. Parameter verification failed. 676 * @throws { BusinessError } 16000050 - Internal error. 677 * @syscap SystemCapability.Ability.AbilityRuntime.Core 678 * @atomicservice 679 * @since 11 680 */ 681 function getRunningProcessInformation(callback: AsyncCallback<Array<ProcessInformation>>): void; 682 683 /** 684 * Check whether the shared bundle is running. 685 * 686 * @permission ohos.permission.GET_RUNNING_INFO 687 * @param { string } bundleName - Indicates the bundle name of the shared bundle. 688 * @param { number } versionCode - Indicates the version code of the shared bundle. 689 * @returns { Promise<boolean> } Returns the shared bundle running result. The result is true if running, false otherwise. 690 * @throws { BusinessError } 201 - Permission denied. 691 * @throws { BusinessError } 202 - Not system application. 692 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 693 * 2. Incorrect parameter types; 3. Parameter verification failed. 694 * @throws { BusinessError } 16000050 - Internal error. 695 * @syscap SystemCapability.Ability.AbilityRuntime.Core 696 * @systemapi 697 * @since 10 698 */ 699 function isSharedBundleRunning(bundleName: string, versionCode: number): Promise<boolean>; 700 701 /** 702 * Check whether the shared bundle is running. 703 * 704 * @permission ohos.permission.GET_RUNNING_INFO 705 * @param { string } bundleName - Indicates the bundle name of the shared bundle. 706 * @param { number } versionCode - Indicates the version code of the shared bundle. 707 * @param { AsyncCallback<boolean> } callback - The callback of checking the shared bundle running result. 708 * The result is true if running, false otherwise. 709 * @throws { BusinessError } 201 - Permission denied. 710 * @throws { BusinessError } 202 - Not system application. 711 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 712 * 2. Incorrect parameter types; 3. Parameter verification failed. 713 * @throws { BusinessError } 16000050 - Internal error. 714 * @syscap SystemCapability.Ability.AbilityRuntime.Core 715 * @systemapi 716 * @since 10 717 */ 718 function isSharedBundleRunning(bundleName: string, versionCode: number, callback: AsyncCallback<boolean>): void; 719 720 /** 721 * Obtains memory usage of one process by its pid. 722 * 723 * @param { number } pid - Indicates the pid of the process. 724 * @returns { Promise<number> } Returns the memory usage of the process in KB. 725 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 726 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 727 * 2. Incorrect parameter types; 3. Parameter verification failed. 728 * @throws { BusinessError } 16000050 - Internal error. 729 * @syscap SystemCapability.Ability.AbilityRuntime.Core 730 * @systemapi 731 * @since 10 732 */ 733 function getProcessMemoryByPid(pid: number): Promise<number>; 734 735 /** 736 * Obtains memory usage of one process by its pid. 737 * 738 * @param { number } pid - Indicates the pid of the process. 739 * @param { AsyncCallback<number> } callback - Indicates the callback of getting process memory by pid result. 740 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 741 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 742 * 2. Incorrect parameter types; 3. Parameter verification failed. 743 * @throws { BusinessError } 16000050 - Internal error. 744 * @syscap SystemCapability.Ability.AbilityRuntime.Core 745 * @systemapi 746 * @since 10 747 */ 748 function getProcessMemoryByPid(pid: number, callback: AsyncCallback<number>): void; 749 750 /** 751 * Obtains the process information list of running processes that belong to a specific bundle of current user. 752 * 753 * @param { string } bundleName - Indicates the bundle name of the application to which the processes belong to. 754 * @param { AsyncCallback<Array<ProcessInformation>> } callback - Indicates the callback of getting process information by bundleName result. 755 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 756 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 757 * 2. Incorrect parameter types; 3. Parameter verification failed. 758 * @throws { BusinessError } 16000050 - Internal error. 759 * @syscap SystemCapability.Ability.AbilityRuntime.Core 760 * @systemapi 761 * @since 10 762 */ 763 function getRunningProcessInfoByBundleName(bundleName: string, callback: AsyncCallback<Array<ProcessInformation>>): void; 764 765 /** 766 * Obtains the process information list of running processes that belong to a specific bundle and specific user ID. 767 * 768 * @param { string } bundleName - Indicates the bundle name of the application to which the processes belong to. 769 * @param { number } userId - Indicates the user ID of the application to which the processes belong to. 770 * @param { AsyncCallback<Array<ProcessInformation>> } callback - Indicates the callback of getting process information by bundleName result. 771 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 772 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 773 * 2. Incorrect parameter types; 3. Parameter verification failed. 774 * @throws { BusinessError } 16000050 - Internal error. 775 * @syscap SystemCapability.Ability.AbilityRuntime.Core 776 * @systemapi 777 * @since 10 778 */ 779 function getRunningProcessInfoByBundleName(bundleName: string, userId: number, callback: AsyncCallback<Array<ProcessInformation>>): void; 780 781 /** 782 * Obtains the process information list of running processes that belong to a specific bundle of current user. 783 * 784 * @param { string } bundleName - Indicates the bundle name of the application to which the processes belong to. 785 * @returns { Promise<Array<ProcessInformation>> } Returns a list of process information. 786 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 787 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 788 * 2. Incorrect parameter types; 3. Parameter verification failed. 789 * @throws { BusinessError } 16000050 - Internal error. 790 * @syscap SystemCapability.Ability.AbilityRuntime.Core 791 * @systemapi 792 * @since 10 793 */ 794 function getRunningProcessInfoByBundleName(bundleName: string): Promise<Array<ProcessInformation>>; 795 796 /** 797 * Obtains the process information list of running processes that belong to a specific bundle and specific user ID. 798 * 799 * @param { string } bundleName - Indicates the bundle name of the application to which the processes belong to. 800 * @param { number } userId - Indicates the user ID of the application to which the processes belong to. 801 * @returns { Promise<Array<ProcessInformation>> } Returns a list of process information. 802 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 803 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 804 * 2. Incorrect parameter types; 3. Parameter verification failed. 805 * @throws { BusinessError } 16000050 - Internal error. 806 * @syscap SystemCapability.Ability.AbilityRuntime.Core 807 * @systemapi 808 * @since 10 809 */ 810 function getRunningProcessInfoByBundleName(bundleName: string, userId: number): Promise<Array<ProcessInformation>>; 811 812 /** 813 * Check whether the bundle is running. 814 * 815 * @permission ohos.permission.GET_RUNNING_INFO 816 * @param { string } bundleName - Indicates the bundle name of the bundle. 817 * @returns { Promise<boolean> } Returns the bundle running result. The result is true if running, false otherwise. 818 * @throws { BusinessError } 201 - Permission denied. 819 * @throws { BusinessError } 202 - Not system application. 820 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 821 * 2. Incorrect parameter types; 3. Parameter verification failed. 822 * @throws { BusinessError } 16000050 - Internal error. 823 * @syscap SystemCapability.Ability.AbilityRuntime.Core 824 * @systemapi 825 * @since 11 826 */ 827 function isApplicationRunning(bundleName: string): Promise<boolean>; 828 829 /** 830 * Check whether the bundle is running. 831 * 832 * @permission ohos.permission.GET_RUNNING_INFO 833 * @param { string } bundleName - Indicates the bundle name of the bundle. 834 * @param { AsyncCallback<boolean> } callback - The callback of checking the bundle running result. 835 * The result is true if running, false otherwise. 836 * @throws { BusinessError } 201 - Permission denied. 837 * @throws { BusinessError } 202 - Not system application. 838 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 839 * 2. Incorrect parameter types; 3. Parameter verification failed. 840 * @throws { BusinessError } 16000050 - Internal error. 841 * @syscap SystemCapability.Ability.AbilityRuntime.Core 842 * @systemapi 843 * @since 11 844 */ 845 function isApplicationRunning(bundleName: string, callback: AsyncCallback<boolean>): void; 846 847 /** 848 * Preload the target application, create process and initialize resources. 849 * 850 * @permission ohos.permission.PRELOAD_APPLICATION 851 * @param { string } bundleName - The bundle name of the application to preload. 852 * @param { number } userId - Indicates the user identification. 853 * @param { PreloadMode } mode - Preload application mode. 854 * @param { number } [appIndex] - The index of application clone. 855 * @returns { Promise<void> } Returns the result of preloadApplication. 856 * @throws { BusinessError } 201 - The application does not have permission to call the interface. 857 * @throws { BusinessError } 202 - Not system application. 858 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 859 * 2. Incorrect parameter types; 3. Parameter verification failed. 860 * @throws { BusinessError } 16000050 - Internal error. 861 * @throws { BusinessError } 16300005 - The target bundle does not exist. 862 * @syscap SystemCapability.Ability.AbilityRuntime.Core 863 * @systemapi 864 * @stagemodelonly 865 * @since 12 866 */ 867 function preloadApplication(bundleName: string, userId: number, mode: PreloadMode, appIndex?: number): Promise<void>; 868 869 /** 870 * Get all running multi app info by bundleName 871 * 872 * @permission ohos.permission.GET_RUNNING_INFO 873 * @param { string } bundleName - The bundle name of the application to query. 874 * @returns { Promise<RunningMultiAppInfo> } Returns the {@link RunningMultiAppInfo} for given bundle. 875 * @throws { BusinessError } 201 - Permission denied. 876 * @throws { BusinessError } 202 - Not system application. 877 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 878 * 2. Incorrect parameter types; 3. Parameter verification failed. 879 * @throws { BusinessError } 16000072 - App clone or multi-instance is not supported. 880 * @throws { BusinessError } 18500001 - The bundle does not exist. 881 * @syscap SystemCapability.Ability.AbilityRuntime.Core 882 * @systemapi 883 * @stagemodelonly 884 * @since 12 885 */ 886 function getRunningMultiAppInfo(bundleName: string): Promise<RunningMultiAppInfo>; 887 888 /** 889 * Check whether the bundle is running. 890 * 891 * @permission ohos.permission.GET_RUNNING_INFO 892 * @param { string } bundleName - Indicates the bundle name of the bundle. 893 * @param { number } [appCloneIndex] - app clone index 894 * @returns { Promise<boolean> } Returns the bundle running result. The result is true if running, false otherwise. 895 * @throws { BusinessError } 201 - Permission denied. 896 * @throws { BusinessError } 202 - Not system application. 897 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 898 * 2. Incorrect parameter types; 3. Parameter verification failed. 899 * @throws { BusinessError } 16000050 - Internal error. 900 * @throws { BusinessError } 16000073 - The app clone index is invalid. 901 * @syscap SystemCapability.Ability.AbilityRuntime.Core 902 * @systemapi 903 * @since 12 904 */ 905 function isAppRunning(bundleName: string, appCloneIndex?: number): Promise<boolean>; 906 907 /** 908 * Clear up application data by bundle name 909 * 910 * @permission ohos.permission.CLEAN_APPLICATION_DATA 911 * @param { string } bundleName - bundle name. 912 * @param { number } [appCloneIndex] - app clone index 913 * @returns { Promise<void> } The promise returned by the function. 914 * @throws { BusinessError } 201 - Permission denied. 915 * @throws { BusinessError } 202 - Not system application. 916 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 917 * 2. Incorrect parameter types; 3. Parameter verification failed. 918 * @throws { BusinessError } 16000050 - Internal error. 919 * @throws { BusinessError } 16000073 - The app clone index is invalid. 920 * @syscap SystemCapability.Ability.AbilityRuntime.Core 921 * @systemapi 922 * @since 13 923 */ 924 function clearUpAppData(bundleName: string, appCloneIndex?: number): Promise<void>; 925 926 /** 927 * Terminate the mission of a UIAbility and back to caller. 928 * 929 * @permission ohos.permission.KILL_APP_PROCESSES 930 * @param { number } missionId - The mission id of the UIAbility need to be terminated. 931 * @returns { Promise<void> } Returns the result of terminateMission. 932 * @throws { BusinessError } 201 - Permission denied. 933 * @throws { BusinessError } 202 - Not system application. 934 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 935 * 2. Incorrect parameter types; 3. Parameter verification failed. 936 * @throws { BusinessError } 16000050 - Internal error. 937 * @syscap SystemCapability.Ability.AbilityRuntime.Core 938 * @systemapi 939 * @since 13 940 */ 941 function terminateMission(missionId: number): Promise<void>; 942 943 /** 944 * The ability or extension state data. 945 * 946 * @typedef { _AbilityStateData.default } 947 * @syscap SystemCapability.Ability.AbilityRuntime.Core 948 * @systemapi 949 * @since 9 950 */ 951 export type AbilityStateData = _AbilityStateData.default; 952 953 /** 954 * The application state data. 955 * 956 * @typedef { _AppStateData.default } 957 * @syscap SystemCapability.Ability.AbilityRuntime.Core 958 * @systemapi 959 * @since 9 960 */ 961 export type AppStateData = _AppStateData.default; 962 963 /** 964 * The application state observer. 965 * 966 * @typedef { _ApplicationStateObserver.default } 967 * @syscap SystemCapability.Ability.AbilityRuntime.Core 968 * @systemapi 969 * @since 9 970 */ 971 export type ApplicationStateObserver = _ApplicationStateObserver.default; 972 973 /** 974 * The application foreground state observer. 975 * 976 * @typedef { _AppForegroundStateObserver.default } 977 * @syscap SystemCapability.Ability.AbilityRuntime.Core 978 * @systemapi 979 * @since 11 980 */ 981 export type AppForegroundStateObserver = _AppForegroundStateObserver.default; 982 983 /** 984 * The class of a process information. 985 * 986 * @syscap SystemCapability.Ability.AbilityRuntime.Core 987 * @since 9 988 */ 989 /** 990 * The class of a process information. 991 * 992 * @typedef { _ProcessInformation } 993 * @syscap SystemCapability.Ability.AbilityRuntime.Core 994 * @atomicservice 995 * @since 11 996 */ 997 export type ProcessInformation = _ProcessInformation; 998 999 /** 1000 * The class of a process information. 1001 * 1002 * @typedef { _ProcessData.default } 1003 * @syscap SystemCapability.Ability.AbilityRuntime.Core 1004 * @systemapi 1005 * @since 10 1006 */ 1007 export type ProcessData = _ProcessData.default; 1008 1009 /** 1010 * The ability first frame state observer. 1011 * 1012 * @typedef { _AbilityFirstFrameStateObserver.default } 1013 * @syscap SystemCapability.Ability.AbilityRuntime.Core 1014 * @systemapi 1015 * @since 12 1016 */ 1017 export type AbilityFirstFrameStateObserver = _AbilityFirstFrameStateObserver.default; 1018 1019 /** 1020 * The class of an ability first frame state data. 1021 * 1022 * @typedef { _AbilityFirstFrameStateData.default } 1023 * @syscap SystemCapability.Ability.AbilityRuntime.Core 1024 * @systemapi 1025 * @since 12 1026 */ 1027 export type AbilityFirstFrameStateData = _AbilityFirstFrameStateData.default; 1028 1029 /** 1030 * The class of running multi app information. 1031 * 1032 * @typedef { _RunningMultiAppInfo } 1033 * @syscap SystemCapability.Ability.AbilityRuntime.Core 1034 * @systemapi 1035 * @since 12 1036 */ 1037 export type RunningMultiAppInfo = _RunningMultiAppInfo; 1038} 1039 1040export default appManager; 1041