diff --git a/frameworks/napi/input_consumer/include/js_register_module.h b/frameworks/napi/input_consumer/include/js_register_module.h index c6da2a7c2066d1a50038b98fcacd21e6474e7f1a..a4db1766df731e55f78ca3e628469cd75e13fea6 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 77524d908e302310a3e50d3d19ac6718ef51b91a..7e87db03c2dc039e5e8ed9115107c07876a7ea9b 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 0d7f904f9335ad00d49dd04829f11b646545a8c4..3705dfacad87f91578d88ee8ae17b946608a3858 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 c7744c8654400b6e7c2eed87eccd39827c79b15f..9eae2cc14241b53f2cdc4b88149c6e90980ca8fb 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;