diff --git a/frameworks/proxy/module_loader/src/mmi_client.cpp b/frameworks/proxy/module_loader/src/mmi_client.cpp index de0ade62ca939ebd0882549a318a6bd313f9da93..d33b168435826e0ee9700a4fcbfd35f60707843d 100644 --- a/frameworks/proxy/module_loader/src/mmi_client.cpp +++ b/frameworks/proxy/module_loader/src/mmi_client.cpp @@ -27,7 +27,6 @@ #include "qos.h" #include "proto.h" #include "util.h" -#include "parameters.h" #undef MMI_LOG_TAG #define MMI_LOG_TAG "MMIClient" @@ -36,8 +35,6 @@ namespace OHOS { namespace MMI { namespace { const std::string THREAD_NAME { "OS_mmi_EventHdr" }; -static const bool USE_ISOLATE_DISPATCH_THREAD = false; -static const bool USE_FILE_DESCRIPTION = system::GetBoolParameter("const.sys.param_file_description_monitor", false); } // namespace using namespace AppExecFwk; @@ -52,7 +49,6 @@ void MMIClient::SetEventHandler(EventHandlerPtr eventHandler) { CHKPV(eventHandler); // use the new thread untill eventhandler use poll thread - eventHandler_ = eventHandler; } void MMIClient::MarkIsEventHandlerChanged(EventHandlerPtr eventHandler) @@ -116,32 +112,24 @@ bool MMIClient::StartEventRunner() { CALL_DEBUG_ENTER; CHK_PID_AND_TID(); - if (USE_ISOLATE_DISPATCH_THREAD || eventHandler_ == nullptr) { - auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME); - eventHandler_ = std::make_shared(runner); - eventHandler_->PostTask([this] { this->SetScheduler(); }); - MMI_HILOGI("Create event handler, thread name:%{public}s", runner->GetRunnerThreadName().c_str()); - if (!eventHandler_->PostTask([this] { return this->OnReconnect(); }, CLIENT_RECONNECT_COOLING_TIME)) { - MMI_HILOGE("Send reconnect event failed"); + auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME); + eventHandler_ = std::make_shared(runner); + eventHandler_->PostTask([this] { this->SetScheduler(); }); + MMI_HILOGI("Create event handler, thread name:%{public}s", runner->GetRunnerThreadName().c_str()); + + if (isConnected_ && fd_ >= 0) { + if (isListening_) { + MMI_HILOGI("File fd is in listening"); + return true; + } + if (!AddFdListener(fd_)) { + MMI_HILOGE("Add fd listener failed"); return false; } } else { - if (!USE_FILE_DESCRIPTION) { - MMI_HILOGE("const.sys.param_file_description_monitor is false, can not reuse fd thread"); - return true; - } - if (isConnected_ && fd_ >= 0 && isListening_) { - MMI_HILOGI("File fd is in listening"); - return true; - } else { - if (!AddFdListener(fd_)) { - MMI_HILOGE("Add fd listener failed"); - return false; - } else { - auto runner = eventHandler_->GetEventRunner(); - MMI_HILOGI("Reuse current event handler, thread name:%{public}s", - runner->GetRunnerThreadName().c_str()); - } + if (!eventHandler_->PostTask([this] { return this->OnReconnect(); }, CLIENT_RECONNECT_COOLING_TIME)) { + MMI_HILOGE("Send reconnect event failed"); + return false; } } return true; @@ -156,10 +144,6 @@ bool MMIClient::AddFdListener(int32_t fd) } CHKPF(eventHandler_); auto fdListener = std::make_shared(GetSharedPtr()); - if (!USE_ISOLATE_DISPATCH_THREAD) { - fdListener->SetDeamonWaiter(); - } - auto errCode = eventHandler_->AddFileDescriptorListener(fd, FILE_DESCRIPTOR_INPUT_EVENT, fdListener, "MMITask", AppExecFwk::EventQueue::Priority::VIP); if (errCode != ERR_OK) { @@ -182,8 +166,9 @@ bool MMIClient::DelFdListener(int32_t fd) } else { MMI_HILOGE("Invalid fd:%{public}d", fd); } - - if (USE_ISOLATE_DISPATCH_THREAD) { + auto runner = eventHandler_->GetEventRunner(); + CHKPF(runner); + if (runner->GetRunnerThreadName() == THREAD_NAME) { eventHandler_->RemoveAllEvents(); MMI_HILOGI("Remove all events success"); }