1 /* 2 * Copyright (c) 2021 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_AAFWK_ABILITY_STACK_MANAGER_H 17 #define OHOS_AAFWK_ABILITY_STACK_MANAGER_H 18 19 #include <mutex> 20 #include <list> 21 #include <queue> 22 #include <unordered_map> 23 #include <vector> 24 25 #include "ability_info.h" 26 #include "ability_record.h" 27 #include "application_info.h" 28 #include "aafwk_dummy_configuration.h" 29 #include "mission_record.h" 30 #include "mission_stack.h" 31 #include "mission_option.h" 32 #include "ability_mission_info.h" 33 #include "lock_mission_container.h" 34 #include "resume_mission_container.h" 35 #include "stack_info.h" 36 #include "power_storage.h" 37 #include "want.h" 38 39 namespace OHOS { 40 namespace AAFwk { 41 enum class SystemWindowMode { 42 DEFAULT_WINDOW_MODE = 0, 43 SPLITSCREEN_WINDOW_MODE, 44 FLOATING_WINDOW_MODE, 45 FLOATING_AND_SPLITSCREEN_WINDOW_MODE, 46 }; 47 /** 48 * @class AbilityStackManager 49 * AbilityStackManager provides a facility for managing page ability life cycle. 50 */ 51 class AbilityStackManager : public std::enable_shared_from_this<AbilityStackManager> { 52 public: 53 explicit AbilityStackManager(int userId); 54 ~AbilityStackManager(); 55 56 /** 57 * init ability stack manager. 58 * 59 */ 60 void Init(); 61 62 /** 63 * StartAbility with request. 64 * 65 * @param abilityRequest, the request of the service ability to start. 66 * @return Returns ERR_OK on success, others on failure. 67 */ 68 int StartAbility(const AbilityRequest &abilityRequest); 69 70 /** 71 * TerminateAbility with token and result want. 72 * 73 * @param token, the token of service type's ability to terminate. 74 * @param resultCode, the result code of service type's ability to terminate. 75 * @param resultWant, the result want for service type's ability to terminate. 76 * @return Returns ERR_OK on success, others on failure. 77 */ 78 int TerminateAbility(const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant); 79 80 /** 81 * TerminateAbility, terminate the special ability. 82 * 83 * @param caller, caller ability record. 84 * @param requestCode, abililty request code 85 * @return Returns ERR_OK on success, others on failure. 86 */ 87 int TerminateAbility(const std::shared_ptr<AbilityRecord> &caller, int requestCode); 88 89 /** 90 * get ability stack manager's user id. 91 * 92 * @return Returns userId. 93 */ 94 int GetAbilityStackManagerUserId() const; 95 96 /** 97 * get current working mission stack. 98 * 99 * @return current mission stack. 100 */ GetCurrentMissionStack()101 std::shared_ptr<MissionStack> GetCurrentMissionStack() const 102 { 103 return currentMissionStack_; 104 } 105 106 /** 107 * get current top ability's token of stack. 108 * 109 * @return top ability record's token. 110 */ 111 sptr<Token> GetCurrentTopAbilityToken(); 112 113 /** 114 * get the ability record by token. 115 * 116 * @param recordId, ability record id. 117 * @return ability record. 118 */ 119 std::shared_ptr<AbilityRecord> GetAbilityRecordById(const int64_t recordId); 120 121 /** 122 * get the stack by id. 123 * 124 * @param recordId, stack id. 125 * @return MissionStack. 126 */ 127 std::shared_ptr<MissionStack> GetStackById(int stackId); 128 129 /** 130 * get current top mission of stack. 131 * 132 * @return top mission record. 133 */ 134 std::shared_ptr<MissionRecord> GetTopMissionRecord() const; 135 136 /** 137 * get the ability record by token. 138 * 139 * @param token, the token of ability. 140 * @return ability record. 141 */ 142 std::shared_ptr<AbilityRecord> GetAbilityRecordByToken(const sptr<IRemoteObject> &token); 143 144 /** 145 * get terminating ability from terminate list. 146 * 147 * @param token, the token of ability. 148 */ 149 std::shared_ptr<AbilityRecord> GetAbilityFromTerminateList(const sptr<IRemoteObject> &token); 150 151 /** 152 * get the mission record by record id. 153 * 154 * @param id, the record id of mission. 155 * @return mission record. 156 */ 157 std::shared_ptr<MissionRecord> GetMissionRecordById(int id) const; 158 159 /** 160 * get the mission record by record name. 161 * 162 * @param name, the record name of mission. 163 * @return mission record. 164 */ 165 std::shared_ptr<MissionRecord> GetMissionRecordByName(std::string name) const; 166 167 /** 168 * get the mission record by record id from all stacks. 169 * 170 * @param id, the record id of mission. 171 * @return mission record. 172 */ 173 std::shared_ptr<MissionRecord> GetMissionRecordFromAllStacks(int id) const; 174 175 /** 176 * remove the mission record by record id. 177 * 178 * @param id, the record id of mission. 179 * @return Returns true on success, false on failure. 180 */ 181 bool RemoveMissionRecordById(int id); 182 183 /** 184 * attach ability thread ipc object. 185 * 186 * @param scheduler, ability thread ipc object. 187 * @param token, the token of ability. 188 * @return Returns ERR_OK on success, others on failure. 189 */ 190 int AttachAbilityThread(const sptr<IAbilityScheduler> &scheduler, const sptr<IRemoteObject> &token); 191 192 /** 193 * AbilityTransitionDone, ability call this interface after lift cycle was changed. 194 * 195 * @param token,.ability's token. 196 * @param state,.the state of ability lift cycle. 197 * @return Returns ERR_OK on success, others on failure. 198 */ 199 int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state); 200 201 /** 202 * AddWindowInfo, add windowToken to AbilityRecord. 203 * 204 * @param token, the token of the ability. 205 * @param windowToken, window id of the ability. 206 */ 207 void AddWindowInfo(const sptr<IRemoteObject> &token, int32_t windowToken); 208 209 /** 210 * OnAbilityRequestDone, app manager service call this interface after ability request done. 211 * 212 * @param token,ability's token. 213 * @param state,the state of ability lift cycle. 214 */ 215 void OnAbilityRequestDone(const sptr<IRemoteObject> &token, const int32_t state); 216 217 void OnAppStateChanged(const AppInfo &info); 218 219 /** 220 * Remove the specified mission from the stack by mission id. 221 * 222 * @param missionId, target mission id. 223 * @return Returns ERR_OK on success, others on failure. 224 */ 225 int RemoveMissionById(int missionId); 226 227 /** 228 * Remove the specified mission stack by stack id 229 * 230 * @param id. 231 * @return Returns ERR_OK on success, others on failure. 232 */ 233 int RemoveStack(int stackId); 234 235 /** 236 * move the mission stack to the top. 237 * 238 * @param stack, target mission stack. 239 */ 240 void MoveMissionStackToTop(const std::shared_ptr<MissionStack> &stack); 241 242 int GetMaxHoldMissionsByStackId(int stackId) const; 243 bool SupportSyncVisualByStackId(int stackId) const; 244 245 void SetMissionStackSetting(const StackSetting &stackSetting); 246 247 /** 248 * complete ability life cycle . 249 * 250 * @param abilityRecord. 251 */ 252 void CompleteActive(const std::shared_ptr<AbilityRecord> &abilityRecord); 253 void CompleteInactive(const std::shared_ptr<AbilityRecord> &abilityRecord); 254 void CompleteBackground(const std::shared_ptr<AbilityRecord> &abilityRecord); 255 void CompleteTerminate(const std::shared_ptr<AbilityRecord> &abilityRecord); 256 257 void MoveToBackgroundTask(const std::shared_ptr<AbilityRecord> &abilityRecord); 258 259 /** 260 * dump ability stack info, about userID, mission stack info, 261 * mission record info and ability info. 262 * 263 * @param info Ability stack info. 264 * @return Returns ERR_OK on success, others on failure. 265 */ 266 void Dump(std::vector<std::string> &info); 267 void DumpWaittingAbilityQueue(std::string &result); 268 void DumpTopAbility(std::vector<std::string> &info); 269 void DumpMission(int missionId, std::vector<std::string> &info); 270 void DumpStack(int missionStackId, std::vector<std::string> &info); 271 void DumpStackList(std::vector<std::string> &info); 272 void DumpFocusMap(std::vector<std::string> &info); 273 274 /** 275 * get the target mission stack by want info. 276 * 277 * @param want , the want for starting ability. 278 */ 279 std::shared_ptr<MissionStack> GetTargetMissionStack(const AbilityRequest &abilityRequest); 280 std::shared_ptr<MissionStack> GetTargetMissionStackByDefault(const AbilityRequest &abilityRequest); 281 std::shared_ptr<MissionStack> GetTargetMissionStackBySetting(const AbilityRequest &abilityRequest); 282 283 /** 284 * Obtains information about ability stack that are running on the device. 285 * 286 * @param stackInfo Ability stack info. 287 * @return Returns ERR_OK on success, others on failure. 288 */ 289 void GetAllStackInfo(StackInfo &stackInfo); 290 291 /** 292 * Get the list of the missions that the user has recently launched, 293 * with the most recent being first and older ones after in order. 294 * 295 * @param recentList recent mission info 296 * @param numMax The maximum number of entries to return in the list. The 297 * actual number returned may be smaller, depending on how many tasks the 298 * user has started and the maximum number the system can remember. 299 * @param falgs Information about what to return. May be any combination 300 * of {@link #RECENT_WITH_EXCLUDED} and {@link #RECENT_IGNORE_UNAVAILABLE}. 301 * @return Returns ERR_OK on success, others on failure. 302 */ 303 int GetRecentMissions(const int32_t numMax, const int32_t flags, std::vector<AbilityMissionInfo> &recentList); 304 305 /** 306 * Ask that the mission associated with a given mission ID be moved to the 307 * front of the stack, so it is now visible to the user. 308 * 309 * @param missionId. 310 * @return Returns ERR_OK on success, others on failure. 311 */ 312 int MoveMissionToTop(int32_t missionId); 313 314 /** 315 * Requires that tasks associated with a given capability token be moved to the background 316 * 317 * @param token ability token 318 * @param nonFirst If nonfirst is false and not the lowest ability of the mission, you cannot move mission to end 319 * @return Returns ERR_OK on success, others on failure. 320 */ 321 int MoveMissionToEnd(const sptr<IRemoteObject> &token, const bool nonFirst); 322 323 int MoveMissionToEndLocked(int missionId); 324 325 /** 326 * Ability detects death 327 * 328 * @param abilityRecord 329 */ 330 void OnAbilityDied(std::shared_ptr<AbilityRecord> abilityRecord); 331 332 /** 333 * Uninstall app 334 * 335 * @param bundleName. 336 */ 337 void UninstallApp(const std::string &bundleName); 338 339 void OnTimeOut(uint32_t msgId, int64_t eventId); 340 bool IsFirstInMission(const sptr<IRemoteObject> &token); 341 bool IsFrontInAllStack(const std::shared_ptr<MissionStack> &stack) const; 342 bool IsTopInMission(const std::shared_ptr<AbilityRecord> &abilityRecord) const; 343 344 /** 345 * Moving some missions to the specified stack by mission option(Enter splitscreen or floating window mode). 346 * @param missionOption, target mission option 347 * @return Returns ERR_OK on success, others on failure. 348 */ 349 int MoveMissionToFloatingStack(const MissionOption &missionOption); 350 int MoveMissionToSplitScreenStack(const MissionOption &missionOption); 351 352 /** 353 * minimize multiwindow by mission id. 354 * @param missionId, the id of target mission 355 * @return Returns ERR_OK on success, others on failure. 356 */ 357 int MinimizeMultiWindow(int missionId); 358 /** 359 * maximize multiwindow by mission id. 360 * @param missionId, the id of target mission 361 * @return Returns ERR_OK on success, others on failure. 362 */ 363 int MaximizeMultiWindow(int missionId); 364 365 /** 366 * Change the focus of ability in the mission stack. 367 * @param lostToken, the token of lost focus ability 368 * @param getToken, the token of get focus ability 369 * @return Returns ERR_OK on success, others on failure. 370 */ 371 int ChangeFocusAbility(const sptr<IRemoteObject> &lostFocusToken, const sptr<IRemoteObject> &getFocusToken); 372 373 /** 374 * get missions info of floating mission stack. 375 * @param list, mission info. 376 * @return Returns ERR_OK on success, others on failure. 377 */ 378 int GetFloatingMissions(std::vector<AbilityMissionInfo> &list); 379 380 /** 381 * close multiwindow by mission id. 382 * @param missionId, the id of target mission. 383 * @return Returns ERR_OK on success, others on failure. 384 */ 385 int CloseMultiWindow(int missionId); 386 387 void JudgingIsRemoveMultiScreenStack(std::shared_ptr<MissionStack> &stack); 388 389 /** 390 * Save the top ability States and move them to the background 391 * @return Returns ERR_OK on success, others on failure. 392 */ 393 int PowerOff(); 394 395 /** 396 * Restore the state before top ability poweroff 397 * @return Returns ERR_OK on success, others on failure. 398 */ 399 int PowerOn(); 400 401 int StartLockMission(int uid, int missionId, bool isSystemApp, int isLock); 402 int SetMissionDescriptionInfo( 403 const std::shared_ptr<AbilityRecord> &abilityRecord, const MissionDescriptionInfo &description); 404 int GetMissionLockModeState(); 405 406 /** 407 * update configuration to ability 408 * @return Returns ERR_OK on success, others on failure. 409 */ 410 int UpdateConfiguration(const DummyConfiguration &config); 411 412 void RestartAbility(const std::shared_ptr<AbilityRecord> abilityRecord); 413 414 private: 415 /** 416 * dispatch ability life cycle . 417 * 418 * @param abilityRecord. 419 * @param state. 420 */ 421 int DispatchState(const std::shared_ptr<AbilityRecord> &abilityRecord, int state); 422 int DispatchActive(const std::shared_ptr<AbilityRecord> &abilityRecord, int state); 423 int DispatchInactive(const std::shared_ptr<AbilityRecord> &abilityRecord, int state); 424 int DispatchBackground(const std::shared_ptr<AbilityRecord> &abilityRecord, int state); 425 int DispatchTerminate(const std::shared_ptr<AbilityRecord> &abilityRecord, int state); 426 int DispatchLifecycle(const std::shared_ptr<AbilityRecord> &lastTopAbility, 427 const std::shared_ptr<AbilityRecord> ¤tTopAbility, bool isTopFullScreen = false); 428 void ContinueLifecycle(); 429 430 /** 431 * get current top ability of stack. 432 * 433 * @return top ability record. 434 */ 435 std::shared_ptr<AbilityRecord> GetCurrentTopAbility() const; 436 437 /** 438 * StartAbilityLocked. 439 * 440 * @param currentTopAbilityRecord, current top ability. 441 * @param abilityRequest the request of the ability to start. 442 * @return Returns ERR_OK on success, others on failure. 443 */ 444 int StartAbilityLocked( 445 const std::shared_ptr<AbilityRecord> ¤tTopAbility, const AbilityRequest &abilityRequest); 446 447 int StartAbilityAsSpecialLocked( 448 const std::shared_ptr<AbilityRecord> ¤tTopAbility, const AbilityRequest &abilityRequest); 449 450 /** 451 * TerminateAbilityLocked. 452 * 453 * @param abilityRecord, target ability. 454 * @param resultCode the result code of the ability to terminate. 455 * @param resultWant the result Want of the ability to terminate. 456 * @return Returns ERR_OK on success, others on failure. 457 */ 458 int TerminateAbilityLocked( 459 const std::shared_ptr<AbilityRecord> &abilityRecord, int resultCode, const Want *resultWant); 460 461 /** 462 * Remove the specified mission from the stack by mission id. 463 * 464 * @param missionId, target mission id. 465 * @return Returns ERR_OK on success, others on failure. 466 */ 467 int RemoveMissionByIdLocked(int missionId); 468 469 /** 470 * remove terminating ability from stack. 471 * 472 * @param abilityRecord, target ability. 473 */ 474 void RemoveTerminatingAbility(const std::shared_ptr<AbilityRecord> &abilityRecord); 475 476 /** 477 * push waitting ability to queue. 478 * 479 * @param abilityRequest, the request of ability. 480 */ 481 void EnqueueWaittingAbility(const AbilityRequest &abilityRequest); 482 483 /** 484 * start waitting ability. 485 */ 486 void StartWaittingAbility(); 487 488 /** 489 * get tartget ability and mission by request and top ability. 490 * 491 * @param abilityRequest, the request of ability. 492 * @param currentTopAbility, top ability. 493 * @param tragetAbilityRecord, out param. 494 * @param targetMissionRecord, out param. 495 */ 496 void GetMissionRecordAndAbilityRecord(const AbilityRequest &abilityRequest, 497 const std::shared_ptr<AbilityRecord> ¤tTopAbility, std::shared_ptr<AbilityRecord> &tragetAbilityRecord, 498 std::shared_ptr<MissionRecord> &targetMissionRecord); 499 500 /** 501 * check wheather the ability is launcher. 502 * 503 * @param abilityRequest, the abilityRequest fot starting ability. 504 * @return Returns true on success, false on failure. 505 */ 506 bool IsLauncherAbility(const AbilityRequest &abilityRequest) const; 507 508 /** 509 * check wheather the mission has launcher ability. 510 * 511 * @param id, mission id. 512 * @return Returns true on success, false on failure. 513 */ 514 bool IsLauncherMission(int id); 515 516 /** 517 * Get the list of the missions that the user has recently launched, 518 * with the most recent being first and older ones after in order. 519 * 520 * @param recentList recent mission info 521 * @param numMax The maximum number of entries to return in the list. The 522 * actual number returned may be smaller, depending on how many tasks the 523 * user has started and the maximum number the system can remember. 524 * @param falgs Information about what to return. May be any combination 525 * of {@link #RECENT_WITH_EXCLUDED} and {@link #RECENT_IGNORE_UNAVAILABLE}. 526 * @return Returns ERR_OK on success, others on failure. 527 */ 528 int GetRecentMissionsLocked(const int32_t numMax, const int32_t flags, std::vector<AbilityMissionInfo> &recentList); 529 530 void CreateRecentMissionInfo(const MissionRecordInfo &mission, AbilityMissionInfo &recentMissionInfo); 531 532 /** 533 * Ask that the mission associated with a given mission ID be moved to the 534 * front of the stack, so it is now visible to the user. 535 * 536 * @param missionId. 537 * @return Returns ERR_OK on success, others on failure. 538 */ 539 int MoveMissionToTopLocked(int32_t missionId); 540 541 /** 542 * Requires that tasks associated with a given capability token be moved to the background 543 * 544 * @param token ability token 545 * @param nonFirst If nonfirst is false and not the lowest ability of the mission, you cannot move mission to end 546 * @return Returns ERR_OK on success, others on failure. 547 */ 548 int MoveMissionToEndLocked(const sptr<IRemoteObject> &token, const bool nonFirst); 549 550 /** 551 * Remove the specified mission stack by stack id 552 * 553 * @param id. 554 * @return Returns ERR_OK on success, others on failure. 555 */ 556 int RemoveStackLocked(int stackId); 557 558 /** 559 * Force return to launcher 560 */ 561 void BackToLauncher(); 562 void DelayedStartLauncher(); 563 564 /** 565 * Ability from launcher stack detects death 566 * 567 * @param abilityRecord 568 */ 569 void OnAbilityDiedByLauncher(std::shared_ptr<AbilityRecord> abilityRecord); 570 571 /** 572 * Ability from default stack detects death 573 * 574 * @param abilityRecord 575 */ 576 void OnAbilityDiedByDefault(std::shared_ptr<AbilityRecord> abilityRecord); 577 578 /** 579 * Add uninstall tags to ability 580 * 581 * @param bundleName 582 */ 583 void AddUninstallTags(const std::string &bundleName); 584 585 /** 586 * Get target record by start mode. 587 */ 588 void GetRecordBySingleton(const AbilityRequest &abilityRequest, 589 const std::shared_ptr<AbilityRecord> ¤tTopAbility, std::shared_ptr<AbilityRecord> &targetAbilityRecord, 590 std::shared_ptr<MissionRecord> &targetMissionRecord); 591 592 void GetRecordByStandard(const AbilityRequest &abilityRequest, 593 const std::shared_ptr<AbilityRecord> ¤tTopAbility, std::shared_ptr<AbilityRecord> &targetAbilityRecord, 594 std::shared_ptr<MissionRecord> &targetMissionRecord); 595 596 /** 597 * Get root ability from launcher mission stack. 598 */ 599 std::shared_ptr<AbilityRecord> GetLauncherRootAbility() const; 600 601 /** 602 * Get ability record by event id. 603 * @param eventId 604 * @return Returns target record. 605 */ 606 std::shared_ptr<AbilityRecord> GetAbilityRecordByEventId(int64_t eventId) const; 607 608 /** 609 * Get or Create mission stack by stack id, 610 * @param stackId, target stack id 611 * @param isCreateFlag, if the stack is not exist, decide whether or not to create a new mission stack, 612 * default is fasle. 613 * @return Returns target missionStack. 614 */ 615 std::shared_ptr<MissionStack> GetOrCreateMissionStack(int stackId, bool isCreateFlag = false); 616 617 /** 618 * Moving some missions to the specified stack by mission option(Enter splitscreen or floating window mode). 619 * @param missionOption, target mission option 620 * @return Returns ERR_OK on success, others on failure. 621 */ 622 int MoveMissionsToStackLocked(const std::list<MissionOption> &missionOptions); 623 int CheckMultiWindowCondition(const std::list<MissionOption> &missionOptions) const; 624 int CheckMultiWindowCondition( 625 const std::shared_ptr<AbilityRecord> ¤tTopAbility, const AbilityRequest &abilityRequest) const; 626 bool CheckMissionStackWillOverflow(const std::list<MissionOption> &missionOptions) const; 627 int CompleteMoveMissionToStack( 628 const std::shared_ptr<MissionRecord> &missionRecord, const std::shared_ptr<MissionStack> &stack); 629 int CompleteMissionMoving(std::shared_ptr<MissionRecord> &missionRecord, int stackId); 630 SystemWindowMode JudgingTargetSystemWindowMode(AbilityWindowConfiguration config) const; 631 SystemWindowMode GetTargetSystemWindowMode(const SystemWindowMode &willWinMode); 632 int JudgingTargetStackId(AbilityWindowConfiguration config) const; 633 int StartAbilityLifeCycle(std::shared_ptr<AbilityRecord> lastTopAbility, 634 std::shared_ptr<AbilityRecord> currentTopAbility, std::shared_ptr<AbilityRecord> targetAbility); 635 636 void ActiveTopAbility(const std::shared_ptr<AbilityRecord> &abilityRecord); 637 void MoveMissionAndAbility(const std::shared_ptr<AbilityRecord> ¤tTopAbility, 638 std::shared_ptr<AbilityRecord> &targetAbilityRecord, std::shared_ptr<MissionRecord> &targetMissionRecord); 639 int PowerOffLocked(); 640 int PowerOnLocked(); 641 642 bool CheckLockMissionCondition( 643 int uid, int missionId, int isLock, bool isSystemApp, std::shared_ptr<MissionRecord> &mission, int &lockUid); 644 bool CanStartInLockMissionState( 645 const AbilityRequest &abilityRequest, const std::shared_ptr<AbilityRecord> ¤tTopAbility) const; 646 bool CanStopInLockMissionState(const std::shared_ptr<AbilityRecord> &terminateAbility) const; 647 void SendUnlockMissionMessage(); 648 std::shared_ptr<MissionStack> GetTopFullScreenStack(); 649 bool IsFullScreenStack(int stackId) const; 650 651 /** 652 * minimize multiwindow by mission id. 653 * @param missionId, the id of target mission 654 * @return Returns ERR_OK on success, others on failure. 655 */ 656 int MinimizeMultiWindowLocked(int missionId); 657 int ChangeFocusAbilityLocked(const std::shared_ptr<AbilityRecord> &targetAbility); 658 659 void NotifyWindowModeChanged(const SystemWindowMode &windowMode); 660 661 int ProcessConfigurationChange(); 662 663 void UpdateFocusAbilityRecord( 664 int displayId, const std::shared_ptr<AbilityRecord> &focusAbility, bool isNotify = false); 665 void UpdateFocusAbilityRecord(const std::shared_ptr<AbilityRecord> &abilityRecord, bool isNotify = false); 666 void CheckMissionRecordIsResume(const std::shared_ptr<MissionRecord> &mission); 667 int ChangedPowerStorageAbilityToActive(std::shared_ptr<PowerStorage> &powerStorage); 668 void HandleActiveTimeout(const std::shared_ptr<AbilityRecord> &ability); 669 670 private: 671 static constexpr int MIN_MISSION_STACK_ID = LAUNCHER_MISSION_STACK_ID; 672 static constexpr int MAX_MISSION_STACK_ID = FLOATING_MISSION_STACK_ID; 673 static constexpr int MAX_CAN_MOVE_MISSIONS = 2; 674 675 int userId_; 676 bool powerOffing_ = false; 677 std::recursive_mutex stackLock_; 678 std::shared_ptr<MissionStack> launcherMissionStack_; 679 std::shared_ptr<MissionStack> defaultMissionStack_; 680 std::shared_ptr<MissionStack> currentMissionStack_; 681 std::shared_ptr<MissionStack> lastMissionStack_; 682 std::list<std::shared_ptr<MissionStack>> missionStackList_; 683 std::list<std::shared_ptr<AbilityRecord>> terminateAbilityRecordList_; // abilities on terminating put in this 684 // list. 685 std::queue<AbilityRequest> waittingAbilityQueue_; 686 std::list<wptr<IRemoteObject>> focusWaitingList_; 687 std::shared_ptr<PowerStorage> powerStorage_; 688 // find AbilityRecord by windowToken. one windowToken has one and only one AbilityRecord. 689 std::unordered_map<int, std::shared_ptr<AbilityRecord>> windowTokenToAbilityMap_; 690 std::shared_ptr<LockMissionContainer> lockMissionContainer_ = nullptr; 691 SystemWindowMode curSysWindowMode_ = SystemWindowMode::DEFAULT_WINDOW_MODE; 692 bool isMultiWinMoving_ = false; 693 std::vector<StackSetting> stackSettings_; 694 std::map<int, std::weak_ptr<AbilityRecord>> focusAbilityRecordMap_; // abilities has been focused , 695 // key : display id, value: focused ability 696 std::shared_ptr<ResumeMissionContainer> resumeMissionContainer_; 697 }; 698 } // namespace AAFwk 699 } // namespace OHOS 700 #endif // OHOS_AAFWK_ABILITY_STACK_MANAGER_H 701