From 6eb9ecd746614900f7cd5b629f01449bac650464 Mon Sep 17 00:00:00 2001 From: litiangang4 Date: Thu, 24 Aug 2023 22:19:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B6=85=E5=A4=A7=E6=BA=90=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: litiangang4 --- services/source/sourcemanager/BUILD.gn | 5 +- .../include/dinput_source_event_handler.h | 76 ++ .../include/dinput_source_listener.h | 79 ++ .../distributed_input_source_manager.h | 27 +- .../src/dinput_source_event_handler.cpp | 378 ++++++++ .../src/dinput_source_listener.cpp | 524 ++++++++++ .../src/distributed_input_source_manager.cpp | 918 +----------------- 7 files changed, 1075 insertions(+), 932 deletions(-) create mode 100644 services/source/sourcemanager/include/dinput_source_event_handler.h create mode 100644 services/source/sourcemanager/include/dinput_source_listener.h create mode 100644 services/source/sourcemanager/src/dinput_source_event_handler.cpp create mode 100644 services/source/sourcemanager/src/dinput_source_listener.cpp diff --git a/services/source/sourcemanager/BUILD.gn b/services/source/sourcemanager/BUILD.gn index ae0609f..a97e0c1 100644 --- a/services/source/sourcemanager/BUILD.gn +++ b/services/source/sourcemanager/BUILD.gn @@ -12,8 +12,7 @@ # limitations under the License. import("//build/ohos.gni") -import( - "//foundation/distributedhardware/distributed_input/distributedinput.gni") +import("../../../distributedinput.gni") ohos_shared_library("libdinput_source") { include_dirs = [ @@ -76,6 +75,8 @@ ohos_shared_library("libdinput_source") { "${ipc_path}/src/unprepare_d_input_call_back_stub.cpp", "${ipc_path}/src/unregister_d_input_call_back_proxy.cpp", "${ipc_path}/src/unregister_d_input_call_back_stub.cpp", + "src/dinput_source_event_handler.cpp", + "src/dinput_source_listener.cpp", "src/distributed_input_source_event_handler.cpp", "src/distributed_input_source_manager.cpp", "src/distributed_input_source_sa_cli_mgr.cpp", diff --git a/services/source/sourcemanager/include/dinput_source_event_handler.h b/services/source/sourcemanager/include/dinput_source_event_handler.h new file mode 100644 index 0000000..fa30ff1 --- /dev/null +++ b/services/source/sourcemanager/include/dinput_source_event_handler.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DINPUT_SOURCE_EVENT_HANDLER_H +#define DINPUT_SOURCE_EVENT_HANDLER_H + +#include +#include +#include + +#include +#include + +#include "event_handler.h" +#include "ipublisher_listener.h" +#include "publisher_listener_stub.h" +#include "singleton.h" + +#include "constants_dinput.h" +#include "dinput_context.h" +#include "dinput_source_trans_callback.h" +#include "distributed_input_source_manager.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +class DistributedInputSourceManager; +class DInputSourceEventHandler : public AppExecFwk::EventHandler { +public: + DInputSourceEventHandler(const std::shared_ptr &runner, + DistributedInputSourceManager *manager); + ~DInputSourceEventHandler() override; + + void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; +private: + void NotifyRegisterCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyUnregisterCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyStartCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyStopCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyKeyStateCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyStartServerCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyRelayPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyRelayUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyRelayStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyRelayStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyRelayStartTypeCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyRelayStopTypeCallback(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyRelayPrepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event); + void NotifyRelayUnprepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event); + + using SourceEventFunc = void (DInputSourceEventHandler::*)( + const AppExecFwk::InnerEvent::Pointer &event); + std::map eventFuncMap_; + DistributedInputSourceManager *sourceManagerObj_; +}; +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS + +#endif // DINPUT_SOURCE_EVENT_HANDLER_H \ No newline at end of file diff --git a/services/source/sourcemanager/include/dinput_source_listener.h b/services/source/sourcemanager/include/dinput_source_listener.h new file mode 100644 index 0000000..9b60d0b --- /dev/null +++ b/services/source/sourcemanager/include/dinput_source_listener.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DINPUT_SOURCE_LISTENER_H +#define DINPUT_SOURCE_LISTENER_H + +#include +#include +#include + +#include +#include + +#include "event_handler.h" +#include "ipublisher_listener.h" +#include "publisher_listener_stub.h" +#include "singleton.h" + +#include "constants_dinput.h" +#include "dinput_context.h" +#include "dinput_source_trans_callback.h" +#include "distributed_input_source_manager.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +class DistributedInputSourceManager; +class DInputSourceListener : public DInputSourceTransCallback { +public: + explicit DInputSourceListener(DistributedInputSourceManager *manager); + virtual ~DInputSourceListener(); + void OnResponseRegisterDistributedHardware(const std::string deviceId, const std::string dhId, + bool result) override; + void OnResponsePrepareRemoteInput(const std::string deviceId, bool result, const std::string &object) override; + void OnResponseUnprepareRemoteInput(const std::string deviceId, bool result) override; + void OnResponseStartRemoteInput(const std::string deviceId, const uint32_t inputTypes, bool result) override; + void OnResponseStopRemoteInput(const std::string deviceId, const uint32_t inputTypes, bool result) override; + void OnResponseStartRemoteInputDhid(const std::string deviceId, const std::string &dhids, bool result) override; + void OnResponseStopRemoteInputDhid(const std::string deviceId, const std::string &dhids, bool result) override; + void OnResponseKeyState(const std::string deviceId, const std::string &dhid, const uint32_t type, + const uint32_t code, const uint32_t value) override; + void OnReceivedEventRemoteInput(const std::string deviceId, const std::string &event) override; + void OnResponseRelayPrepareRemoteInput(int32_t sessionId, const std::string &deviceId, bool result, + const std::string &object) override; + void OnResponseRelayUnprepareRemoteInput(int32_t sessionId, const std::string &deviceId, bool result) override; + + void OnReceiveRelayPrepareResult(int32_t status, const std::string &srcId, const std::string &sinkId) override; + void OnReceiveRelayUnprepareResult(int32_t status, const std::string &srcId, + const std::string &sinkId) override; + void OnReceiveRelayStartDhidResult(int32_t status, const std::string &srcId, const std::string &sinkId, + const std::string &dhids) override; + void OnReceiveRelayStopDhidResult(int32_t status, const std::string &srcId, const std::string &sinkId, + const std::string &dhids) override; + void OnReceiveRelayStartTypeResult(int32_t status, const std::string &srcId, const std::string &sinkId, + uint32_t inputTypes) override; + void OnReceiveRelayStopTypeResult(int32_t status, const std::string &srcId, const std::string &sinkId, + uint32_t inputTypes) override; + void RecordEventLog(int64_t when, int32_t type, int32_t code, int32_t value, const std::string &path); + +private: + DistributedInputSourceManager *sourceManagerObj_; +}; +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS + +#endif // DINPUT_SOURCE_LISTENER_H \ No newline at end of file diff --git a/services/source/sourcemanager/include/distributed_input_source_manager.h b/services/source/sourcemanager/include/distributed_input_source_manager.h index a888add..7022607 100644 --- a/services/source/sourcemanager/include/distributed_input_source_manager.h +++ b/services/source/sourcemanager/include/distributed_input_source_manager.h @@ -345,6 +345,18 @@ public: uint32_t GetAllInputTypesMap(); void ClearResourcesStatus(); +public: + void RunRelayPrepareCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status); + void RunRelayUnprepareCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status); + void RunRelayStartDhidCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status, + const std::string &dhids); + void RunRelayStopDhidCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status, + const std::string &dhids); + void RunRelayStartTypeCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status, + uint32_t inputTypes); + void RunRelayStopTypeCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status, + uint32_t inputTypes); + private: struct DInputClientRegistInfo { std::string devId; @@ -437,7 +449,7 @@ private: ServiceSourceRunningState serviceRunningState_ = ServiceSourceRunningState::STATE_NOT_START; DInputServerType isStartTrans_ = DInputServerType::NULL_SERVER_TYPE; - std::shared_ptr statuslistener_; + std::shared_ptr statuslistener_; std::shared_ptr srcMgrListener_; std::vector regCallbacks_; @@ -465,7 +477,7 @@ private: std::map InputTypesMap_; std::shared_ptr runner_; std::shared_ptr handler_; - std::shared_ptr callBackHandler_; + std::shared_ptr callBackHandler_; std::vector inputDevice_; bool InitAuto(); void handleStartServerCallback(const std::string &devId); @@ -479,17 +491,6 @@ private: std::mutex syncNodeInfoMutex_; std::map> syncNodeInfoMap_; - void RunRelayPrepareCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status); - void RunRelayUnprepareCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status); - void RunRelayStartDhidCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status, - const std::string &dhids); - void RunRelayStopDhidCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status, - const std::string &dhids); - void RunRelayStartTypeCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status, - uint32_t inputTypes); - void RunRelayStopTypeCallback(const std::string &srcId, const std::string &sinkId, const int32_t &status, - uint32_t inputTypes); - int32_t RelayStartRemoteInputByType(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, sptr callback); int32_t RelayStopRemoteInputByType(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, diff --git a/services/source/sourcemanager/src/dinput_source_event_handler.cpp b/services/source/sourcemanager/src/dinput_source_event_handler.cpp new file mode 100644 index 0000000..51342b6 --- /dev/null +++ b/services/source/sourcemanager/src/dinput_source_event_handler.cpp @@ -0,0 +1,378 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dinput_source_event_handler.h" + +#include "dinput_softbus_define.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" +#include "nlohmann/json.hpp" +#include "system_ability_definition.h" +#include "string_ex.h" +#include "distributed_hardware_fwk_kit.h" + +#include "constants_dinput.h" +#include "dinput_errcode.h" +#include "dinput_log.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +DInputSourceEventHandler::DInputSourceEventHandler( + const std::shared_ptr &runner, DistributedInputSourceManager *manager) + : AppExecFwk::EventHandler(runner) +{ + eventFuncMap_[DINPUT_SOURCE_MANAGER_RIGISTER_MSG] = &DInputSourceEventHandler::NotifyRegisterCallback; + eventFuncMap_[DINPUT_SOURCE_MANAGER_UNRIGISTER_MSG] = &DInputSourceEventHandler::NotifyUnregisterCallback; + eventFuncMap_[DINPUT_SOURCE_MANAGER_PREPARE_MSG] = &DInputSourceEventHandler::NotifyPrepareCallback; + eventFuncMap_[DINPUT_SOURCE_MANAGER_UNPREPARE_MSG] = &DInputSourceEventHandler::NotifyUnprepareCallback; + eventFuncMap_[DINPUT_SOURCE_MANAGER_START_MSG] = &DInputSourceEventHandler::NotifyStartCallback; + eventFuncMap_[DINPUT_SOURCE_MANAGER_STOP_MSG] = &DInputSourceEventHandler::NotifyStopCallback; + eventFuncMap_[DINPUT_SOURCE_MANAGER_START_DHID_MSG] = &DInputSourceEventHandler::NotifyStartDhidCallback; + eventFuncMap_[DINPUT_SOURCE_MANAGER_STOP_DHID_MSG] = &DInputSourceEventHandler::NotifyStopDhidCallback; + eventFuncMap_[DINPUT_SOURCE_MANAGER_KEY_STATE_MSG] = &DInputSourceEventHandler::NotifyKeyStateCallback; + eventFuncMap_[DINPUT_SOURCE_MANAGER_STARTSERVER_MSG] = &DInputSourceEventHandler::NotifyStartServerCallback; + eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_TO_ORIGIN] = + &DInputSourceEventHandler::NotifyRelayPrepareRemoteInput; + eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_TO_ORIGIN] = + &DInputSourceEventHandler::NotifyRelayUnprepareRemoteInput; + eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_MMI] = + &DInputSourceEventHandler::NotifyRelayPrepareCallback; + eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_MMI] = + &DInputSourceEventHandler::NotifyRelayUnprepareCallback; + eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_STARTDHID_RESULT_MMI] = + &DInputSourceEventHandler::NotifyRelayStartDhidCallback; + eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_STOPDHID_RESULT_MMI] = + &DInputSourceEventHandler::NotifyRelayStopDhidCallback; + eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_STARTTYPE_RESULT_MMI] = + &DInputSourceEventHandler::NotifyRelayStartTypeCallback; + eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_STOPTYPE_RESULT_MMI] = + &DInputSourceEventHandler::NotifyRelayStopTypeCallback; + + sourceManagerObj_ = manager; +} + +DInputSourceEventHandler::~DInputSourceEventHandler() +{ + eventFuncMap_.clear(); + sourceManagerObj_ = nullptr; +} + +void DInputSourceEventHandler::NotifyRegisterCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + auto it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; + std::string dhId = innerMsg[INPUT_SOURCEMANAGER_KEY_HWID]; + bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; + + DistributedInputSourceManager::InputDeviceId inputDeviceId {deviceId, dhId}; + std::vector tmpInputDevId = sourceManagerObj_->GetInputDeviceId(); + // Find out if the dh exists + auto devIt = std::find(tmpInputDevId.begin(), tmpInputDevId.end(), inputDeviceId); + if (devIt != tmpInputDevId.end()) { + if (result == false) { + sourceManagerObj_->RemoveInputDeviceId(deviceId, dhId); + } + } else { + DHLOGW("ProcessEvent DINPUT_SOURCE_MANAGER_RIGISTER_MSG the " + "devId: %s, dhId: %s is bad data.", GetAnonyString(deviceId).c_str(), GetAnonyString(dhId).c_str()); + } + + sourceManagerObj_->RunRegisterCallback(deviceId, dhId, + result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_REGISTER_MSG_IS_BAD); +} + +void DInputSourceEventHandler::NotifyUnregisterCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + auto it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; + std::string dhId = innerMsg[INPUT_SOURCEMANAGER_KEY_HWID]; + bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; + if (result) { + sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_OFF); + } + sourceManagerObj_->RunUnregisterCallback(deviceId, dhId, + result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNREGISTER_MSG_IS_BAD); +} + +void DInputSourceEventHandler::NotifyPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + auto it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; + bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; + std::string object = innerMsg[INPUT_SOURCEMANAGER_KEY_WHITELIST]; + + sourceManagerObj_->RunPrepareCallback(deviceId, + result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_MSG_IS_BAD, object); +} + +void DInputSourceEventHandler::NotifyUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + auto it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; + bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; + if (result) { + sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_OFF); + } + sourceManagerObj_->RunUnprepareCallback(deviceId, + result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_MSG_IS_BAD); +} + +void DInputSourceEventHandler::NotifyStartCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + auto it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; + uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_ITP]; + bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; + DHLOGI("Start DInput Recv Callback ret: %s, devId: %s, inputTypes: %d", + result ? "true" : "false", GetAnonyString(deviceId).c_str(), inputTypes); + if (result) { + sourceManagerObj_->SetInputTypesMap( + deviceId, sourceManagerObj_->GetInputTypesMap(deviceId) | inputTypes); + } + sourceManagerObj_->SetStartTransFlag((result && (sourceManagerObj_->GetInputTypesMap(deviceId) > 0)) ? + DInputServerType::SOURCE_SERVER_TYPE : DInputServerType::NULL_SERVER_TYPE); + sourceManagerObj_->RunStartCallback(deviceId, inputTypes, + result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_MSG_IS_BAD); +} + +void DInputSourceEventHandler::NotifyStopCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + auto it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; + uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_ITP]; + bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; + + DHLOGI("Stop DInput Recv Callback ret: %B, devId: %s, inputTypes: %d", + result, GetAnonyString(deviceId).c_str(), inputTypes); + if (result && (sourceManagerObj_->GetInputTypesMap(deviceId) & inputTypes)) { + sourceManagerObj_->SetInputTypesMap( + deviceId, sourceManagerObj_->GetInputTypesMap(deviceId) - + (sourceManagerObj_->GetInputTypesMap(deviceId) & inputTypes)); + } + + if (sourceManagerObj_->GetInputTypesMap(deviceId) == 0) { + sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_OFF); + } + + // DeviceMap_ all sink device switch is off,call isstart's callback + bool isAllDevSwitchOff = sourceManagerObj_->GetDeviceMapAllDevSwitchOff(); + if (isAllDevSwitchOff) { + DHLOGI("All Dev Switch Off"); + sourceManagerObj_->SetStartTransFlag(DInputServerType::NULL_SERVER_TYPE); + } + sourceManagerObj_->RunStopCallback(deviceId, inputTypes, + result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_MSG_IS_BAD); +} + +void DInputSourceEventHandler::NotifyStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + auto it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; + std::string dhidStr = innerMsg[INPUT_SOURCEMANAGER_KEY_DHID]; + bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; + + sourceManagerObj_->RunStartDhidCallback(deviceId, dhidStr, + result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_MSG_IS_BAD); +} + +void DInputSourceEventHandler::NotifyStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + auto it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; + std::string dhidStr = innerMsg[INPUT_SOURCEMANAGER_KEY_DHID]; + bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; + + sourceManagerObj_->RunStopDhidCallback(deviceId, dhidStr, + result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_MSG_IS_BAD); +} + +void DInputSourceEventHandler::NotifyKeyStateCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + auto it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; + std::string dhid = innerMsg[INPUT_SOURCEMANAGER_KEY_DHID]; + uint32_t keyType = innerMsg[INPUT_SOURCEMANAGER_KEY_TYPE]; + uint32_t keyCode = innerMsg[INPUT_SOURCEMANAGER_KEY_CODE]; + uint32_t keyValue = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; + + sourceManagerObj_->RunKeyStateCallback(deviceId, dhid, keyType, keyCode, keyValue); +} + +void DInputSourceEventHandler::NotifyStartServerCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + auto it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + int32_t serType = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; + DInputServerType startTransFlag = DInputServerType(serType); + sourceManagerObj_->SetStartTransFlag(startTransFlag); +} + + +void DInputSourceEventHandler::NotifyRelayPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + nlohmann::json::iterator it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; + std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; + std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; + + sourceManagerObj_->RunRelayPrepareCallback(srcId, sinkId, status); +} + +void DInputSourceEventHandler::NotifyRelayUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + nlohmann::json::iterator it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; + std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; + std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; + + sourceManagerObj_->RunRelayUnprepareCallback(srcId, sinkId, status); +} + +void DInputSourceEventHandler::NotifyRelayPrepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + nlohmann::json::iterator it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; + bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; + std::string object = innerMsg[INPUT_SOURCEMANAGER_KEY_WHITELIST]; + int32_t toSrcSessionId = innerMsg[INPUT_SOURCEMANAGER_KEY_SESSIONID]; + DHLOGI("Device whitelist object: %s", object.c_str()); + std::string localNetworkId = GetLocalNetworkId(); + if (localNetworkId.empty()) { + return; + } + + // notify to origin sourcesa result. + int32_t ret = DistributedInputSourceTransport::GetInstance().NotifyOriginPrepareResult(toSrcSessionId, + localNetworkId, deviceId, result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_MSG_IS_BAD); + if (ret != DH_SUCCESS) { + DHLOGE("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_TO_ORIGIN notify is fail."); + return; + } + sourceManagerObj_->RunWhiteListCallback(deviceId, object); +} + +void DInputSourceEventHandler::NotifyRelayUnprepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + nlohmann::json::iterator it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; + bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; + int32_t toSrcSessionId = innerMsg[INPUT_SOURCEMANAGER_KEY_SESSIONID]; + std::string localNetworkId = GetLocalNetworkId(); + if (localNetworkId.empty()) { + return; + } + + // notify to origin sourcesa result. + int32_t ret = DistributedInputSourceTransport::GetInstance().NotifyOriginUnprepareResult(toSrcSessionId, + localNetworkId, deviceId, result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_MSG_IS_BAD); + if (ret != DH_SUCCESS) { + DHLOGE("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_TO_ORIGIN notify is fail."); + return; + } +} + +void DInputSourceEventHandler::NotifyRelayStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + nlohmann::json::iterator it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; + std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; + std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; + std::string dhids = innerMsg[INPUT_SOURCEMANAGER_KEY_DHID]; + + sourceManagerObj_->RunRelayStartDhidCallback(srcId, sinkId, status, dhids); +} + +void DInputSourceEventHandler::NotifyRelayStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + nlohmann::json::iterator it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; + std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; + std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; + std::string dhids = innerMsg[INPUT_SOURCEMANAGER_KEY_DHID]; + + sourceManagerObj_->RunRelayStopDhidCallback(srcId, sinkId, status, dhids); +} + +void DInputSourceEventHandler::NotifyRelayStartTypeCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + nlohmann::json::iterator it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; + std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; + std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; + uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_TYPE]; + + sourceManagerObj_->RunRelayStartTypeCallback(srcId, sinkId, status, inputTypes); +} + +void DInputSourceEventHandler::NotifyRelayStopTypeCallback(const AppExecFwk::InnerEvent::Pointer &event) +{ + std::shared_ptr dataMsg = event->GetSharedObject(); + nlohmann::json::iterator it = dataMsg->begin(); + nlohmann::json innerMsg = *(it); + int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; + std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; + std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; + uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_TYPE]; + + sourceManagerObj_->RunRelayStopTypeCallback(srcId, sinkId, status, inputTypes); +} + +void DInputSourceEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) +{ + auto iter = eventFuncMap_.find(event->GetInnerEventId()); + if (iter == eventFuncMap_.end()) { + DHLOGE("Event Id %d is undefined.", event->GetInnerEventId()); + return; + } + SourceEventFunc &func = iter->second; + (this->*func)(event); +} +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/services/source/sourcemanager/src/dinput_source_listener.cpp b/services/source/sourcemanager/src/dinput_source_listener.cpp new file mode 100644 index 0000000..9b3aac0 --- /dev/null +++ b/services/source/sourcemanager/src/dinput_source_listener.cpp @@ -0,0 +1,524 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dinput_source_listener.h" + +#include "dinput_softbus_define.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" +#include "nlohmann/json.hpp" +#include "system_ability_definition.h" +#include "string_ex.h" +#include "distributed_hardware_fwk_kit.h" + +#include "constants_dinput.h" +#include "dinput_errcode.h" +#include "dinput_log.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +DInputSourceListener::DInputSourceListener(DistributedInputSourceManager *manager) +{ + sourceManagerObj_ = manager; + DHLOGI("DInputSourceListener init."); +} + +DInputSourceListener::~DInputSourceListener() +{ + sourceManagerObj_ = nullptr; + DHLOGI("DInputSourceListener destory."); +} + +void DInputSourceListener::OnResponseRegisterDistributedHardware(const std::string deviceId, + const std::string dhId, bool result) +{ + DHLOGI("OnResponseRegisterDistributedHardware called, deviceId: %s, " + "result: %s.", GetAnonyString(deviceId).c_str(), result ? "success" : "failed"); + if (sourceManagerObj_ == nullptr) { + DHLOGE("OnResponseRegisterDistributedHardware sourceManagerObj is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + sourceManagerObj_->RunRegisterCallback(deviceId, dhId, + ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL); + DHLOGE("OnResponseRegisterDistributedHardware GetCallbackEventHandler is null."); + return; + } + + std::shared_ptr jsonArrayMsg = std::make_shared(); + + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; + tmpJson[INPUT_SOURCEMANAGER_KEY_HWID] = dhId; + tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( + DINPUT_SOURCE_MANAGER_RIGISTER_MSG, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::OnResponsePrepareRemoteInput(const std::string deviceId, + bool result, const std::string &object) +{ + DHLOGI("OnResponsePrepareRemoteInput called, deviceId: %s, result: %s.", + GetAnonyString(deviceId).c_str(), result ? "success" : "failed"); + + if (sourceManagerObj_ == nullptr) { + DHLOGE("OnResponsePrepareRemoteInput sourceManagerObj is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + sourceManagerObj_->RunPrepareCallback(deviceId, + ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL, object); + DHLOGE("OnResponsePrepareRemoteInput GetCallbackEventHandler is null."); + return; + } + std::shared_ptr jsonArrayMsg = std::make_shared(); + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; + tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; + tmpJson[INPUT_SOURCEMANAGER_KEY_WHITELIST] = object; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( + DINPUT_SOURCE_MANAGER_PREPARE_MSG, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::OnResponseUnprepareRemoteInput(const std::string deviceId, bool result) +{ + DHLOGI("OnResponseUnprepareRemoteInput called, deviceId: %s, " + "result: %s.", GetAnonyString(deviceId).c_str(), result ? "success" : "failed"); + + if (sourceManagerObj_ == nullptr) { + DHLOGE("OnResponseUnprepareRemoteInput sourceManagerObj is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + sourceManagerObj_->RunUnprepareCallback(deviceId, + ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL); + DHLOGE("OnResponseUnprepareRemoteInput GetCallbackEventHandler is null."); + return; + } + std::shared_ptr jsonArrayMsg = std::make_shared(); + + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; + tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( + DINPUT_SOURCE_MANAGER_UNPREPARE_MSG, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::OnResponseRelayPrepareRemoteInput(int32_t toSrcSessionId, const std::string &deviceId, + bool result, const std::string &object) +{ + DHLOGI("OnResponseRelayPrepareRemoteInput deviceId: %s, result: %d.", GetAnonyString(deviceId).c_str(), result); + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + DHLOGE("GetCallbackEventHandler is null."); + return; + } + std::shared_ptr jsonArrayMsg = std::make_shared(); + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; + tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; + tmpJson[INPUT_SOURCEMANAGER_KEY_WHITELIST] = object; + tmpJson[INPUT_SOURCEMANAGER_KEY_SESSIONID] = toSrcSessionId; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( + DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_TO_ORIGIN, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::OnResponseRelayUnprepareRemoteInput(int32_t toSrcSessionId, const std::string &deviceId, + bool result) +{ + DHLOGI("OnResponseRelayUnprepareRemoteInput deviceId: %s, result: %d.", GetAnonyString(deviceId).c_str(), result); + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + DHLOGE("GetCallbackEventHandler is null."); + return; + } + std::shared_ptr jsonArrayMsg = std::make_shared(); + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; + tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; + tmpJson[INPUT_SOURCEMANAGER_KEY_SESSIONID] = toSrcSessionId; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( + DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_TO_ORIGIN, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::OnResponseStartRemoteInput(const std::string deviceId, const uint32_t inputTypes, + bool result) +{ + DHLOGI("OnResponseStartRemoteInput called, deviceId: %s, inputTypes: %d, result: %s.", + GetAnonyString(deviceId).c_str(), inputTypes, result ? "success" : "failed"); + + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + sourceManagerObj_->RunStartCallback(deviceId, inputTypes, + ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL); + DHLOGE("GetCallbackEventHandler is null."); + return; + } + if (result) { + sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_ON); + } + + std::shared_ptr jsonArrayMsg = std::make_shared(); + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; + tmpJson[INPUT_SOURCEMANAGER_KEY_ITP] = inputTypes; + tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( + DINPUT_SOURCE_MANAGER_START_MSG, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::OnResponseStopRemoteInput(const std::string deviceId, const uint32_t inputTypes, bool result) +{ + DHLOGI("OnResponseStopRemoteInput called, deviceId: %s, inputTypes: %d, result: %s.", + GetAnonyString(deviceId).c_str(), inputTypes, result ? "true" : "failed"); + + if (sourceManagerObj_ == nullptr) { + DHLOGE("OnResponseStopRemoteInput sourceManagerObj_ is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + DHLOGE("OnResponseStopRemoteInput GetCallbackEventHandler is null."); + sourceManagerObj_->RunStopCallback(deviceId, inputTypes, + ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL); + return; + } + std::shared_ptr jsonArrayMsg = std::make_shared(); + + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; + tmpJson[INPUT_SOURCEMANAGER_KEY_ITP] = inputTypes; + tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( + DINPUT_SOURCE_MANAGER_STOP_MSG, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::OnResponseStartRemoteInputDhid(const std::string deviceId, const std::string &dhids, + bool result) +{ + DHLOGI("OnResponseStartRemoteInputDhid called, deviceId: %s, result: %s.", + GetAnonyString(deviceId).c_str(), result ? "success" : "failed"); + + if (sourceManagerObj_ == nullptr) { + DHLOGE("OnResponseStartRemoteInputDhid sourceManagerObj_ is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + DHLOGE("OnResponseStartRemoteInputDhid GetCallbackEventHandler is null."); + sourceManagerObj_->RunStartDhidCallback(deviceId, dhids, + ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL); + return; + } + if (result) { + sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_ON); + } + + std::vector vecStr; + StringSplitToVector(dhids, INPUT_STRING_SPLIT_POINT, vecStr); + DInputState::GetInstance().RecordDhids(vecStr, DhidState::THROUGH_IN, -1); + + std::shared_ptr jsonArrayMsg = std::make_shared(); + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; + tmpJson[INPUT_SOURCEMANAGER_KEY_DHID] = dhids; + tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = + AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_START_DHID_MSG, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::OnResponseStopRemoteInputDhid(const std::string deviceId, const std::string &dhids, + bool result) +{ + DHLOGI("OnResponseStopRemoteInputDhid called, deviceId: %s, result: %s.", + GetAnonyString(deviceId).c_str(), result ? "success" : "failed"); + + if (sourceManagerObj_ == nullptr) { + DHLOGE("OnResponseStopRemoteInputDhid sourceManagerObj_ is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + DHLOGE("OnResponseStopRemoteInputDhid GetCallbackEventHandler is null."); + sourceManagerObj_->RunStopDhidCallback(deviceId, dhids, + ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL); + return; + } + std::shared_ptr jsonArrayMsg = std::make_shared(); + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; + tmpJson[INPUT_SOURCEMANAGER_KEY_DHID] = dhids; + tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = + AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_STOP_DHID_MSG, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::OnResponseKeyState(const std::string deviceId, const std::string &dhid, + const uint32_t type, const uint32_t code, const uint32_t value) +{ + DHLOGI("OnResponseKeyState called, deviceId: %s, dhid: %s.", GetAnonyString(deviceId).c_str(), + GetAnonyString(dhid).c_str()); + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + DHLOGE("GetCallbackEventHandler is null."); + sourceManagerObj_->RunKeyStateCallback(deviceId, dhid, type, code, value); + return; + } + std::shared_ptr jsonArrayMsg = std::make_shared(); + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; + tmpJson[INPUT_SOURCEMANAGER_KEY_DHID] = dhid; + tmpJson[INPUT_SOURCEMANAGER_KEY_TYPE] = type; + tmpJson[INPUT_SOURCEMANAGER_KEY_CODE] = code; + tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = value; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = + AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_KEY_STATE_MSG, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::OnReceivedEventRemoteInput(const std::string deviceId, const std::string &event) +{ + nlohmann::json inputData = nlohmann::json::parse(event, nullptr, false); + if (inputData.is_discarded()) { + DHLOGE("inputData parse failed!"); + return; + } + size_t jsonSize = inputData.size(); + DHLOGI("OnReceivedEventRemoteInput called, deviceId: %s, json size:%d.", + GetAnonyString(deviceId).c_str(), jsonSize); + + if (!inputData.is_array()) { + DHLOGE("inputData not vector!"); + return; + } + + RawEvent mEventBuffer[jsonSize]; + int idx = 0; + for (auto it = inputData.begin(); it != inputData.end(); ++it) { + nlohmann::json oneData = (*it); + if (!IsInt64(oneData, INPUT_KEY_WHEN) || !IsUInt32(oneData, INPUT_KEY_TYPE) || + !IsUInt32(oneData, INPUT_KEY_CODE) || !IsInt32(oneData, INPUT_KEY_VALUE) || + !IsString(oneData, INPUT_KEY_DESCRIPTOR) || !IsString(oneData, INPUT_KEY_PATH)) { + DHLOGE("The key is invaild."); + continue; + } + mEventBuffer[idx].when = oneData[INPUT_KEY_WHEN]; + mEventBuffer[idx].type = oneData[INPUT_KEY_TYPE]; + mEventBuffer[idx].code = oneData[INPUT_KEY_CODE]; + mEventBuffer[idx].value = oneData[INPUT_KEY_VALUE]; + mEventBuffer[idx].descriptor = oneData[INPUT_KEY_DESCRIPTOR]; + mEventBuffer[idx].path = oneData[INPUT_KEY_PATH]; + RecordEventLog(oneData[INPUT_KEY_WHEN], oneData[INPUT_KEY_TYPE], oneData[INPUT_KEY_CODE], + oneData[INPUT_KEY_VALUE], oneData[INPUT_KEY_PATH]); + ++idx; + } + DistributedInputInject::GetInstance().RegisterDistributedEvent(mEventBuffer, jsonSize); +} + +void DInputSourceListener::OnReceiveRelayPrepareResult(int32_t status, const std::string &srcId, + const std::string &sinkId) +{ + DHLOGI("status:%d, srcId: %s, sinkId: %s.", status, GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str()); + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + DHLOGE("GetCallbackEventHandler is null."); + return; + } + std::shared_ptr jsonArrayMsg = std::make_shared(); + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_SRC_DEVID] = srcId; + tmpJson[INPUT_SOURCEMANAGER_KEY_SINK_DEVID] = sinkId; + tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = status; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = + AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_MMI, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::OnReceiveRelayUnprepareResult(int32_t status, const std::string &srcId, + const std::string &sinkId) +{ + DHLOGI("status:%d, srcId: %s, sinkId: %s.", status, GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str()); + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + DHLOGE("GetCallbackEventHandler is null."); + return; + } + std::shared_ptr jsonArrayMsg = std::make_shared(); + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_SRC_DEVID] = srcId; + tmpJson[INPUT_SOURCEMANAGER_KEY_SINK_DEVID] = sinkId; + tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = status; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = + AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_MMI, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::OnReceiveRelayStartDhidResult(int32_t status, const std::string &srcId, + const std::string &sinkId, const std::string &dhids) +{ + DHLOGI("status:%d, srcId: %s, sinkId: %s.", status, GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str()); + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + DHLOGE("GetCallbackEventHandler is null."); + return; + } + std::shared_ptr jsonArrayMsg = std::make_shared(); + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_SRC_DEVID] = srcId; + tmpJson[INPUT_SOURCEMANAGER_KEY_SINK_DEVID] = sinkId; + tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = status; + tmpJson[INPUT_SOURCEMANAGER_KEY_DHID] = dhids; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = + AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_RELAY_STARTDHID_RESULT_MMI, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::OnReceiveRelayStopDhidResult(int32_t status, const std::string &srcId, + const std::string &sinkId, const std::string &dhids) +{ + DHLOGI("status:%d, srcId: %s, sinkId: %s.", status, GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str()); + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + DHLOGE("GetCallbackEventHandler is null."); + return; + } + std::shared_ptr jsonArrayMsg = std::make_shared(); + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_SRC_DEVID] = srcId; + tmpJson[INPUT_SOURCEMANAGER_KEY_SINK_DEVID] = sinkId; + tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = status; + tmpJson[INPUT_SOURCEMANAGER_KEY_DHID] = dhids; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = + AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_RELAY_STOPDHID_RESULT_MMI, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::OnReceiveRelayStartTypeResult(int32_t status, const std::string &srcId, + const std::string &sinkId, uint32_t inputTypes) +{ + DHLOGI("status:%d, srcId: %s, sinkId: %s.", status, GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str()); + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + DHLOGE("GetCallbackEventHandler is null."); + return; + } + std::shared_ptr jsonArrayMsg = std::make_shared(); + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_SRC_DEVID] = srcId; + tmpJson[INPUT_SOURCEMANAGER_KEY_SINK_DEVID] = sinkId; + tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = status; + tmpJson[INPUT_SOURCEMANAGER_KEY_TYPE] = inputTypes; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = + AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_RELAY_STARTTYPE_RESULT_MMI, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::OnReceiveRelayStopTypeResult(int32_t status, const std::string &srcId, + const std::string &sinkId, uint32_t inputTypes) +{ + DHLOGI("status:%d, srcId: %s, sinkId: %s.", status, GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str()); + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj is null."); + return; + } + if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { + DHLOGE("GetCallbackEventHandler is null."); + return; + } + std::shared_ptr jsonArrayMsg = std::make_shared(); + nlohmann::json tmpJson; + tmpJson[INPUT_SOURCEMANAGER_KEY_SRC_DEVID] = srcId; + tmpJson[INPUT_SOURCEMANAGER_KEY_SINK_DEVID] = sinkId; + tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = status; + tmpJson[INPUT_SOURCEMANAGER_KEY_TYPE] = inputTypes; + jsonArrayMsg->push_back(tmpJson); + AppExecFwk::InnerEvent::Pointer msgEvent = + AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_RELAY_STOPTYPE_RESULT_MMI, jsonArrayMsg, 0); + sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void DInputSourceListener::RecordEventLog(int64_t when, int32_t type, int32_t code, + int32_t value, const std::string &path) +{ + std::string eventType = ""; + switch (type) { + case EV_KEY: + eventType = "EV_KEY"; + break; + case EV_REL: + eventType = "EV_REL"; + break; + case EV_ABS: + eventType = "EV_ABS"; + break; + default: + eventType = "other type"; + break; + } + DHLOGD("3.E2E-Test Source softBus receive event, EventType: %s, Code: %d, Value: %d, Path: %s, When: %" PRId64 "", + eventType.c_str(), code, value, path.c_str(), when); +} +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/services/source/sourcemanager/src/distributed_input_source_manager.cpp b/services/source/sourcemanager/src/distributed_input_source_manager.cpp index 452ca1d..48197a8 100644 --- a/services/source/sourcemanager/src/distributed_input_source_manager.cpp +++ b/services/source/sourcemanager/src/distributed_input_source_manager.cpp @@ -15,11 +15,6 @@ #include "distributed_input_source_manager.h" -#include -#include -#include -#include - #include "dinput_softbus_define.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" @@ -28,7 +23,6 @@ #include "string_ex.h" #include "distributed_hardware_fwk_kit.h" -#include "ipublisher_listener.h" #include "constants_dinput.h" #include "dinput_errcode.h" @@ -64,477 +58,6 @@ DistributedInputSourceManager::~DistributedInputSourceManager() stopDScreenListener_ = nullptr; } -DistributedInputSourceManager::DInputSourceListener::DInputSourceListener(DistributedInputSourceManager *manager) -{ - sourceManagerObj_ = manager; - DHLOGI("DInputSourceListener init."); -} - -DistributedInputSourceManager::DInputSourceListener::~DInputSourceListener() -{ - sourceManagerObj_ = nullptr; - DHLOGI("DInputSourceListener destory."); -} - -void DistributedInputSourceManager::DInputSourceListener::OnResponseRegisterDistributedHardware( - const std::string deviceId, const std::string dhId, bool result) -{ - DHLOGI("OnResponseRegisterDistributedHardware called, deviceId: %s, " - "result: %s.", GetAnonyString(deviceId).c_str(), result ? "success" : "failed"); - if (sourceManagerObj_ == nullptr) { - DHLOGE("OnResponseRegisterDistributedHardware sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - sourceManagerObj_->RunRegisterCallback(deviceId, dhId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL); - DHLOGE("OnResponseRegisterDistributedHardware GetCallbackEventHandler is null."); - return; - } - - std::shared_ptr jsonArrayMsg = std::make_shared(); - - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; - tmpJson[INPUT_SOURCEMANAGER_KEY_HWID] = dhId; - tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( - DINPUT_SOURCE_MANAGER_RIGISTER_MSG, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DistributedInputSourceManager::DInputSourceListener::OnResponsePrepareRemoteInput(const std::string deviceId, - bool result, const std::string &object) -{ - DHLOGI("OnResponsePrepareRemoteInput called, deviceId: %s, result: %s.", - GetAnonyString(deviceId).c_str(), result ? "success" : "failed"); - - if (sourceManagerObj_ == nullptr) { - DHLOGE("OnResponsePrepareRemoteInput sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - sourceManagerObj_->RunPrepareCallback(deviceId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL, object); - DHLOGE("OnResponsePrepareRemoteInput GetCallbackEventHandler is null."); - return; - } - std::shared_ptr jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; - tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; - tmpJson[INPUT_SOURCEMANAGER_KEY_WHITELIST] = object; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( - DINPUT_SOURCE_MANAGER_PREPARE_MSG, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DistributedInputSourceManager::DInputSourceListener::OnResponseUnprepareRemoteInput( - const std::string deviceId, bool result) -{ - DHLOGI("OnResponseUnprepareRemoteInput called, deviceId: %s, " - "result: %s.", GetAnonyString(deviceId).c_str(), result ? "success" : "failed"); - - if (sourceManagerObj_ == nullptr) { - DHLOGE("OnResponseUnprepareRemoteInput sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - sourceManagerObj_->RunUnprepareCallback(deviceId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL); - DHLOGE("OnResponseUnprepareRemoteInput GetCallbackEventHandler is null."); - return; - } - std::shared_ptr jsonArrayMsg = std::make_shared(); - - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; - tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( - DINPUT_SOURCE_MANAGER_UNPREPARE_MSG, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DistributedInputSourceManager::DInputSourceListener::OnResponseRelayPrepareRemoteInput(int32_t toSrcSessionId, - const std::string &deviceId, bool result, const std::string &object) -{ - DHLOGI("OnResponseRelayPrepareRemoteInput deviceId: %s, result: %d.", GetAnonyString(deviceId).c_str(), result); - if (sourceManagerObj_ == nullptr) { - DHLOGE("sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - DHLOGE("GetCallbackEventHandler is null."); - return; - } - std::shared_ptr jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; - tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; - tmpJson[INPUT_SOURCEMANAGER_KEY_WHITELIST] = object; - tmpJson[INPUT_SOURCEMANAGER_KEY_SESSIONID] = toSrcSessionId; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( - DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_TO_ORIGIN, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DistributedInputSourceManager::DInputSourceListener::OnResponseRelayUnprepareRemoteInput(int32_t toSrcSessionId, - const std::string &deviceId, bool result) -{ - DHLOGI("OnResponseRelayUnprepareRemoteInput deviceId: %s, result: %d.", GetAnonyString(deviceId).c_str(), result); - if (sourceManagerObj_ == nullptr) { - DHLOGE("sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - DHLOGE("GetCallbackEventHandler is null."); - return; - } - std::shared_ptr jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; - tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; - tmpJson[INPUT_SOURCEMANAGER_KEY_SESSIONID] = toSrcSessionId; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( - DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_TO_ORIGIN, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DistributedInputSourceManager::DInputSourceListener::OnResponseStartRemoteInput( - const std::string deviceId, const uint32_t inputTypes, bool result) -{ - DHLOGI("OnResponseStartRemoteInput called, deviceId: %s, inputTypes: %d, result: %s.", - GetAnonyString(deviceId).c_str(), inputTypes, result ? "success" : "failed"); - - if (sourceManagerObj_ == nullptr) { - DHLOGE("sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - sourceManagerObj_->RunStartCallback(deviceId, inputTypes, - ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL); - DHLOGE("GetCallbackEventHandler is null."); - return; - } - if (result) { - sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_ON); - } - - std::shared_ptr jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; - tmpJson[INPUT_SOURCEMANAGER_KEY_ITP] = inputTypes; - tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( - DINPUT_SOURCE_MANAGER_START_MSG, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DistributedInputSourceManager::DInputSourceListener::OnResponseStopRemoteInput( - const std::string deviceId, const uint32_t inputTypes, bool result) -{ - DHLOGI("OnResponseStopRemoteInput called, deviceId: %s, inputTypes: %d, result: %s.", - GetAnonyString(deviceId).c_str(), inputTypes, result ? "true" : "failed"); - - if (sourceManagerObj_ == nullptr) { - DHLOGE("OnResponseStopRemoteInput sourceManagerObj_ is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - DHLOGE("OnResponseStopRemoteInput GetCallbackEventHandler is null."); - sourceManagerObj_->RunStopCallback(deviceId, inputTypes, - ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL); - return; - } - std::shared_ptr jsonArrayMsg = std::make_shared(); - - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; - tmpJson[INPUT_SOURCEMANAGER_KEY_ITP] = inputTypes; - tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( - DINPUT_SOURCE_MANAGER_STOP_MSG, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DistributedInputSourceManager::DInputSourceListener::OnResponseStartRemoteInputDhid( - const std::string deviceId, const std::string &dhids, bool result) -{ - DHLOGI("OnResponseStartRemoteInputDhid called, deviceId: %s, result: %s.", - GetAnonyString(deviceId).c_str(), result ? "success" : "failed"); - - if (sourceManagerObj_ == nullptr) { - DHLOGE("OnResponseStartRemoteInputDhid sourceManagerObj_ is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - DHLOGE("OnResponseStartRemoteInputDhid GetCallbackEventHandler is null."); - sourceManagerObj_->RunStartDhidCallback(deviceId, dhids, - ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL); - return; - } - if (result) { - sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_ON); - } - - std::vector vecStr; - StringSplitToVector(dhids, INPUT_STRING_SPLIT_POINT, vecStr); - DInputState::GetInstance().RecordDhids(vecStr, DhidState::THROUGH_IN, -1); - - std::shared_ptr jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; - tmpJson[INPUT_SOURCEMANAGER_KEY_DHID] = dhids; - tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = - AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_START_DHID_MSG, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DistributedInputSourceManager::DInputSourceListener::OnResponseStopRemoteInputDhid( - const std::string deviceId, const std::string &dhids, bool result) -{ - DHLOGI("OnResponseStopRemoteInputDhid called, deviceId: %s, result: %s.", - GetAnonyString(deviceId).c_str(), result ? "success" : "failed"); - - if (sourceManagerObj_ == nullptr) { - DHLOGE("OnResponseStopRemoteInputDhid sourceManagerObj_ is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - DHLOGE("OnResponseStopRemoteInputDhid GetCallbackEventHandler is null."); - sourceManagerObj_->RunStopDhidCallback(deviceId, dhids, - ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL); - return; - } - std::shared_ptr jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; - tmpJson[INPUT_SOURCEMANAGER_KEY_DHID] = dhids; - tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = result; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = - AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_STOP_DHID_MSG, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DistributedInputSourceManager::DInputSourceListener::OnResponseKeyState(const std::string deviceId, - const std::string &dhid, const uint32_t type, const uint32_t code, const uint32_t value) -{ - DHLOGI("OnResponseKeyState called, deviceId: %s, dhid: %s.", GetAnonyString(deviceId).c_str(), - GetAnonyString(dhid).c_str()); - if (sourceManagerObj_ == nullptr) { - DHLOGE("sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - DHLOGE("GetCallbackEventHandler is null."); - sourceManagerObj_->RunKeyStateCallback(deviceId, dhid, type, code, value); - return; - } - std::shared_ptr jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId; - tmpJson[INPUT_SOURCEMANAGER_KEY_DHID] = dhid; - tmpJson[INPUT_SOURCEMANAGER_KEY_TYPE] = type; - tmpJson[INPUT_SOURCEMANAGER_KEY_CODE] = code; - tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = value; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = - AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_KEY_STATE_MSG, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DistributedInputSourceManager::DInputSourceListener::OnReceivedEventRemoteInput( - const std::string deviceId, const std::string &event) -{ - nlohmann::json inputData = nlohmann::json::parse(event, nullptr, false); - if (inputData.is_discarded()) { - DHLOGE("inputData parse failed!"); - return; - } - size_t jsonSize = inputData.size(); - DHLOGI("OnReceivedEventRemoteInput called, deviceId: %s, json size:%d.", - GetAnonyString(deviceId).c_str(), jsonSize); - - if (!inputData.is_array()) { - DHLOGE("inputData not vector!"); - return; - } - - RawEvent mEventBuffer[jsonSize]; - int idx = 0; - for (auto it = inputData.begin(); it != inputData.end(); ++it) { - nlohmann::json oneData = (*it); - if (!IsInt64(oneData, INPUT_KEY_WHEN) || !IsUInt32(oneData, INPUT_KEY_TYPE) || - !IsUInt32(oneData, INPUT_KEY_CODE) || !IsInt32(oneData, INPUT_KEY_VALUE) || - !IsString(oneData, INPUT_KEY_DESCRIPTOR) || !IsString(oneData, INPUT_KEY_PATH)) { - DHLOGE("The key is invaild."); - continue; - } - mEventBuffer[idx].when = oneData[INPUT_KEY_WHEN]; - mEventBuffer[idx].type = oneData[INPUT_KEY_TYPE]; - mEventBuffer[idx].code = oneData[INPUT_KEY_CODE]; - mEventBuffer[idx].value = oneData[INPUT_KEY_VALUE]; - mEventBuffer[idx].descriptor = oneData[INPUT_KEY_DESCRIPTOR]; - mEventBuffer[idx].path = oneData[INPUT_KEY_PATH]; - RecordEventLog(oneData[INPUT_KEY_WHEN], oneData[INPUT_KEY_TYPE], oneData[INPUT_KEY_CODE], - oneData[INPUT_KEY_VALUE], oneData[INPUT_KEY_PATH]); - ++idx; - } - DistributedInputInject::GetInstance().RegisterDistributedEvent(mEventBuffer, jsonSize); -} - -void DistributedInputSourceManager::DInputSourceListener::OnReceiveRelayPrepareResult(int32_t status, - const std::string &srcId, const std::string &sinkId) -{ - DHLOGI("status:%d, srcId: %s, sinkId: %s.", status, GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str()); - if (sourceManagerObj_ == nullptr) { - DHLOGE("sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - DHLOGE("GetCallbackEventHandler is null."); - return; - } - std::shared_ptr jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_SRC_DEVID] = srcId; - tmpJson[INPUT_SOURCEMANAGER_KEY_SINK_DEVID] = sinkId; - tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = status; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = - AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_MMI, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DistributedInputSourceManager::DInputSourceListener::OnReceiveRelayUnprepareResult(int32_t status, - const std::string &srcId, const std::string &sinkId) -{ - DHLOGI("status:%d, srcId: %s, sinkId: %s.", status, GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str()); - if (sourceManagerObj_ == nullptr) { - DHLOGE("sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - DHLOGE("GetCallbackEventHandler is null."); - return; - } - std::shared_ptr jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_SRC_DEVID] = srcId; - tmpJson[INPUT_SOURCEMANAGER_KEY_SINK_DEVID] = sinkId; - tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = status; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = - AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_MMI, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DistributedInputSourceManager::DInputSourceListener::OnReceiveRelayStartDhidResult(int32_t status, - const std::string &srcId, const std::string &sinkId, const std::string &dhids) -{ - DHLOGI("status:%d, srcId: %s, sinkId: %s.", status, GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str()); - if (sourceManagerObj_ == nullptr) { - DHLOGE("sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - DHLOGE("GetCallbackEventHandler is null."); - return; - } - std::shared_ptr jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_SRC_DEVID] = srcId; - tmpJson[INPUT_SOURCEMANAGER_KEY_SINK_DEVID] = sinkId; - tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = status; - tmpJson[INPUT_SOURCEMANAGER_KEY_DHID] = dhids; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = - AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_RELAY_STARTDHID_RESULT_MMI, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DistributedInputSourceManager::DInputSourceListener::OnReceiveRelayStopDhidResult(int32_t status, - const std::string &srcId, const std::string &sinkId, const std::string &dhids) -{ - DHLOGI("status:%d, srcId: %s, sinkId: %s.", status, GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str()); - if (sourceManagerObj_ == nullptr) { - DHLOGE("sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - DHLOGE("GetCallbackEventHandler is null."); - return; - } - std::shared_ptr jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_SRC_DEVID] = srcId; - tmpJson[INPUT_SOURCEMANAGER_KEY_SINK_DEVID] = sinkId; - tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = status; - tmpJson[INPUT_SOURCEMANAGER_KEY_DHID] = dhids; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = - AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_RELAY_STOPDHID_RESULT_MMI, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DistributedInputSourceManager::DInputSourceListener::OnReceiveRelayStartTypeResult(int32_t status, - const std::string &srcId, const std::string &sinkId, uint32_t inputTypes) -{ - DHLOGI("status:%d, srcId: %s, sinkId: %s.", status, GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str()); - if (sourceManagerObj_ == nullptr) { - DHLOGE("sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - DHLOGE("GetCallbackEventHandler is null."); - return; - } - std::shared_ptr jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_SRC_DEVID] = srcId; - tmpJson[INPUT_SOURCEMANAGER_KEY_SINK_DEVID] = sinkId; - tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = status; - tmpJson[INPUT_SOURCEMANAGER_KEY_TYPE] = inputTypes; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = - AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_RELAY_STARTTYPE_RESULT_MMI, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - -void DistributedInputSourceManager::DInputSourceListener::OnReceiveRelayStopTypeResult(int32_t status, - const std::string &srcId, const std::string &sinkId, uint32_t inputTypes) -{ - DHLOGI("status:%d, srcId: %s, sinkId: %s.", status, GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str()); - if (sourceManagerObj_ == nullptr) { - DHLOGE("sourceManagerObj is null."); - return; - } - if (sourceManagerObj_->GetCallbackEventHandler() == nullptr) { - DHLOGE("GetCallbackEventHandler is null."); - return; - } - std::shared_ptr jsonArrayMsg = std::make_shared(); - nlohmann::json tmpJson; - tmpJson[INPUT_SOURCEMANAGER_KEY_SRC_DEVID] = srcId; - tmpJson[INPUT_SOURCEMANAGER_KEY_SINK_DEVID] = sinkId; - tmpJson[INPUT_SOURCEMANAGER_KEY_VALUE] = status; - tmpJson[INPUT_SOURCEMANAGER_KEY_TYPE] = inputTypes; - jsonArrayMsg->push_back(tmpJson); - AppExecFwk::InnerEvent::Pointer msgEvent = - AppExecFwk::InnerEvent::Get(DINPUT_SOURCE_MANAGER_RELAY_STOPTYPE_RESULT_MMI, jsonArrayMsg, 0); - sourceManagerObj_->GetCallbackEventHandler()->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - DistributedInputSourceManager::DInputSrcMgrListener::DInputSrcMgrListener(DistributedInputSourceManager *manager) { sourceManagerObj_ = manager; @@ -579,7 +102,6 @@ void DistributedInputSourceManager::OnStart() if (!ret) { return; } - DHLOGI("DistributedInputSourceManager start success."); } @@ -589,380 +111,15 @@ bool DistributedInputSourceManager::InitAuto() if (runner_ == nullptr) { return false; } - handler_ = std::make_shared(runner_); DHLOGI("init success"); std::shared_ptr runner = AppExecFwk::EventRunner::Create(true); - callBackHandler_ = std::make_shared(runner, this); - + callBackHandler_ = std::make_shared(runner, this); return true; } -DistributedInputSourceManager::DInputSourceManagerEventHandler::DInputSourceManagerEventHandler( - const std::shared_ptr &runner, DistributedInputSourceManager *manager) - : AppExecFwk::EventHandler(runner) -{ - eventFuncMap_[DINPUT_SOURCE_MANAGER_RIGISTER_MSG] = &DInputSourceManagerEventHandler::NotifyRegisterCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_UNRIGISTER_MSG] = &DInputSourceManagerEventHandler::NotifyUnregisterCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_PREPARE_MSG] = &DInputSourceManagerEventHandler::NotifyPrepareCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_UNPREPARE_MSG] = &DInputSourceManagerEventHandler::NotifyUnprepareCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_START_MSG] = &DInputSourceManagerEventHandler::NotifyStartCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_STOP_MSG] = &DInputSourceManagerEventHandler::NotifyStopCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_START_DHID_MSG] = &DInputSourceManagerEventHandler::NotifyStartDhidCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_STOP_DHID_MSG] = &DInputSourceManagerEventHandler::NotifyStopDhidCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_KEY_STATE_MSG] = &DInputSourceManagerEventHandler::NotifyKeyStateCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_STARTSERVER_MSG] = &DInputSourceManagerEventHandler::NotifyStartServerCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_TO_ORIGIN] = - &DInputSourceManagerEventHandler::NotifyRelayPrepareRemoteInput; - eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_TO_ORIGIN] = - &DInputSourceManagerEventHandler::NotifyRelayUnprepareRemoteInput; - eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_MMI] = - &DInputSourceManagerEventHandler::NotifyRelayPrepareCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_MMI] = - &DInputSourceManagerEventHandler::NotifyRelayUnprepareCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_STARTDHID_RESULT_MMI] = - &DInputSourceManagerEventHandler::NotifyRelayStartDhidCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_STOPDHID_RESULT_MMI] = - &DInputSourceManagerEventHandler::NotifyRelayStopDhidCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_STARTTYPE_RESULT_MMI] = - &DInputSourceManagerEventHandler::NotifyRelayStartTypeCallback; - eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_STOPTYPE_RESULT_MMI] = - &DInputSourceManagerEventHandler::NotifyRelayStopTypeCallback; - - sourceManagerObj_ = manager; -} - -DistributedInputSourceManager::DInputSourceManagerEventHandler::~DInputSourceManagerEventHandler() -{ - eventFuncMap_.clear(); - sourceManagerObj_ = nullptr; -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyRegisterCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - auto it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; - std::string dhId = innerMsg[INPUT_SOURCEMANAGER_KEY_HWID]; - bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - - InputDeviceId inputDeviceId {deviceId, dhId}; - std::vector tmpInputDevId = sourceManagerObj_->GetInputDeviceId(); - // Find out if the dh exists - auto devIt = std::find(tmpInputDevId.begin(), tmpInputDevId.end(), inputDeviceId); - if (devIt != tmpInputDevId.end()) { - if (result == false) { - sourceManagerObj_->RemoveInputDeviceId(deviceId, dhId); - } - } else { - DHLOGW("ProcessEvent DINPUT_SOURCE_MANAGER_RIGISTER_MSG the " - "devId: %s, dhId: %s is bad data.", GetAnonyString(deviceId).c_str(), GetAnonyString(dhId).c_str()); - } - - sourceManagerObj_->RunRegisterCallback(deviceId, dhId, - result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_REGISTER_MSG_IS_BAD); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyUnregisterCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - auto it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; - std::string dhId = innerMsg[INPUT_SOURCEMANAGER_KEY_HWID]; - bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - if (result) { - sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_OFF); - } - sourceManagerObj_->RunUnregisterCallback(deviceId, dhId, - result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNREGISTER_MSG_IS_BAD); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyPrepareCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - auto it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; - bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - std::string object = innerMsg[INPUT_SOURCEMANAGER_KEY_WHITELIST]; - - sourceManagerObj_->RunPrepareCallback(deviceId, - result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_MSG_IS_BAD, object); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyUnprepareCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - auto it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; - bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - if (result) { - sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_OFF); - } - sourceManagerObj_->RunUnprepareCallback(deviceId, - result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_MSG_IS_BAD); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyStartCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - auto it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; - uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_ITP]; - bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - DHLOGI("Start DInput Recv Callback ret: %s, devId: %s, inputTypes: %d", - result ? "true" : "false", GetAnonyString(deviceId).c_str(), inputTypes); - if (result) { - sourceManagerObj_->SetInputTypesMap( - deviceId, sourceManagerObj_->GetInputTypesMap(deviceId) | inputTypes); - } - sourceManagerObj_->SetStartTransFlag((result && (sourceManagerObj_->GetInputTypesMap(deviceId) > 0)) ? - DInputServerType::SOURCE_SERVER_TYPE : DInputServerType::NULL_SERVER_TYPE); - sourceManagerObj_->RunStartCallback(deviceId, inputTypes, - result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_MSG_IS_BAD); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyStopCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - auto it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; - uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_ITP]; - bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - - DHLOGI("Stop DInput Recv Callback ret: %B, devId: %s, inputTypes: %d", - result, GetAnonyString(deviceId).c_str(), inputTypes); - if (result && (sourceManagerObj_->GetInputTypesMap(deviceId) & inputTypes)) { - sourceManagerObj_->SetInputTypesMap( - deviceId, sourceManagerObj_->GetInputTypesMap(deviceId) - - (sourceManagerObj_->GetInputTypesMap(deviceId) & inputTypes)); - } - - if (sourceManagerObj_->GetInputTypesMap(deviceId) == 0) { - sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_OFF); - } - - // DeviceMap_ all sink device switch is off,call isstart's callback - bool isAllDevSwitchOff = sourceManagerObj_->GetDeviceMapAllDevSwitchOff(); - if (isAllDevSwitchOff) { - DHLOGI("All Dev Switch Off"); - sourceManagerObj_->SetStartTransFlag(DInputServerType::NULL_SERVER_TYPE); - } - sourceManagerObj_->RunStopCallback(deviceId, inputTypes, - result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_MSG_IS_BAD); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyStartDhidCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - auto it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; - std::string dhidStr = innerMsg[INPUT_SOURCEMANAGER_KEY_DHID]; - bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - - sourceManagerObj_->RunStartDhidCallback(deviceId, dhidStr, - result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_MSG_IS_BAD); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyStopDhidCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - auto it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; - std::string dhidStr = innerMsg[INPUT_SOURCEMANAGER_KEY_DHID]; - bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - - sourceManagerObj_->RunStopDhidCallback(deviceId, dhidStr, - result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_MSG_IS_BAD); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyKeyStateCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - auto it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; - std::string dhid = innerMsg[INPUT_SOURCEMANAGER_KEY_DHID]; - uint32_t keyType = innerMsg[INPUT_SOURCEMANAGER_KEY_TYPE]; - uint32_t keyCode = innerMsg[INPUT_SOURCEMANAGER_KEY_CODE]; - uint32_t keyValue = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; - - sourceManagerObj_->RunKeyStateCallback(deviceId, dhid, keyType, keyCode, keyValue); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyStartServerCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - auto it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - int32_t serType = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - DInputServerType startTransFlag = DInputServerType(serType); - sourceManagerObj_->SetStartTransFlag(startTransFlag); -} - - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyRelayPrepareCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - nlohmann::json::iterator it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; - std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; - std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; - - sourceManagerObj_->RunRelayPrepareCallback(srcId, sinkId, status); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyRelayUnprepareCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - nlohmann::json::iterator it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; - std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; - std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; - - sourceManagerObj_->RunRelayUnprepareCallback(srcId, sinkId, status); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyRelayPrepareRemoteInput( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - nlohmann::json::iterator it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; - bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - std::string object = innerMsg[INPUT_SOURCEMANAGER_KEY_WHITELIST]; - int32_t toSrcSessionId = innerMsg[INPUT_SOURCEMANAGER_KEY_SESSIONID]; - DHLOGI("Device whitelist object: %s", object.c_str()); - std::string localNetworkId = GetLocalNetworkId(); - if (localNetworkId.empty()) { - return; - } - - // notify to origin sourcesa result. - int32_t ret = DistributedInputSourceTransport::GetInstance().NotifyOriginPrepareResult(toSrcSessionId, - localNetworkId, deviceId, result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_MSG_IS_BAD); - if (ret != DH_SUCCESS) { - DHLOGE("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_TO_ORIGIN notify is fail."); - return; - } - sourceManagerObj_->RunWhiteListCallback(deviceId, object); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyRelayUnprepareRemoteInput( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - nlohmann::json::iterator it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; - bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - int32_t toSrcSessionId = innerMsg[INPUT_SOURCEMANAGER_KEY_SESSIONID]; - std::string localNetworkId = GetLocalNetworkId(); - if (localNetworkId.empty()) { - return; - } - - // notify to origin sourcesa result. - int32_t ret = DistributedInputSourceTransport::GetInstance().NotifyOriginUnprepareResult(toSrcSessionId, - localNetworkId, deviceId, result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_MSG_IS_BAD); - if (ret != DH_SUCCESS) { - DHLOGE("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_TO_ORIGIN notify is fail."); - return; - } -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyRelayStartDhidCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - nlohmann::json::iterator it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; - std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; - std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; - std::string dhids = innerMsg[INPUT_SOURCEMANAGER_KEY_DHID]; - - sourceManagerObj_->RunRelayStartDhidCallback(srcId, sinkId, status, dhids); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyRelayStopDhidCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - nlohmann::json::iterator it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; - std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; - std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; - std::string dhids = innerMsg[INPUT_SOURCEMANAGER_KEY_DHID]; - - sourceManagerObj_->RunRelayStopDhidCallback(srcId, sinkId, status, dhids); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyRelayStartTypeCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - nlohmann::json::iterator it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; - std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; - std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; - uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_TYPE]; - - sourceManagerObj_->RunRelayStartTypeCallback(srcId, sinkId, status, inputTypes); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyRelayStopTypeCallback( - const AppExecFwk::InnerEvent::Pointer &event) -{ - std::shared_ptr dataMsg = event->GetSharedObject(); - nlohmann::json::iterator it = dataMsg->begin(); - nlohmann::json innerMsg = *(it); - int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; - std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; - std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; - uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_TYPE]; - - sourceManagerObj_->RunRelayStopTypeCallback(srcId, sinkId, status, inputTypes); -} - -void DistributedInputSourceManager::DInputSourceManagerEventHandler::ProcessEvent( - const AppExecFwk::InnerEvent::Pointer &event) -{ - auto iter = eventFuncMap_.find(event->GetInnerEventId()); - if (iter == eventFuncMap_.end()) { - DHLOGE("Event Id %d is undefined.", event->GetInnerEventId()); - return; - } - SourceEventFunc &func = iter->second; - (this->*func)(event); -} - void DistributedInputSourceManager::OnStop() { DHLOGI("stop service"); @@ -1007,7 +164,6 @@ int32_t DistributedInputSourceManager::Init() DHLOGE("DInputState init fail!"); return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_INIT_FAIL; } - return DH_SUCCESS; } @@ -1114,8 +270,6 @@ int32_t DistributedInputSourceManager::RegisterDistributedHardware(const std::st DInputClientRegistInfo info {devId, dhId, callback}; regCallbacks_.push_back(info); InputDeviceId inputDeviceId {devId, dhId, GetNodeDesc(parameters)}; - DHLOGI("RegisterDistributedHardware deviceId: %s, dhId: %s", - GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); // 1.Find out if the dh exists auto it = std::find(inputDevice_.begin(), inputDevice_.end(), inputDeviceId); @@ -1246,7 +400,6 @@ int32_t DistributedInputSourceManager::CheckDeviceIsExists(const std::string &de } return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNREGISTER_FAIL; } - return DH_SUCCESS; } @@ -1299,8 +452,6 @@ int32_t DistributedInputSourceManager::UnregisterDistributedHardware(const std:: unregCallbacks_.push_back(info); InputDeviceId inputDeviceId {devId, dhId}; - DHLOGI("Unregister deviceId: %s, dhId: %s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); - auto it = inputDevice_.begin(); if (CheckDeviceIsExists(devId, dhId, inputDeviceId, it) != DH_SUCCESS) { DHLOGE("Unregister deviceId: %s is not exist.", GetAnonyString(devId).c_str()); @@ -1372,7 +523,6 @@ int32_t DistributedInputSourceManager::PrepareRemoteInput( } return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_FAIL; } - return DH_SUCCESS; } @@ -1415,7 +565,6 @@ int32_t DistributedInputSourceManager::UnprepareRemoteInput( } return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL; } - return DH_SUCCESS; } @@ -1460,7 +609,6 @@ int32_t DistributedInputSourceManager::StartRemoteInput( } return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; } - return DH_SUCCESS; } @@ -1504,7 +652,6 @@ int32_t DistributedInputSourceManager::StopRemoteInput( } return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; } - return DH_SUCCESS; } @@ -1639,7 +786,6 @@ int32_t DistributedInputSourceManager::RelayStartRemoteInputByType(const std::st } return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; } - return DH_SUCCESS; } @@ -1668,7 +814,6 @@ int32_t DistributedInputSourceManager::RelayStopRemoteInputByType( } return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; } - return DH_SUCCESS; } @@ -1714,7 +859,6 @@ int32_t DistributedInputSourceManager::PrepareRemoteInput(const std::string &src } return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_FAIL; } - return DH_SUCCESS; } @@ -2104,7 +1248,6 @@ int32_t DistributedInputSourceManager::RelayPrepareRemoteInput(const std::string } return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_FAIL; } - return DH_SUCCESS; } @@ -2133,7 +1276,6 @@ int32_t DistributedInputSourceManager::RelayUnprepareRemoteInput(const std::stri } return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL; } - return DH_SUCCESS; } @@ -2162,7 +1304,6 @@ int32_t DistributedInputSourceManager::RelayStartRemoteInputByDhid(const std::st } return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; } - return DH_SUCCESS; } @@ -2191,7 +1332,6 @@ int32_t DistributedInputSourceManager::RelayStopRemoteInputByDhid(const std::str } return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; } - return DH_SUCCESS; } @@ -2223,7 +1363,6 @@ void DistributedInputSourceManager::RunUnregisterCallback( return; } } - DHLOGE("ProcessEvent unregisterCallback is null."); } @@ -2240,7 +1379,6 @@ void DistributedInputSourceManager::RunPrepareCallback( return; } } - DHLOGE("ProcessEvent parepareCallback is null."); } @@ -2305,7 +1443,6 @@ void DistributedInputSourceManager::RunUnprepareCallback(const std::string &devI return; } } - DHLOGE("ProcessEvent unparepareCallback is null."); } @@ -2506,7 +1643,6 @@ std::vector DistributedInputSource void DistributedInputSourceManager::RemoveInputDeviceId(const std::string deviceId, const std::string dhId) { InputDeviceId inputDeviceId {deviceId, dhId}; - auto it = std::find(inputDevice_.begin(), inputDevice_.end(), inputDeviceId); if (it == inputDevice_.end()) { return; @@ -2600,38 +1736,6 @@ void DistributedInputSourceManager::DeleteSyncNodeInfo(const std::string &devId) syncNodeInfoMap_.erase(devId); } -void DistributedInputSourceManager::DInputSourceListener::RecordEventLog(int64_t when, int32_t type, int32_t code, - int32_t value, const std::string &path) -{ - std::string eventType = ""; - switch (type) { - case EV_KEY: - eventType = "EV_KEY"; - break; - case EV_REL: - eventType = "EV_REL"; - break; - case EV_ABS: - eventType = "EV_ABS"; - break; - default: - eventType = "other type"; - break; - } - DHLOGD("3.E2E-Test Source softBus receive event, EventType: %s, Code: %d, Value: %d, Path: %s, When: %" PRId64 "", - eventType.c_str(), code, value, path.c_str(), when); -} - -DistributedInputSourceManager::StartDScreenListener::StartDScreenListener() -{ - DHLOGI("StartDScreenListener ctor!"); -} - -DistributedInputSourceManager::StartDScreenListener::~StartDScreenListener() -{ - DHLOGI("StartDScreenListener dtor!"); -} - void DistributedInputSourceManager::StartDScreenListener::OnMessage(const DHTopic topic, const std::string &message) { DHLOGI("StartDScreenListener OnMessage!"); @@ -2743,16 +1847,6 @@ int32_t DistributedInputSourceManager::StartDScreenListener::UpdateSrcScreenInfo return DInputContext::GetInstance().UpdateSrcScreenInfo(srcScreenInfoKey, srcScreenInfo); } -DistributedInputSourceManager::StopDScreenListener::StopDScreenListener() -{ - DHLOGI("StopDScreenListener ctor!"); -} - -DistributedInputSourceManager::StopDScreenListener::~StopDScreenListener() -{ - DHLOGI("StopDScreenListener dtor!"); -} - void DistributedInputSourceManager::StopDScreenListener::OnMessage(const DHTopic topic, const std::string &message) { DHLOGI("StopDScreenListener OnMessage!"); @@ -2821,11 +1915,6 @@ DistributedInputSourceManager::DeviceOfflineListener::DeviceOfflineListener( sourceManagerContext_ = srcManagerContext; } -DistributedInputSourceManager::DeviceOfflineListener::~DeviceOfflineListener() -{ - DHLOGI("DeviceOfflineListener dtor!"); -} - void DistributedInputSourceManager::DeviceOfflineListener::OnMessage(const DHTopic topic, const std::string &message) { DHLOGI("DeviceOfflineListener OnMessage!"); @@ -2868,11 +1957,6 @@ DistributedInputSourceManager::DScreenSourceSvrRecipient::DScreenSourceSvrRecipi this->srcWinId_ = srcWinId; } -DistributedInputSourceManager::DScreenSourceSvrRecipient::~DScreenSourceSvrRecipient() -{ - DHLOGI("DScreenStatusListener dtor!"); -} - void DistributedInputSourceManager::DScreenSourceSvrRecipient::OnRemoteDied(const wptr &remote) { DHLOGI("DScreenStatusListener OnRemoveSystemAbility"); -- Gitee