mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 06:20:07 +00:00
解决重复初始化的异常问题
Signed-off-by: m30043719 <maxiaodong25@huawei.com>
This commit is contained in:
parent
5993af7fb5
commit
d3408acb00
@ -37,6 +37,10 @@ IMPLEMENT_SINGLE_INSTANCE(MMIAdapter);
|
||||
void MMIAdapter::Init()
|
||||
{
|
||||
HILOGI("Init");
|
||||
if (eventHandler_ != nullptr) {
|
||||
HILOGI("Already inited, end.");
|
||||
return;
|
||||
}
|
||||
mmiCallback_ = std::make_shared<MMIAdapter::MMIEventCallback>();
|
||||
eventThread_ = std::thread(&MMIAdapter::StartEvent, this);
|
||||
std::unique_lock<std::mutex> lock(eventMutex_);
|
||||
|
@ -199,6 +199,10 @@ void DSchedContinue::SetEventData()
|
||||
int32_t DSchedContinue::Init()
|
||||
{
|
||||
HILOGI("DSchedContinue init start");
|
||||
if (eventHandler_ != nullptr) {
|
||||
HILOGI("Already inited, end.");
|
||||
return ERR_OK;
|
||||
}
|
||||
auto dContinue = std::shared_ptr<DSchedContinue>(shared_from_this());
|
||||
stateMachine_ = std::make_shared<DSchedContinueStateMachine>(dContinue);
|
||||
if (direction_ == CONTINUE_SOURCE) {
|
||||
|
@ -52,6 +52,10 @@ IMPLEMENT_SINGLE_INSTANCE(DMSContinueRecvMgr);
|
||||
void DMSContinueRecvMgr::Init()
|
||||
{
|
||||
HILOGI("Init start");
|
||||
if (eventHandler_ != nullptr) {
|
||||
HILOGI("Already inited, end.");
|
||||
return;
|
||||
}
|
||||
{
|
||||
std::shared_ptr<SoftbusAdapterListener> missionBroadcastListener =
|
||||
std::make_shared<DistributedMissionBroadcastListener>();
|
||||
|
@ -53,6 +53,10 @@ IMPLEMENT_SINGLE_INSTANCE(DMSContinueSendMgr);
|
||||
void DMSContinueSendMgr::Init()
|
||||
{
|
||||
HILOGI("Init start");
|
||||
if (eventHandler_ != nullptr) {
|
||||
HILOGI("Already inited, end.");
|
||||
return;
|
||||
}
|
||||
{
|
||||
MMIAdapter::GetInstance().Init();
|
||||
SoftbusAdapter::GetInstance().Init();
|
||||
|
@ -36,6 +36,10 @@ IMPLEMENT_SINGLE_INSTANCE(SoftbusAdapter);
|
||||
|
||||
void SoftbusAdapter::Init()
|
||||
{
|
||||
if (eventHandler_ != nullptr) {
|
||||
HILOGI("Already inited, end.");
|
||||
return;
|
||||
}
|
||||
eventThread_ = std::thread(&SoftbusAdapter::StartEvent, this);
|
||||
std::unique_lock<std::mutex> lock(eventMutex_);
|
||||
eventCon_.wait(lock, [this] {
|
||||
|
@ -97,6 +97,25 @@ HWTEST_F(DMSContinueManagerTest, testUnInit001, TestSize.Level3)
|
||||
DTEST_LOG << "DMSContinueManagerTest testUnInit001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testUnInit002
|
||||
* @tc.desc: test UnInit
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I7F8KH
|
||||
*/
|
||||
HWTEST_F(DMSContinueManagerTest, testUnInit002, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DMSContinueManagerTest testUnInit002 begin" << std::endl;
|
||||
|
||||
DistributedSchedUtil::MockManageMissions();
|
||||
DMSContinueSendMgr::GetInstance().Init();
|
||||
EXPECT_NE(DMSContinueSendMgr::GetInstance().eventHandler_, nullptr);
|
||||
|
||||
DMSContinueSendMgr::GetInstance().UnInit();
|
||||
EXPECT_EQ(DMSContinueSendMgr::GetInstance().eventHandler_, nullptr);
|
||||
DTEST_LOG << "DMSContinueManagerTest testUnInit002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testPostUnfocusedTaskWithDelay001
|
||||
* @tc.desc: test PostUnfocusedTaskWithDelay
|
||||
|
Loading…
Reference in New Issue
Block a user