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);