From adb0cea38ad77e7eb2780b0cd23cd130fa02d4c8 Mon Sep 17 00:00:00 2001 From: zhouyongfei Date: Mon, 11 Oct 2021 19:05:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=BB=B6=E8=BF=9F3=E7=A7=92?= =?UTF-8?q?=E6=8B=89=E8=B5=B7=E8=BE=93=E5=85=A5=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyongfei --- .../include/input_method_controller.h | 4 ++-- .../src/input_method_controller.cpp | 6 +++--- services/include/peruser_session.h | 1 + services/src/peruser_session.cpp | 9 +++++++++ unitest/src/input_method_controller_test.cpp | 4 ++-- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/frameworks/inputmethod_controller/include/input_method_controller.h b/frameworks/inputmethod_controller/include/input_method_controller.h index 84f9902..f1ec5d6 100644 --- a/frameworks/inputmethod_controller/include/input_method_controller.h +++ b/frameworks/inputmethod_controller/include/input_method_controller.h @@ -47,8 +47,8 @@ namespace MiscServices { class InputMethodController : public RefBase { public: static sptr GetInstance(); - void Attach(); - void ShowTextInput(sptr &listener); + void Attach(sptr &listener); + void ShowTextInput(); void HideTextInput(); void Close(); void OnRemoteSaDied(const wptr &object); diff --git a/frameworks/inputmethod_controller/src/input_method_controller.cpp b/frameworks/inputmethod_controller/src/input_method_controller.cpp index f695006..5e926d3 100644 --- a/frameworks/inputmethod_controller/src/input_method_controller.cpp +++ b/frameworks/inputmethod_controller/src/input_method_controller.cpp @@ -156,15 +156,15 @@ using namespace MessageID; } } - void InputMethodController::Attach() + void InputMethodController::Attach(sptr &listener) { PrepareInput(0, mClient, mInputDataChannel, mAttribute); + textListener=listener; } - void InputMethodController::ShowTextInput(sptr &listener) + void InputMethodController::ShowTextInput() { IMSA_HILOGI("InputMethodController::ShowTextInput"); - textListener = listener; StartInput(mClient); } diff --git a/services/include/peruser_session.h b/services/include/peruser_session.h index edfb3b8..77fdbb5 100644 --- a/services/include/peruser_session.h +++ b/services/include/peruser_session.h @@ -124,6 +124,7 @@ namespace MiscServices { int MIN_IME = 2; int IME_ERROR_CODE = 3; int COMMON_COUNT_THREE_HUNDRED = 300; + int SLEEP_TIME = 300000; InputMethodProperty *currentIme[MAX_IME]; // 0 - the default ime. 1 - security ime diff --git a/services/src/peruser_session.cpp b/services/src/peruser_session.cpp index 8430fbc..7884b3c 100644 --- a/services/src/peruser_session.cpp +++ b/services/src/peruser_session.cpp @@ -1305,6 +1305,15 @@ namespace MiscServices { } else { IMSA_HILOGI("PerUserSession::onSetInputMethodCore End...[%{public}d]\n", userId_); } + if (currentClient != nullptr) { + usleep(SLEEP_TIME); + ret = ShowKeyboard(currentClient); + if (ret != ErrorCode::NO_ERROR) { + IMSA_HILOGE("PerUserSession::OnStartInput Aborted! %{public}s", ErrorCode::ToString(ret)); + } else { + IMSA_HILOGI("PerUserSession::OnStartInput End...[%{public}d]\n", userId_); + } + } } /*! Stop input. Called by an input client. diff --git a/unitest/src/input_method_controller_test.cpp b/unitest/src/input_method_controller_test.cpp index dc95211..4a41ce7 100644 --- a/unitest/src/input_method_controller_test.cpp +++ b/unitest/src/input_method_controller_test.cpp @@ -198,12 +198,12 @@ namespace MiscServices { sptr textListener = new TextListener(); IMSA_HILOGI("IMC Attach START"); - imc->Attach(); + imc->Attach(textListener); int waitForStatusOk = 2; sleep(waitForStatusOk); IMSA_HILOGI("IMC ShowTextInput START"); - imc->ShowTextInput(textListener); + imc->ShowTextInput(); sleep(10); IMSA_HILOGI("IMC HideTextInput START");