根据进程获取用户然后获取管理类

Signed-off-by: 韦国庆 <weiguoqing2@huawei.com>
This commit is contained in:
韦国庆 2024-11-18 10:19:04 +08:00
parent c8e4c4f4ef
commit cfdbecf424
2 changed files with 22 additions and 2 deletions

View File

@ -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();

View File

@ -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()
{