mirror of
https://gitee.com/openharmony/deviceprofile_device_info_manager
synced 2024-11-23 07:30:13 +00:00
accountCommonEventManager_添加锁保护
Signed-off-by: wangzhaohao <wangzhaohao@huawei.com>
This commit is contained in:
parent
1c60081980
commit
163a91ffea
@ -94,6 +94,7 @@ private:
|
||||
void ClearProfileCache();
|
||||
|
||||
private:
|
||||
std::mutex accountCommonEventManagerMtx_;
|
||||
std::shared_ptr<DpAccountCommonEventManager> accountCommonEventManager_;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> unloadHandler_;
|
||||
std::mutex unloadMutex_;
|
||||
|
@ -628,8 +628,11 @@ void DistributedDeviceProfileServiceNew::OnAddSystemAbility(int32_t systemAbilit
|
||||
void DistributedDeviceProfileServiceNew::SubscribeAccountCommonEvent()
|
||||
{
|
||||
HILOGI("Start");
|
||||
if (accountCommonEventManager_ == nullptr) {
|
||||
accountCommonEventManager_ = std::make_shared<DpAccountCommonEventManager>();
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(accountCommonEventManagerMtx_);
|
||||
if (accountCommonEventManager_ == nullptr) {
|
||||
accountCommonEventManager_ = std::make_shared<DpAccountCommonEventManager>();
|
||||
}
|
||||
}
|
||||
AccountEventCallback callback = [=](const auto &arg1, const auto &arg2) {
|
||||
this->AccountCommonEventCallback(arg1, arg2);
|
||||
@ -639,6 +642,7 @@ void DistributedDeviceProfileServiceNew::SubscribeAccountCommonEvent()
|
||||
AccountCommonEventVec.emplace_back(EventFwk::CommonEventSupport::COMMON_EVENT_USER_REMOVED);
|
||||
AccountCommonEventVec.emplace_back(EventFwk::CommonEventSupport::COMMON_EVENT_HWID_LOGOUT);
|
||||
AccountCommonEventVec.emplace_back(EventFwk::CommonEventSupport::COMMON_EVENT_HWID_LOGIN);
|
||||
std::lock_guard<std::mutex> lock(accountCommonEventManagerMtx_);
|
||||
if (accountCommonEventManager_->SubscribeAccountCommonEvent(AccountCommonEventVec, callback)) {
|
||||
HILOGI("Success");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user