From b4f5c51d9c976492f0024860240c2e0203df26c6 Mon Sep 17 00:00:00 2001 From: zhouyongfei Date: Mon, 21 Feb 2022 15:26:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=A4=9A=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E4=BC=98=E5=8C=96=E5=88=87=E6=8D=A2=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=B3=95=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyongfei --- services/src/input_method_system_ability.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index 2d59c93..b38c4e8 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -547,27 +547,30 @@ namespace MiscServices { IMSA_HILOGE("Aborted! %s\n", ErrorCode::ToString(ErrorCode::ERROR_BAD_PARAMETERS)); return ErrorCode::ERROR_BAD_PARAMETERS; } - std::string defaultIme = ParaHandle::GetDefaultIme(userId_); + std::string currentDefaultIme = ParaHandle::GetDefaultIme(userId_); int32_t userId = msg->msgContent_->ReadInt32(); userId_ = userId; IMSA_HILOGI("InputMethodSystemAbility::OnUserStarted userId = %{public}u", userId); + std::string newDefaultIme = ParaHandle::GetDefaultIme(userId_); + + if (newDefaultIme != currentDefaultIme) { + StopInputService(currentDefaultIme); + StartInputService(newDefaultIme); + } + PerUserSetting *setting = GetUserSetting(userId); if (setting != nullptr) { IMSA_HILOGE("Aborted! %s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_ALREADY_STARTED), userId); return ErrorCode::ERROR_USER_ALREADY_STARTED; } - StopInputService(defaultIme); - setting = new PerUserSetting(userId); setting->Initialize(); PerUserSession *session = new PerUserSession(userId); userSettings.insert(std::pair(userId, setting)); userSessions.insert(std::pair(userId, session)); - defaultIme = ParaHandle::GetDefaultIme(userId_); - StartInputService(defaultIme); return ErrorCode::NO_ERROR; }