From f1ed6306e76bd732ba5395fd2e2ca29d2dff3396 Mon Sep 17 00:00:00 2001 From: zhouyongfei Date: Wed, 16 Mar 2022 14:33:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A9=BA=E6=8C=87=E9=92=88?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyongfei --- .../src/input_method_core_proxy.cpp | 3 +++ services/src/input_method_system_ability.cpp | 14 ++++++++------ services/src/peruser_session.cpp | 1 + 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp index 3adc7d5..6b16bbf 100644 --- a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp +++ b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp @@ -43,6 +43,7 @@ namespace MiscServices { if (inputControlChannel == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::initializeInput inputControlChannel is nullptr"); + return ErrorCode::ERROR_NULL_POINTER; } IMSA_HILOGI("InputMethodCoreProxy::initializeInput displayId = %{public}d", displayId); MessageParcel data, reply; @@ -51,6 +52,7 @@ namespace MiscServices { sptr channelObject = inputControlChannel->AsObject(); if (channelObject == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::initializeInput channelObject is nullptr"); + return ErrorCode::ERROR_NULL_POINTER; } bool wor = data.WriteRemoteObject(channelObject); if (wor) { @@ -137,6 +139,7 @@ namespace MiscServices { } if (inputDataChannel == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::startInput inputDataChannel is nullptr"); + return false; } MessageParcel data; diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index 68338ce..7d35050 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -209,11 +209,11 @@ namespace MiscServices { if (it == msgHandlers.end()) { IMSA_HILOGE("InputMethodSystemAbility::StartInputService() need start handler"); MessageHandler *handler = new MessageHandler(); - if (session == nullptr) { - IMSA_HILOGE("InputMethodSystemAbility::OnPrepareInput session is nullptr"); + if (session != nullptr) { + IMSA_HILOGE("InputMethodSystemAbility::OnPrepareInput session is not nullptr"); + session->CreateWorkThread(*handler); + msgHandlers.insert(std::pair(MAIN_USER_ID, handler)); } - session->CreateWorkThread(*handler); - msgHandlers.insert(std::pair(MAIN_USER_ID, handler)); } bool isStartSuccess = false; @@ -245,6 +245,7 @@ namespace MiscServices { PerUserSession *session = GetUserSession(MAIN_USER_ID); if (session == nullptr){ IMSA_HILOGE("InputMethodSystemAbility::StopInputService abort session is nullptr"); + return; } session->StopInputService(imeId); @@ -723,8 +724,6 @@ namespace MiscServices { } if (setting == nullptr || setting->GetUserState() != UserState::USER_STATE_UNLOCKED) { IMSA_HILOGE("InputMethodSystemAbility::OnHandleMessage Aborted! userId = %{public}d,", userId); - IMSA_HILOGE("InputMethodSystemAbility::OnHandleMessage Aborted! userState = %{public}d", - setting->GetUserState()); return ErrorCode::ERROR_USER_NOT_UNLOCKED; } @@ -848,6 +847,9 @@ namespace MiscServices { return ErrorCode::ERROR_USER_NOT_UNLOCKED; } PerUserSession *session = GetUserSession(userId); + if (session == nullptr) { + return ErrorCode::ERROR_NULL_POINTER; + } int32_t ret = session->OnSettingChanged(updatedKey, updatedValue); if (ret == ErrorCode::ERROR_SETTING_SAME_VALUE) { IMSA_HILOGI("End...No need to update\n"); diff --git a/services/src/peruser_session.cpp b/services/src/peruser_session.cpp index 5682952..a0275db 100644 --- a/services/src/peruser_session.cpp +++ b/services/src/peruser_session.cpp @@ -1182,6 +1182,7 @@ namespace MiscServices { InputAttribute *attribute = data->ReadParcelable(); if (attribute == nullptr) { IMSA_HILOGI("PerUserSession::OnPrepareInput attribute is nullptr"); + return; } int ret = AddClient(pid, uid, displayId, client, channel, *attribute);