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_ABILITY_RECORD_H 17 #define OHOS_ABILITY_RUNTIME_ABILITY_RECORD_H 18 19 #include <ctime> 20 #include <functional> 21 #include <list> 22 #include <memory> 23 #include <vector> 24 #include <set> 25 #include <utility> 26 #include "cpp/mutex.h" 27 #include "cpp/condition_variable.h" 28 29 #include "ability_connect_callback_interface.h" 30 #include "ability_info.h" 31 #include "ability_start_setting.h" 32 #include "ability_state.h" 33 #include "ability_token_stub.h" 34 #include "app_scheduler.h" 35 #include "application_info.h" 36 #include "bundlemgr/bundle_mgr_interface.h" 37 #include "call_container.h" 38 #include "exit_reason.h" 39 #include "ipc_skeleton.h" 40 #include "lifecycle_deal.h" 41 #include "lifecycle_state_info.h" 42 #include "session_info.h" 43 #include "ui_extension_window_command.h" 44 #include "uri.h" 45 #include "want.h" 46 #include "window_config.h" 47 #ifdef SUPPORT_GRAPHICS 48 #include "ability_window_configuration.h" 49 #include "resource_manager.h" 50 #include "start_options.h" 51 #include "window_manager_service_handler.h" 52 #endif 53 54 namespace OHOS { 55 namespace AAFwk { 56 using Closure = std::function<void()>; 57 58 class AbilityRecord; 59 class ConnectionRecord; 60 class CallContainer; 61 62 constexpr const char* ABILITY_TOKEN_NAME = "AbilityToken"; 63 constexpr const char* LAUNCHER_BUNDLE_NAME = "com.ohos.launcher"; 64 65 /** 66 * @class Token 67 * Token is identification of ability and used to interact with kit and wms. 68 */ 69 class Token : public AbilityTokenStub { 70 public: 71 explicit Token(std::weak_ptr<AbilityRecord> abilityRecord); 72 virtual ~Token(); 73 74 std::shared_ptr<AbilityRecord> GetAbilityRecord() const; 75 static std::shared_ptr<AbilityRecord> GetAbilityRecordByToken(const sptr<IRemoteObject> &token); 76 77 private: 78 std::weak_ptr<AbilityRecord> abilityRecord_; // ability of this token 79 }; 80 81 /** 82 * @class AbilityResult 83 * Record requestCode of for-result start mode and result. 84 */ 85 class AbilityResult { 86 public: 87 AbilityResult() = default; AbilityResult(int requestCode,int resultCode,const Want & resultWant)88 AbilityResult(int requestCode, int resultCode, const Want &resultWant) 89 : requestCode_(requestCode), resultCode_(resultCode), resultWant_(resultWant) 90 {} ~AbilityResult()91 virtual ~AbilityResult() 92 {} 93 94 int requestCode_ = -1; // requestCode of for-result start mode 95 int resultCode_ = -1; // resultCode of for-result start mode 96 Want resultWant_; // for-result start mode ability will send the result to caller 97 }; 98 99 /** 100 * @class SystemAbilityCallerRecord 101 * Record system caller ability of for-result start mode and result. 102 */ 103 class SystemAbilityCallerRecord { 104 public: SystemAbilityCallerRecord(std::string & srcAbilityId,const sptr<IRemoteObject> & callerToken)105 SystemAbilityCallerRecord(std::string &srcAbilityId, const sptr<IRemoteObject> &callerToken) 106 : srcAbilityId_(srcAbilityId), callerToken_(callerToken) 107 {} ~SystemAbilityCallerRecord()108 virtual ~SystemAbilityCallerRecord() 109 {} 110 GetSrcAbilityId()111 std::string GetSrcAbilityId() 112 { 113 return srcAbilityId_; 114 } GetCallerToken()115 const sptr<IRemoteObject> GetCallerToken() 116 { 117 return callerToken_; 118 } SetResult(Want & want,int resultCode)119 void SetResult(Want &want, int resultCode) 120 { 121 resultWant_ = want; 122 resultCode_ = resultCode; 123 } GetResultWant()124 Want &GetResultWant() 125 { 126 return resultWant_; 127 } GetResultCode()128 int &GetResultCode() 129 { 130 return resultCode_; 131 } 132 /** 133 * Set result to system ability. 134 * 135 */ 136 void SetResultToSystemAbility(std::shared_ptr<SystemAbilityCallerRecord> callerSystemAbilityRecord, 137 Want &resultWant, int resultCode); 138 /** 139 * Send result to system ability. 140 * 141 */ 142 void SendResultToSystemAbility(int requestCode, 143 const std::shared_ptr<SystemAbilityCallerRecord> callerSystemAbilityRecord, 144 int32_t callerUid, uint32_t accessToken, bool schedulerdied); 145 146 private: 147 std::string srcAbilityId_; 148 sptr<IRemoteObject> callerToken_; 149 Want resultWant_; 150 int resultCode_ = -1; 151 }; 152 153 /** 154 * @struct CallerAbilityInfo 155 * caller ability info. 156 */ 157 struct CallerAbilityInfo { 158 public: 159 int32_t callerTokenId = 0; 160 int32_t callerUid = 0; 161 int32_t callerPid = 0; 162 int32_t callerAppCloneIndex = 0; 163 std::string callerNativeName; 164 std::string callerBundleName; 165 std::string callerAbilityName; 166 }; 167 168 /** 169 * @class CallerRecord 170 * Record caller ability of for-result start mode and result. 171 */ 172 class CallerRecord { 173 public: 174 CallerRecord() = default; 175 CallerRecord(int requestCode, std::weak_ptr<AbilityRecord> caller); CallerRecord(int requestCode,std::shared_ptr<SystemAbilityCallerRecord> saCaller)176 CallerRecord(int requestCode, std::shared_ptr<SystemAbilityCallerRecord> saCaller) : requestCode_(requestCode), 177 saCaller_(saCaller) 178 {} ~CallerRecord()179 virtual ~CallerRecord() 180 {} 181 GetRequestCode()182 int GetRequestCode() 183 { 184 return requestCode_; 185 } GetCaller()186 std::shared_ptr<AbilityRecord> GetCaller() 187 { 188 return caller_.lock(); 189 } GetSaCaller()190 std::shared_ptr<SystemAbilityCallerRecord> GetSaCaller() 191 { 192 return saCaller_; 193 } GetCallerInfo()194 std::shared_ptr<CallerAbilityInfo> GetCallerInfo() 195 { 196 return callerInfo_; 197 } IsHistoryRequestCode(int32_t requestCode)198 bool IsHistoryRequestCode(int32_t requestCode) 199 { 200 return requestCodeSet_.count(requestCode) > 0; 201 } RemoveHistoryRequestCode(int32_t requestCode)202 void RemoveHistoryRequestCode(int32_t requestCode) 203 { 204 requestCodeSet_.erase(requestCode); 205 } AddHistoryRequestCode(int32_t requestCode)206 void AddHistoryRequestCode(int32_t requestCode) 207 { 208 requestCodeSet_.insert(requestCode); 209 } SetRequestCodeSet(const std::set<int32_t> & requestCodeSet)210 void SetRequestCodeSet(const std::set<int32_t> &requestCodeSet) 211 { 212 requestCodeSet_ = requestCodeSet; 213 } GetRequestCodeSet()214 std::set<int32_t> GetRequestCodeSet() 215 { 216 return requestCodeSet_; 217 } 218 219 private: 220 int requestCode_ = -1; // requestCode of for-result start mode 221 std::weak_ptr<AbilityRecord> caller_; 222 std::shared_ptr<SystemAbilityCallerRecord> saCaller_ = nullptr; 223 std::shared_ptr<CallerAbilityInfo> callerInfo_ = nullptr; 224 std::set<int32_t> requestCodeSet_; 225 }; 226 227 /** 228 * @class AbilityRequest 229 * Wrap parameters of starting ability. 230 */ 231 enum AbilityCallType { 232 INVALID_TYPE = 0, 233 CALL_REQUEST_TYPE, 234 START_OPTIONS_TYPE, 235 START_SETTINGS_TYPE, 236 START_EXTENSION_TYPE, 237 }; 238 239 enum CollaboratorType { 240 DEFAULT_TYPE = 0, 241 RESERVE_TYPE, 242 OTHERS_TYPE 243 }; 244 245 struct AbilityRequest { 246 bool restart = false; 247 bool startRecent = false; 248 bool uriReservedFlag = false; 249 bool isFromIcon = false; 250 bool isShellCall = false; 251 // ERMS embedded atomic service 252 bool isQueryERMS = false; 253 bool isEmbeddedAllowed = false; 254 bool callSpecifiedFlagTimeout = false; 255 int32_t restartCount = -1; 256 int32_t uid = 0; 257 int32_t collaboratorType = CollaboratorType::DEFAULT_TYPE; 258 int32_t callerTokenRecordId = -1; 259 int32_t userId = -1; 260 uint32_t callerAccessTokenId = -1; 261 uint32_t specifyTokenId = 0; 262 int callerUid = -1; // call ability 263 int requestCode = -1; 264 AbilityCallType callType = AbilityCallType::INVALID_TYPE; // call ability 265 int64_t restartTime = 0; 266 sptr<IRemoteObject> callerToken = nullptr; // call ability 267 sptr<IRemoteObject> asCallerSourceToken = nullptr; // call ability 268 sptr<IAbilityConnection> connect = nullptr; 269 sptr<IRemoteObject> abilityInfoCallback = nullptr; 270 sptr<SessionInfo> sessionInfo; 271 std::shared_ptr<AbilityStartSetting> startSetting = nullptr; 272 std::shared_ptr<ProcessOptions> processOptions = nullptr; 273 std::shared_ptr<StartWindowOption> startWindowOption = nullptr; 274 std::vector<AppExecFwk::SupportWindowMode> supportWindowModes; 275 AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED; 276 AppExecFwk::ExtensionProcessMode extensionProcessMode = AppExecFwk::ExtensionProcessMode::UNDEFINED; 277 std::string specifiedFlag; 278 std::string customProcess; 279 std::string reservedBundleName; 280 std::string appId; 281 std::string startTime; 282 Want want; 283 AppExecFwk::AbilityInfo abilityInfo; 284 AppExecFwk::ApplicationInfo appInfo; IsContinuationAbilityRequest285 std::pair<bool, LaunchReason> IsContinuation() const 286 { 287 auto flags = want.GetFlags(); 288 if ((flags & Want::FLAG_ABILITY_CONTINUATION) == Want::FLAG_ABILITY_CONTINUATION) { 289 return {true, LaunchReason::LAUNCHREASON_CONTINUATION}; 290 } 291 if ((flags & Want::FLAG_ABILITY_PREPARE_CONTINUATION) == Want::FLAG_ABILITY_PREPARE_CONTINUATION) { 292 return {true, LaunchReason::LAUNCHREASON_PREPARE_CONTINUATION}; 293 } 294 return {false, LaunchReason::LAUNCHREASON_UNKNOWN}; 295 } 296 IsAcquireShareDataAbilityRequest297 bool IsAcquireShareData() const 298 { 299 return want.GetBoolParam(Want::PARAM_ABILITY_ACQUIRE_SHARE_DATA, false); 300 } 301 IsAppRecoveryAbilityRequest302 bool IsAppRecovery() const 303 { 304 return want.GetBoolParam(Want::PARAM_ABILITY_RECOVERY_RESTART, false); 305 } 306 IsCallTypeAbilityRequest307 bool IsCallType(const AbilityCallType & type) const 308 { 309 return (callType == type); 310 } 311 DumpAbilityRequest312 void Dump(std::vector<std::string> &state) 313 { 314 std::string dumpInfo = " want [" + want.ToUri() + "]"; 315 state.push_back(dumpInfo); 316 dumpInfo = " app name [" + abilityInfo.applicationName + "]"; 317 state.push_back(dumpInfo); 318 dumpInfo = " main name [" + abilityInfo.name + "]"; 319 state.push_back(dumpInfo); 320 dumpInfo = " request code [" + std::to_string(requestCode) + "]"; 321 state.push_back(dumpInfo); 322 } 323 324 void Voluation(const Want &srcWant, int srcRequestCode, 325 const sptr<IRemoteObject> &srcCallerToken, const std::shared_ptr<AbilityStartSetting> srcStartSetting = nullptr, 326 int srcCallerUid = -1) 327 { 328 want = srcWant; 329 requestCode = srcRequestCode; 330 callerToken = srcCallerToken; 331 startSetting = srcStartSetting; 332 callerUid = srcCallerUid == -1 ? IPCSkeleton::GetCallingUid() : srcCallerUid; 333 } 334 }; 335 336 // new version 337 enum ResolveResultType { 338 OK_NO_REMOTE_OBJ = 0, 339 OK_HAS_REMOTE_OBJ, 340 NG_INNER_ERROR, 341 }; 342 343 enum class AbilityWindowState { 344 FOREGROUND = 0, 345 BACKGROUND, 346 TERMINATE, 347 FOREGROUNDING, 348 BACKGROUNDING, 349 TERMINATING 350 }; 351 352 enum class AbilityVisibilityState { 353 INITIAL = 0, 354 FOREGROUND_HIDE, 355 FOREGROUND_SHOW, 356 UNSPECIFIED, 357 }; 358 359 struct LaunchDebugInfo { 360 public: 361 void Update(const Want &want); 362 363 bool isDebugAppSet = false; 364 bool isNativeDebugSet = false; 365 bool isPerfCmdSet = false; 366 bool debugApp = false; 367 bool nativeDebug = false; 368 std::string perfCmd; 369 }; 370 371 /** 372 * @class AbilityRecord 373 * AbilityRecord records ability info and states and used to schedule ability life. 374 */ 375 class AbilityRecord : public std::enable_shared_from_this<AbilityRecord> { 376 public: 377 AbilityRecord(const Want &want, const AppExecFwk::AbilityInfo &abilityInfo, 378 const AppExecFwk::ApplicationInfo &applicationInfo, int requestCode = -1); 379 380 virtual ~AbilityRecord(); 381 382 /** 383 * CreateAbilityRecord. 384 * 385 * @param abilityRequest,create ability record. 386 * @return Returns ability record ptr. 387 */ 388 static std::shared_ptr<AbilityRecord> CreateAbilityRecord(const AbilityRequest &abilityRequest); 389 390 /** 391 * Init ability record. 392 * 393 * @return Returns true on success, others on failure. 394 */ 395 bool Init(); 396 397 /** 398 * load UI ability. 399 * 400 */ 401 void LoadUIAbility(); 402 403 /** 404 * load ability. 405 * 406 * @return Returns ERR_OK on success, others on failure. 407 */ 408 int LoadAbility(bool isShellCall = false); 409 410 /** 411 * foreground the ability. 412 * 413 */ 414 void ForegroundAbility(uint32_t sceneFlag = 0); 415 void ForegroundUIExtensionAbility(uint32_t sceneFlag = 0); 416 417 /** 418 * process request of foregrounding the ability. 419 * 420 */ 421 void ProcessForegroundAbility(uint32_t tokenId, uint32_t sceneFlag = 0, bool isShellCall = false); 422 423 /** 424 * post foreground timeout task for ui ability. 425 * 426 */ 427 void PostForegroundTimeoutTask(); 428 429 void RemoveForegroundTimeoutTask(); 430 431 void RemoveLoadTimeoutTask(); 432 433 void PostUIExtensionAbilityTimeoutTask(uint32_t messageId); 434 435 /** 436 * move the ability to back ground. 437 * 438 * @param task timeout task. 439 */ 440 void BackgroundAbility(const Closure &task); 441 442 /** 443 * prepare terminate ability. 444 * 445 * @param isSCBCall, if the call is from SCB. 446 * @return Returns true on stop terminating; returns false on terminate. 447 */ 448 bool PrepareTerminateAbility(bool isSCBCall); 449 450 /** 451 * prepare terminate ability done. 452 * 453 * @param isTerminate, the result of the onPrepareToTerminate/onPrepareToTerminateAsync. 454 */ 455 void PrepareTerminateAbilityDone(bool isTerminate); 456 457 /** 458 * terminate ability. 459 * 460 * @return Returns ERR_OK on success, others on failure. 461 */ 462 int TerminateAbility(); 463 464 /** 465 * get ability's info. 466 * 467 * @return ability info. 468 */ 469 const AppExecFwk::AbilityInfo &GetAbilityInfo() const; 470 471 /** 472 * get application's info. 473 * 474 * @return application info. 475 */ 476 const AppExecFwk::ApplicationInfo &GetApplicationInfo() const; 477 478 /** 479 * set ability's state. 480 * 481 * @param state, ability's state. 482 */ 483 void SetAbilityState(AbilityState state); 484 485 bool GetAbilityForegroundingFlag() const; 486 487 void SetAbilityForegroundingFlag(); 488 489 /** 490 * get ability's state. 491 * 492 * @return ability state. 493 */ 494 AbilityState GetAbilityState() const; 495 496 /** 497 * get ability's windowconfig. 498 * 499 * @return ability windowconfig. 500 */ 501 WindowConfig GetAbilityWindowConfig() const; 502 503 bool IsForeground() const; 504 505 AbilityVisibilityState GetAbilityVisibilityState() const; 506 void SetAbilityVisibilityState(AbilityVisibilityState state); 507 508 void UpdateAbilityVisibilityState(); 509 510 /** 511 * set ability scheduler for accessing ability thread. 512 * 513 * @param scheduler , ability scheduler. 514 */ 515 void SetScheduler(const sptr<IAbilityScheduler> &scheduler); 516 GetScheduler()517 inline sptr<IAbilityScheduler> GetScheduler() const 518 { 519 return scheduler_; 520 } 521 522 sptr<SessionInfo> GetSessionInfo() const; 523 524 /** 525 * get ability's token. 526 * 527 * @return ability's token. 528 */ 529 sptr<Token> GetToken() const; 530 531 /** 532 * set ability's previous ability record. 533 * 534 * @param abilityRecord , previous ability record 535 */ 536 void SetPreAbilityRecord(const std::shared_ptr<AbilityRecord> &abilityRecord); 537 538 /** 539 * get ability's previous ability record. 540 * 541 * @return previous ability record 542 */ 543 std::shared_ptr<AbilityRecord> GetPreAbilityRecord() const; 544 545 /** 546 * set ability's next ability record. 547 * 548 * @param abilityRecord , next ability record 549 */ 550 void SetNextAbilityRecord(const std::shared_ptr<AbilityRecord> &abilityRecord); 551 552 /** 553 * get ability's previous ability record. 554 * 555 * @return previous ability record 556 */ 557 std::shared_ptr<AbilityRecord> GetNextAbilityRecord() const; 558 559 /** 560 * check whether the ability is ready. 561 * 562 * @return true : ready ,false: not ready 563 */ 564 bool IsReady() const; 565 566 void UpdateRecoveryInfo(bool hasRecoverInfo); 567 568 bool GetRecoveryInfo(); 569 570 #ifdef SUPPORT_SCREEN 571 /** 572 * check whether the ability 's window is attached. 573 * 574 * @return true : attached ,false: not attached 575 */ 576 bool IsWindowAttached() const; 577 IsStartingWindow()578 inline bool IsStartingWindow() const 579 { 580 return isStartingWindow_; 581 } 582 SetStartingWindow(bool isStartingWindow)583 inline void SetStartingWindow(bool isStartingWindow) 584 { 585 isStartingWindow_ = isStartingWindow; 586 } 587 SetKillReason(const std::string & reason)588 inline void SetKillReason(const std::string &reason) 589 { 590 killReason_ = reason; 591 } 592 GetKillReason()593 inline std::string GetKillReason() 594 { 595 return killReason_; 596 } 597 598 void PostCancelStartingWindowHotTask(); 599 600 /** 601 * process request of foregrounding the ability. 602 * 603 */ 604 void ProcessForegroundAbility(bool isRecent, const AbilityRequest &abilityRequest, 605 std::shared_ptr<StartOptions> &startOptions, const std::shared_ptr<AbilityRecord> &callerAbility, 606 uint32_t sceneFlag = 0); 607 608 void ProcessForegroundAbility(const std::shared_ptr<AbilityRecord> &callerAbility, bool needExit = true, 609 uint32_t sceneFlag = 0); 610 void NotifyAnimationFromTerminatingAbility() const; 611 void NotifyAnimationFromMinimizeAbility(bool& animaEnabled); 612 613 bool ReportAtomicServiceDrawnCompleteEvent(); 614 void SetCompleteFirstFrameDrawing(const bool flag); 615 bool IsCompleteFirstFrameDrawing() const; 616 bool GetColdStartFlag(); 617 void SetColdStartFlag(bool isColdStart); 618 #endif 619 620 /** 621 * check whether the ability is launcher. 622 * 623 * @return true : launcher ,false: not launcher 624 */ 625 bool IsLauncherAbility() const; 626 627 /** 628 * check whether the ability is terminating. 629 * 630 * @return true : yes ,false: not 631 */ 632 bool IsTerminating() const; 633 634 /** 635 * set the ability is terminating. 636 * 637 */ 638 void SetTerminatingState(); 639 640 /** 641 * set the ability is new want flag. 642 * 643 * @return isNewWant 644 */ 645 void SetIsNewWant(bool isNewWant); 646 647 /** 648 * check whether the ability is new want flag. 649 * 650 * @return true : yes ,false: not 651 */ 652 bool IsNewWant() const; 653 654 /** 655 * check whether the ability is created by connect ability mode. 656 * 657 * @return true : yes ,false: not 658 */ 659 bool IsCreateByConnect() const; 660 661 /** 662 * set the ability is created by connect ability mode. 663 * 664 */ 665 void SetCreateByConnectMode(bool isCreatedByConnect = true); 666 667 /** 668 * active the ability. 669 * 670 */ 671 virtual void Activate(); 672 673 /** 674 * inactive the ability. 675 * 676 */ 677 virtual void Inactivate(); 678 679 /** 680 * terminate the ability. 681 * 682 */ 683 void Terminate(const Closure &task); 684 685 /** 686 * connect the ability. 687 * 688 */ 689 void ConnectAbility(); 690 691 /** 692 * connect the ability with want. 693 * 694 */ 695 void ConnectAbilityWithWant(const Want &want); 696 697 /** 698 * disconnect the ability. 699 * 700 */ 701 void DisconnectAbility(); 702 703 /** 704 * disconnect the ability with want 705 * 706 */ 707 void DisconnectAbilityWithWant(const Want &want); 708 709 /** 710 * Command the ability. 711 * 712 */ 713 void CommandAbility(); 714 715 void CommandAbilityWindow(const sptr<SessionInfo> &sessionInfo, WindowCommand winCmd); 716 717 /** 718 * save ability state. 719 * 720 */ 721 void SaveAbilityState(); 722 void SaveAbilityState(const PacMap &inState); 723 void SaveAbilityWindowConfig(const WindowConfig &windowConfig); 724 725 /** 726 * restore ability state. 727 * 728 */ 729 void RestoreAbilityState(); 730 731 /** 732 * notify top active ability updated. 733 * 734 */ 735 void TopActiveAbilityChanged(bool flag); 736 737 /** 738 * set the want for start ability. 739 * 740 */ 741 void SetWant(const Want &want); 742 743 /** 744 * get the want for start ability. 745 * 746 */ 747 Want GetWant() const; 748 749 /** 750 * remove signature info of want. 751 * 752 */ 753 void RemoveSignatureInfo(); 754 755 /** 756 * remove specified wantParam for start ability. 757 * 758 */ 759 void RemoveSpecifiedWantParam(const std::string &key); 760 761 /** 762 * get request code of the ability to start. 763 * 764 */ 765 int GetRequestCode() const; 766 767 /** 768 * set the result object of the ability which one need to be terminated. 769 * 770 */ 771 void SetResult(const std::shared_ptr<AbilityResult> &result); 772 773 /** 774 * get the result object of the ability which one need to be terminated. 775 * 776 */ 777 std::shared_ptr<AbilityResult> GetResult() const; 778 779 /** 780 * send result object to caller ability thread. 781 * 782 */ 783 void SendResult(bool isSandboxApp, uint32_t tokeId); 784 785 /** 786 * send result object to caller ability thread. 787 * 788 */ 789 void SendResultByBackToCaller(const std::shared_ptr<AbilityResult> &result); 790 791 /** 792 * send result object to caller ability thread for sandbox app file saving. 793 */ 794 void SendSandboxSavefileResult(const Want &want, int resultCode, int requestCode); 795 796 /** 797 * send result object to caller ability. 798 * 799 */ 800 void SendResultToCallers(bool schedulerdied = false); 801 802 /** 803 * save result object to caller ability. 804 * 805 */ 806 void SaveResultToCallers(const int resultCode, const Want *resultWant); 807 808 std::shared_ptr<AbilityRecord> GetCallerByRequestCode(int32_t requestCode, int32_t pid); 809 810 /** 811 * save result to caller ability. 812 * 813 */ 814 void SaveResult(int resultCode, const Want *resultWant, std::shared_ptr<CallerRecord> caller); 815 816 bool NeedConnectAfterCommand(); 817 818 /** 819 * add connect record to the list. 820 * 821 */ 822 void AddConnectRecordToList(const std::shared_ptr<ConnectionRecord> &connRecord); 823 824 /** 825 * get the list of connect record. 826 * 827 */ 828 std::list<std::shared_ptr<ConnectionRecord>> GetConnectRecordList() const; 829 830 /** 831 * get the list of connect record. 832 * 833 */ 834 std::list<std::shared_ptr<ConnectionRecord>> GetConnectingRecordList(); 835 836 /** 837 * get the count of In Progress record. 838 * 839 */ 840 uint32_t GetInProgressRecordCount(); 841 /** 842 * remove the connect record from list. 843 * 844 */ 845 void RemoveConnectRecordFromList(const std::shared_ptr<ConnectionRecord> &connRecord); 846 847 /** 848 * check whether connect list is empty. 849 * 850 */ 851 bool IsConnectListEmpty(); 852 853 size_t GetConnectedListSize(); 854 855 size_t GetConnectingListSize(); 856 857 void RemoveCallerRequestCode(std::shared_ptr<AbilityRecord> callerAbilityRecord, int32_t requestCode); 858 859 /** 860 * add caller record 861 * 862 */ 863 void AddCallerRecord(const sptr<IRemoteObject> &callerToken, int requestCode, const Want &want, 864 std::string srcAbilityId = "", uint32_t callingTokenId = 0); 865 866 /** 867 * get caller record to list. 868 * 869 */ 870 std::list<std::shared_ptr<CallerRecord>> GetCallerRecordList() const; 871 std::shared_ptr<AbilityRecord> GetCallerRecord() const; 872 873 std::shared_ptr<CallerAbilityInfo> GetCallerInfo() const; 874 875 /** 876 * get connecting record from list. 877 * 878 */ 879 std::shared_ptr<ConnectionRecord> GetConnectingRecord() const; 880 881 /** 882 * get disconnecting record from list. 883 * 884 */ 885 std::shared_ptr<ConnectionRecord> GetDisconnectingRecord() const; 886 887 /** 888 * convert ability state (enum type to string type). 889 * 890 */ 891 static std::string ConvertAbilityState(const AbilityState &state); 892 893 static std::string ConvertAppState(const AppState &state); 894 895 /** 896 * convert life cycle state to ability state . 897 * 898 */ 899 static int ConvertLifeCycleToAbilityState(const AbilityLifeCycleState &state); 900 901 /** 902 * get the ability record id. 903 * 904 */ GetRecordId()905 inline int GetRecordId() const 906 { 907 return recordId_; 908 } 909 910 /** 911 * dump ability info. 912 * 913 */ 914 void Dump(std::vector<std::string> &info); 915 916 void DumpClientInfo(std::vector<std::string> &info, const std::vector<std::string> ¶ms, 917 bool isClient = false, bool dumpConfig = true) const; 918 919 /** 920 * Called when client complete dump. 921 * 922 * @param infos The dump info. 923 */ 924 void DumpAbilityInfoDone(std::vector<std::string> &infos); 925 926 /** 927 * dump ability state info. 928 * 929 */ 930 void DumpAbilityState(std::vector<std::string> &info, bool isClient, const std::vector<std::string> ¶ms); 931 932 void SetStartTime(); 933 934 int64_t GetStartTime() const; 935 936 /** 937 * dump service info. 938 * 939 */ 940 void DumpService(std::vector<std::string> &info, bool isClient = false) const; 941 942 /** 943 * dump service info. 944 * 945 */ 946 void DumpService(std::vector<std::string> &info, std::vector<std::string> ¶ms, bool isClient = false) const; 947 948 /** 949 * set connect remote object. 950 * 951 */ 952 void SetConnRemoteObject(const sptr<IRemoteObject> &remoteObject); 953 954 /** 955 * get connect remote object. 956 * 957 */ 958 sptr<IRemoteObject> GetConnRemoteObject() const; 959 960 /** 961 * check whether the ability is never started. 962 */ 963 bool IsNeverStarted() const; 964 965 void AddStartId(); 966 int GetStartId() const; 967 968 void SetIsUninstallAbility(); 969 /** 970 * Determine whether ability is uninstalled 971 * 972 * @return true: uninstalled false: installed 973 */ 974 bool IsUninstallAbility() const; 975 void ShareData(const int32_t &uniqueId); 976 void SetLauncherRoot(); 977 bool IsLauncherRoot() const; 978 bool IsAbilityState(const AbilityState &state) const; 979 bool IsActiveState() const; 980 981 void SetStartSetting(const std::shared_ptr<AbilityStartSetting> &setting); 982 std::shared_ptr<AbilityStartSetting> GetStartSetting() const; 983 984 void SetRestarting(const bool isRestart); 985 void SetRestarting(const bool isRestart, int32_t canReStartCount); 986 int32_t GetRestartCount() const; 987 void SetRestartCount(int32_t restartCount); 988 bool GetKeepAlive() const; SetKeepAliveBundle(bool value)989 void SetKeepAliveBundle(bool value) 990 { 991 keepAliveBundle_ = value; 992 } IsKeepAliveBundle()993 bool IsKeepAliveBundle() const 994 { 995 return keepAliveBundle_; 996 } 997 void SetLoading(bool status); 998 bool IsLoading() const; 999 int64_t GetRestartTime(); 1000 void SetRestartTime(const int64_t restartTime); 1001 void SetAppIndex(const int32_t appIndex); 1002 int32_t GetAppIndex() const; 1003 void SetWantAppIndex(const int32_t appIndex); 1004 int32_t GetWantAppIndex() const; 1005 bool IsRestarting() const; 1006 void SetAppState(const AppState &state); 1007 AppState GetAppState() const; 1008 1009 void SetLaunchReason(const LaunchReason &reason); 1010 void SetLaunchReasonMessage(const std::string &launchReasonMessage); 1011 void SetLastExitReason(const ExitReason &exitReason, const AppExecFwk::RunningProcessInfo &processsInfo, 1012 const int64_t timestamp, bool withKillReason); 1013 void ContinueAbility(const std::string &deviceId, uint32_t versionCode); 1014 void NotifyContinuationResult(int32_t result); 1015 1016 void SetMissionId(int32_t missionId); 1017 int32_t GetMissionId() const; 1018 1019 void SetUid(int32_t uid); 1020 int32_t GetUid(); 1021 pid_t GetPid(); 1022 void SetPid(pid_t pid); 1023 void SetSwitchingPause(bool state); 1024 bool IsSwitchingPause(); 1025 void SetOwnerMissionUserId(int32_t userId); 1026 int32_t GetOwnerMissionUserId(); 1027 1028 // new version 1029 ResolveResultType Resolve(const AbilityRequest &abilityRequest); 1030 bool ReleaseCall(const sptr<IAbilityConnection> &connect); 1031 bool IsNeedToCallRequest() const; 1032 bool IsStartedByCall() const; 1033 void SetStartedByCall(const bool isFlag); 1034 void CallRequest(); 1035 bool CallRequestDone(const sptr<IRemoteObject> &callStub) const; 1036 bool IsStartToBackground() const; 1037 void SetStartToBackground(const bool flag); 1038 bool IsStartToForeground() const; 1039 void SetStartToForeground(const bool flag); 1040 bool IsCallerSetProcess() const; 1041 void SetCallerSetProcess(const bool flag); 1042 void SetSessionInfo(sptr<SessionInfo> sessionInfo); 1043 void UpdateSessionInfo(sptr<IRemoteObject> sessionToken); 1044 void SetMinimizeReason(bool fromUser); 1045 void SetSceneFlag(uint32_t sceneFlag); 1046 bool IsMinimizeFromUser() const; 1047 void SetClearMissionFlag(bool clearMissionFlag); 1048 bool IsClearMissionFlag(); 1049 1050 void SetSpecifiedFlag(const std::string &flag); 1051 std::string GetSpecifiedFlag() const; 1052 void SetWindowMode(int32_t windowMode); 1053 void RemoveWindowMode(); 1054 LifeCycleStateInfo lifeCycleStateInfo_; // target life state info 1055 1056 bool CanRestartRootLauncher(); 1057 1058 bool CanRestartResident(); 1059 1060 std::string GetLabel(); GetAbilityRecordId()1061 inline int64_t GetAbilityRecordId() const 1062 { 1063 return recordId_; 1064 } 1065 1066 void SetPendingState(AbilityState state); 1067 AbilityState GetPendingState() const; 1068 1069 bool IsNeedBackToOtherMissionStack(); 1070 void SetNeedBackToOtherMissionStack(bool isNeedBackToOtherMissionStack); 1071 std::shared_ptr<AbilityRecord> GetOtherMissionStackAbilityRecord() const; 1072 void SetOtherMissionStackAbilityRecord(const std::shared_ptr<AbilityRecord> &abilityRecord); 1073 void RemoveAbilityDeathRecipient() const; 1074 bool IsExistConnection(const sptr<IAbilityConnection> &connect); 1075 1076 int32_t GetCollaboratorType() const; 1077 1078 std::string GetMissionAffinity() const; 1079 1080 void SetLockedState(bool lockedState); 1081 bool GetLockedState(); 1082 1083 void SetAttachDebug(const bool isAttachDebug); 1084 void SetAssertDebug(bool isAssertDebug); 1085 int32_t CreateModalUIExtension(const Want &want); 1086 1087 AppExecFwk::ElementName GetElementName() const; 1088 bool IsDebugApp() const; 1089 bool IsDebug() const; 1090 1091 void AddAbilityWindowStateMap(uint64_t uiExtensionComponentId, 1092 AbilityWindowState abilityWindowState); 1093 1094 void RemoveAbilityWindowStateMap(uint64_t uiExtensionComponentId); 1095 1096 bool IsAbilityWindowReady(); 1097 1098 void SetAbilityWindowState(const sptr<SessionInfo> &sessionInfo, 1099 WindowCommand winCmd, bool isFinished); 1100 1101 void SetUIExtensionAbilityId(const int32_t uiExtensionAbilityId); 1102 int32_t GetUIExtensionAbilityId() const; 1103 1104 void OnProcessDied(); 1105 1106 void SetProcessName(const std::string &process); 1107 1108 std::string GetProcessName() const; 1109 1110 void SetCustomProcessFlag(const std::string &process); 1111 1112 std::string GetCustomProcessFlag() const; 1113 1114 void SetExtensionProcessMode(const uint32_t &extensionProcessMode); 1115 1116 uint32_t GetExtensionProcessMode() const; 1117 1118 void SetURI(const std::string &uri); 1119 std::string GetURI() const; 1120 1121 void DoBackgroundAbilityWindowDelayed(bool needBackground); 1122 bool BackgroundAbilityWindowDelayed(); 1123 1124 bool IsSceneBoard() const; 1125 1126 void SetRestartAppFlag(bool isRestartApp); 1127 bool GetRestartAppFlag() const; 1128 1129 void SetKillForPermissionUpdateFlag(bool isKillForPermissionUpdate); 1130 bool GetKillForPermissionUpdateFlag() const; 1131 1132 void UpdateUIExtensionInfo(const WantParams &wantParams); 1133 1134 void SetSpecifyTokenId(const uint32_t specifyTokenId); 1135 1136 void SaveConnectWant(const Want &want); 1137 1138 void UpdateConnectWant(); 1139 1140 void RemoveConnectWant(); 1141 1142 void UpdateDmsCallerInfo(Want &want); 1143 1144 void SetDebugUIExtension(); 1145 1146 #ifdef SUPPORT_UPMS 1147 void GrantUriPermission(); 1148 1149 void GrantUriPermission(const std::vector<std::string> &uriVec, int32_t flag, 1150 const std::string &targetBundleName, uint32_t callerTokenId); 1151 #endif // SUPPORT_UPMS 1152 GetInstanceKey()1153 inline std::string GetInstanceKey() const 1154 { 1155 return instanceKey_; 1156 } 1157 SetInstanceKey(const std::string & key)1158 void SetInstanceKey(const std::string& key) 1159 { 1160 instanceKey_ = key; 1161 } 1162 SetSecurityFlag(bool securityFlag)1163 void SetSecurityFlag(bool securityFlag) 1164 { 1165 securityFlag_ = securityFlag; 1166 } 1167 GetSecurityFlag()1168 bool GetSecurityFlag() const 1169 { 1170 return securityFlag_; 1171 } 1172 1173 void ScheduleCollaborate(const Want &want); 1174 1175 protected: 1176 void SendEvent(uint32_t msg, uint32_t timeOut, int32_t param = -1, bool isExtension = false); 1177 1178 sptr<Token> token_ = {}; // used to interact with kit and wms 1179 std::unique_ptr<LifecycleDeal> lifecycleDeal_ = {}; // life manager used to schedule life 1180 AbilityState currentState_ = AbilityState::INITIAL; // current life state 1181 Want want_ = {}; // want to start this ability 1182 1183 private: 1184 /** 1185 * get the type of ability. 1186 * 1187 */ 1188 void GetAbilityTypeString(std::string &typeStr); 1189 void OnSchedulerDied(const wptr<IRemoteObject> &remote); 1190 #ifdef SUPPORT_UPMS 1191 void GrantUriPermission(Want &want, std::string targetBundleName, bool isSandboxApp, uint32_t tokenId); 1192 #endif // SUPPORT_UPMS 1193 int32_t GetCurrentAccountId() const; 1194 1195 /** 1196 * add system ability caller record 1197 * 1198 */ 1199 void AddSystemAbilityCallerRecord(const sptr<IRemoteObject> &callerToken, int requestCode, 1200 std::string srcAbilityId); 1201 1202 bool IsSystemAbilityCall(const sptr<IRemoteObject> &callerToken, uint32_t callingTokenId = 0); 1203 1204 void RecordSaCallerInfo(const Want &want); 1205 1206 #ifdef WITH_DLP 1207 void HandleDlpAttached(); 1208 void HandleDlpClosed(); 1209 #endif // WITH_DLP 1210 void NotifyRemoveShellProcess(int32_t type); 1211 void NotifyAnimationAbilityDied(); SetCallerAccessTokenId(uint32_t callerAccessTokenId)1212 inline void SetCallerAccessTokenId(uint32_t callerAccessTokenId) 1213 { 1214 callerAccessTokenId_ = callerAccessTokenId; 1215 } 1216 1217 LastExitReason CovertAppExitReasonToLastReason(const Reason exitReason); 1218 1219 void NotifyMissionBindPid(); 1220 1221 void DumpUIExtensionRootHostInfo(std::vector<std::string> &info) const; 1222 1223 void DumpUIExtensionPid(std::vector<std::string> &info, bool isUIExtension) const; 1224 1225 void SetDebugAppByWaitingDebugFlag(); 1226 void AfterLoaded(); 1227 1228 void CancelPrepareTerminate(); 1229 1230 #ifdef SUPPORT_SCREEN 1231 std::shared_ptr<Want> GetWantFromMission() const; 1232 void SetShowWhenLocked(const AppExecFwk::AbilityInfo &abilityInfo, sptr<AbilityTransitionInfo> &info) const; 1233 void SetAbilityTransitionInfo(const AppExecFwk::AbilityInfo &abilityInfo, 1234 sptr<AbilityTransitionInfo> &info) const; 1235 void SetAbilityTransitionInfo(sptr<AbilityTransitionInfo>& info) const; 1236 sptr<IWindowManagerServiceHandler> GetWMSHandler() const; 1237 void SetWindowModeAndDisplayId(sptr<AbilityTransitionInfo> &info, const std::shared_ptr<Want> &want) const; 1238 sptr<AbilityTransitionInfo> CreateAbilityTransitionInfo(); 1239 sptr<AbilityTransitionInfo> CreateAbilityTransitionInfo(const std::shared_ptr<StartOptions> &startOptions, 1240 const std::shared_ptr<Want> &want) const; 1241 sptr<AbilityTransitionInfo> CreateAbilityTransitionInfo(const AbilityRequest &abilityRequest) const; 1242 sptr<AbilityTransitionInfo> CreateAbilityTransitionInfo(const std::shared_ptr<StartOptions> &startOptions, 1243 const std::shared_ptr<Want> &want, const AbilityRequest &abilityRequest); 1244 std::shared_ptr<Global::Resource::ResourceManager> CreateResourceManager() const; 1245 std::shared_ptr<Media::PixelMap> GetPixelMap(const uint32_t windowIconId, 1246 std::shared_ptr<Global::Resource::ResourceManager> resourceMgr) const; 1247 1248 void AnimationTask(bool isRecent, const AbilityRequest &abilityRequest, 1249 const std::shared_ptr<StartOptions> &startOptions, const std::shared_ptr<AbilityRecord> &callerAbility); 1250 void NotifyAnimationFromStartingAbility(const std::shared_ptr<AbilityRecord> &callerAbility, 1251 const AbilityRequest &abilityRequest) const; 1252 void NotifyAnimationFromRecentTask(const std::shared_ptr<StartOptions> &startOptions, 1253 const std::shared_ptr<Want> &want) const; 1254 void NotifyAnimationFromTerminatingAbility(const std::shared_ptr<AbilityRecord> &callerAbility, bool needExit, 1255 bool flag); 1256 1257 void StartingWindowTask(bool isRecent, bool isCold, const AbilityRequest &abilityRequest, 1258 std::shared_ptr<StartOptions> &startOptions); 1259 void StartingWindowColdTask(bool isRecent, const AbilityRequest &abilityRequest, 1260 std::shared_ptr<StartOptions> &startOptions); 1261 void PostCancelStartingWindowColdTask(); 1262 void StartingWindowHot(const std::shared_ptr<StartOptions> &startOptions, const std::shared_ptr<Want> &want, 1263 const AbilityRequest &abilityRequest); 1264 void StartingWindowHot(); 1265 void StartingWindowCold(const std::shared_ptr<StartOptions> &startOptions, const std::shared_ptr<Want> &want, 1266 const AbilityRequest &abilityRequest); 1267 void InitColdStartingWindowResource(const std::shared_ptr<Global::Resource::ResourceManager> &resourceMgr); 1268 void GetColdStartingWindowResource(std::shared_ptr<Media::PixelMap> &bg, uint32_t &bgColor); 1269 void SetAbilityStateInner(AbilityState state); 1270 #endif 1271 1272 static std::atomic<int64_t> abilityRecordId; 1273 bool isReady_ = false; // is ability thread attached? 1274 bool isWindowStarted_ = false; // is window hotstart or coldstart? 1275 bool isWindowAttached_ = false; // Is window of this ability attached? 1276 bool isLauncherAbility_ = false; // is launcher? 1277 bool isLoading_ = false; // is loading? 1278 bool isTerminating_ = false; // is terminating ? 1279 bool isCreateByConnect_ = false; // is created by connect ability mode? 1280 bool isUninstall_ = false; 1281 bool isLauncherRoot_ = false; 1282 bool isSwitchingPause_ = false; 1283 /** 1284 * When this ability startAbilityForResult another ability, if another ability is terminated, 1285 * this ability will move to foreground, during this time, isAbilityForegrounding_ is true, 1286 * isAbilityForegrounding_ will be set to false when this ability is background 1287 */ 1288 bool isAbilityForegrounding_ = false; 1289 bool isRestarting_ = false; // is restarting ? 1290 bool isStartedByCall_ = false; // new version 1291 bool isStartToBackground_ = false; // new version 1292 bool isStartToForeground_ = false; // new version 1293 bool minimizeReason_ = false; // new version 1294 bool clearMissionFlag_ = false; 1295 bool keepAliveBundle_ = false; 1296 bool isNeedBackToOtherMissionStack_ = false; 1297 bool lockedState_ = false; 1298 bool isAttachDebug_ = false; 1299 bool isAssertDebug_ = false; 1300 bool isAppAutoStartup_ = false; 1301 bool isConnected = false; 1302 bool isRestartApp_ = false; // Only app calling RestartApp can be set to true 1303 bool isLaunching_ = true; 1304 bool securityFlag_ = false; 1305 std::atomic_bool isCallerSetProcess_ = false; // new version 1306 std::atomic_bool backgroundAbilityWindowDelayed_ = false; 1307 1308 int32_t uiExtensionAbilityId_ = 0; // uiextension ability id 1309 int32_t uid_ = 0; 1310 pid_t pid_ = 0; 1311 int32_t missionId_ = -1; 1312 int32_t ownerMissionUserId_ = -1; 1313 uint32_t extensionProcessMode_ = 0; // new version 1314 int32_t appIndex_ = 0; // new version 1315 int32_t restartCount_ = -1; 1316 int32_t restartMax_ = -1; 1317 int32_t collaboratorType_ = 0; 1318 uint32_t callerAccessTokenId_ = -1; 1319 uint32_t specifyTokenId_ = 0; 1320 1321 int recordId_ = 0; // record id 1322 int requestCode_ = -1; // requestCode_: >= 0 for-result start mode; <0 for normal start mode in default. 1323 int startId_ = 0; // service(ability) start id 1324 1325 AppExecFwk::AbilityInfo abilityInfo_ = {}; // the ability info get from BMS 1326 std::weak_ptr<AbilityRecord> preAbilityRecord_ = {}; // who starts this ability record 1327 std::weak_ptr<AbilityRecord> nextAbilityRecord_ = {}; // ability that started by this ability 1328 int64_t startTime_ = 0; // records first time of ability start 1329 int64_t restartTime_ = 0; // the time of last trying restart 1330 sptr<IAbilityScheduler> scheduler_ = {}; // kit scheduler 1331 sptr<IRemoteObject::DeathRecipient> schedulerDeathRecipient_ = {}; // scheduler binderDied Recipient 1332 1333 /** 1334 * result_: ability starts with for-result mode will send result before being terminated. 1335 * Its caller will receive results before active. 1336 * Now we assume only one result generate when terminate. 1337 */ 1338 std::shared_ptr<AbilityResult> result_ = {}; 1339 1340 // service(ability) can be connected by multi-pages(abilities), so need to store this service's connections 1341 mutable ffrt::mutex connRecordListMutex_; 1342 std::list<std::shared_ptr<ConnectionRecord>> connRecordList_ = {}; 1343 // service(ability) onConnect() return proxy of service ability 1344 sptr<IRemoteObject> connRemoteObject_ = {}; 1345 1346 // page(ability) can be started by multi-pages(abilities), so need to store this ability's caller 1347 std::list<std::shared_ptr<CallerRecord>> callerList_ = {}; 1348 mutable ffrt::mutex callerListLock_; 1349 1350 PacMap stateDatas_; // ability saved ability state data 1351 WindowConfig windowConfig_; 1352 AppState appState_ = AppState::BEGIN; 1353 1354 std::shared_ptr<CallContainer> callContainer_ = nullptr; // new version 1355 std::string customProcessFlag_ = ""; // new version 1356 std::string specifiedFlag_; 1357 std::string uri_; 1358 1359 mutable ffrt::mutex dumpInfoLock_; 1360 mutable ffrt::mutex dumpLock_; 1361 mutable ffrt::mutex resultLock_; 1362 mutable ffrt::mutex wantLock_; 1363 mutable ffrt::condition_variable dumpCondition_; 1364 mutable bool isDumpTimeout_ = false; 1365 std::vector<std::string> dumpInfos_; 1366 std::atomic<AbilityState> pendingState_ = AbilityState::INITIAL; // pending life state 1367 std::atomic<AbilityVisibilityState> abilityVisibilityState_ = AbilityVisibilityState::INITIAL; 1368 1369 // scene session 1370 sptr<SessionInfo> sessionInfo_ = nullptr; 1371 mutable ffrt::mutex sessionLock_; 1372 std::map<uint64_t, AbilityWindowState> abilityWindowStateMap_; 1373 1374 #ifdef SUPPORT_SCREEN 1375 bool isStartingWindow_ = false; 1376 bool isCompleteFirstFrameDrawing_ = false; 1377 bool coldStart_ = false; 1378 uint32_t bgColor_ = 0; 1379 std::shared_ptr<Media::PixelMap> startingWindowBg_ = nullptr; 1380 #endif 1381 1382 std::weak_ptr<AbilityRecord> otherMissionStackAbilityRecord_; // who starts this ability record by SA 1383 1384 std::shared_ptr<Want> connectWant_ = nullptr; 1385 std::shared_ptr<CallerAbilityInfo> saCallerInfo_ = nullptr; 1386 LaunchDebugInfo launchDebugInfo_; 1387 1388 std::string instanceKey_ = ""; 1389 std::string missionAffinity_ = ""; 1390 1391 ffrt::mutex lock_; 1392 ffrt::mutex connectWantLock_; 1393 std::mutex collaborateWantLock_; 1394 1395 bool isKillForPermissionUpdate_ = false; 1396 1397 std::mutex isPrepareTerminateAbilityMutex_; 1398 std::condition_variable isPrepareTerminateAbilityCv_; 1399 std::atomic_bool isPrepareTerminateAbilityCalled_ = false; 1400 std::atomic_bool isPrepareTerminateAbilityDone_ = false; 1401 bool isPrepareTerminate_ = false; 1402 1403 std::string killReason_ = ""; 1404 }; 1405 } // namespace AAFwk 1406 } // namespace OHOS 1407 #endif // OHOS_ABILITY_RUNTIME_ABILITY_RECORD_H 1408