From b61148e53285ab79e46306bcf5bb4436bac63558 Mon Sep 17 00:00:00 2001 From: zhouyongfei Date: Wed, 9 Mar 2022 11:59:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=BB=E5=B9=B2bug?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyongfei --- .../src/input_method_ability.cpp | 9 ++-- .../src/input_method_core_proxy.cpp | 52 +++++++++++++++---- .../include/js_input_method_utils.h | 1 - .../src/js_editor_attribute.cpp | 2 - services/src/input_method_system_ability.cpp | 4 +- services/src/platform_callback_stub.cpp | 4 ++ 6 files changed, 55 insertions(+), 17 deletions(-) diff --git a/frameworks/inputmethod_ability/src/input_method_ability.cpp b/frameworks/inputmethod_ability/src/input_method_ability.cpp index 7e6ddfb..7a26b6b 100644 --- a/frameworks/inputmethod_ability/src/input_method_ability.cpp +++ b/frameworks/inputmethod_ability/src/input_method_ability.cpp @@ -426,7 +426,8 @@ namespace MiscServices { return; } - int32_t InputMethodAbility::GetEnterKeyType() { + int32_t InputMethodAbility::GetEnterKeyType() + { IMSA_HILOGI("InputMethodAbility::GetEnterKeyType"); if (inputDataChannel == nullptr) { @@ -436,7 +437,8 @@ namespace MiscServices { return inputDataChannel->GetEnterKeyType(); } - int32_t InputMethodAbility::GetInputPattern() { + int32_t InputMethodAbility::GetInputPattern() + { IMSA_HILOGI("InputMethodAbility::GetInputPattern"); if (inputDataChannel == nullptr) { @@ -446,7 +448,8 @@ namespace MiscServices { return inputDataChannel->GetInputPattern(); } - void InputMethodAbility::StopInput() { + void InputMethodAbility::StopInput() + { IMSA_HILOGI("InputMethodAbility::StopInput"); if (inputDataChannel == nullptr) { diff --git a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp index ba952c1..3adc7d5 100644 --- a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp +++ b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp @@ -32,6 +32,11 @@ namespace MiscServices { sptr &inputControlChannel) { IMSA_HILOGI("InputMethodCoreProxy::initializeInput"); + auto remote = Remote(); + if (remote == nullptr) { + IMSA_HILOGI("remote is nullptr"); + return ErrorCode::ERROR_NULL_POINTER; + } if (startInputToken == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::initializeInput startInputToken is nullptr"); } @@ -56,7 +61,7 @@ namespace MiscServices { MessageOption option { MessageOption::TF_SYNC }; - int32_t status = Remote()->SendRequest(INITIALIZE_INPUT, data, reply, option); + int32_t status = remote->SendRequest(INITIALIZE_INPUT, data, reply, option); if (status != ErrorCode::NO_ERROR) { IMSA_HILOGI("InputMethodCoreProxy::initializeInput status = %{public}d", status); return status; @@ -68,7 +73,11 @@ namespace MiscServices { int32_t InputMethodCoreProxy::InitInputControlChannel(sptr &inputControlChannel) { IMSA_HILOGI("InputMethodCoreProxy::InitInputControlChannel"); - + auto remote = Remote(); + if (remote == nullptr) { + IMSA_HILOGI("remote is nullptr"); + return ErrorCode::ERROR_NULL_POINTER; + } if (inputControlChannel == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::InitInputControlChannel inputControlChannel is nullptr"); return ErrorCode::ERROR_EX_NULL_POINTER; @@ -78,12 +87,13 @@ namespace MiscServices { sptr channelObject = inputControlChannel->AsObject(); if (channelObject == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::InitInputControlChannel channelObject is nullptr"); + return ErrorCode::ERROR_EX_NULL_POINTER; } data.WriteRemoteObject(channelObject); MessageOption option { MessageOption::TF_SYNC }; - int32_t status = Remote()->SendRequest(INIT_INPUT_CONTROL_CHANNEL, data, reply, option); + int32_t status = remote->SendRequest(INIT_INPUT_CONTROL_CHANNEL, data, reply, option); if (status != ErrorCode::NO_ERROR) { IMSA_HILOGI("InputMethodCoreProxy::InitInputControlChannel status = %{public}d", status); return status; @@ -95,6 +105,11 @@ namespace MiscServices { void InputMethodCoreProxy::SetClientState(bool state) { IMSA_HILOGI("InputMethodCoreProxy::SetClientState"); + auto remote = Remote(); + if (remote == nullptr) { + IMSA_HILOGI("remote is nullptr"); + return; + } MessageParcel data; if (!(data.WriteInterfaceToken(GetDescriptor()) && data.WriteBool(state))) { @@ -106,7 +121,7 @@ namespace MiscServices { MessageOption::TF_SYNC }; - int32_t status = Remote()->SendRequest(SET_CLIENT_STATE, data, reply, option); + int32_t status = remote->SendRequest(SET_CLIENT_STATE, data, reply, option); if (status != ErrorCode::NO_ERROR) { IMSA_HILOGI("InputMethodCoreProxy::SetClientState status = %{public}d", status); } @@ -115,6 +130,11 @@ namespace MiscServices { const InputAttribute& editorAttribute, bool supportPhysicalKbd) { IMSA_HILOGI("InputMethodCoreProxy::startInput"); + auto remote = Remote(); + if (remote == nullptr) { + IMSA_HILOGI("remote is nullptr"); + return false; + } if (inputDataChannel == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::startInput inputDataChannel is nullptr"); } @@ -132,7 +152,7 @@ namespace MiscServices { MessageOption::TF_SYNC }; - int32_t status = Remote()->SendRequest(START_INPUT, data, reply, option); + int32_t status = remote->SendRequest(START_INPUT, data, reply, option); if (status != ErrorCode::NO_ERROR) { IMSA_HILOGI("InputMethodCoreProxy::startInput status = %{public}d", status); return false; @@ -145,12 +165,17 @@ namespace MiscServices { int32_t InputMethodCoreProxy::stopInput() { IMSA_HILOGI("InputMethodCoreProxy::stopInput"); + auto remote = Remote(); + if (remote == nullptr) { + IMSA_HILOGI("remote is nullptr"); + return ErrorCode::ERROR_NULL_POINTER; + } MessageParcel data, reply; data.WriteInterfaceToken(GetDescriptor()); MessageOption option { MessageOption::TF_SYNC }; - int32_t status = Remote()->SendRequest(STOP_INPUT, data, reply, option); + int32_t status = remote->SendRequest(STOP_INPUT, data, reply, option); if (status != ErrorCode::NO_ERROR) { IMSA_HILOGI("InputMethodCoreProxy::stopInput status = %{public}d", status); return status; @@ -192,7 +217,6 @@ namespace MiscServices { void InputMethodCoreProxy::StopInputService(std::string imeId) { IMSA_HILOGI("InputMethodCoreProxy::StopInputService"); - auto remote = Remote(); if (remote == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::StopInputService remote is nullptr"); @@ -241,13 +265,18 @@ namespace MiscServices { int32_t InputMethodCoreProxy::setKeyboardType(const KeyboardType& type) { IMSA_HILOGI("InputMethodCoreProxy::setKeyboardType"); + auto remote = Remote(); + if (remote == nullptr) { + IMSA_HILOGI("remote is nullptr"); + return ErrorCode::ERROR_NULL_POINTER; + } MessageParcel data, reply; data.WriteInterfaceToken(GetDescriptor()); data.WriteParcelable(&type); MessageOption option { MessageOption::TF_SYNC }; - int32_t status = Remote()->SendRequest(SET_KEYBOARD_TYPE, data, reply, option); + int32_t status = remote->SendRequest(SET_KEYBOARD_TYPE, data, reply, option); if (status != ErrorCode::NO_ERROR) { return status; } @@ -258,12 +287,17 @@ namespace MiscServices { int32_t InputMethodCoreProxy::getKeyboardWindowHeight(int32_t retHeight) { IMSA_HILOGI("InputMethodCoreProxy::getKeyboardWindowHeight"); + auto remote = Remote(); + if (remote == nullptr) { + IMSA_HILOGI("remote is nullptr"); + return ErrorCode::ERROR_NULL_POINTER; + } MessageParcel data, reply; data.WriteInterfaceToken(GetDescriptor()); MessageOption option { MessageOption::TF_SYNC }; - int32_t status = Remote()->SendRequest(GET_KEYBOARD_WINDOW_HEIGHT, data, reply, option); + int32_t status = remote->SendRequest(GET_KEYBOARD_WINDOW_HEIGHT, data, reply, option); if (status != ErrorCode::NO_ERROR) { return status; } diff --git a/interfaces/kits/js/napi/inputmethod/include/js_input_method_utils.h b/interfaces/kits/js/napi/inputmethod/include/js_input_method_utils.h index fa32354..5fee57a 100644 --- a/interfaces/kits/js/napi/inputmethod/include/js_input_method_utils.h +++ b/interfaces/kits/js/napi/inputmethod/include/js_input_method_utils.h @@ -22,7 +22,6 @@ #include "js_input_method_setting.h" namespace OHOS { namespace MiscServices { -// class JsInputMethodSetting; NativeValue *CreateInputMethodSetting(NativeEngine& engine); NativeValue *CreateInputMethodController(NativeEngine& engine); } diff --git a/interfaces/kits/js/napi/inputmethodengine/src/js_editor_attribute.cpp b/interfaces/kits/js/napi/inputmethodengine/src/js_editor_attribute.cpp index b833d92..9612dd9 100644 --- a/interfaces/kits/js/napi/inputmethodengine/src/js_editor_attribute.cpp +++ b/interfaces/kits/js/napi/inputmethodengine/src/js_editor_attribute.cpp @@ -22,8 +22,6 @@ #include "input_method_ability.h" namespace OHOS { namespace MiscServices { -// constexpr size_t ARGC_ZERO = 0; - void JsEditorAttribute::Finalizer(NativeEngine* engine, void* data, void* hint) { IMSA_HILOGI("JsEditorAttribute::Finalizer is called"); diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index 177e6fb..68338ce 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -137,6 +137,7 @@ namespace MiscServices { state_ = ServiceRunningState::STATE_RUNNING; std::string defaultIme = ParaHandle::GetDefaultIme(userId_); StartInputService(defaultIme); + StartUserIdListener(); return ErrorCode::NO_ERROR; } @@ -182,8 +183,6 @@ namespace MiscServices { userId_ = MAIN_USER_ID; setting->Initialize(); - - StartUserIdListener(); } void InputMethodSystemAbility::StartUserIdListener() @@ -884,6 +883,7 @@ namespace MiscServices { IMSA_HILOGI("InputMethodSystemAbility::OnDisplayOptionalInputMethod has no ime"); return; } + std::string defaultIme = ParaHandle::GetDefaultIme(userId_); std::string params = ""; std::vector::iterator it; diff --git a/services/src/platform_callback_stub.cpp b/services/src/platform_callback_stub.cpp index e90a4e7..352b006 100644 --- a/services/src/platform_callback_stub.cpp +++ b/services/src/platform_callback_stub.cpp @@ -34,6 +34,10 @@ namespace MiscServices { int PlatformCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { + auto descriptorToken = data.ReadInterfaceToken(); + if (descriptorToken != GetDescriptor()) { + return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION; + } switch (code) { case NOTIFY_EVENT: { int eventId = data.ReadInt32();