diff --git a/frameworks/native/inputmethod_ability/src/input_method_ability.cpp b/frameworks/native/inputmethod_ability/src/input_method_ability.cpp index 34d34cc1..e5955ad0 100644 --- a/frameworks/native/inputmethod_ability/src/input_method_ability.cpp +++ b/frameworks/native/inputmethod_ability/src/input_method_ability.cpp @@ -1070,7 +1070,9 @@ void InputMethodAbility::OnClientInactive(const sptr &channel) IMSA_HILOGE("failed to create channel proxy!"); return; } - imeListener_->OnKeyboardStatus(false); + if (imeListener_ != nullptr) { + imeListener_->OnKeyboardStatus(false); + } panels_.ForEach([this, &channelProxy](const PanelType &panelType, const std::shared_ptr &panel) { if (panelType != PanelType::SOFT_KEYBOARD || panel->GetPanelFlag() != PanelFlag::FLG_FIXED) { auto ret = panel->HidePanel(false); diff --git a/frameworks/native/inputmethod_controller/src/input_method_controller.cpp b/frameworks/native/inputmethod_controller/src/input_method_controller.cpp index 7c54a4a1..fa097833 100644 --- a/frameworks/native/inputmethod_controller/src/input_method_controller.cpp +++ b/frameworks/native/inputmethod_controller/src/input_method_controller.cpp @@ -349,7 +349,9 @@ int32_t InputMethodController::Close() OperateIMEInfoCode infoCode = OperateIMEInfoCode::IME_UNBIND; { std::lock_guard lock(clientInfoLock_); - infoCode = clientInfo_.isShowKeyboard ? OperateIMEInfoCode::IME_HIDE_UNBIND : OperateIMEInfoCode::IME_UNBIND; + if (clientInfo_.isShowKeyboard) { + infoCode = OperateIMEInfoCode::IME_HIDE_UNBIND; + } } InputMethodSyncTrace tracer("InputMethodController Close trace."); InputMethodSysEvent::GetInstance().OperateSoftkeyboardBehaviour(infoCode); diff --git a/test/unittest/cpp_test/mock/ime_info_inquirer.h b/test/unittest/cpp_test/mock/ime_info_inquirer.h index 827098b2..57b4640a 100644 --- a/test/unittest/cpp_test/mock/ime_info_inquirer.h +++ b/test/unittest/cpp_test/mock/ime_info_inquirer.h @@ -32,8 +32,8 @@ public: std::shared_ptr GetDefaultImeInfo(int32_t userId); std::shared_ptr GetCurrentInputMethod(int32_t userId); std::shared_ptr GetDefaultImeCfgProp(); - bool GetImeAppId(int32_t userId, const std::string &bundleName, std::string &appId); - bool GetImeVersionCode(int32_t userId, const std::string &bundleName, uint32_t &versionCode); + static bool GetImeAppId(int32_t userId, const std::string &bundleName, std::string &appId); + static bool GetImeVersionCode(int32_t userId, const std::string &bundleName, uint32_t &versionCode); private: static std::shared_ptr defaultIme_;