diff --git a/frameworks/inputmethod_ability/include/i_input_method_core.h b/frameworks/inputmethod_ability/include/i_input_method_core.h index d3f38fa14ceae2fc2d7a2d841d1f5ff0aceaeebe..22bdda39680377a47242d59f646617c1df3d5219 100644 --- a/frameworks/inputmethod_ability/include/i_input_method_core.h +++ b/frameworks/inputmethod_ability/include/i_input_method_core.h @@ -34,6 +34,7 @@ namespace MiscServices { public: enum { INITIALIZE_INPUT = FIRST_CALL_TRANSACTION, + SET_CLIENT_STATE, START_INPUT, STOP_INPUT, SHOW_KEYBOARD, @@ -56,6 +57,7 @@ namespace MiscServices { virtual int32_t setKeyboardType(const KeyboardType& type) = 0; virtual int32_t getKeyboardWindowHeight(int32_t retHeight) = 0; virtual int32_t InitInputControlChannel(sptr &inputControlChannel) = 0; + virtual void SetClientState(bool state) = 0; }; } } diff --git a/frameworks/inputmethod_ability/include/input_method_ability.h b/frameworks/inputmethod_ability/include/input_method_ability.h index 3c8dfaddc5473d439b289f286e0cdd460116d0e7..88dce9dc6b1db143f9d91b9dc8ad303ecbfc09a6 100644 --- a/frameworks/inputmethod_ability/include/input_method_ability.h +++ b/frameworks/inputmethod_ability/include/input_method_ability.h @@ -64,6 +64,7 @@ namespace MiscServices { bool stop_; int32_t KEYBOARD_HIDE = 1; int32_t KEYBOARD_SHOW = 2; + bool isBindClient = false; // communicating with IMSA sptr inputControlChannel; diff --git a/frameworks/inputmethod_ability/include/input_method_core_proxy.h b/frameworks/inputmethod_ability/include/input_method_core_proxy.h index 32be7cada3daed0ee35bfdae5d0b1c98f9fa4a7c..91923f1be7f2e57681233c2131e45ddd4b1b68f7 100644 --- a/frameworks/inputmethod_ability/include/input_method_core_proxy.h +++ b/frameworks/inputmethod_ability/include/input_method_core_proxy.h @@ -45,7 +45,7 @@ namespace MiscServices { virtual int32_t setKeyboardType(const KeyboardType& type) override; virtual int32_t getKeyboardWindowHeight(int32_t retHeight) override; virtual int32_t InitInputControlChannel(sptr &inputControlChannel) override; - + virtual void SetClientState(bool state) override; private: static inline BrokerDelegator delegator_; }; diff --git a/frameworks/inputmethod_ability/include/input_method_core_stub.h b/frameworks/inputmethod_ability/include/input_method_core_stub.h index 9c22c43dde11c63fe657472e7820af260a70b905..b314264357b0a9b778ea5395fed82feaa322a183 100644 --- a/frameworks/inputmethod_ability/include/input_method_core_stub.h +++ b/frameworks/inputmethod_ability/include/input_method_core_stub.h @@ -54,6 +54,7 @@ namespace MiscServices { virtual int32_t setKeyboardType(const KeyboardType& type) override; virtual int32_t getKeyboardWindowHeight(int32_t retHeight) override; virtual int32_t InitInputControlChannel(sptr &inputControlChannel) override; + virtual void SetClientState(bool state) override; void SetMessageHandler(MessageHandler *msgHandler); private: diff --git a/frameworks/inputmethod_ability/src/input_method_ability.cpp b/frameworks/inputmethod_ability/src/input_method_ability.cpp index 6fff11462445f4b1da136bd6bd911f32a48b9417..03ead7f7f9a9fac562bb1d217d820b21944969a1 100644 --- a/frameworks/inputmethod_ability/src/input_method_ability.cpp +++ b/frameworks/inputmethod_ability/src/input_method_ability.cpp @@ -138,6 +138,11 @@ namespace MiscServices { OnInitInputControlChannel(msg); break; } + case MSG_ID_SET_CLIENT_STATE: { + MessageParcel *data = msg->msgContent_; + isBindClient = data->ReadBool(); + break; + } case MSG_ID_START_INPUT: { OnStartInput(msg); break; @@ -252,6 +257,10 @@ namespace MiscServices { { IMSA_HILOGI("InputMethodAbility::DispatchKeyEvent"); IMSA_HILOGI("InputMethodAbility::DispatchKeyEvent: key = %{public}d, status = %{public}d", keyCode, keyStatus); + if (!isBindClient) { + IMSA_HILOGI("InputMethodAbility::DispatchKeyEvent abort. no client"); + return false; + } return imeListener_->OnKeyEvent(keyCode, keyStatus); } diff --git a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp index fde9c990cb86248cfc8690c756f70ec8c26405bf..2155aa3f0fa0ec9e8e683deaec828ffc49fd82b0 100644 --- a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp +++ b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp @@ -90,6 +90,25 @@ namespace MiscServices { return code; } + void InputMethodCoreProxy::SetClientState(bool state) + { + IMSA_HILOGI("InputMethodCoreProxy::SetClientState"); + MessageParcel data; + if (!(data.WriteInterfaceToken(GetDescriptor()) + && data.WriteBool(state))) { + IMSA_HILOGI("InputMethodCoreProxy::SetClientState write error"); + return; + } + MessageParcel reply; + MessageOption option { + MessageOption::TF_SYNC + }; + + int32_t status = Remote()->SendRequest(SET_CLIENT_STATE, data, reply, option); + if (status != ErrorCode::NO_ERROR) { + IMSA_HILOGI("InputMethodCoreProxy::SetClientState status = %{public}d", status); + } + } bool InputMethodCoreProxy::startInput(const sptr &inputDataChannel, const InputAttribute& editorAttribute, bool supportPhysicalKbd) { diff --git a/frameworks/inputmethod_ability/src/input_method_core_stub.cpp b/frameworks/inputmethod_ability/src/input_method_core_stub.cpp index 6ee000231b372deb4a11592612fe4a0dbaa87ffd..f8717704d0bafe2792fa140c7c4bc5ea476f62eb 100644 --- a/frameworks/inputmethod_ability/src/input_method_core_stub.cpp +++ b/frameworks/inputmethod_ability/src/input_method_core_stub.cpp @@ -94,6 +94,11 @@ namespace MiscServices { reply.WriteNoException(); break; } + case SET_CLIENT_STATE: { + bool state = data.ReadBool(); + SetClientState(state); + break; + } case STOP_INPUT: { stopInput(); reply.WriteNoException(); @@ -201,6 +206,18 @@ namespace MiscServices { return ErrorCode::NO_ERROR; } + void InputMethodCoreStub::SetClientState(bool state) + { + IMSA_HILOGI("InputMethodCoreStub::SetClientState"); + if (msgHandler_ == nullptr) { + return; + } + MessageParcel *data = new MessageParcel(); + + Message *msg = new Message(MessageID::MSG_ID_SET_CLIENT_STATE, data); + msgHandler_->SendMessage(msg); + } + bool InputMethodCoreStub::showKeyboard(const sptr& inputDataChannel) { IMSA_HILOGI("InputMethodCoreStub::showKeyboard"); diff --git a/services/include/message_handler.h b/services/include/message_handler.h index d5a41ce1fd7dbeaa08cb5e58b176252125cc719e..3a12967ceff23666d1db462e1ac89b5b1a925fcc 100644 --- a/services/include/message_handler.h +++ b/services/include/message_handler.h @@ -70,6 +70,7 @@ namespace MessageID { MSG_ID_MOVE_CURSOR, // the request from IMSA to IMA + MSG_ID_SET_CLIENT_STATE, MSG_ID_SHOW_KEYBOARD, MSG_ID_INITIALIZE_INPUT, MSG_ID_HIDE_KEYBOARD, diff --git a/services/src/peruser_session.cpp b/services/src/peruser_session.cpp index dfc9ad69587ad45a4e143eb4c42ddfed5f3f3730..aacb8c8fe9481765bde553f429b6860880153a7d 100644 --- a/services/src/peruser_session.cpp +++ b/services/src/peruser_session.cpp @@ -1218,6 +1218,7 @@ namespace MiscServices { sptr client = new InputClientProxy(clientObject); sptr interface = client; int remainClientNum = 0; + imsCore[0]->SetClientState(false); HideKeyboard(client); int ret = RemoveClient(client, remainClientNum); if (ret != ErrorCode::NO_ERROR) { @@ -1237,6 +1238,7 @@ namespace MiscServices { MessageParcel *data = msg->msgContent_; sptr clientObject = data->ReadRemoteObject(); sptr client = new InputClientProxy(clientObject); + imsCore[0]->SetClientState(true); ShowKeyboard(client); }