1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_APPEXECFWK_SERVICES_APPMGR_INCLUDE_APP_MGR_SERVICE_INNER_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_APPMGR_INCLUDE_APP_MGR_SERVICE_INNER_H 18 19 #include <list> 20 #include <map> 21 #include <vector> 22 #include <regex> 23 24 #include "iremote_object.h" 25 #include "refbase.h" 26 27 #include "ability_info.h" 28 #include "appexecfwk_errors.h" 29 #include "app_death_recipient.h" 30 #include "app_mgr_constants.h" 31 #include "app_record_id.h" 32 #include "app_running_record.h" 33 #include "app_scheduler_interface.h" 34 #include "app_spawn_client.h" 35 #include "app_task_info.h" 36 #include "iapp_state_callback.h" 37 #include "iapplication_state_observer.h" 38 #include "app_process_manager.h" 39 #include "remote_client_manager.h" 40 #include "app_running_manager.h" 41 #include "record_query_result.h" 42 #include "running_process_info.h" 43 #include "bundle_info.h" 44 #include "istart_specified_ability_response.h" 45 46 #include "ohos/aafwk/content/want.h" 47 48 namespace OHOS { 49 namespace AppExecFwk { 50 using OHOS::AAFwk::Want; 51 class AppMgrServiceInner : public std::enable_shared_from_this<AppMgrServiceInner> { 52 public: 53 AppMgrServiceInner(); 54 virtual ~AppMgrServiceInner(); 55 56 /** 57 * Initialize the object. 58 */ 59 void Init(); 60 /** 61 * LoadAbility, load the ability that needed to be started. 62 * 63 * @param token, the unique identification to start the ability. 64 * @param preToken, the unique identification to call the ability. 65 * @param abilityInfo, the ability information. 66 * @param appInfo, the app information. 67 * @param want the ability want. 68 * 69 * @return 70 */ 71 virtual void LoadAbility(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &preToken, 72 const std::shared_ptr<AbilityInfo> &abilityInfo, const std::shared_ptr<ApplicationInfo> &appInfo, 73 const std::shared_ptr<AAFwk::Want> &want); 74 75 /** 76 * TerminateAbility, terminate the token ability. 77 * 78 * @param token, he unique identification to terminate the ability. 79 * 80 * @return 81 */ 82 virtual void TerminateAbility(const sptr<IRemoteObject> &token); 83 84 /** 85 * UpdateAbilityState, update the ability status. 86 * 87 * @param token, the unique identification to update the ability. 88 * @param state, ability status that needs to be updated. 89 * 90 * @return 91 */ 92 virtual void UpdateAbilityState(const sptr<IRemoteObject> &token, const AbilityState state); 93 94 /** 95 * UpdateExtensionState, call UpdateExtensionState() through the proxy object, update the extension status. 96 * 97 * @param token, the unique identification to update the extension. 98 * @param state, extension status that needs to be updated. 99 */ 100 virtual void UpdateExtensionState(const sptr<IRemoteObject> &token, const ExtensionState state); 101 102 /** 103 * StateChangedNotifyObserver, Call ability state change. 104 * 105 * @param ability, the ability info. 106 * @param state, the ability state. 107 * 108 * @return 109 */ 110 void StateChangedNotifyObserver(const AbilityStateData abilityStateData, bool isAbility); 111 112 /** 113 * RegisterAppStateCallback, register the callback. 114 * 115 * @param callback, Ams register the callback. 116 * 117 * @return 118 */ 119 virtual void RegisterAppStateCallback(const sptr<IAppStateCallback> &callback); 120 121 /** 122 * AbilityBehaviorAnalysis, ability behavior analysis assistant process optimization. 123 * 124 * @param token, the unique identification to start the ability. 125 * @param preToken, the unique identification to call the ability. 126 * @param visibility, the visibility information about windows info. 127 * @param perceptibility, the Perceptibility information about windows info. 128 * @param connectionState, the service ability connection state. 129 * @return 130 */ 131 virtual void AbilityBehaviorAnalysis(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &preToken, 132 const int32_t visibility, const int32_t perceptibility, const int32_t connectionState); 133 134 /** 135 * KillProcessByAbilityToken, kill the process by ability token. 136 * 137 * @param token, the unique identification to the ability. 138 * @return 139 */ 140 virtual void KillProcessByAbilityToken(const sptr<IRemoteObject> &token); 141 142 /** 143 * KillProcessesByUserId, kill the processes by userId. 144 * 145 * @param userId, the user id. 146 * @return 147 */ 148 virtual void KillProcessesByUserId(int32_t userId); 149 150 /** 151 * AttachApplication, get all the information needed to start the Application 152 * (data related to the Application ). 153 * 154 * @param app, information needed to start the Application. 155 * 156 * @return 157 */ 158 virtual void AttachApplication(const pid_t pid, const sptr<IAppScheduler> &app); 159 160 /** 161 * ApplicationForegrounded, set the application to Foreground State. 162 * 163 * @param recordId, a unique record that identifies this Application from others. 164 * 165 * @return 166 */ 167 virtual void ApplicationForegrounded(const int32_t recordId); 168 169 /** 170 * ApplicationBackgrounded, set the application to Backgrounded State. 171 * 172 * @param recordId, a unique record that identifies this Application from others. 173 * 174 * @return 175 */ 176 virtual void ApplicationBackgrounded(const int32_t recordId); 177 178 /** 179 * ApplicationTerminated, terminate the application. 180 * 181 * @param recordId, a unique record that identifies this Application from others. 182 * 183 * @return 184 */ 185 virtual void ApplicationTerminated(const int32_t recordId); 186 187 /** 188 * AbilityTerminated, terminate the ability. 189 * 190 * @param token, the unique identification to terminated the ability. 191 * 192 * @return 193 */ 194 virtual void AbilityTerminated(const sptr<IRemoteObject> &token); 195 196 /** 197 * KillApplication, kill the application. 198 * 199 * @param bundleName, bundle name in Application record. 200 * 201 * @return ERR_OK, return back success, others fail. 202 */ 203 virtual int32_t KillApplication(const std::string &bundleName); 204 205 /** 206 * KillApplicationByUid, call KillApplicationByUid() through proxy object, kill the application. 207 * 208 * @param bundleName, bundle name in Application record. 209 * @param uid, uid. 210 * @return ERR_OK, return back success, others fail. 211 */ 212 virtual int32_t KillApplicationByUid(const std::string &bundleName, const int uid); 213 214 /** 215 * KillApplicationByUserId, kill the application by user ID. 216 * 217 * @param bundleName, bundle name in Application record. 218 * @param userId, user ID. 219 * 220 * @return ERR_OK, return back success, others fail. 221 */ 222 virtual int32_t KillApplicationByUserId(const std::string &bundleName, const int userId); 223 224 /** 225 * ClearUpApplicationData, clear the application data. 226 * 227 * @param bundleName, bundle name in Application record. 228 * @param callerUid, app uid in Application record. 229 * @param callerPid, app pid in Application record. 230 * 231 * @return 232 */ 233 virtual void ClearUpApplicationData(const std::string &bundleName, const int32_t callerUid, const pid_t callerPid); 234 235 /** 236 * GetAllRunningProcesses, Obtains information about application processes that are running on the device. 237 * 238 * @param info, app name in Application record. 239 * 240 * @return ERR_OK ,return back success,others fail. 241 */ 242 virtual int32_t GetAllRunningProcesses(std::vector<RunningProcessInfo> &info); 243 244 /** 245 * GetProcessRunningInfosByUserId, Obtains information about application processes that are running on the device. 246 * 247 * @param info, app name in Application record. 248 * @param userId, userId. 249 * 250 * @return ERR_OK ,return back success,others fail. 251 */ 252 virtual int32_t GetProcessRunningInfosByUserId(std::vector<RunningProcessInfo> &info, int32_t userId); 253 254 std::shared_ptr<AppRunningRecord> CreateAppRunningRecord( 255 const sptr<IRemoteObject> &token, 256 const sptr<IRemoteObject> &preToken, 257 const std::shared_ptr<ApplicationInfo> &appInfo, 258 const std::shared_ptr<AbilityInfo> &abilityInfo, 259 const std::string &processName, 260 const BundleInfo &bundleInfo, 261 const HapModuleInfo &hapModuleInfo, 262 const std::shared_ptr<AAFwk::Want> &want); 263 264 /** 265 * OnStop, Application management service stopped. 266 * 267 * @return 268 */ 269 void OnStop(); 270 271 /** 272 * OpenAppSpawnConnection, Open connection with appspwan. 273 * 274 * @return ERR_OK ,return back success,others fail. 275 */ 276 virtual ErrCode OpenAppSpawnConnection(); 277 278 /** 279 * CloseAppSpawnConnection, Close connection with appspwan. 280 * 281 * @return 282 */ 283 virtual void CloseAppSpawnConnection() const; 284 285 /** 286 * QueryAppSpawnConnectionState, Query the connection status with appspwan. 287 * 288 * @return Returns the connection status with appspwan. 289 */ 290 virtual SpawnConnectionState QueryAppSpawnConnectionState() const; 291 292 /** 293 * SetAppSpawnClient, Setting the client to connect with appspwan. 294 * 295 * @param spawnClient, the client to connect with appspwan. 296 * 297 * @return 298 */ 299 void SetAppSpawnClient(std::shared_ptr<AppSpawnClient> spawnClient); 300 301 // Schedule launch application with specified |appRecord| 302 303 /** 304 * LaunchApplication, Notify application to launch application. 305 * 306 * @param appRecord, the application record. 307 * 308 * @return 309 */ 310 void LaunchApplication(const std::shared_ptr<AppRunningRecord> &appRecord); 311 312 /** 313 * Notice of AddAbilityStageInfo() 314 * 315 * @param recordId, the application record. 316 */ 317 virtual void AddAbilityStageDone(const int32_t recordId); 318 319 /** 320 * GetRecordMap, Get all the ability information in the application record. 321 * 322 * @return all the ability information in the application record. 323 */ 324 const std::map<const int32_t, const std::shared_ptr<AppRunningRecord>> &GetRecordMap() const; 325 326 /** 327 * GetAppRunningRecordByPid, Get process record by application pid. 328 * 329 * @param pid, the application pid. 330 * 331 * @return process record. 332 */ 333 std::shared_ptr<AppRunningRecord> GetAppRunningRecordByPid(const pid_t pid) const; 334 335 /** 336 * GetAppRunningRecordByAbilityToken, Get process record by ability token. 337 * 338 * @param abilityToken, the ability token. 339 * 340 * @return process record. 341 */ 342 std::shared_ptr<AppRunningRecord> GetAppRunningRecordByAbilityToken(const sptr<IRemoteObject> &abilityToken) const; 343 344 /** 345 * GetAppRunningRecordByAppRecordId, Get process record by application id. 346 * 347 * @param recordId, the application id. 348 * 349 * @return process record. 350 */ 351 std::shared_ptr<AppRunningRecord> GetAppRunningRecordByAppRecordId(const int32_t recordId) const; 352 353 /** 354 * OnAbilityStateChanged, Call ability state change. 355 * 356 * @param ability, the ability info. 357 * @param state, the ability state. 358 * 359 * @return 360 */ 361 void OnAbilityStateChanged(const std::shared_ptr<AbilityRunningRecord> &ability, const AbilityState state); 362 363 /** 364 * GetRecentAppList, Get a list of recent applications. 365 * 366 * @return a list of recent applications. 367 */ 368 const std::list<const std::shared_ptr<AppTaskInfo>> &GetRecentAppList() const; 369 370 /** 371 * GetRecentAppList, Remove the corresponding latest application list data by applying the name. 372 * 373 * @param appName, the application name. 374 * @param processName, the process name. 375 * 376 * @return 377 */ 378 void RemoveAppFromRecentList(const std::string &appName, const std::string &processName); 379 380 /** 381 * GetRecentAppList, Clear recent application list. 382 * 383 * @return 384 */ 385 void ClearRecentAppList(); 386 387 /** 388 * OnRemoteDied, Equipment death notification. 389 * 390 * @param remote, Death client. 391 * @param isRenderProcess is render process died. 392 * @return 393 */ 394 void OnRemoteDied(const wptr<IRemoteObject> &remote, bool isRenderProcess = false); 395 396 /** 397 * AddAppDeathRecipient, Add monitoring death application record. 398 * 399 * @param pid, the application pid. 400 * @param appDeathRecipient, Application death recipient list. 401 * 402 * @return 403 */ 404 405 virtual void AddAppDeathRecipient(const pid_t pid, const sptr<AppDeathRecipient> &appDeathRecipient) const; 406 407 void HandleTimeOut(const InnerEvent::Pointer &event); 408 409 void SetEventHandler(const std::shared_ptr<AMSEventHandler> &handler); 410 411 void HandleAbilityAttachTimeOut(const sptr<IRemoteObject> &token); 412 413 void PrepareTerminate(const sptr<IRemoteObject> &token); 414 415 /** 416 * OnAppStateChanged, Application state changed. 417 * 418 * @param appRecord, the app information. 419 * @param state, the app state. 420 */ 421 void OnAppStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord, const ApplicationState state); 422 423 void GetRunningProcessInfoByToken(const sptr<IRemoteObject> &token, AppExecFwk::RunningProcessInfo &info); 424 425 /** 426 * UpdateConfiguration, ANotify application update system environment changes. 427 * 428 * @param config, System environment change parameters. 429 */ 430 void UpdateConfiguration(const Configuration &config); 431 432 std::shared_ptr<AppExecFwk::Configuration> GetConfiguration(); 433 /** 434 * Start empty process 435 */ 436 void LoadResidentProcess(const std::vector<BundleInfo> &infos); 437 438 void StartResidentProcess(const std::vector<BundleInfo> &infos, int restartCount); 439 440 bool CheckRemoteClient(); 441 442 /** 443 * Register application or process state observer. 444 * @param observer, ability token. 445 * @return Returns ERR_OK on success, others on failure. 446 */ 447 int32_t RegisterApplicationStateObserver(const sptr<IApplicationStateObserver> &observer); 448 449 /** 450 * Unregister application or process state observer. 451 * @param observer, ability token. 452 * @return Returns ERR_OK on success, others on failure. 453 */ 454 int32_t UnregisterApplicationStateObserver(const sptr<IApplicationStateObserver> &observer); 455 456 /** 457 * Get Foreground Applications. 458 * 459 * @return Foreground Applications. 460 */ 461 int32_t GetForegroundApplications(std::vector<AppStateData> &list); 462 463 /** 464 * Start user test process. 465 * @param want, want object. 466 * @param observer, test observer remote object. 467 * @param bundleInfo, bundle info. 468 * @param userId the user id. 469 * @return Returns ERR_OK on success, others on failure. 470 */ 471 int StartUserTestProcess(const AAFwk::Want &want, const sptr<IRemoteObject> &observer, 472 const AppExecFwk::BundleInfo &bundleInfo, int32_t userId); 473 474 /** 475 * @brief Finish user test. 476 * @param msg user test message. 477 * @param resultCode user test result Code. 478 * @param bundleName user test bundleName. 479 * @param pid the user test process id. 480 * 481 * @return Returns ERR_OK on success, others on failure. 482 */ 483 int FinishUserTest(const std::string &msg, const int &resultCode, const std::string &bundleName, const pid_t &pid); 484 485 void StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo); 486 487 void RegisterStartSpecifiedAbilityResponse(const sptr<IStartSpecifiedAbilityResponse> &response); 488 489 void ScheduleAcceptWantDone(const int32_t recordId, const AAFwk::Want &want, const std::string &flag); 490 491 /** 492 * Get the token of ability records by process ID. 493 * 494 * @param pid The process id. 495 * @param tokens The token of ability records. 496 * @return Returns true on success, others on failure. 497 */ 498 int GetAbilityRecordsByProcessID(const int pid, std::vector<sptr<IRemoteObject>> &tokens); 499 500 virtual int32_t StartRenderProcess(const pid_t hostPid, const std::string &renderParam, 501 int32_t ipcFd, int32_t sharedFd, pid_t &renderPid); 502 503 virtual void AttachRenderProcess(const pid_t pid, const sptr<IRenderScheduler> &scheduler); 504 505 virtual int GetRenderProcessTerminationStatus(pid_t renderPid, int &status); 506 507 int VerifyProcessPermission(); 508 509 int VerifyAccountPermission(const std::string &permissionName, const int userId); 510 511 private: 512 513 void StartEmptyResidentProcess(const BundleInfo &info, const std::string &processName, int restartCount); 514 515 void RestartResidentProcess(std::shared_ptr<AppRunningRecord> appRecord); 516 517 bool CheckLoadabilityConditions(const sptr<IRemoteObject> &token, 518 const std::shared_ptr<AbilityInfo> &abilityInfo, const std::shared_ptr<ApplicationInfo> &appInfo); 519 520 bool GetBundleInfo(const std::string &bundelName, BundleInfo &bundleInfo); 521 522 void MakeProcessName(std::string &processName, const std::shared_ptr<AbilityInfo> &abilityInfo, 523 const std::shared_ptr<ApplicationInfo> &appInfo, HapModuleInfo &hapModuleInfo); 524 void MakeProcessName( 525 std::string &processName, const std::shared_ptr<ApplicationInfo> &appInfo, HapModuleInfo &hapModuleInfo); 526 /** 527 * StartAbility, load the ability that needed to be started(Start on the basis of the original process). 528 * Start on a new boot process 529 * @param token, the unique identification to start the ability. 530 * @param preToken, the unique identification to call the ability. 531 * @param abilityInfo, the ability information. 532 * @param appInfo, the app information. 533 * 534 * @return 535 */ 536 void StartAbility(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &preToken, 537 const std::shared_ptr<AbilityInfo> &abilityInfo, const std::shared_ptr<AppRunningRecord> &appRecord, 538 const HapModuleInfo &hapModuleInfo, const std::shared_ptr<AAFwk::Want> &want); 539 540 /** 541 * StartProcess, load the ability that needed to be started(Start on a new boot process). 542 * 543 * @param appName, the app name. 544 * @param processName, the process name. 545 * @param appRecord, the app information. 546 * @param uid, the process uid. 547 * @param bundleName, the app bundleName. 548 * 549 * @return 550 */ 551 void StartProcess(const std::string &appName, const std::string &processName, bool coldStart, 552 const std::shared_ptr<AppRunningRecord> &appRecord, const int uid, const std::string &bundleName); 553 554 /** 555 * PushAppFront, Adjust the latest application record to the top level. 556 * 557 * @param recordId, the app record id. 558 * 559 * @return 560 */ 561 void PushAppFront(const int32_t recordId); 562 563 /** 564 * RemoveAppFromRecentListById, Remove the specified recent application record by application record id. 565 * 566 * @param recordId, the app record id. 567 * 568 * @return 569 */ 570 void RemoveAppFromRecentListById(const int32_t recordId); 571 572 /** 573 * AddAppToRecentList, Add application to recent list. 574 * 575 * @param appName, the app name. 576 * @param processName, the process name. 577 * @param pid, the app pid. 578 * @param recordId, the app record id. 579 * 580 * @return 581 */ 582 void AddAppToRecentList( 583 const std::string &appName, const std::string &processName, const pid_t pid, const int32_t recordId); 584 585 /** 586 * AddAppToRecentList, Get application task information through ID. 587 * 588 * @param recordId, the app record id. 589 * 590 * @return application task information. 591 */ 592 const std::shared_ptr<AppTaskInfo> GetAppTaskInfoById(const int32_t recordId) const; 593 594 /** 595 * KillApplicationByUserId, kill the application by user ID. 596 * 597 * @param bundleName, bundle name in Application record. 598 * @param userId, user ID. 599 * 600 * @return ERR_OK, return back success, others fail. 601 */ 602 int32_t KillApplicationByUserIdLocked(const std::string &bundleName, const int userId); 603 604 /** 605 * KillProcessByPid, Kill process by PID. 606 * 607 * @param pid_t, the app record pid. 608 * 609 * @return ERR_OK, return back success,others fail. 610 */ 611 int32_t KillProcessByPid(const pid_t pid) const; 612 613 /** 614 * WaitForRemoteProcessExit, Wait for the process to exit normally. 615 * 616 * @param pids, process number collection to exit. 617 * @param startTime, execution process security exit start time. 618 * 619 * @return true, return back success,others fail. 620 */ 621 bool WaitForRemoteProcessExit(std::list<pid_t> &pids, const int64_t startTime); 622 623 /** 624 * GetAllPids, Get the corresponding pid collection. 625 * 626 * @param pids, process number collection to exit. 627 * 628 * @return true, return back success,others fail. 629 */ 630 bool GetAllPids(std::list<pid_t> &pids); 631 632 /** 633 * process_exist, Judge whether the process exists. 634 * 635 * @param pids, process number collection to exit. 636 * 637 * @return true, return back existed,others non-existent. 638 */ 639 bool process_exist(pid_t &pid); 640 641 /** 642 * CheckAllProcessExist, Determine whether all processes exist . 643 * 644 * @param pids, process number collection to exit. 645 * 646 * @return true, Returns that a process exists and all other processes do not exist. 647 */ 648 bool CheckAllProcessExist(std::list<pid_t> &pids); 649 650 /** 651 * SystemTimeMillis, Get system time. 652 * 653 * @return the system time. 654 */ 655 int64_t SystemTimeMillis(); 656 657 // Test add the bundle manager instance. 658 void SetBundleManager(sptr<IBundleMgr> bundleManager); 659 660 void HandleTerminateApplicationTimeOut(const int64_t eventId); 661 662 void HandleAddAbilityStageTimeOut(const int64_t eventId); 663 664 void ClipStringContent(const std::regex &re, const std::string &sorce, std::string &afferCutStr); 665 666 bool GetBundleAndHapInfo(const AbilityInfo &abilityInfo, const std::shared_ptr<ApplicationInfo> &appInfo, 667 BundleInfo &bundleInfo, HapModuleInfo &hapModuleInfo); 668 AppProcessData WrapAppProcessData(const std::shared_ptr<AppRunningRecord> &appRecord, 669 const ApplicationState state); 670 671 AppStateData WrapAppStateData(const std::shared_ptr<AppRunningRecord> &appRecord, 672 const ApplicationState state); 673 674 ProcessData WrapProcessData(const std::shared_ptr<AppRunningRecord> &appRecord); 675 676 void AddObserverDeathRecipient(const sptr<IApplicationStateObserver> &observer); 677 678 void RemoveObserverDeathRecipient(const sptr<IApplicationStateObserver> &observer); 679 680 void OnObserverDied(const wptr<IRemoteObject> &remote); 681 682 void HandleObserverDiedTask(const sptr<IRemoteObject> &observer); 683 684 bool ObserverExist(const sptr<IApplicationStateObserver> &observer); 685 686 void OnProcessCreated(const std::shared_ptr<AppRunningRecord> &appRecord); 687 688 void OnProcessDied(const std::shared_ptr<AppRunningRecord> &appRecord); 689 690 int UserTestAbnormalFinish(const sptr<IRemoteObject> &observer, const std::string &msg); 691 int GetHapModuleInfoForTestRunner(const AAFwk::Want &want, const sptr<IRemoteObject> &observer, 692 const BundleInfo &bundleInfo, HapModuleInfo &hapModuleInfo); 693 int StartEmptyProcess(const AAFwk::Want &want, const sptr<IRemoteObject> &observer, const BundleInfo &info, 694 const std::string &processName, const int userId); 695 696 void HandleStartSpecifiedAbilityTimeOut(const int64_t eventId); 697 698 void GetGlobalConfiguration(); 699 700 void GetRunningProcesses(const std::shared_ptr<AppRunningRecord> &appRecord, std::vector<RunningProcessInfo> &info); 701 702 int StartRenderProcessImpl(const std::shared_ptr<RenderRecord> &renderRecord, 703 const std::shared_ptr<AppRunningRecord> appRecord, pid_t &renderPid); 704 705 void OnRenderRemoteDied(const wptr<IRemoteObject> &remote); 706 private: 707 /** 708 * ClearUpApplicationData, clear the application data. 709 * 710 * @param bundleName, bundle name in Application record. 711 * @param uid, app uid in Application record. 712 * @param pid, app pid in Application record. 713 * @param userId, userId. 714 * 715 * @return 716 */ 717 void ClearUpApplicationDataByUserId(const std::string &bundleName, 718 int32_t callerUid, pid_t callerPid, const int userId); 719 720 int VerifyObserverPermission(); 721 722 private: 723 /** 724 * Notify application status. 725 * 726 * @param bundleName Indicates the name of the bundle. 727 * @param eventData Indicates the event defined by CommonEventSupport 728 * 729 * @return 730 */ 731 void NotifyAppStatus(const std::string &bundleName, const std::string &eventData); 732 /** 733 * Notify application status. 734 * 735 * @param bundleName Indicates the name of the bundle. 736 * @param bundleName Indicates the name of the bundle. 737 * @param eventData Indicates the event defined by CommonEventSupport 738 * 739 * @return 740 */ 741 void NotifyAppStatusByCallerUid(const std::string &bundleName, const int32_t userId, const int32_t callerUid, 742 const std::string &eventData); 743 void KillApplicationByRecord(const std::shared_ptr<AppRunningRecord> &appRecord); 744 void SendHiSysEvent(const int32_t innerEventId, const int64_t eventId); 745 int FinishUserTestLocked( 746 const std::string &msg, const int &resultCode, std::shared_ptr<AppRunningRecord> &appRecord); 747 const std::string TASK_ON_CALLBACK_DIED = "OnCallbackDiedTask"; 748 std::vector<sptr<IApplicationStateObserver>> appStateObservers_; 749 std::map<sptr<IRemoteObject>, sptr<IRemoteObject::DeathRecipient>> recipientMap_; 750 std::recursive_mutex observerLock_; 751 std::vector<const sptr<IAppStateCallback>> appStateCallbacks_; 752 std::shared_ptr<AppProcessManager> appProcessManager_; 753 std::shared_ptr<RemoteClientManager> remoteClientManager_; 754 std::shared_ptr<AppRunningManager> appRunningManager_; 755 std::shared_ptr<AMSEventHandler> eventHandler_; 756 std::shared_ptr<Configuration> configuration_; 757 std::mutex userTestLock_; 758 sptr<IStartSpecifiedAbilityResponse> startSpecifiedAbilityResponse_; 759 }; 760 } // namespace AppExecFwk 761 } // namespace OHOS 762 #endif // FOUNDATION_APPEXECFWK_SERVICES_APPMGR_INCLUDE_APP_MGR_SERVICE_INNER_H 763