/* * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_ABILITY_RUNTIME_SUB_MANAGERS_HELPER_H #define OHOS_ABILITY_RUNTIME_SUB_MANAGERS_HELPER_H #include #include #include #include "ability_connect_manager.h" #include "ability_event_handler.h" #include "cpp/mutex.h" #include "data_ability_manager.h" #include "mission_list_manager_interface.h" #include "nocopyable.h" #include "pending_want_manager.h" #include "scene_board/ui_ability_lifecycle_manager.h" #include "task_handler_wrap.h" namespace OHOS { namespace AAFwk { using CreateMissionListMgrFunc = MissionListWrap*(*)(); class SubManagersHelper { public: SubManagersHelper(std::shared_ptr taskHandler, std::shared_ptr eventHandler); virtual ~SubManagersHelper(); void InitSubManagers(int userId, bool switchUser); void InitMissionListManager(int userId, bool switchUser); void InitUIAbilityManager(int userId, bool switchUser); void InitConnectManager(int32_t userId, bool switchUser); void InitDataAbilityManager(int32_t userId, bool switchUser); void InitPendWantManager(int32_t userId, bool switchUser); void ClearSubManagers(int userId); std::shared_ptr GetCurrentDataAbilityManager(); std::shared_ptr GetDataAbilityManager(const sptr &scheduler); std::unordered_map> GetDataAbilityManagers(); std::shared_ptr GetDataAbilityManagerByUserId(int32_t userId); std::shared_ptr GetDataAbilityManagerByToken(const sptr &token); std::unordered_map> GetConnectManagers(); std::shared_ptr GetCurrentConnectManager(); std::shared_ptr GetConnectManagerByUserId(int32_t userId); std::shared_ptr GetConnectManagerByToken(const sptr &token); std::shared_ptr GetConnectManagerByAbilityRecordId(const int64_t &abilityRecordId); std::shared_ptr GetCurrentPendingWantManager(); std::shared_ptr GetPendingWantManagerByUserId(int32_t userId); std::unordered_map> GetMissionListManagers(); std::shared_ptr GetCurrentMissionListManager(); std::shared_ptr GetMissionListManagerByUserId(int32_t userId); std::shared_ptr GetMissionListManagerByUid(int32_t uid); std::unordered_map> GetUIAbilityManagers(); std::shared_ptr GetCurrentUIAbilityManager(); std::shared_ptr GetUIAbilityManagerByUserId(int32_t userId); std::shared_ptr GetUIAbilityManagerByUid(int32_t uid); void UninstallApp(const std::string &bundleName, int32_t uid); void UninstallAppInUIAbilityManagers(int32_t userId, const std::string &bundleName, int32_t uid); void UninstallAppInMissionListManagers(int32_t userId, const std::string &bundleName, int32_t uid); bool VerificationAllToken(const sptr &token); bool VerificationAllTokenForConnectManagers(const sptr &token); std::shared_ptr GetMissionListWrap(); std::shared_ptr CreateMissionListMgr(int32_t userId); private: DISALLOW_COPY_AND_MOVE(SubManagersHelper); std::shared_ptr taskHandler_; std::shared_ptr eventHandler_; ffrt::mutex managersMutex_; std::unordered_map> connectManagers_; std::shared_ptr currentConnectManager_; std::unordered_map> dataAbilityManagers_; std::shared_ptr currentDataAbilityManager_; std::unordered_map> pendingWantManagers_; std::shared_ptr currentPendingWantManager_; std::unordered_map> missionListManagers_; std::shared_ptr currentMissionListManager_; std::unordered_map> uiAbilityManagers_; std::shared_ptr currentUIAbilityManager_; std::mutex missionListWrapMutex_; void* missionLibHandle_ = nullptr; std::shared_ptr missionListWrap_; }; } // namespace AAFwk } // namespace OHOS #endif // OHOS_ABILITY_RUNTIME_SUB_MANAGERS_HELPER_H