mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-27 00:41:04 +00:00
Signed-off-by: ma-shaoyin <mashaoyin1@huawei.com>
Changes to be committed:
This commit is contained in:
parent
56595f2842
commit
2ea7f4e288
@ -40,11 +40,10 @@ public:
|
||||
~ImCommonEventManager();
|
||||
static sptr<ImCommonEventManager> GetInstance();
|
||||
bool SubscribeEvent();
|
||||
bool SubscribeKeyboardEvent(KeyHandle handle);
|
||||
bool SubscribeKeyboardEvent(const Handler &handler);
|
||||
bool SubscribeWindowManagerService(const Handler &handler);
|
||||
bool SubscribeMemMgrService(const Handler &handler);
|
||||
bool SubscribeAccountManagerService(Handler handle);
|
||||
bool SubscribeMMIService(const Handler &handler);
|
||||
bool UnsubscribeEvent();
|
||||
// only public the status change of softKeyboard in FLG_FIXED or FLG_FLOATING
|
||||
int32_t PublishPanelStatusChangeEvent(int32_t userId, const InputWindowStatus &status, const ImeWindowInfo &info);
|
||||
|
@ -149,7 +149,6 @@ private:
|
||||
bool stop_ = false;
|
||||
void InitMonitors();
|
||||
int32_t InitKeyEventMonitor();
|
||||
bool InitMmiMonitor();
|
||||
bool InitWmsMonitor();
|
||||
void InitSystemLanguageMonitor();
|
||||
bool InitMemMgrMonitor();
|
||||
@ -172,7 +171,7 @@ private:
|
||||
// if switch input type need to switch ime, then no need to hide panel first.
|
||||
void NeedHideWhenSwitchInputType(int32_t userId, bool &needHide);
|
||||
bool GetDeviceFunctionKeyState(int32_t functionKey, bool &isEnable);
|
||||
bool CheckImeCfgCapsCorrect();
|
||||
bool ModifyImeCfgWithWrongCaps();
|
||||
void HandleBundleScanFinished();
|
||||
|
||||
std::mutex checkMutex_;
|
||||
|
@ -93,7 +93,7 @@ bool ImCommonEventManager::SubscribeEvent()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImCommonEventManager::SubscribeKeyboardEvent(KeyHandle handle)
|
||||
bool ImCommonEventManager::SubscribeKeyboardEvent(const Handler &handler)
|
||||
{
|
||||
IMSA_HILOGI("ImCommonEventManager::SubscribeKeyboardEvent start.");
|
||||
auto abilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
@ -101,10 +101,10 @@ bool ImCommonEventManager::SubscribeKeyboardEvent(KeyHandle handle)
|
||||
IMSA_HILOGE("SubscribeKeyboardEvent abilityManager is nullptr!");
|
||||
return false;
|
||||
}
|
||||
sptr<ISystemAbilityStatusChange> listener = new (std::nothrow) SystemAbilityStatusChangeListener([handle]() {
|
||||
int32_t ret = KeyboardEvent::GetInstance().AddKeyEventMonitor(handle);
|
||||
IMSA_HILOGI("SubscribeKeyboardEvent add monitor: %{public}s.",
|
||||
ret == ErrorCode::NO_ERROR ? "success" : "failed");
|
||||
sptr<ISystemAbilityStatusChange> listener = new (std::nothrow) SystemAbilityStatusChangeListener([handler]() {
|
||||
if (handler != nullptr) {
|
||||
handler();
|
||||
}
|
||||
});
|
||||
if (listener == nullptr) {
|
||||
IMSA_HILOGE("listener is nullptr!");
|
||||
@ -191,30 +191,6 @@ bool ImCommonEventManager::SubscribeAccountManagerService(Handler handler)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImCommonEventManager::SubscribeMMIService(const Handler &handler)
|
||||
{
|
||||
auto abilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (abilityManager == nullptr) {
|
||||
IMSA_HILOGE("abilityManager is nullptr!");
|
||||
return false;
|
||||
}
|
||||
sptr<ISystemAbilityStatusChange> listener = new (std::nothrow) SystemAbilityStatusChangeListener([handler]() {
|
||||
if (handler != nullptr) {
|
||||
handler();
|
||||
}
|
||||
});
|
||||
if (listener == nullptr) {
|
||||
IMSA_HILOGE("failed to create listener!");
|
||||
return false;
|
||||
}
|
||||
int32_t ret = abilityManager->SubscribeSystemAbility(MULTIMODAL_INPUT_SERVICE_ID, listener);
|
||||
if (ret != ERR_OK) {
|
||||
IMSA_HILOGE("subscribe system ability failed, ret: %{public}d", ret);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImCommonEventManager::UnsubscribeEvent()
|
||||
{
|
||||
return true;
|
||||
|
@ -1367,8 +1367,6 @@ void InputMethodSystemAbility::InitMonitors()
|
||||
IMSA_HILOGI("init KeyEvent monitor, ret: %{public}d.", ret);
|
||||
ret = InitWmsMonitor();
|
||||
IMSA_HILOGI("init wms monitor, ret: %{public}d.", ret);
|
||||
ret = InitMmiMonitor();
|
||||
IMSA_HILOGI("init MMI monitor, ret: %{public}d.", ret);
|
||||
InitSystemLanguageMonitor();
|
||||
if (ImeInfoInquirer::GetInstance().IsEnableInputMethod()) {
|
||||
IMSA_HILOGW("Enter enable mode.");
|
||||
@ -1403,8 +1401,15 @@ int32_t InputMethodSystemAbility::InitAccountMonitor()
|
||||
int32_t InputMethodSystemAbility::InitKeyEventMonitor()
|
||||
{
|
||||
IMSA_HILOGI("InputMethodSystemAbility::InitKeyEventMonitor start.");
|
||||
bool ret = ImCommonEventManager::GetInstance()->SubscribeKeyboardEvent(
|
||||
[this](uint32_t keyCode) { return SwitchByCombinationKey(keyCode); });
|
||||
auto handler = [this](){
|
||||
auto switchTrigger = [this](uint32_t keyCode) { return SwitchByCombinationKey(keyCode);};
|
||||
int32_t ret = KeyboardEvent::GetInstance().AddKeyEventMonitor(switchTrigger);
|
||||
IMSA_HILOGI("SubscribeKeyboardEvent add monitor: %{public}s.",
|
||||
ret == ErrorCode::NO_ERROR ? "success" : "failed");
|
||||
// Check device capslock status and ime cfg corrent, when device power-up.
|
||||
HandleImeCfgCapsState();
|
||||
};
|
||||
bool ret = ImCommonEventManager::GetInstance()->SubscribeKeyboardEvent(handler);
|
||||
return ret ? ErrorCode::NO_ERROR : ErrorCode::ERROR_SERVICE_START_FAILED;
|
||||
}
|
||||
|
||||
@ -1860,7 +1865,7 @@ void InputMethodSystemAbility::HandleBundleScanFinished()
|
||||
HandleImeCfgCapsState();
|
||||
}
|
||||
|
||||
bool InputMethodSystemAbility::CheckImeCfgCapsCorrect()
|
||||
bool InputMethodSystemAbility::ModifyImeCfgWithWrongCaps()
|
||||
{
|
||||
bool isCapsEnable = false;
|
||||
if (!GetDeviceFunctionKeyState(MMI::KeyEvent::CAPS_LOCK_FUNCTION_KEY, isCapsEnable)) {
|
||||
@ -1922,15 +1927,9 @@ void InputMethodSystemAbility::HandleImeCfgCapsState()
|
||||
IMSA_HILOGE("MMI service is not ready.");
|
||||
return;
|
||||
}
|
||||
if (!CheckImeCfgCapsCorrect()) {
|
||||
if (!ModifyImeCfgWithWrongCaps()) {
|
||||
IMSA_HILOGE("Check ImeCfg capslock state correct failed!");
|
||||
}
|
||||
}
|
||||
|
||||
bool InputMethodSystemAbility::InitMmiMonitor()
|
||||
{
|
||||
IMSA_HILOGI("InputMethodSystemAbility::InitMmiMonitor start.");
|
||||
return ImCommonEventManager::GetInstance()->SubscribeMMIService([this]() { HandleImeCfgCapsState(); });
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
Loading…
Reference in New Issue
Block a user