From a2a4b163b7b42ed4c4ca9118cdf426debaac9f2f Mon Sep 17 00:00:00 2001 From: houchengyu2022 Date: Wed, 15 Mar 2023 20:09:27 +0800 Subject: [PATCH] fix warning Signed-off-by: houchengyu2022 --- .../input_consumer/include/js_register_module.h | 12 ++++++++++++ frameworks/proxy/events/include/event_log_helper.h | 8 +++++++- .../device_manager/src/input_device_manager.cpp | 14 ++++++++++++++ .../src/input_device_cooperate_sm.cpp | 11 +++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/frameworks/napi/input_consumer/include/js_register_module.h b/frameworks/napi/input_consumer/include/js_register_module.h index c6da2a7c20..a4db1766df 100644 --- a/frameworks/napi/input_consumer/include/js_register_module.h +++ b/frameworks/napi/input_consumer/include/js_register_module.h @@ -53,6 +53,18 @@ struct KeyEventMonitorInfo { napi_ref callback[1] {}; int32_t subscribeId { 0 }; std::shared_ptr keyOption { nullptr }; + bool valid { true }; + std::mutex refLock; + void SetValid(bool flag) + { + std::lock_guard lock(refLock); + valid = flag; + } + bool IsValid() + { + std::lock_guard lock(refLock); + return valid; + } }; typedef std::map> Callbacks; diff --git a/frameworks/proxy/events/include/event_log_helper.h b/frameworks/proxy/events/include/event_log_helper.h index 77524d908e..7e87db03c2 100644 --- a/frameworks/proxy/events/include/event_log_helper.h +++ b/frameworks/proxy/events/include/event_log_helper.h @@ -37,6 +37,11 @@ public: private: static void Print(const std::shared_ptr event) { + + if (!HiLogIsLoggable(OHOS::MMI::MMI_LOG_DOMAIN, LABEL.tag, LOG_DEBUG) + && event->GetKeyCode() != KeyEvent::KEYCODE_POWER) { + return; + } std::vector eventItems { event->GetKeyItems() }; MMI_HILOGD("KeyCode:%{public}d,ActionTime:%{public}" PRId64 ",ActionStartTime:%{public}" PRId64 ",EventType:%{public}s,Flag:%{public}d,KeyAction:%{public}s,NumLock:%{public}d," @@ -134,7 +139,8 @@ template void EventLogHelper::PrintEventData(std::shared_ptr event) { CHKPV(event); - if (HiLogIsLoggable(OHOS::MMI::MMI_LOG_DOMAIN, LABEL.tag, LOG_DEBUG)) { + if (HiLogIsLoggable(OHOS::MMI::MMI_LOG_DOMAIN, LABEL.tag, LOG_DEBUG) + || (event->GetAction() == InputEvent::EVENT_TYPE_KEY)) { EventLogHelper::Print(event); } } diff --git a/service/device_manager/src/input_device_manager.cpp b/service/device_manager/src/input_device_manager.cpp index 0d7f904f93..3705dfacad 100644 --- a/service/device_manager/src/input_device_manager.cpp +++ b/service/device_manager/src/input_device_manager.cpp @@ -675,6 +675,20 @@ bool InputDeviceManager::HasLocalPointerDevice() const return false; } +void InputDeviceManager::NotifyVirtualKeyBoardStatus(int32_t deviceId, bool isAvailable) const +{ + MMI_HILOGI("virtual keyboard device %{public}s", isAvailable ? "online" : "offline"); + if (deviceId == -1) { + MMI_HILOGE("no virtual keyboard device for this device!"); + return; + } + + for (const auto &item : devListener_) { + CHKPC(item.first); + item.second(deviceId, isAvailable ? "add" : "remove"); + } +} + std::string InputDeviceManager::MakeNetworkId(const char *phys) const { std::string networkId; diff --git a/service/input_device_cooperate/src/input_device_cooperate_sm.cpp b/service/input_device_cooperate/src/input_device_cooperate_sm.cpp index c7744c8654..9eae2cc142 100755 --- a/service/input_device_cooperate/src/input_device_cooperate_sm.cpp +++ b/service/input_device_cooperate/src/input_device_cooperate_sm.cpp @@ -142,6 +142,17 @@ void InputDeviceCooperateSM::OnCloseCooperation(const std::string &networkId, bo } } +void InputDeviceCooperateSM::SetVirtualKeyBoardDevId(int32_t deviceId) +{ + virtualKeyBoardId_ = deviceId; + MMI_HILOGI("virtualKeyBoardId_ has been set to%{public}d", virtualKeyBoardId_); +} + +int32_t InputDeviceCooperateSM::GetVirtualKeyBoardDevId() +{ + return virtualKeyBoardId_; +} + void InputDeviceCooperateSM::GetCooperateState(const std::string &deviceId) { CALL_INFO_TRACE; -- Gitee