diff --git a/bundle.json b/bundle.json index 9393e7a0..6a531577 100644 --- a/bundle.json +++ b/bundle.json @@ -19,7 +19,8 @@ "imf_screenlock_mgr_enable" ], "hisysevent_config": [ - "//base/inputmethod/imf/hisysevent.yaml" + "//base/inputmethod/imf/hisysevent.yaml", + "//base/inputmethod/imf/hisysevent_ue.yaml" ], "adapted_system_type": [ "standard" diff --git a/common/include/inputmethod_sysevent.h b/common/include/inputmethod_sysevent.h index 4278fcaf..217d208a 100644 --- a/common/include/inputmethod_sysevent.h +++ b/common/include/inputmethod_sysevent.h @@ -55,6 +55,7 @@ public: void ReportImeState(ImeState state, pid_t pid, const std::string &bundleName); bool StartTimerForReport(); void SetUserId(int32_t userId); + void ReportSystemShortCut(const std::string &shortcutName); private: InputMethodSysEvent() = default; diff --git a/common/src/inputmethod_sysevent.cpp b/common/src/inputmethod_sysevent.cpp index 3ebda2b5..6403a5a1 100644 --- a/common/src/inputmethod_sysevent.cpp +++ b/common/src/inputmethod_sysevent.cpp @@ -203,5 +203,15 @@ bool InputMethodSysEvent::StartTimerForReport() std::lock_guard lock(timerLock_); return StartTimer(reportCallback, ONE_DAY_IN_HOURS * ONE_HOUR_IN_SECONDS * SECONDS_TO_MILLISECONDS); } + +void InputMethodSysEvent::ReportSystemShortCut(const std::string &shortcutName) +{ + IMSA_HILOGD("run in."); + int32_t ret = HiSysEventWrite(HiSysEventNameSpace::Domain::INPUTMETHOD_UE, "SYSTEM_SHORTCUT", + HiSysEventNameSpace::EventType::BEHAVIOR, "PROCESS_NAME", "inputmethod_service", "SHORTCUT_NAME", shortcutName); + if (ret != HiviewDFX::SUCCESS) { + IMSA_HILOGE("system shortcut: %{public}s report failed! ret: %{public}d", shortcutName.c_str(), ret); + } +} } // namespace MiscServices } // namespace OHOS \ No newline at end of file diff --git a/hisysevent_ue.yaml b/hisysevent_ue.yaml new file mode 100644 index 00000000..9c1c66ee --- /dev/null +++ b/hisysevent_ue.yaml @@ -0,0 +1,19 @@ +# Copyright (c) 2024 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. + +domain: INPUTMETHOD_UE + +SYSTEM_SHORTCUT: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: Operating the input method through system shortcuts, preserve: true} + PROCESS_NAME: {type: STRING, desc: 'process name'} + SHORTCUT_NAME: {type: STRING, desc: 'system shortcut name'} \ No newline at end of file diff --git a/services/adapter/keyboard/src/input_event_callback.cpp b/services/adapter/keyboard/src/input_event_callback.cpp index 990bc3fe..991e6dbd 100644 --- a/services/adapter/keyboard/src/input_event_callback.cpp +++ b/services/adapter/keyboard/src/input_event_callback.cpp @@ -22,10 +22,6 @@ namespace MiscServices { uint32_t InputEventCallback::keyState_ = static_cast(0); bool InputEventCallback::isKeyHandled_ = false; const std::map MASK_MAP{ - { MMI::KeyEvent::KEYCODE_SHIFT_LEFT, KeyboardEvent::SHIFT_LEFT_MASK }, - { MMI::KeyEvent::KEYCODE_SHIFT_RIGHT, KeyboardEvent::SHIFT_RIGHT_MASK }, - { MMI::KeyEvent::KEYCODE_CTRL_LEFT, KeyboardEvent::CTRL_LEFT_MASK }, - { MMI::KeyEvent::KEYCODE_CTRL_RIGHT, KeyboardEvent::CTRL_RIGHT_MASK }, { MMI::KeyEvent::KEYCODE_CAPS_LOCK, KeyboardEvent::CAPS_MASK }, }; diff --git a/services/adapter/keyboard/src/keyboard_event.cpp b/services/adapter/keyboard/src/keyboard_event.cpp index 9c13cd89..c5b00ad2 100644 --- a/services/adapter/keyboard/src/keyboard_event.cpp +++ b/services/adapter/keyboard/src/keyboard_event.cpp @@ -21,6 +21,7 @@ #include "global.h" #include "input_event_callback.h" #include "key_event.h" +#include "inputmethod_sysevent.h" namespace OHOS { namespace MiscServices { @@ -50,6 +51,7 @@ int32_t KeyboardEvent::AddKeyEventMonitor(KeyHandle handle) IMSA_HILOGD("add monitor success, id: %{public}d.", monitorId); CombinationKeyCallBack combinationKeyCallBack = [callback](std::shared_ptr keyEvent) { + InputMethodSysEvent::GetInstance().ReportSystemShortCut("usual.event.WIN_SPACE"); if (callback == nullptr) { IMSA_HILOGE("callback is nullptr!"); return; @@ -58,6 +60,20 @@ int32_t KeyboardEvent::AddKeyEventMonitor(KeyHandle handle) }; SubscribeCombinationKey(MMI::KeyEvent::KEYCODE_META_LEFT, MMI::KeyEvent::KEYCODE_SPACE, combinationKeyCallBack); SubscribeCombinationKey(MMI::KeyEvent::KEYCODE_META_RIGHT, MMI::KeyEvent::KEYCODE_SPACE, combinationKeyCallBack); + + CombinationKeyCallBack ctrlShiftCallBack = [callback](std::shared_ptr keyEvent) { + InputMethodSysEvent::GetInstance().ReportSystemShortCut("usual.event.CTRL_SHIFT"); + if (callback == nullptr) { + IMSA_HILOGE("callback is nullptr!"); + return; + } + callback->TriggerSwitch(); + }; + + SubscribeCombinationKey(MMI::KeyEvent::KEYCODE_CTRL_LEFT, MMI::KeyEvent::KEYCODE_SHIFT_LEFT, ctrlShiftCallBack); + SubscribeCombinationKey(MMI::KeyEvent::KEYCODE_CTRL_LEFT, MMI::KeyEvent::KEYCODE_SHIFT_RIGHT, ctrlShiftCallBack); + SubscribeCombinationKey(MMI::KeyEvent::KEYCODE_CTRL_RIGHT, MMI::KeyEvent::KEYCODE_SHIFT_LEFT, ctrlShiftCallBack); + SubscribeCombinationKey(MMI::KeyEvent::KEYCODE_CTRL_RIGHT, MMI::KeyEvent::KEYCODE_SHIFT_RIGHT, ctrlShiftCallBack); return ErrorCode::NO_ERROR; } diff --git a/services/adapter/settings_data_provider/BUILD.gn b/services/adapter/settings_data_provider/BUILD.gn index 1a9416c4..1d7101a3 100644 --- a/services/adapter/settings_data_provider/BUILD.gn +++ b/services/adapter/settings_data_provider/BUILD.gn @@ -56,6 +56,7 @@ ohos_static_library("settings_data_static") { "data_share:datashare_consumer", "hilog:libhilog", "resource_management:global_resmgr", + "samgr:samgr_proxy", ] subsystem_name = "inputmethod"