mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-23 06:40:06 +00:00
fix:add shortcut switch inputmethod sysevent
Signed-off-by: 吴成文 <wuchengwen4@huawei.com>
This commit is contained in:
parent
11656567fb
commit
2aef4039ca
@ -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"
|
||||
|
@ -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;
|
||||
|
@ -203,5 +203,15 @@ bool InputMethodSysEvent::StartTimerForReport()
|
||||
std::lock_guard<std::mutex> 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
|
19
hisysevent_ue.yaml
Normal file
19
hisysevent_ue.yaml
Normal file
@ -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'}
|
@ -22,10 +22,6 @@ namespace MiscServices {
|
||||
uint32_t InputEventCallback::keyState_ = static_cast<uint32_t>(0);
|
||||
bool InputEventCallback::isKeyHandled_ = false;
|
||||
const std::map<int32_t, uint8_t> 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 },
|
||||
};
|
||||
|
||||
|
@ -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<MMI::KeyEvent> 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<MMI::KeyEvent> 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;
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user