diff --git a/services/dtbschedmgr/include/multi_user_manager.h b/services/dtbschedmgr/include/multi_user_manager.h index f11bd57d..bfb845f0 100644 --- a/services/dtbschedmgr/include/multi_user_manager.h +++ b/services/dtbschedmgr/include/multi_user_manager.h @@ -26,7 +26,15 @@ namespace OHOS { namespace DistributedSchedule { class MultiUserManager { - DECLARE_SINGLE_INSTANCE(MultiUserManager); +public: + static MultiUserManager& GetInstance(); +private: + MultiUserManager(const MultiUserManager&) = delete; + MultiUserManager& operator= (const MultiUserManager&) = delete; + MultiUserManager(MultiUserManager&&) = delete; + MultiUserManager& operator= (MultiUserManager&&) = delete; + MultiUserManager(); + ~MultiUserManager() = default; public: void Init(); diff --git a/services/dtbschedmgr/src/multi_user_manager.cpp b/services/dtbschedmgr/src/multi_user_manager.cpp index 254128b0..90dc5182 100644 --- a/services/dtbschedmgr/src/multi_user_manager.cpp +++ b/services/dtbschedmgr/src/multi_user_manager.cpp @@ -31,7 +31,19 @@ namespace { const std::string TAG = "MultiUserManager"; } -IMPLEMENT_SINGLE_INSTANCE(MultiUserManager); +MultiUserManager& MultiUserManager::GetInstance() +{ + static auto instance = new MultiUserManager(); + return *instance; +} + +MultiUserManager::MultiUserManager() +{ + HILOGI("Start."); + if (currentUserId_ <= 0) { + Init(); + } +} void MultiUserManager::Init() {