!1178 根据进程号获取用户id然后创建新的管理类

Merge pull request !1178 from 韦国庆/master
This commit is contained in:
openharmony_ci 2024-11-18 12:17:09 +00:00 committed by Gitee
commit 917bf8d784
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 22 additions and 2 deletions

View File

@ -26,7 +26,15 @@
namespace OHOS { namespace OHOS {
namespace DistributedSchedule { namespace DistributedSchedule {
class MultiUserManager { 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: public:
void Init(); void Init();

View File

@ -31,7 +31,19 @@ namespace {
const std::string TAG = "MultiUserManager"; 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() void MultiUserManager::Init()
{ {