1 /* 2 * Copyright (c) 2021-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 #ifndef OHOS_ABILITY_RUNTIME_APP_MGR_SERVICE_INNER_H 17 #define OHOS_ABILITY_RUNTIME_APP_MGR_SERVICE_INNER_H 18 19 #include <list> 20 #include <map> 21 #include <mutex> 22 #include <regex> 23 #include <unordered_map> 24 #include <unordered_set> 25 #include <vector> 26 27 #include "ability_debug_response_interface.h" 28 #include "ability_foreground_state_observer_interface.h" 29 #include "ability_info.h" 30 #include "advanced_security_mode_manager.h" 31 #include "app_death_recipient.h" 32 #include "app_debug_listener_interface.h" 33 #include "app_debug_manager.h" 34 #include "app_foreground_state_observer_interface.h" 35 #include "app_malloc_info.h" 36 #include "app_mgr_constants.h" 37 #include "app_mgr_event.h" 38 #include "app_preloader.h" 39 #include "app_record_id.h" 40 #include "app_running_manager.h" 41 #include "app_running_record.h" 42 #include "app_running_status_listener_interface.h" 43 #include "app_running_status_module.h" 44 #include "app_scheduler_interface.h" 45 #include "app_spawn_client.h" 46 #include "appexecfwk_errors.h" 47 #include "bundle_info.h" 48 #include "bundle_mgr_helper.h" 49 #include "child_process_info.h" 50 #include "child_process_request.h" 51 #include "cpp/mutex.h" 52 #include "event_report.h" 53 #include "fault_data.h" 54 #include "hisysevent.h" 55 #include "iapp_state_callback.h" 56 #include "iapplication_state_observer.h" 57 #include "iconfiguration_observer.h" 58 #include "iremote_object.h" 59 #include "irender_state_observer.h" 60 #include "istart_specified_ability_response.h" 61 #include "kia_interceptor_interface.h" 62 #include "record_query_result.h" 63 #include "refbase.h" 64 #include "remote_client_manager.h" 65 #include "render_process_info.h" 66 #include "running_process_info.h" 67 #include "shared/base_shared_bundle_info.h" 68 #include "task_handler_wrap.h" 69 #include "want.h" 70 #include "app_jsheap_mem_info.h" 71 #include "running_multi_info.h" 72 73 namespace OHOS { 74 namespace AbilityRuntime { 75 struct LoadParam; 76 } 77 namespace Rosen { 78 class WindowVisibilityInfo; 79 class WindowPidVisibilityInfo; 80 class FocusChangeInfo; 81 } 82 namespace AppExecFwk { 83 using OHOS::AAFwk::Want; 84 class WindowFocusChangedListener; 85 class WindowVisibilityChangedListener; 86 class WindowPidVisibilityChangedListener; 87 using LoadAbilityTaskFunc = std::function<void()>; 88 constexpr int32_t BASE_USER_RANGE = 200000; 89 90 class AppMgrServiceInner : public std::enable_shared_from_this<AppMgrServiceInner> { 91 public: 92 struct ConfigurationObserverWithUserId { 93 sptr<IConfigurationObserver> observer; 94 int32_t userId = -1; 95 }; 96 struct AppStateCallbackWithUserId { 97 sptr<IAppStateCallback> callback; 98 int32_t userId = -1; 99 }; 100 101 AppMgrServiceInner(); 102 virtual ~AppMgrServiceInner(); 103 104 /** 105 * Initialize the object. 106 */ 107 void Init(); 108 /** 109 * LoadAbility, load the ability that needed to be started. 110 * 111 * @param token, the unique identification to start the ability. 112 * @param preToken, the unique identification to call the ability. 113 * @param abilityInfo, the ability information. 114 * @param appInfo, the app information. 115 * @param want the ability want. 116 * 117 * @return 118 */ 119 virtual void LoadAbility(std::shared_ptr<AbilityInfo> abilityInfo, std::shared_ptr<ApplicationInfo> appInfo, 120 std::shared_ptr<AAFwk::Want> want, std::shared_ptr<AbilityRuntime::LoadParam> loadParam); 121 122 /** 123 * TerminateAbility, terminate the token ability. 124 * 125 * @param token, he unique identification to terminate the ability. 126 * @param clearMissionFlag, indicates whether terminate the ability when clearMission. 127 * @return 128 */ 129 virtual void TerminateAbility(const sptr<IRemoteObject> &token, bool clearMissionFlag); 130 131 /** 132 * UpdateAbilityState, update the ability status. 133 * 134 * @param token, the unique identification to update the ability. 135 * @param state, ability status that needs to be updated. 136 * 137 * @return 138 */ 139 virtual void UpdateAbilityState(const sptr<IRemoteObject> &token, const AbilityState state); 140 141 /** 142 * UpdateExtensionState, call UpdateExtensionState() through the proxy object, update the extension status. 143 * 144 * @param token, the unique identification to update the extension. 145 * @param state, extension status that needs to be updated. 146 */ 147 virtual void UpdateExtensionState(const sptr<IRemoteObject> &token, const ExtensionState state); 148 149 /** 150 * StateChangedNotifyObserver, Call ability state change. 151 * 152 * @param ability, the ability info. 153 * @param state, the ability state. 154 * 155 * @return 156 */ 157 void StateChangedNotifyObserver( 158 const AbilityStateData abilityStateData, bool isAbility, bool isFromWindowFocusChanged); 159 160 /** 161 * RegisterAppStateCallback, register the callback. 162 * 163 * @param callback, Ams register the callback. 164 * 165 * @return 166 */ 167 virtual void RegisterAppStateCallback(const sptr<IAppStateCallback> &callback); 168 void RemoveDeadAppStateCallback(const wptr<IRemoteObject> &remote); 169 170 /** 171 * KillProcessByAbilityToken, kill the process by ability token. 172 * 173 * @param token, the unique identification to the ability. 174 * @return 175 */ 176 virtual void KillProcessByAbilityToken(const sptr<IRemoteObject> &token); 177 178 /** 179 * KillProcessesByUserId, kill the processes by userId. 180 * 181 * @param userId, the user id. 182 * @return 183 */ 184 virtual void KillProcessesByUserId(int32_t userId); 185 186 /** 187 * KillProcessesByPids, only in process call is allowed, 188 * kill the processes by pid list given. 189 * 190 * @param pids, the pid list of processes are going to be killed. 191 * @return 192 */ 193 virtual void KillProcessesByPids(std::vector<int32_t> &pids); 194 195 /** 196 * Set child and parent relationship 197 * @param token child process 198 * @param callerToken parent process 199 */ 200 virtual void AttachPidToParent(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &callerToken); 201 202 /** 203 * AttachApplication, get all the information needed to start the Application 204 * (data related to the Application ). 205 * 206 * @param appScheduler, information needed to start the Application. 207 * 208 * @return 209 */ 210 virtual void AttachApplication(const pid_t pid, const sptr<IAppScheduler> &appScheduler); 211 212 /** 213 * Preload application. 214 * 215 * @param bundleName The bundle name of the application to preload. 216 * @param userId Indicates the user identification. 217 * @param preloadMode Preload application mode. 218 * @param appIndex The index of application clone. 219 * @return Returns ERR_OK on success, others on failure. 220 */ 221 virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId, 222 AppExecFwk::PreloadMode preloadMode, int32_t appIndex); 223 224 /** 225 * ApplicationForegrounded, set the application to Foreground State. 226 * 227 * @param recordId, a unique record that identifies this Application from others. 228 * 229 * @return 230 */ 231 virtual void ApplicationForegrounded(const int32_t recordId); 232 233 /** 234 * ApplicationBackgrounded, set the application to Backgrounded State. 235 * 236 * @param recordId, a unique record that identifies this Application from others. 237 * 238 * @return 239 */ 240 virtual void ApplicationBackgrounded(const int32_t recordId); 241 242 /** 243 * ApplicationTerminated, terminate the application. 244 * 245 * @param recordId, a unique record that identifies this Application from others. 246 * 247 * @return 248 */ 249 virtual void ApplicationTerminated(const int32_t recordId); 250 251 /** 252 * AbilityTerminated, terminate the ability. 253 * 254 * @param token, the unique identification to terminated the ability. 255 * 256 * @return 257 */ 258 virtual void AbilityTerminated(const sptr<IRemoteObject> &token); 259 260 /** 261 * UpdateApplicationInfoInstalled, update the application info after new module installed. 262 * 263 * @param bundleName, bundle name in Application record. 264 * @param uid, uid. 265 * @return ERR_OK, return back success, others fail. 266 */ 267 virtual int32_t UpdateApplicationInfoInstalled(const std::string &bundleName, const int uid); 268 269 /** 270 * KillApplication, kill the application. 271 * 272 * @param bundleName, bundle name in Application record. 273 * 274 * @return ERR_OK, return back success, others fail. 275 */ 276 virtual int32_t KillApplication(const std::string &bundleName, const bool clearPageStack = false); 277 278 /** 279 * ForceKillApplication, force kill the application. 280 * 281 * @param bundleName, bundle name in Application record. 282 * @param userId, userId. 283 * @param appIndex, appIndex. 284 * @return ERR_OK, return back success, others fail. 285 */ 286 virtual int32_t ForceKillApplication(const std::string &bundleName, const int userId = -1, 287 const int appIndex = 0); 288 289 /** 290 * KillProcessesByAccessTokenId. 291 * 292 * @param accessTokenId, accessTokenId. 293 * @return ERR_OK, return back success, others fail. 294 */ 295 virtual int32_t KillProcessesByAccessTokenId(const uint32_t accessTokenId); 296 297 /** 298 * KillApplicationByUid, call KillApplicationByUid() through proxy object, kill the application. 299 * 300 * @param bundleName, bundle name in Application record. 301 * @param uid, uid. 302 * @param reason, caller function name. 303 * @return ERR_OK, return back success, others fail. 304 */ 305 virtual int32_t KillApplicationByUid(const std::string &bundleName, const int uid, 306 const std::string& reason = "KillApplicationByUid"); 307 308 /** 309 * KillApplicationSelf, this allows app to terminate itself. 310 * 311 * @param clearPageStack, the flag indicates if ClearPageStack lifecycle should be scheduled. 312 * @return ERR_OK for success call, others for failure. 313 */ 314 virtual int32_t KillApplicationSelf(const bool clearPageStack = false, 315 const std::string& reason = "KillApplicationSelf"); 316 317 /** 318 * KillApplicationByUserId, kill the application by user ID. 319 * 320 * @param bundleName, bundle name in Application record. 321 * @param appCloneIndex the app clone id. 322 * @param userId, user ID. 323 * @param reason, caller function name. 324 * 325 * @return ERR_OK, return back success, others fail. 326 */ 327 virtual int32_t KillApplicationByUserId(const std::string &bundleName, int32_t appCloneIndex, int userId, 328 const bool clearPageStack = false, const std::string& reason = "KillApplicationByUserId"); 329 330 /** 331 * ClearUpApplicationData, clear the application data. 332 * 333 * @param bundleName, bundle name in Application record. 334 * @param callerUid, app uid in Application record. 335 * @param callerPid, app pid in Application record. 336 * @param appCloneIndex the app clone id. 337 * @param userId the user id 338 * @return ERR_OK, return back success, others fail. 339 */ 340 virtual int32_t ClearUpApplicationData(const std::string &bundleName, 341 int32_t callerUid, pid_t callerPid, int32_t appCloneIndex, int32_t userId = -1); 342 343 /** 344 * ClearUpApplicationDataBySelf, clear the application data. 345 * 346 * @param callerUid, app uid in Application record. 347 * @param callerPid, app pid in Application record. 348 * @param userId, user ID. 349 * 350 * @return ERR_OK, return back success, others fail. 351 */ 352 virtual int32_t ClearUpApplicationDataBySelf(int32_t callerUid, pid_t callerPid, int32_t userId = -1); 353 354 /** 355 * GetAllRunningProcesses, Obtains information about application processes that are running on the device. 356 * 357 * @param info, app name in Application record. 358 * 359 * @return ERR_OK ,return back success,others fail. 360 */ 361 virtual int32_t GetAllRunningProcesses(std::vector<RunningProcessInfo> &info); 362 363 /** 364 * GetRunningMultiAppInfoByBundleName, call GetRunningMultiAppInfoByBundleName through proxy project. 365 * Obtains information about TwinApp that are running on the device. 366 * 367 * @param bundleName, input. 368 * @param info, output multiapp information. 369 * @return void. 370 */ 371 virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName, 372 RunningMultiAppInfo &info); 373 374 /** 375 * GetAllRunningInstanceKeysBySelf, call GetAllRunningInstanceKeysBySelf() through proxy project. 376 * Obtains running instance keys of multi-instance app that are running on the device. 377 * 378 * @param instanceKeys, output instance keys of the multi-instance app. 379 * @return ERR_OK ,return back success,others fail. 380 */ 381 virtual int32_t GetAllRunningInstanceKeysBySelf(std::vector<std::string> &instanceKeys); 382 383 /** 384 * GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project. 385 * Obtains running instance keys of multi-instance app that are running on the device. 386 * 387 * @param bundlename, bundle name in Application record. 388 * @param instanceKeys, output instance keys of the multi-instance app. 389 * @param userId, user id. 390 * @return ERR_OK ,return back success,others fail. 391 */ 392 virtual int32_t GetAllRunningInstanceKeysByBundleName(const std::string &bundleName, 393 std::vector<std::string> &instanceKeys, int32_t userId = -1); 394 395 /** 396 * GetRunningProcessesByBundleType, Obtains information about application processes by bundle type. 397 * 398 * @param bundleType, the bundle type of the application process 399 * @param info, app name in Application record. 400 * 401 * @return ERR_OK ,return back success,others fail. 402 */ 403 virtual int32_t GetRunningProcessesByBundleType(BundleType bundleType, std::vector<RunningProcessInfo> &info); 404 405 /** 406 * GetProcessRunningInfosByUserId, Obtains information about application processes that are running on the device. 407 * 408 * @param info, app name in Application record. 409 * @param userId, userId. 410 * 411 * @return ERR_OK ,return back success,others fail. 412 */ 413 virtual int32_t GetProcessRunningInfosByUserId(std::vector<RunningProcessInfo> &info, int32_t userId); 414 415 /** 416 * GetProcessRunningInformation, Obtains information about current application process 417 * which is running on the device. 418 * @param info, app name in Application record. 419 * 420 * @return ERR_OK ,return back success,others fail. 421 */ 422 virtual int32_t GetProcessRunningInformation(RunningProcessInfo &info); 423 424 /** 425 * GetAllRenderProcesses, Obtains information about render processes that are running on the device. 426 * 427 * @param info, render process record. 428 * 429 * @return ERR_OK, return back success, others fail. 430 */ 431 virtual int32_t GetAllRenderProcesses(std::vector<RenderProcessInfo> &info); 432 433 /** 434 * GetAllChildrenProcesses, call GetAllChildrenProcesses() through proxy project. 435 * Obtains information about children processes that are running on the device. 436 * 437 * @param info, child process info. 438 * @return ERR_OK, return back success, others fail. 439 */ 440 virtual int GetAllChildrenProcesses(std::vector<ChildProcessInfo> &info); 441 442 /** 443 * NotifyMemoryLevel, Notify applications background the current memory level. 444 * 445 * @param level, current memory level. 446 * 447 * @return ERR_OK ,return back success,others fail. 448 */ 449 virtual int32_t NotifyMemoryLevel(int32_t level); 450 451 /** 452 * NotifyProcMemoryLevel, Notify applications background the current memory level. 453 * 454 * @param procLevelMap , <pid_t, MemoryLevel>. 455 * 456 * @return ERR_OK ,return back success,others fail. 457 */ 458 virtual int32_t NotifyProcMemoryLevel(const std::map<pid_t, MemoryLevel> &procLevelMap); 459 460 /** 461 * DumpHeapMemory, get the application's memory info. 462 * Get the application's memory allocation info. 463 * 464 * @param pid, pid input. 465 * @param mallocInfo, dynamic storage information output. 466 * 467 * @return ERR_OK, return back success,others fail. 468 */ 469 virtual int32_t DumpHeapMemory(const int32_t pid, OHOS::AppExecFwk::MallocInfo &mallocInfo); 470 471 /** 472 * DumpJsHeapMemory, call DumpJsHeapMemory() through proxy project. 473 * triggerGC and dump the application's jsheap memory info. 474 * 475 * @param info, pid, tid, needGc, needSnapshot 476 * @return Returns ERR_OK on success, others on failure. 477 */ 478 virtual int32_t DumpJsHeapMemory(OHOS::AppExecFwk::JsHeapDumpInfo &info); 479 480 /** 481 * @brief Check whether the shared bundle is running. 482 * 483 * @param bundleName Shared bundle name. 484 * @param versionCode Shared bundle version code. 485 * @return Returns the shared bundle running result. The result is true if running, false otherwise. 486 */ 487 virtual bool IsSharedBundleRunning(const std::string &bundleName, uint32_t versionCode); 488 489 /** 490 * Check whether the bundle is running. 491 * 492 * @param bundleName Indicates the bundle name of the bundle. 493 * @param isRunning Obtain the running status of the application, the result is true if running, false otherwise. 494 * @return Return ERR_OK if success, others fail. 495 */ 496 int32_t IsApplicationRunning(const std::string &bundleName, bool &isRunning); 497 498 /** 499 * Check whether the bundle is running. 500 * 501 * @param bundleName Indicates the bundle name of the bundle. 502 * @param appCloneIndex the appindex of the bundle. 503 * @param isRunning Obtain the running status of the application, the result is true if running, false otherwise. 504 * @return Return ERR_OK if success, others fail. 505 */ 506 int32_t IsAppRunning(const std::string &bundleName, int32_t appCloneIndex, bool &isRunning); 507 508 /** 509 * start native process for debugger. 510 * 511 * @param want param to start a process. 512 */ 513 int32_t StartNativeProcessForDebugger(const AAFwk::Want &want); 514 515 std::shared_ptr<AppRunningRecord> CreateAppRunningRecord( 516 std::shared_ptr<AbilityRuntime::LoadParam> loadParam, 517 std::shared_ptr<ApplicationInfo> appInfo, 518 std::shared_ptr<AbilityInfo> abilityInfo, 519 const std::string &processName, 520 const BundleInfo &bundleInfo, 521 const HapModuleInfo &hapModuleInfo, 522 std::shared_ptr<AAFwk::Want> want, 523 bool isKia = false); 524 525 /** 526 * OnStop, Application management service stopped. 527 * 528 * @return 529 */ 530 void OnStop(); 531 532 /** 533 * OpenAppSpawnConnection, Open connection with appspawn. 534 * 535 * @return ERR_OK ,return back success,others fail. 536 */ 537 virtual ErrCode OpenAppSpawnConnection(); 538 539 /** 540 * CloseAppSpawnConnection, Close connection with appspawn. 541 * 542 * @return 543 */ 544 virtual void CloseAppSpawnConnection() const; 545 546 /** 547 * QueryAppSpawnConnectionState, Query the connection status with appspawn. 548 * 549 * @return Returns the connection status with appspawn. 550 */ 551 virtual SpawnConnectionState QueryAppSpawnConnectionState() const; 552 553 /** 554 * SetAppSpawnClient, Setting the client to connect with appspawn. 555 * 556 * @param spawnClient, the client to connect with appspawn. 557 * 558 * @return 559 */ 560 void SetAppSpawnClient(std::shared_ptr<AppSpawnClient> spawnClient); 561 562 // Schedule launch application with specified |appRecord| 563 564 /** 565 * LaunchApplication, Notify application to launch application. 566 * 567 * @param appRecord, the application record. 568 * 569 * @return 570 */ 571 void LaunchApplication(const std::shared_ptr<AppRunningRecord> &appRecord); 572 573 /** 574 * Notice of AddAbilityStageInfo() 575 * 576 * @param recordId, the application record. 577 */ 578 virtual void AddAbilityStageDone(const int32_t recordId); 579 580 /** 581 * GetAppRunningRecordByPid, Get process record by application pid. 582 * 583 * @param pid, the application pid. 584 * 585 * @return process record. 586 */ 587 std::shared_ptr<AppRunningRecord> GetAppRunningRecordByPid(const pid_t pid) const; 588 589 /** 590 * GetAppRunningRecordByAbilityToken, Get process record by ability token. 591 * 592 * @param abilityToken, the ability token. 593 * 594 * @return process record. 595 */ 596 std::shared_ptr<AppRunningRecord> GetAppRunningRecordByAbilityToken(const sptr<IRemoteObject> &abilityToken) const; 597 598 /** 599 * GetTerminatingAppRunningRecord, Get process record by ability token. 600 * 601 * @param abilityToken, the ability token. 602 * 603 * @return process record. 604 */ 605 std::shared_ptr<AppRunningRecord> GetTerminatingAppRunningRecord(const sptr<IRemoteObject> &token) const; 606 607 /** 608 * GetAppRunningRecordByAppRecordId, Get process record by application id. 609 * 610 * @param recordId, the application id. 611 * 612 * @return process record. 613 */ 614 std::shared_ptr<AppRunningRecord> GetAppRunningRecordByAppRecordId(const int32_t recordId) const; 615 616 /** 617 * OnAbilityStateChanged, Call ability state change. 618 * 619 * @param ability, the ability info. 620 * @param state, the ability state. 621 * 622 * @return 623 */ 624 void OnAbilityStateChanged(const std::shared_ptr<AbilityRunningRecord> &ability, const AbilityState state); 625 626 /** 627 * OnRemoteDied, Equipment death notification. 628 * 629 * @param remote, Death client. 630 * @param isRenderProcess is render process died. 631 * @param isChildProcess is child process died. 632 * @return 633 */ 634 void OnRemoteDied(const wptr<IRemoteObject> &remote, bool isRenderProcess = false, bool isChildProcess = false); 635 636 void HandleTimeOut(const AAFwk::EventWrap &event); 637 DecreaseWillKillPidsNum()638 void DecreaseWillKillPidsNum() 639 { 640 willKillPidsNum_ -= 1; 641 } 642 SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler)643 void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler) 644 { 645 taskHandler_ = taskHandler; 646 } 647 SetEventHandler(const std::shared_ptr<AMSEventHandler> &eventHandler)648 void SetEventHandler(const std::shared_ptr<AMSEventHandler> &eventHandler) 649 { 650 eventHandler_ = eventHandler; 651 } 652 653 /** 654 * HandleAbilityAttachTimeOut, called by ability manager service when an ability is loaded timeout. 655 * 656 * @param token indicates the token of the ability which is timeout. 657 */ 658 void HandleAbilityAttachTimeOut(const sptr<IRemoteObject> &token); 659 660 /** 661 * PrepareTerminate, called before terminating one ability by ability manager service to notify application. 662 * 663 * @param token indicates the token of the ability to be terminated. 664 * @param clearMissionFlag indicates whether it is caused by cleaning mission. 665 */ 666 void PrepareTerminate(const sptr<IRemoteObject> &token, bool clearMissionFlag = false); 667 668 void OnAppStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord, const ApplicationState state, 669 bool needNotifyApp, bool isFromWindowFocusChanged); 670 671 void OnAppStarted(const std::shared_ptr<AppRunningRecord> &appRecord); 672 673 void OnAppStopped(const std::shared_ptr<AppRunningRecord> &appRecord); 674 675 /** 676 * GetRunningProcessInfoByToken, get process info for one ability. 677 * 678 * @param token indicates the token of the ability requested. 679 * @param info output of the information. 680 */ 681 void GetRunningProcessInfoByToken(const sptr<IRemoteObject> &token, AppExecFwk::RunningProcessInfo &info); 682 683 int32_t GetRunningProcessInfoByPid(const pid_t pid, OHOS::AppExecFwk::RunningProcessInfo &info) const; 684 685 /** 686 * Set AbilityForegroundingFlag of an app-record to true. 687 * 688 * @param pid, pid. 689 * 690 */ 691 void SetAbilityForegroundingFlagToAppRecord(const pid_t pid) const; 692 693 /** 694 * UpdateConfiguration, ANotify application update system environment changes. 695 * 696 * @param config, System environment change parameters. 697 * @return Returns ERR_OK on success, others on failure. 698 */ 699 int32_t UpdateConfiguration(const Configuration &config, const int32_t userId = -1); 700 701 int32_t UpdateConfigurationByBundleName(const Configuration &config, const std::string &name); 702 703 std::shared_ptr<AppExecFwk::Configuration> GetConfiguration(); 704 705 int32_t RegisterConfigurationObserver(const sptr<IConfigurationObserver>& observer); 706 707 int32_t UnregisterConfigurationObserver(const sptr<IConfigurationObserver>& observer); 708 709 /** 710 * Start empty process 711 */ 712 void LoadResidentProcess(const std::vector<BundleInfo> &infos); 713 714 void StartResidentProcess(const std::vector<BundleInfo> &infos, int restartCount, bool isEmptyKeepAliveApp); 715 716 bool CheckRemoteClient(); 717 718 /** 719 * Register application or process state observer. 720 * @param observer, ability token. 721 * @return Returns ERR_OK on success, others on failure. 722 */ 723 int32_t RegisterApplicationStateObserver(const sptr<IApplicationStateObserver> &observer, 724 const std::vector<std::string> &bundleNameList = {}); 725 726 /** 727 * Unregister application or process state observer. 728 * @param observer, ability token. 729 * @return Returns ERR_OK on success, others on failure. 730 */ 731 int32_t UnregisterApplicationStateObserver(const sptr<IApplicationStateObserver> &observer); 732 733 /** 734 * Register application or process state observer. 735 * @param observer, Is ability foreground state observer 736 * @return Returns ERR_OK on success, others on failure. 737 */ 738 int32_t RegisterAbilityForegroundStateObserver(const sptr<IAbilityForegroundStateObserver> &observer); 739 740 /** 741 * Unregister application or process state observer. 742 * @param observer, Is ability foreground state observer 743 * @return Returns ERR_OK on success, others on failure. 744 */ 745 int32_t UnregisterAbilityForegroundStateObserver(const sptr<IAbilityForegroundStateObserver> &observer); 746 747 /** 748 * Get Foreground Applications. 749 * 750 * @return Foreground Applications. 751 */ 752 int32_t GetForegroundApplications(std::vector<AppStateData> &list); 753 754 /** 755 * Start user test process. 756 * @param want, want object. 757 * @param observer, test observer remote object. 758 * @param bundleInfo, bundle info. 759 * @param userId the user id. 760 * @return Returns ERR_OK on success, others on failure. 761 */ 762 int StartUserTestProcess(const AAFwk::Want &want, const sptr<IRemoteObject> &observer, 763 const AppExecFwk::BundleInfo &bundleInfo, int32_t userId); 764 765 /** 766 * @brief Finish user test. 767 * @param msg user test message. 768 * @param resultCode user test result Code. 769 * @param bundleName user test bundleName. 770 * @param pid the user test process id. 771 * 772 * @return Returns ERR_OK on success, others on failure. 773 */ 774 int FinishUserTest( 775 const std::string &msg, const int64_t &resultCode, const std::string &bundleName, const pid_t &pid); 776 777 /** 778 * Start specified ability. 779 * 780 * @param want Want contains information of the ability to start. 781 * @param abilityInfo Ability information. 782 * @param requestId request id to callback 783 */ 784 void StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, 785 int32_t requestId = 0); 786 787 /** 788 * Start specified process. 789 * 790 * @param want Want contains information wish to start. 791 * @param abilityInfo Ability information. 792 * @param requestId for callback 793 */ 794 void StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, 795 int32_t requestId = 0); 796 797 void RegisterStartSpecifiedAbilityResponse(const sptr<IStartSpecifiedAbilityResponse> &response); 798 799 /** 800 * @brief called when the abilityStage's onAcceptWant lifecycle completed. 801 * @param recordId record id of the ability. 802 * @param want want has been accepted. 803 * @param flag flag get from OnAcceptWant. 804 */ 805 void ScheduleAcceptWantDone(const int32_t recordId, const AAFwk::Want &want, const std::string &flag); 806 807 void ScheduleNewProcessRequestDone(const int32_t recordId, const AAFwk::Want &want, const std::string &flag); 808 809 /** 810 * Get the token of ability records by process ID. 811 * 812 * @param pid The process id. 813 * @param tokens The token of ability records. 814 * @return Returns true on success, others on failure. 815 */ 816 int GetAbilityRecordsByProcessID(const int pid, std::vector<sptr<IRemoteObject>> &tokens); 817 818 virtual int32_t PreStartNWebSpawnProcess(const pid_t hostPid); 819 820 virtual int32_t StartRenderProcess(const pid_t hostPid, 821 const std::string &renderParam, 822 int32_t ipcFd, int32_t sharedFd, 823 int32_t crashFd, pid_t &renderPid, bool isGPU = false); 824 825 virtual void AttachRenderProcess(const pid_t pid, const sptr<IRenderScheduler> &scheduler); 826 827 virtual int GetRenderProcessTerminationStatus(pid_t renderPid, int &status); 828 829 int VerifyKillProcessPermission(const sptr<IRemoteObject> &token) const; 830 831 int VerifyAccountPermission(const std::string &permissionName, const int userId) const; 832 833 int VerifyRequestPermission() const; 834 835 void ClearAppRunningData(const std::shared_ptr<AppRunningRecord> &appRecord, bool containsApp); 836 837 void TerminateApplication(const std::shared_ptr<AppRunningRecord> &appRecord); 838 839 int GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug); 840 841 /** 842 * Record process exit reason to appRunningRecord 843 * @param pid pid 844 * @param reason reason enum 845 * @param exitMsg exitMsg 846 * @return Returns ERR_OK on success, others on failure. 847 */ 848 int32_t NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg); 849 850 /** 851 * Notify application status. 852 * 853 * @param bundleName Indicates the name of the bundle. 854 * @param eventData Indicates the event defined by CommonEventSupport 855 * 856 * @return 857 */ 858 void NotifyAppStatus(const std::string &bundleName, const std::string &eventData); 859 860 int32_t KillProcessByPid(const pid_t pid, const std::string& reason = "foundation"); 861 862 /** 863 * @brief Get the running state of application by bundle name. 864 * 865 * @param bundleName Bundle name 866 * @return Returns true if process is running, false if process isn't running. 867 */ 868 bool GetAppRunningStateByBundleName(const std::string &bundleName); 869 870 /** 871 * @brief Notify application load patch. 872 * 873 * @param bundleName Bundle name 874 * @param callback called when LoadPatch finished. 875 * @return Returns ERR_OK on success, error code on failure. 876 */ 877 int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback); 878 879 int32_t NotifyHotReloadPage(const std::string &bundleName, const sptr<IQuickFixCallback> &callback); 880 881 int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback); 882 #ifdef SUPPORT_SCREEN 883 void HandleFocused(const sptr<OHOS::Rosen::FocusChangeInfo> &focusChangeInfo); 884 void HandleUnfocused(const sptr<OHOS::Rosen::FocusChangeInfo> &focusChangeInfo); 885 886 /** 887 * Handle window visibility changed. 888 */ 889 void HandleWindowVisibilityChanged( 890 const std::vector<sptr<OHOS::Rosen::WindowVisibilityInfo>> &windowVisibilityInfos); 891 892 /** 893 * Handle window pid visibility changed. 894 */ 895 void HandleWindowPidVisibilityChanged(const sptr<OHOS::Rosen::WindowPidVisibilityInfo>& windowPidVisibilityInfo); 896 #endif //SUPPORT_SCREEN 897 /** 898 * Set the current userId, only used by abilityMgr. 899 * 900 * @param userId the user id. 901 * 902 * @return 903 */ 904 void SetCurrentUserId(const int32_t userId); 905 906 /** 907 * Set enable start process flag by userId 908 * @param userId the user id. 909 * @param enableStartProcess enable start process. 910 * @return 911 */ 912 void SetEnableStartProcessFlagByUserId(int32_t userId, bool enableStartProcess); 913 914 #ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE 915 int32_t SetContinuousTaskProcess(int32_t pid, bool isContinuousTask); 916 #endif 917 918 /** 919 * Get bundleName by pid. 920 * 921 * @param pid process id. 922 * @param bundleName Output parameters, return bundleName. 923 * @param uid Output parameters, return userId. 924 * @return Returns ERR_OK on success, others on failure. 925 */ 926 int32_t GetBundleNameByPid(const int32_t pid, std::string &bundleName, int32_t &uid); 927 928 /** 929 * Notify Fault Data 930 * 931 * @param faultData the fault data. 932 * @return Returns ERR_OK on success, others on failure. 933 */ 934 int32_t NotifyAppFault(const FaultData &faultData); 935 936 /** 937 * Transformed Notify Fault Data 938 * 939 * @param faultData Transformed the fault data. 940 * @return Returns ERR_OK on success, others on failure. 941 */ 942 943 int32_t TransformedNotifyAppFault(const AppFaultDataBySA &faultData); 944 945 /** 946 * Notify Fault Data By SA 947 * 948 * @param faultData the fault data notified by SA. 949 * @return Returns ERR_OK on success, others on failure. 950 */ 951 int32_t NotifyAppFaultBySA(const AppFaultDataBySA &faultData); 952 953 /** 954 * Set Appfreeze Detect Filter 955 * 956 * @param pid the process pid. 957 * @return Returns true on success, others on failure. 958 */ 959 bool SetAppFreezeFilter(int32_t pid); 960 961 /** 962 * get memorySize by pid. 963 * 964 * @param pid process id. 965 * @param memorySize Output parameters, return memorySize in KB. 966 * @return Returns ERR_OK on success, others on failure. 967 */ 968 virtual int32_t GetProcessMemoryByPid(const int32_t pid, int32_t &memorySize); 969 970 /** 971 * get application processes information list by bundleName. 972 * 973 * @param bundleName Bundle name. 974 * @param userId user Id in Application record. 975 * @param info Output parameters, return running process info list. 976 * @return Returns ERR_OK on success, others on failure. 977 */ 978 virtual int32_t GetRunningProcessInformation( 979 const std::string &bundleName, int32_t userId, std::vector<RunningProcessInfo> &info); 980 981 /** 982 * init focusListener. 983 * 984 * @return 985 */ 986 void InitFocusListener(); 987 988 /** 989 * free focusListener. 990 * 991 * @return 992 */ 993 void FreeFocusListener(); 994 995 /** 996 * Init window visibility changed listener. 997 */ 998 void InitWindowVisibilityChangedListener(); 999 1000 /** 1001 * Free window visibility changed listener. 1002 */ 1003 void FreeWindowVisibilityChangedListener(); 1004 1005 /** 1006 * Init window pid visibility changed listener. 1007 */ 1008 void InitWindowPidVisibilityChangedListener(); 1009 1010 /** 1011 * Free window pid visibility changed listener. 1012 */ 1013 void FreeWindowPidVisibilityChangedListener(); 1014 1015 /* 1016 * @brief Notify NativeEngine GC of status change. 1017 * 1018 * @param state GC state 1019 * @param pid pid 1020 * 1021 * @return Is the status change completed. 1022 */ 1023 int32_t ChangeAppGcState(pid_t pid, int32_t state); 1024 1025 /** 1026 * @brief Register app debug listener. 1027 * @param listener App debug listener. 1028 * @return Returns ERR_OK on success, others on failure. 1029 */ 1030 int32_t RegisterAppDebugListener(const sptr<IAppDebugListener> &listener); 1031 1032 /** 1033 * @brief Unregister app debug listener. 1034 * @param listener App debug listener. 1035 * @return Returns ERR_OK on success, others on failure. 1036 */ 1037 int32_t UnregisterAppDebugListener(const sptr<IAppDebugListener> &listener); 1038 1039 /** 1040 * @brief Attach app debug. 1041 * @param bundleName The application bundle name. 1042 * @return Returns ERR_OK on success, others on failure. 1043 */ 1044 int32_t AttachAppDebug(const std::string &bundleName); 1045 1046 /** 1047 * @brief Detach app debug. 1048 * @param bundleName The application bundle name. 1049 * @return Returns ERR_OK on success, others on failure. 1050 */ 1051 int32_t DetachAppDebug(const std::string &bundleName); 1052 1053 /** 1054 * @brief Set app waiting debug mode. 1055 * @param bundleName The application bundle name. 1056 * @param isPersist The persist flag. 1057 * @return Returns ERR_OK on success, others on failure. 1058 */ 1059 int32_t SetAppWaitingDebug(const std::string &bundleName, bool isPersist); 1060 1061 /** 1062 * @brief Cancel app waiting debug mode. 1063 * @return Returns ERR_OK on success, others on failure. 1064 */ 1065 int32_t CancelAppWaitingDebug(); 1066 1067 /** 1068 * @brief Get waiting debug mode application. 1069 * @param bundleNameList The application bundle name list. 1070 * @return Returns ERR_OK on success, others on failure. 1071 */ 1072 int32_t GetWaitingDebugApp(std::vector<std::string> &bundleNameList); 1073 1074 /** 1075 * @brief Determine whether it is a waiting debug application based on the bundle name. 1076 * @return Returns true if it is a waiting debug application, otherwise it returns false. 1077 */ 1078 bool IsWaitingDebugApp(const std::string &bundleName); 1079 1080 /** 1081 * @brief Clear non persist waiting debug flag. 1082 */ 1083 void ClearNonPersistWaitingDebugFlag(); 1084 1085 /** 1086 * @brief Registering ability debug mode response. 1087 * @param response Response for ability debug object. 1088 * @return Returns ERR_OK on success, others on failure. 1089 */ 1090 int32_t RegisterAbilityDebugResponse(const sptr<IAbilityDebugResponse> &response); 1091 1092 /** 1093 * @brief Determine whether it is an attachment debug application based on the bundle name. 1094 * @param bundleName The application bundle name. 1095 * @return Returns true if it is an attach debug application, otherwise it returns false. 1096 */ 1097 bool IsAttachDebug(const std::string &bundleName); 1098 1099 /** 1100 * @brief Notify AbilityManagerService the page show. 1101 * @param token Ability identify. 1102 * @param pageStateData The data of ability's page state. 1103 * @return Returns ERR_OK on success, others on failure. 1104 */ 1105 virtual int32_t NotifyPageShow(const sptr<IRemoteObject> &token, const PageStateData &pageStateData); 1106 1107 /** 1108 * @brief Notify AbilityManagerService the page hide. 1109 * @param token Ability identify. 1110 * @param pageStateData The data of ability's page state. 1111 * @return Returns ERR_OK on success, others on failure. 1112 */ 1113 virtual int32_t NotifyPageHide(const sptr<IRemoteObject> &token, const PageStateData &pageStateData); 1114 1115 /** 1116 * Register appRunning status listener. 1117 * 1118 * @param listener Running status listener. 1119 * @return Returns ERR_OK on success, others on failure. 1120 */ 1121 int32_t RegisterAppRunningStatusListener(const sptr<IRemoteObject> &listener); 1122 1123 /** 1124 * Unregister appRunning status listener. 1125 * 1126 * @param listener Running status listener. 1127 * @return Returns ERR_OK on success, others on failure. 1128 */ 1129 int32_t UnregisterAppRunningStatusListener(const sptr<IRemoteObject> &listener); 1130 1131 /** 1132 * Register application foreground state observer. 1133 * @param observer Is app foreground statue observer 1134 * @return Returns ERR_OK on success, others on failure. 1135 */ 1136 int32_t RegisterAppForegroundStateObserver(const sptr<IAppForegroundStateObserver> &observer); 1137 1138 /** 1139 * Unregister application foreground state observer. 1140 * @param observer Is app foreground statue observer 1141 * @return Returns ERR_OK on success, others on failure. 1142 */ 1143 int32_t UnregisterAppForegroundStateObserver(const sptr<IAppForegroundStateObserver> &observer); 1144 1145 /** 1146 * Start child process, called by ChildProcessManager. 1147 * 1148 * @param callingPid Calling process pid. 1149 * @param childPid Created child process pid. 1150 * @param request Child process start request params. 1151 * @return Returns ERR_OK on success, others on failure. 1152 */ 1153 virtual int32_t StartChildProcess(const pid_t callingPid, pid_t &childPid, const ChildProcessRequest &request); 1154 1155 /** 1156 * Get child process record for self. 1157 * 1158 * @return child process record. 1159 */ 1160 virtual int32_t GetChildProcessInfoForSelf(ChildProcessInfo &info); 1161 1162 /** 1163 * Attach child process scheduler to app manager service. 1164 * 1165 * @param pid the child process pid to exit. 1166 * @param childScheduler scheduler of child process. 1167 */ 1168 virtual void AttachChildProcess(const pid_t pid, const sptr<IChildScheduler> &childScheduler); 1169 1170 /** 1171 * Exit child process safely by child process pid. 1172 * 1173 * @param pid child process pid. 1174 */ 1175 virtual void ExitChildProcessSafelyByChildPid(const pid_t pid); 1176 1177 /** 1178 * Start native child process, callde by ChildProcessManager. 1179 * @param hostPid Host process pid. 1180 * @param childProcessCount current started child process count 1181 * @param libName lib file name to be load in child process 1182 * @param callback callback for notify start result 1183 * @return Returns ERR_OK on success, others on failure. 1184 */ 1185 virtual int32_t StartNativeChildProcess(const pid_t hostPid, 1186 const std::string &libName, int32_t childProcessCount, const sptr<IRemoteObject> &callback); 1187 1188 /** 1189 * To clear the process by ability token. 1190 * 1191 * @param token the unique identification to the ability. 1192 */ 1193 void ClearProcessByToken(sptr<IRemoteObject> token); 1194 1195 /** 1196 * Whether the current application process is the last surviving process. 1197 * @param bundleName To query the bundle name of a process. 1198 * @return Returns true is final application process, others return false. 1199 */ 1200 bool IsFinalAppProcessByBundleName(const std::string &bundleName); 1201 1202 /** 1203 * @brief Notify memory size state changed to sufficient or insufficient. 1204 * @param isMemorySizeSufficient Indicates the memory size state. 1205 * @return Returns ERR_OK on success, others on failure. 1206 */ 1207 int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficient); 1208 1209 /** 1210 * whether memory size is sufficient. 1211 * @return Returns true is sufficient memory size, others return false. 1212 */ 1213 bool IsMemorySizeSufficient(); 1214 1215 /** 1216 * Register render state observer. 1217 * @param observer Render process state observer. 1218 * @return Returns ERR_OK on success, others on failure. 1219 */ 1220 int32_t RegisterRenderStateObserver(const sptr<IRenderStateObserver> &observer); 1221 1222 /** 1223 * Unregister render state observer. 1224 * @param observer Render process state observer. 1225 * @return Returns ERR_OK on success, others on failure. 1226 */ 1227 int32_t UnregisterRenderStateObserver(const sptr<IRenderStateObserver> &observer); 1228 1229 /** 1230 * Update render state. 1231 * @param renderPid Render pid. 1232 * @param state foreground or background state. 1233 * @return Returns ERR_OK on success, others on failure. 1234 */ 1235 int32_t UpdateRenderState(pid_t renderPid, int32_t state); 1236 1237 /** 1238 * Mark processes of the uid as the app is going to be restarted. 1239 */ 1240 int32_t SignRestartAppFlag(int32_t uid); 1241 1242 int32_t GetAppIndexByPid(pid_t pid, int32_t &appIndex) const; 1243 1244 /** 1245 * Set application assertion pause state. 1246 * 1247 * @param flag assertion pause state. 1248 */ 1249 void SetAppAssertionPauseState(bool flag); 1250 1251 /** 1252 * @brief A process can config itself to keep alive or not. 1253 * when one process started, this method will be called from ability mgr with data selected from db. 1254 * 1255 * @param bundleName processed of witch to be configed 1256 * @param enable config value 1257 * @param uid indicates user, 0 for all users 1258 */ 1259 void SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid); 1260 1261 int32_t GetAppRunningUniqueIdByPid(pid_t pid, std::string &appRunningUniqueId); 1262 1263 int32_t GetAllUIExtensionRootHostPid(pid_t pid, std::vector<pid_t> &hostPids); 1264 1265 int32_t GetAllUIExtensionProviderPid(pid_t hostPid, std::vector<pid_t> &providerPids); 1266 1267 virtual int DumpIpcAllStart(std::string& result); 1268 1269 virtual int DumpIpcAllStop(std::string& result); 1270 1271 virtual int DumpIpcAllStat(std::string& result); 1272 1273 virtual int DumpIpcStart(const int32_t pid, std::string& result); 1274 1275 virtual int DumpIpcStop(const int32_t pid, std::string& result); 1276 1277 virtual int DumpIpcStat(const int32_t pid, std::string& result); 1278 1279 virtual int DumpFfrt(const std::vector<int32_t>& pids, std::string& result); 1280 1281 /** 1282 * @brief set support process cache by self 1283 */ 1284 int32_t SetSupportedProcessCacheSelf(bool isSupport); 1285 1286 int32_t SetSupportedProcessCache(int32_t pid, bool isSupport); 1287 1288 void OnAppCacheStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord, ApplicationState state); 1289 1290 /** 1291 * set browser channel for caller 1292 * @param hostPid caller pid 1293 */ 1294 virtual void SaveBrowserChannel(const pid_t hostPid, sptr<IRemoteObject> browser); 1295 1296 bool IsAppProcessesAllCached(const std::string &bundleName, int32_t uid, 1297 const std::set<std::shared_ptr<AppRunningRecord>> &cachedSet); 1298 1299 /** 1300 * Check caller is test ability 1301 * 1302 * @param pid, the pid of ability. 1303 * @return Returns ERR_OK is test ability, others is not test ability. 1304 */ 1305 int32_t CheckCallingIsUserTestModeInner(const pid_t pid, bool &isUserTest); 1306 1307 bool GetSceneBoardAttachFlag() const; 1308 1309 void SetSceneBoardAttachFlag(bool flag); 1310 1311 /** 1312 * Scene board has the highest priority. If Scene board is loading cache other apps' request. 1313 */ 1314 void CacheLoadAbilityTask(const LoadAbilityTaskFunc&& func); 1315 1316 void SubmitCacheLoadAbilityTask(); 1317 /** 1318 * Notifies that one ability is attached to status bar. 1319 * 1320 * @param token the token of the abilityRecord that is attached to status bar. 1321 */ 1322 void AttachedToStatusBar(const sptr<IRemoteObject> &token); 1323 void KillApplicationByRecord(const std::shared_ptr<AppRunningRecord> &appRecord); 1324 1325 int32_t NotifyProcessDependedOnWeb(); 1326 1327 void KillProcessDependedOnWeb(); 1328 1329 void RestartResidentProcessDependedOnWeb(); 1330 1331 void BlockProcessCacheByPids(const std::vector<int32_t>& pids); 1332 1333 bool CleanAbilityByUserRequest(const sptr<IRemoteObject> &token); 1334 1335 /** 1336 * whether killed for upgrade web. 1337 * 1338 * @param bundleName the bundle name is killed for upgrade web. 1339 * @return Returns true is killed for upgrade web, others return false. 1340 */ 1341 bool IsKilledForUpgradeWeb(const std::string &bundleName) const; 1342 1343 bool IsProcessContainsOnlyUIAbility(const pid_t pid); 1344 1345 /** 1346 * Whether a process is attached, refer to AttachApplication 1347 */ 1348 bool IsProcessAttached(sptr<IRemoteObject> token) const; 1349 1350 /** 1351 * Is a process of a ability will be killed 1352 * @param indicates the ability 1353 */ 1354 bool IsAppKilling(sptr<IRemoteObject> token) const; 1355 1356 /** 1357 * @brief Notify abilityms app process pre cache 1358 * @param pid process pid. 1359 * @param userId userId Designation User ID. 1360 */ 1361 void NotifyAppPreCache(int32_t pid, int32_t userId); 1362 1363 /** 1364 * Get pids of processes which belong to specific bundle name and support process cache feature. 1365 * 1366 * @param bundleName bundle name. 1367 * @param pidList pid list of processes that support process cache. 1368 * @return Returns ERR_OK on success, others on failure. 1369 */ 1370 virtual int32_t GetSupportedProcessCachePids(const std::string &bundleName, std::vector<int32_t> &pidList); 1371 1372 /** 1373 * Register KIA interceptor. 1374 * @param interceptor KIA interceptor. 1375 * @return Returns ERR_OK on success, others on failure. 1376 */ 1377 virtual int32_t RegisterKiaInterceptor(const sptr<IKiaInterceptor> &interceptor); 1378 1379 /** 1380 * Check if the given pid is a KIA process. 1381 * @param pid process id. 1382 * @return Returns true if it is a KIA process, false otherwise. 1383 */ 1384 virtual int32_t CheckIsKiaProcess(pid_t pid, bool &isKia); 1385 1386 private: 1387 int32_t ForceKillApplicationInner(const std::string &bundleName, const int userId = -1, 1388 const int appIndex = 0); 1389 1390 std::string FaultTypeToString(FaultDataType type); 1391 1392 FaultData ConvertDataTypes(const AppFaultDataBySA &faultData); 1393 1394 /** 1395 * Start a empty resident process 1396 */ 1397 void StartEmptyResidentProcess(const BundleInfo &info, const std::string &processName, int restartCount, 1398 bool isEmptyKeepAliveApp); 1399 1400 /** 1401 * If one app needs keepalive and dies, restart the app again 1402 */ 1403 void RestartResidentProcess(std::shared_ptr<AppRunningRecord> appRecord); 1404 1405 bool CheckLoadAbilityConditions(const sptr<IRemoteObject> &token, 1406 const std::shared_ptr<AbilityInfo> &abilityInfo, const std::shared_ptr<ApplicationInfo> &appInfo); 1407 1408 /** 1409 * query bundle info for the given bundleName 1410 */ 1411 bool GetBundleInfo(const std::string &bundleName, BundleInfo &bundleInfo); 1412 1413 bool GenerateRenderUid(int32_t &renderUid); 1414 1415 /** 1416 * Build a process's name for service extension 1417 */ 1418 void MakeServiceExtProcessName(const std::shared_ptr<AbilityInfo> &abilityInfo, 1419 const std::shared_ptr<ApplicationInfo> &appInfo, std::string &processName) const; 1420 1421 /** 1422 * Build a process's name for the info given 1423 */ 1424 void MakeProcessName(const std::shared_ptr<AbilityInfo> &abilityInfo, 1425 const std::shared_ptr<ApplicationInfo> &appInfo, const HapModuleInfo &hapModuleInfo, int32_t appIndex, 1426 const std::string &specifiedProcessFlag, std::string &processName) const; 1427 1428 /** 1429 * Build a process's name based on the info given 1430 */ 1431 void MakeProcessName(const std::shared_ptr<ApplicationInfo> &appInfo, const HapModuleInfo &hapModuleInfo, 1432 std::string &processName) const; 1433 1434 bool CheckIsolationMode(const HapModuleInfo &hapModuleInfo) const; 1435 1436 bool IsMainProcess(const std::shared_ptr<ApplicationInfo> &appInfo, const std::string &processName) const; 1437 1438 /** 1439 * StartAbility, load the ability that needed to be started(Start on the basis of the original process). 1440 * Start on a new boot process 1441 * @param token, the unique identification to start the ability. 1442 * @param preToken, the unique identification to call the ability. 1443 * @param abilityInfo, the ability information. 1444 * @param appInfo, the app information. 1445 * 1446 * @return 1447 */ 1448 void StartAbility(sptr<IRemoteObject> token, sptr<IRemoteObject> preToken, 1449 std::shared_ptr<AbilityInfo> abilityInfo, std::shared_ptr<AppRunningRecord> appRecord, 1450 const HapModuleInfo &hapModuleInfo, std::shared_ptr<AAFwk::Want> want, int32_t abilityRecordId); 1451 1452 int32_t StartPerfProcess(const std::shared_ptr<AppRunningRecord> &appRecord, const std::string& perfCmd, 1453 const std::string& debugCmd, bool isSandboxApp); 1454 1455 void StartProcessVerifyPermission(const BundleInfo &bundleInfo, bool &hasAccessBundleDirReq, 1456 uint8_t &setAllowInternet, uint8_t &allowInternet, std::vector<int32_t> &gids); 1457 1458 void AddMountPermission(uint32_t accessTokenId, std::set<std::string> &permissions); 1459 1460 /** 1461 * StartProcess, load the ability that needed to be started(Start on a new boot process). 1462 * 1463 * @param appName, the app name. 1464 * @param processName, the process name. 1465 * @param appRecord, the app information. 1466 * @param uid, the process uid. 1467 * @param bundleName, the app bundleName. 1468 * 1469 * @return 1470 */ 1471 void StartProcess(const std::string &appName, const std::string &processName, uint32_t startFlags, 1472 std::shared_ptr<AppRunningRecord> appRecord, const int uid, const BundleInfo &bundleInfo, 1473 const std::string &bundleName, const int32_t bundleIndex, bool appExistFlag = true, 1474 bool isPreload = false, const std::string &moduleName = "", const std::string &abilityName = "", 1475 bool strictMode = false, sptr<IRemoteObject> token = nullptr, 1476 std::shared_ptr<AAFwk::Want> want = nullptr, 1477 ExtensionAbilityType ExtensionAbilityType = ExtensionAbilityType::UNSPECIFIED); 1478 1479 /** 1480 * KillApplicationByUserId, kill the application by user ID. 1481 * 1482 * @param bundleName, bundle name in Application record. 1483 * @param appCloneIndex the app clone id. 1484 * @param userId, user ID. 1485 * @param reason, caller function name. 1486 * 1487 * @return ERR_OK, return back success, others fail. 1488 */ 1489 int32_t KillApplicationByUserIdLocked(const std::string &bundleName, int32_t appCloneIndex, int32_t userId, 1490 const bool clearPageStack = false, const std::string& reason = "KillApplicationByUserIdLocked"); 1491 1492 /** 1493 * WaitForRemoteProcessExit, Wait for the process to exit normally. 1494 * 1495 * @param pids, process number collection to exit. 1496 * @param startTime, execution process security exit start time. 1497 * 1498 * @return true, return back success,others fail. 1499 */ 1500 bool WaitForRemoteProcessExit(std::list<pid_t> &pids, const int64_t startTime); 1501 1502 /** 1503 * ProcessExist, Judge whether the process exists. 1504 * 1505 * @param pids, process number collection to exit. 1506 * 1507 * @return true, return back existed,others non-existent. 1508 */ 1509 bool ProcessExist(pid_t pid); 1510 1511 /** 1512 * CheckAllProcessExist, Determine whether all processes exist . 1513 * 1514 * @param pids, process number collection to exit. 1515 * 1516 * @return true, Returns that a process exists and all other processes do not exist. 1517 */ 1518 bool CheckAllProcessExist(std::list<pid_t> &pids); 1519 1520 /** 1521 * SystemTimeMillisecond, Get system time. 1522 * 1523 * @return the system time. 1524 */ 1525 int64_t SystemTimeMillisecond(); 1526 1527 // Test add the bundle manager instance. 1528 void SetBundleManagerHelper(const std::shared_ptr<BundleMgrHelper> &bundleMgrHelper); 1529 1530 void HandleTerminateApplicationTimeOut(const int64_t eventId); 1531 1532 void HandleAddAbilityStageTimeOut(const int64_t eventId); 1533 1534 void ClipStringContent(const std::regex &re, const std::string &source, std::string &afterCutStr); 1535 1536 bool GetBundleAndHapInfo(const AbilityInfo &abilityInfo, const std::shared_ptr<ApplicationInfo> &appInfo, 1537 BundleInfo &bundleInfo, HapModuleInfo &hapModuleInfo, int32_t appIndex = 0) const; 1538 AppProcessData WrapAppProcessData(const std::shared_ptr<AppRunningRecord> &appRecord, 1539 const ApplicationState state); 1540 1541 int UserTestAbnormalFinish(const sptr<IRemoteObject> &observer, const std::string &msg); 1542 int GetHapModuleInfoForTestRunner(const AAFwk::Want &want, const sptr<IRemoteObject> &observer, 1543 const BundleInfo &bundleInfo, HapModuleInfo &hapModuleInfo); 1544 int StartEmptyProcess(const AAFwk::Want &want, const sptr<IRemoteObject> &observer, const BundleInfo &info, 1545 const std::string &processName, const int userId); 1546 1547 void HandleStartSpecifiedAbilityTimeOut(const int64_t eventId); 1548 1549 void HandleStartSpecifiedProcessTimeout(const int64_t eventId); 1550 1551 void InitGlobalConfiguration(); 1552 1553 /** 1554 * @brief Another way of GetRunningProcess, only one item will be filled into the info 1555 */ 1556 void GetRunningProcesses(const std::shared_ptr<AppRunningRecord> &appRecord, std::vector<RunningProcessInfo> &info); 1557 /** 1558 * @brief Retrieve a process's running info 1559 */ 1560 void GetRunningProcess(const std::shared_ptr<AppRunningRecord> &appRecord, RunningProcessInfo &info); 1561 1562 /** 1563 * @brief query a process's render process info 1564 * @param appRecord the main process 1565 * @param info to retrieve render process info 1566 */ 1567 void GetRenderProcesses(const std::shared_ptr<AppRunningRecord> &appRecord, std::vector<RenderProcessInfo> &info); 1568 1569 void GetChildrenProcesses(const std::shared_ptr<AppRunningRecord> &appRecord, std::vector<ChildProcessInfo> &info); 1570 1571 int StartRenderProcessImpl(const std::shared_ptr<RenderRecord> &renderRecord, 1572 const std::shared_ptr<AppRunningRecord> appRecord, pid_t &renderPid, bool isGPU = false); 1573 1574 void SetRenderStartMsg(AppSpawnStartMsg &startMsg, std::shared_ptr<RenderRecord> renderRecord, 1575 const int32_t renderUid, const bool isGPU); 1576 1577 void OnRenderRemoteDied(const wptr<IRemoteObject> &remote); 1578 1579 void AddWatchParameter(); 1580 1581 bool VerifyAPL() const; 1582 1583 /** 1584 * Register a focus listener to window manager 1585 */ 1586 void RegisterFocusListener(); 1587 1588 static void PointerDeviceEventCallback(const char *key, const char *value, void *context); 1589 1590 /** 1591 * Verify whether the caller has the permission to kill processes of a bundleName. 1592 */ 1593 int VerifyKillProcessPermission(const std::string &bundleName) const; 1594 1595 int32_t VerifyKillProcessPermissionCommon() const; 1596 1597 bool CheckCallerIsAppGallery(); 1598 1599 void ApplicationTerminatedSendProcessEvent(const std::shared_ptr<AppRunningRecord> &appRecord); 1600 void ClearAppRunningDataForKeepAlive(const std::shared_ptr<AppRunningRecord> &appRecord); 1601 1602 int32_t StartChildProcessPreCheck(pid_t callingPid, int32_t childProcessType); 1603 1604 int32_t StartChildProcessImpl(const std::shared_ptr<ChildProcessRecord> childProcessRecord, 1605 const std::shared_ptr<AppRunningRecord> appRecord, pid_t &childPid, const ChildProcessArgs &args, 1606 const ChildProcessOptions &options); 1607 1608 int32_t GetChildProcessInfo(const std::shared_ptr<ChildProcessRecord> childProcessRecord, 1609 const std::shared_ptr<AppRunningRecord> appRecord, ChildProcessInfo &info, 1610 bool isCallFromGetChildrenProcesses = false); 1611 1612 void OnChildProcessRemoteDied(const wptr<IRemoteObject> &remote); 1613 1614 /** 1615 * kill all child processed of a main process 1616 * @param appRecord indicates the main process 1617 */ 1618 void KillChildProcess(const std::shared_ptr<AppRunningRecord> &appRecord); 1619 1620 void KillAttachedChildProcess(const std::shared_ptr<AppRunningRecord> &appRecord); 1621 1622 void PresetMaxChildProcess(std::shared_ptr<AppRunningRecord> appRecord, 1623 int32_t &maxChildProcess); 1624 1625 void AfterLoadAbility(std::shared_ptr<AppRunningRecord> appRecord, std::shared_ptr<AbilityInfo> abilityInfo, 1626 std::shared_ptr<AbilityRuntime::LoadParam> loadParam); 1627 1628 private: 1629 /** 1630 * ClearUpApplicationData, clear the application data. 1631 * 1632 * @param bundleName, bundle name in Application record. 1633 * @param uid, app uid in Application record. 1634 * @param pid, app pid in Application record. 1635 * @param appCloneIndex the app clone id. 1636 * @param userId, userId. 1637 * @param isBySelf, clear data by application self. 1638 * @param reason, caller function. 1639 * 1640 * @return Returns ERR_OK on success, others on failure. 1641 */ 1642 int32_t ClearUpApplicationDataByUserId(const std::string &bundleName, 1643 int32_t callerUid, pid_t callerPid, int32_t appCloneIndex, int32_t userId, bool isBySelf = false, 1644 const std::string& reason = "ClearUpApplicationDataByUserId"); 1645 1646 bool CheckGetRunningInfoPermission() const; 1647 1648 /** 1649 * kill all processes of a bundleName 1650 * @param bundleName bundleName of which to be killed 1651 * @param clearPageStack should schedule clearPage lifecycle 1652 * @param reason caller function name 1653 */ 1654 int32_t KillApplicationByBundleName(const std::string &bundleName, const bool clearPageStack = false, 1655 const std::string& reason = "KillApplicationByBundleName"); 1656 1657 bool SendProcessStartEvent(const std::shared_ptr<AppRunningRecord> &appRecord); 1658 1659 bool SendProcessStartFailedEvent(std::shared_ptr<AppRunningRecord> appRecord, ProcessStartFailedReason reason, 1660 int32_t subReason); 1661 1662 void SendAppStartupTypeEvent(const std::shared_ptr<AppRunningRecord> &appRecord, 1663 const std::shared_ptr<AbilityInfo> &abilityInfo, const AppStartType startType); 1664 1665 bool SendCreateAtomicServiceProcessEvent(const std::shared_ptr<AppRunningRecord> &appRecord, 1666 const BundleType &bundleType, const std::string &moduleName = "", const std::string &abilityName = ""); 1667 1668 void SendProcessExitEvent(const std::shared_ptr<AppRunningRecord> &appRecord); 1669 1670 void SendProcessExitEventTask(const std::shared_ptr<AppRunningRecord> &appRecord, time_t exitTime, int32_t count); 1671 1672 void SetRunningSharedBundleList(const std::string &bundleName, 1673 const std::vector<BaseSharedBundleInfo> baseSharedBundleInfoList); 1674 1675 void RemoveRunningSharedBundleList(const std::string &bundleName); 1676 1677 /** 1678 * kill one process's render process 1679 * @param appRecord the main process 1680 */ 1681 void KillRenderProcess(const std::shared_ptr<AppRunningRecord> &appRecord); 1682 1683 void SetOverlayInfo(const std::string& bundleName, const int32_t userId, AppSpawnStartMsg& startMsg); 1684 void SetAppEnvInfo(const BundleInfo &bundleInfo, AppSpawnStartMsg& startMsg); 1685 1686 void TimeoutNotifyApp(int32_t pid, int32_t uid, const std::string& bundleName, const FaultData &faultData); 1687 1688 void AppRecoveryNotifyApp(int32_t pid, const std::string& bundleName, 1689 FaultDataType faultType, const std::string& markers); 1690 1691 void ProcessAppDebug(const std::shared_ptr<AppRunningRecord> &appRecord, const bool &isDebugStart); 1692 AppDebugInfo MakeAppDebugInfo(const std::shared_ptr<AppRunningRecord> &appRecord, const bool &isDebugStart); 1693 int32_t NotifyAbilitiesDebugChange(const std::string &bundleName, const bool &isAppDebug); 1694 int32_t NotifyAbilitiesAssertDebugChange(const std::shared_ptr<AppRunningRecord> &appRecord, bool isAssertDebug); 1695 1696 void SetProcessJITState(const std::shared_ptr<AppRunningRecord> appRecord); 1697 1698 bool JudgeSelfCalledByToken(const sptr<IRemoteObject> &token, const PageStateData &pageStateData); 1699 1700 void ParseServiceExtMultiProcessWhiteList(); 1701 void ClearData(std::shared_ptr<AppRunningRecord> appRecord); 1702 1703 /** 1704 * Notify the app running status. 1705 * 1706 * @param bundle Bundle name in application record. 1707 * @param uid Uid of bundle. 1708 * @param runningStatus The app running status. 1709 * 1710 * @return 1711 */ 1712 void NotifyAppRunningStatusEvent( 1713 const std::string &bundle, int32_t uid, AbilityRuntime::RunningStatus runningStatus); 1714 1715 void GetRunningCloneAppInfo(const std::shared_ptr<AppRunningRecord> &appRecord, 1716 RunningMultiAppInfo &info); 1717 1718 void GetRunningMultiInstanceKeys(const std::shared_ptr<AppRunningRecord> &appRecord, 1719 std::vector<std::string> &instanceKeys); 1720 /** 1721 * To Prevent process being killed when ability is starting in an existing process, 1722 * we need notify memmgr to increase process priority. 1723 * 1724 * @param appRecord Current app running record. 1725 * 1726 * @return Whether improve priority succeed. 1727 */ 1728 bool NotifyMemMgrPriorityChanged(const std::shared_ptr<AppRunningRecord> appRecord); 1729 1730 void HandlePreloadApplication(const PreloadRequest &request); 1731 1732 std::string GetSpecifiedProcessFlag(std::shared_ptr<AbilityInfo> abilityInfo, std::shared_ptr<AAFwk::Want> want); 1733 1734 void LoadAbilityNoAppRecord(const std::shared_ptr<AppRunningRecord> appRecord, 1735 bool isShellCall, std::shared_ptr<ApplicationInfo> appInfo, 1736 std::shared_ptr<AbilityInfo> abilityInfo, const std::string &processName, 1737 const std::string &specifiedProcessFlag, const BundleInfo &bundleInfo, 1738 const HapModuleInfo &hapModuleInfo, std::shared_ptr<AAFwk::Want> want, 1739 bool appExistFlag, bool isPreload, sptr<IRemoteObject> token = nullptr); 1740 1741 int32_t CreatNewStartMsg(const Want &want, const AbilityInfo &abilityInfo, 1742 const std::shared_ptr<ApplicationInfo> &appInfo, const std::string &processName, 1743 AppSpawnStartMsg &startMsg); 1744 1745 /** 1746 * Build message body for app spawn 1747 */ 1748 int32_t CreateStartMsg(const std::string &processName, uint32_t startFlags, const int uid, 1749 const BundleInfo &bundleInfo, const int32_t bundleIndex, BundleType bundleType, AppSpawnStartMsg &startMsg, 1750 std::shared_ptr<AAFwk::Want> want, const std::string &moduleName = "", const std::string &abilityName = "", 1751 bool strictMode = false); 1752 1753 void QueryExtensionSandBox(const std::string &moduleName, const std::string &abilityName, 1754 const BundleInfo &bundleInfo, AppSpawnStartMsg &startMsg, DataGroupInfoList& dataGroupInfoList, 1755 bool strictMode, std::shared_ptr<AAFwk::Want> want); 1756 1757 int32_t StartPerfProcessByStartMsg(AppSpawnStartMsg &startMsg, const std::string& perfCmd, 1758 const std::string& debugCmd, bool isSandboxApp); 1759 1760 void SetAtomicServiceInfo(BundleType bundleType, AppSpawnStartMsg &startMsg); 1761 1762 void SetAppInfo(const BundleInfo &bundleInfo, AppSpawnStartMsg &startMsg); 1763 1764 /** 1765 * Query ability for one want param 1766 */ 1767 bool CreateAbilityInfo(const AAFwk::Want &want, AbilityInfo &abilityInfo); 1768 1769 /** 1770 * Build event info for one app record 1771 */ 1772 AAFwk::EventInfo BuildEventInfo(std::shared_ptr<AppRunningRecord> appRecord) const; 1773 1774 /** 1775 * @brief Call the callbacks to notify one process should go dying due fatal error. 1776 * @param appRecord indicates the process is going to die. 1777 */ 1778 void NotifyAppAttachFailed(std::shared_ptr<AppRunningRecord> appRecord); 1779 private: 1780 /** 1781 * Notify application status. 1782 * 1783 * @param bundleName Indicates the name of the bundle. 1784 * @param bundleName Indicates the name of the bundle. 1785 * @param eventData Indicates the event defined by CommonEventSupport 1786 * 1787 * @return 1788 */ 1789 void NotifyAppStatusByCallerUid(const std::string &bundleName, const int32_t tokenId, const int32_t userId, 1790 const int32_t callerUid, const std::string &eventData); 1791 void UpdateAllProviderConfig(const std::shared_ptr<AppRunningRecord> &appRecord); 1792 void SendHiSysEvent(const int32_t innerEventId, const int64_t eventId); 1793 int FinishUserTestLocked( 1794 const std::string &msg, const int64_t &resultCode, const std::shared_ptr<AppRunningRecord> &appRecord); 1795 int32_t GetCurrentAccountId() const; 1796 void SendReStartProcessEvent(AAFwk::EventInfo &eventInfo, int32_t appUid); 1797 void SendAppLaunchEvent(const std::shared_ptr<AppRunningRecord> &appRecord); 1798 void InitAppWaitingDebugList(); 1799 void HandleConfigurationChange(const Configuration &config, const int32_t userId = -1); 1800 bool CheckIsThreadInFoundation(pid_t pid); 1801 bool CheckAppFault(const std::shared_ptr<AppRunningRecord> &appRecord, const FaultData &faultData); 1802 int32_t KillFaultApp(int32_t pid, const std::string &bundleName, const FaultData &faultData, 1803 bool isNeedExit = false); 1804 void AddUIExtensionLauncherItem(std::shared_ptr<AAFwk::Want> want, std::shared_ptr<AppRunningRecord> appRecord, 1805 sptr<IRemoteObject> token); 1806 void NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos); 1807 void RemoveUIExtensionLauncherItem(std::shared_ptr<AppRunningRecord> appRecord, sptr<IRemoteObject> token); 1808 bool IsSceneBoardCall(); 1809 void CheckCleanAbilityByUserRequest(const std::shared_ptr<AppRunningRecord> &appRecord, 1810 const std::shared_ptr<AbilityRunningRecord> &abilityRecord, const AbilityState state); 1811 void GetPidsByAccessTokenId(const uint32_t accessTokenId, std::vector<pid_t> &pids); 1812 void MakeIsolateSandBoxProcessName(const std::shared_ptr<AbilityInfo> &abilityInfo, 1813 const HapModuleInfo &hapModuleInfo, std::string &processName) const; 1814 void DealMultiUserConfig(const Configuration &config, const int32_t userId); 1815 bool CheckIsDebugApp(const std::string &bundleName); 1816 int32_t MakeKiaProcess(std::shared_ptr<AAFwk::Want> want, bool &isKia, std::string &watermarkBusinessName, 1817 bool &isWatermarkEnabled, bool &isFileUri, std::string &processName); 1818 int32_t ProcessKia(bool isKia, std::shared_ptr<AppRunningRecord> appRecord, 1819 const std::string& watermarkBusinessName, bool isWatermarkEnabled); 1820 bool CheckAppRecordAndPriorityObject(const std::shared_ptr<AppRunningRecord> &appRecord); 1821 void GetAppCloneInfo(const std::shared_ptr<AppRunningRecord> &appRecord, 1822 RunningMultiAppInfo &info); 1823 void GetMultiInstanceInfo(const std::shared_ptr<AppRunningRecord> &appRecord, 1824 RunningMultiAppInfo &info); 1825 int32_t GetAllRunningInstanceKeysByBundleNameInner(const std::string &bundleName, 1826 std::vector<std::string> &instanceKeys, int32_t userId); 1827 int32_t KillProcessByPidInner(const pid_t pid, const std::string& reason, 1828 const std::string& killReason, std::shared_ptr<AppRunningRecord> appRecord); 1829 const std::string TASK_ON_CALLBACK_DIED = "OnCallbackDiedTask"; 1830 std::vector<AppStateCallbackWithUserId> appStateCallbacks_; 1831 std::shared_ptr<RemoteClientManager> remoteClientManager_; 1832 std::shared_ptr<AppRunningManager> appRunningManager_; 1833 std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler_; 1834 std::shared_ptr<AMSEventHandler> eventHandler_; 1835 std::shared_ptr<Configuration> configuration_; 1836 ffrt::mutex userTestLock_; 1837 ffrt::mutex appStateCallbacksLock_; 1838 ffrt::mutex renderUidSetLock_; 1839 ffrt::mutex exceptionLock_; 1840 ffrt::mutex browserHostLock_; 1841 sptr<IStartSpecifiedAbilityResponse> startSpecifiedAbilityResponse_; 1842 ffrt::mutex configurationObserverLock_; 1843 std::vector<ConfigurationObserverWithUserId> configurationObservers_; 1844 1845 #ifdef SUPPORT_SCREEN 1846 sptr<WindowFocusChangedListener> focusListener_; 1847 sptr<WindowVisibilityChangedListener> windowVisibilityChangedListener_; 1848 sptr<WindowPidVisibilityChangedListener> windowPidVisibilityChangedListener_; 1849 #endif //SUPPORT_SCREEN 1850 std::vector<std::shared_ptr<AppRunningRecord>> restartResidentTaskList_; 1851 std::map<std::string, std::vector<BaseSharedBundleInfo>> runningSharedBundleList_; 1852 std::map<std::string, bool> waitingDebugBundleList_; 1853 ffrt::mutex waitingDebugLock_; 1854 bool isInitAppWaitingDebugListExecuted_ = false; 1855 std::unordered_set<int32_t> renderUidSet_; 1856 std::string supportIsolationMode_ {"false"}; 1857 std::string supportServiceExtMultiProcess_ {"false"}; 1858 int32_t currentUserId_ = 0; 1859 int32_t lastRenderUid_ = Constants::START_UID_FOR_RENDER_PROCESS; 1860 sptr<IAbilityDebugResponse> abilityDebugResponse_; 1861 std::shared_ptr<AppDebugManager> appDebugManager_; 1862 ffrt::mutex killedProcessMapLock_; 1863 mutable std::map<int64_t, std::string> killedProcessMap_; 1864 ffrt::mutex startChildProcessLock_; 1865 std::vector<std::string> serviceExtensionWhiteList_; 1866 std::shared_ptr<AbilityRuntime::AppRunningStatusModule> appRunningStatusModule_; 1867 std::shared_ptr<AdvancedSecurityModeManager> securityModeManager_; 1868 std::shared_ptr<AAFwk::TaskHandlerWrap> dfxTaskHandler_; 1869 std::shared_ptr<AAFwk::TaskHandlerWrap> otherTaskHandler_; 1870 std::shared_ptr<AppPreloader> appPreloader_; 1871 std::atomic<bool> sceneBoardAttachFlag_ = true; 1872 1873 std::mutex loadTaskListMutex_; 1874 std::vector<LoadAbilityTaskFunc> loadAbilityTaskFuncList_; 1875 sptr<IKiaInterceptor> kiaInterceptor_; 1876 std::shared_ptr<MultiUserConfigurationMgr> multiUserConfigurationMgr_; 1877 int32_t willKillPidsNum_; 1878 std::shared_ptr<AAFwk::TaskHandlerWrap> delayKillTaskHandler_; 1879 }; 1880 } // namespace AppExecFwk 1881 } // namespace OHOS 1882 #endif // OHOS_ABILITY_RUNTIME_APP_MGR_SERVICE_INNER_H 1883