diff --git a/common/src/itypes_util.cpp b/common/src/itypes_util.cpp index 9ff020fe..e8001545 100644 --- a/common/src/itypes_util.cpp +++ b/common/src/itypes_util.cpp @@ -120,6 +120,7 @@ bool ITypesUtil::Unmarshalling(sptr &output, MessageParcel &data) output = data.ReadRemoteObject(); return true; } + bool ITypesUtil::Marshalling(const Property &input, MessageParcel &data) { if (!Marshal(data, input.name, input.id, input.label, input.labelId, input.icon, input.iconId)) { @@ -248,7 +249,7 @@ bool ITypesUtil::Unmarshalling(TextTotalConfig &output, MessageParcel &data) bool ITypesUtil::Marshalling(const InputClientInfo &input, MessageParcel &data) { if (!Marshal(data, input.pid, input.uid, input.userID, input.isShowKeyboard, input.eventFlag, input.config, - input.state, input.isNotifyInputStart, input.client->AsObject(), input.channel->AsObject())) { + input.state, input.isNotifyInputStart)) { IMSA_HILOGE("write InputClientInfo to message parcel failed"); return false; } @@ -262,14 +263,6 @@ bool ITypesUtil::Unmarshalling(InputClientInfo &output, MessageParcel &data) IMSA_HILOGE("read InputClientInfo from message parcel failed"); return false; } - auto client = data.ReadRemoteObject(); - auto channel = data.ReadRemoteObject(); - if (client == nullptr || channel == nullptr) { - IMSA_HILOGE("read remote object failed"); - return false; - } - output.client = iface_cast(client); - output.channel = iface_cast(channel); return true; } diff --git a/frameworks/js/napi/inputmethodclient/BUILD.gn b/frameworks/js/napi/inputmethodclient/BUILD.gn index 635ee442..482fd520 100644 --- a/frameworks/js/napi/inputmethodclient/BUILD.gn +++ b/frameworks/js/napi/inputmethodclient/BUILD.gn @@ -64,7 +64,6 @@ ohos_shared_library("inputmethod") { "c_utils:utils", "eventhandler:libeventhandler", "hilog:libhilog", - "ipc:ipc_single", "input:libmmi-client", "napi:ace_napi", ] diff --git a/frameworks/native/inputmethod_ability/include/i_input_method_core.h b/frameworks/native/inputmethod_ability/include/i_input_method_core.h index ceadb416..8590b6c9 100644 --- a/frameworks/native/inputmethod_ability/include/i_input_method_core.h +++ b/frameworks/native/inputmethod_ability/include/i_input_method_core.h @@ -18,8 +18,6 @@ #include "global.h" #include "i_input_control_channel.h" -#include "i_input_data_channel.h" -#include "i_system_cmd_channel.h" #include "input_attribute.h" #include "input_client_info.h" #include "input_method_property.h" @@ -54,7 +52,7 @@ public: DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.IInputMethodCore"); virtual int32_t StartInput(const InputClientInfo &clientInfo, bool isBindFromClient) = 0; - virtual int32_t StopInput(const sptr &channel) = 0; + virtual int32_t StopInput(const sptr &channel) = 0; virtual int32_t ShowKeyboard() = 0; virtual int32_t HideKeyboard() = 0; virtual int32_t InitInputControlChannel(const sptr &inputControlChannel) = 0; @@ -63,8 +61,8 @@ public: virtual bool IsEnable() = 0; virtual int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown) = 0; virtual int32_t OnSecurityChange(int32_t security) = 0 ; - virtual int32_t OnConnectSystemCmd(const sptr &channel, sptr &agent) = 0 ; - virtual void OnClientInactive(const sptr &channel) = 0; + virtual int32_t OnConnectSystemCmd(const sptr &channel, sptr &agent) = 0 ; + virtual void OnClientInactive(const sptr &channel) = 0; }; } // namespace MiscServices } // namespace OHOS diff --git a/frameworks/native/inputmethod_ability/include/input_method_ability.h b/frameworks/native/inputmethod_ability/include/input_method_ability.h index 3fbf3a71..a7383847 100644 --- a/frameworks/native/inputmethod_ability/include/input_method_ability.h +++ b/frameworks/native/inputmethod_ability/include/input_method_ability.h @@ -160,7 +160,7 @@ private: sptr coreStub_{ nullptr }; sptr agentStub_{ nullptr }; - sptr systemAgentStub_{ nullptr }; + sptr systemAgentStub_{ nullptr }; std::mutex imeCheckMutex_; bool isCurrentIme_ = false; diff --git a/frameworks/native/inputmethod_ability/include/input_method_core_proxy.h b/frameworks/native/inputmethod_ability/include/input_method_core_proxy.h index bce5b512..2beb184f 100644 --- a/frameworks/native/inputmethod_ability/include/input_method_core_proxy.h +++ b/frameworks/native/inputmethod_ability/include/input_method_core_proxy.h @@ -16,8 +16,6 @@ #ifndef FRAMEWORKS_INPUTMETHOD_ABILITY_INCLUDE_INPUT_METHOD_CORE_PROXY_H #define FRAMEWORKS_INPUTMETHOD_ABILITY_INCLUDE_INPUT_METHOD_CORE_PROXY_H -#include "i_input_control_channel.h" -#include "i_input_data_channel.h" #include "i_input_method_core.h" #include "input_attribute.h" #include "input_method_property.h" @@ -36,7 +34,7 @@ public: DISALLOW_COPY_AND_MOVE(InputMethodCoreProxy); int32_t StartInput(const InputClientInfo &clientInfo, bool isBindFromClient) override; - int32_t StopInput(const sptr &channel) override; + int32_t StopInput(const sptr &channel) override; int32_t ShowKeyboard() override; int32_t HideKeyboard() override; int32_t InitInputControlChannel(const sptr &inputControlChannel) override; @@ -45,8 +43,8 @@ public: bool IsEnable() override; int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown) override; int32_t OnSecurityChange(int32_t security) override; - int32_t OnConnectSystemCmd(const sptr &channel, sptr &agent) override; - void OnClientInactive(const sptr &channel) override; + int32_t OnConnectSystemCmd(const sptr &channel, sptr &agent) override; + void OnClientInactive(const sptr &channel) override; private: static inline BrokerDelegator delegator_; diff --git a/frameworks/native/inputmethod_ability/include/input_method_core_stub.h b/frameworks/native/inputmethod_ability/include/input_method_core_stub.h index 53759f6e..84a06822 100644 --- a/frameworks/native/inputmethod_ability/include/input_method_core_stub.h +++ b/frameworks/native/inputmethod_ability/include/input_method_core_stub.h @@ -20,9 +20,6 @@ #include #include -#include "i_input_control_channel.h" -#include "i_input_data_channel.h" -#include "i_input_method_agent.h" #include "i_input_method_core.h" #include "input_attribute.h" #include "iremote_broker.h" @@ -39,7 +36,7 @@ public: virtual ~InputMethodCoreStub(); int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; int32_t StartInput(const InputClientInfo &clientInfo, bool isBindFromClient) override; - int32_t StopInput(const sptr &channel) override; + int32_t StopInput(const sptr &channel) override; int32_t ShowKeyboard() override; int32_t HideKeyboard() override; int32_t InitInputControlChannel(const sptr &inputControlChannel) override; @@ -48,8 +45,8 @@ public: bool IsEnable() override; int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown) override; int32_t OnSecurityChange(int32_t security) override; - int32_t OnConnectSystemCmd(const sptr &channel, sptr &agent) override; - void OnClientInactive(const sptr &channel) override; + int32_t OnConnectSystemCmd(const sptr &channel, sptr &agent) override; + void OnClientInactive(const sptr &channel) override; void SetMessageHandler(MessageHandler *msgHandler); private: diff --git a/frameworks/native/inputmethod_ability/src/input_method_ability.cpp b/frameworks/native/inputmethod_ability/src/input_method_ability.cpp index 0f85fba5..94ef0638 100644 --- a/frameworks/native/inputmethod_ability/src/input_method_ability.cpp +++ b/frameworks/native/inputmethod_ability/src/input_method_ability.cpp @@ -119,7 +119,7 @@ int32_t InputMethodAbility::SetCoreAndAgent() IMSA_HILOGE("imsa proxy is nullptr"); return ErrorCode::ERROR_NULL_POINTER; } - int32_t ret = proxy->SetCoreAndAgent(coreStub_, agentStub_); + int32_t ret = proxy->SetCoreAndAgent(coreStub_, agentStub_->AsObject()); if (ret != ErrorCode::NO_ERROR) { IMSA_HILOGE("set failed, ret: %{public}d", ret); return ret; @@ -143,12 +143,12 @@ int32_t InputMethodAbility::UnRegisteredProxyIme(UnRegisteredType type) void InputMethodAbility::Initialize() { IMSA_HILOGD("IMA"); - auto coreStub = new (std::nothrow) InputMethodCoreStub(); + sptr coreStub = new (std::nothrow) InputMethodCoreStub(); if (coreStub == nullptr) { IMSA_HILOGE("failed to create core"); return; } - auto agentStub = new (std::nothrow) InputMethodAgentStub(); + sptr agentStub = new (std::nothrow) InputMethodAgentStub(); if (agentStub == nullptr) { IMSA_HILOGE("failed to create agent"); return; @@ -235,13 +235,13 @@ void InputMethodAbility::OnInitInputControlChannel(Message *msg) int32_t InputMethodAbility::StartInput(const InputClientInfo &clientInfo, bool isBindFromClient) { - if (clientInfo.channel->AsObject() == nullptr) { + if (clientInfo.channel == nullptr) { IMSA_HILOGE("channelObject is nullptr"); return ErrorCode::ERROR_CLIENT_NULL_POINTER; } IMSA_HILOGI( "IMA isShowKeyboard: %{public}d, isBindFromClient: %{public}d", clientInfo.isShowKeyboard, isBindFromClient); - SetInputDataChannel(clientInfo.channel->AsObject()); + SetInputDataChannel(clientInfo.channel); isBindFromClient ? InvokeTextChangeCallback(clientInfo.config) : NotifyAllTextConfig(); SetInputAttribute(clientInfo.config.inputAttribute); if (imeListener_ == nullptr) { diff --git a/frameworks/native/inputmethod_ability/src/input_method_core_proxy.cpp b/frameworks/native/inputmethod_ability/src/input_method_core_proxy.cpp index e8b7f23a..9cdf692f 100644 --- a/frameworks/native/inputmethod_ability/src/input_method_core_proxy.cpp +++ b/frameworks/native/inputmethod_ability/src/input_method_core_proxy.cpp @@ -42,7 +42,7 @@ int32_t InputMethodCoreProxy::StartInput(const InputClientInfo &clientInfo, bool { IMSA_HILOGI("CoreProxy"); return SendRequest(START_INPUT, [&clientInfo, isBindFromClient](MessageParcel &data) { - return ITypesUtil::Marshal(data, isBindFromClient, clientInfo); + return ITypesUtil::Marshal(data, isBindFromClient, clientInfo, clientInfo.channel); }); } @@ -53,13 +53,11 @@ int32_t InputMethodCoreProxy::OnSecurityChange(int32_t security) }); } -int32_t InputMethodCoreProxy::OnConnectSystemCmd(const sptr &channel, sptr &agent) +int32_t InputMethodCoreProxy::OnConnectSystemCmd(const sptr &channel, sptr &agent) { - return SendRequest(ON_CONNECT_SYSTEM_CMD, [channel](MessageParcel& data) { - return data.WriteRemoteObject(channel->AsObject()); - }, [&agent](MessageParcel &reply) { - return ITypesUtil::Unmarshal(reply, agent); - }); + return SendRequest( + ON_CONNECT_SYSTEM_CMD, [channel](MessageParcel &data) { return data.WriteRemoteObject(channel); }, + [&agent](MessageParcel &reply) { return ITypesUtil::Unmarshal(reply, agent); }); } void InputMethodCoreProxy::StopInputService(bool isTerminateIme) @@ -83,10 +81,9 @@ int32_t InputMethodCoreProxy::SetSubtype(const SubProperty &property) return SendRequest(SET_SUBTYPE, [&property](MessageParcel &data) { return ITypesUtil::Marshal(data, property); }); } -int32_t InputMethodCoreProxy::StopInput(const sptr &channel) +int32_t InputMethodCoreProxy::StopInput(const sptr &channel) { - return SendRequest( - STOP_INPUT, [&channel](MessageParcel &data) { return ITypesUtil::Marshal(data, channel->AsObject()); }); + return SendRequest(STOP_INPUT, [&channel](MessageParcel &data) { return ITypesUtil::Marshal(data, channel); }); } bool InputMethodCoreProxy::IsEnable() @@ -104,11 +101,11 @@ int32_t InputMethodCoreProxy::IsPanelShown(const PanelInfo &panelInfo, bool &isS [&isShown](MessageParcel &reply) { return ITypesUtil::Unmarshal(reply, isShown); }); } -void InputMethodCoreProxy::OnClientInactive(const sptr &channel) +void InputMethodCoreProxy::OnClientInactive(const sptr &channel) { SendRequest( - ON_CLIENT_INACTIVE, [&channel](MessageParcel &data) { return ITypesUtil::Marshal(data, channel->AsObject()); }, - nullptr, MessageOption::TF_ASYNC); + ON_CLIENT_INACTIVE, [&channel](MessageParcel &data) { return ITypesUtil::Marshal(data, channel); }, nullptr, + MessageOption::TF_ASYNC); } int32_t InputMethodCoreProxy::SendRequest(int code, ParcelHandler input, ParcelHandler output, MessageOption option) diff --git a/frameworks/native/inputmethod_ability/src/input_method_core_stub.cpp b/frameworks/native/inputmethod_ability/src/input_method_core_stub.cpp index 446ed1bf..5dd566a7 100644 --- a/frameworks/native/inputmethod_ability/src/input_method_core_stub.cpp +++ b/frameworks/native/inputmethod_ability/src/input_method_core_stub.cpp @@ -106,7 +106,8 @@ int32_t InputMethodCoreStub::StartInputOnRemote(MessageParcel &data, MessageParc "CoreStub, callingPid/Uid: %{public}d/%{public}d", IPCSkeleton::GetCallingPid(), IPCSkeleton::GetCallingUid()); bool isBindFromClient = false; InputClientInfo clientInfo = {}; - if (!ITypesUtil::Unmarshal(data, isBindFromClient, clientInfo)) { + sptr channel = nullptr; + if (!ITypesUtil::Unmarshal(data, isBindFromClient, clientInfo, clientInfo.channel)) { IMSA_HILOGE("Unmarshal failed."); return ErrorCode::ERROR_EX_PARCELABLE; } @@ -125,7 +126,7 @@ int32_t InputMethodCoreStub::SecurityChangeOnRemote(MessageParcel &data, Message return ITypesUtil::Marshal(reply, ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE; } -int32_t InputMethodCoreStub::OnConnectSystemCmd(const sptr &channel, sptr &agent) +int32_t InputMethodCoreStub::OnConnectSystemCmd(const sptr &channel, sptr &agent) { return ErrorCode::NO_ERROR; } @@ -231,7 +232,7 @@ int32_t InputMethodCoreStub::OnSecurityChange(int32_t security) return ErrorCode::NO_ERROR; } -int32_t InputMethodCoreStub::StopInput(const sptr &channel) +int32_t InputMethodCoreStub::StopInput(const sptr &channel) { return ErrorCode::NO_ERROR; } @@ -246,7 +247,7 @@ int32_t InputMethodCoreStub::IsPanelShown(const PanelInfo &panelInfo, bool &isSh return InputMethodAbility::GetInstance()->IsPanelShown(panelInfo, isShown); } -void InputMethodCoreStub::OnClientInactive(const sptr &channel) +void InputMethodCoreStub::OnClientInactive(const sptr &channel) { } diff --git a/frameworks/native/inputmethod_controller/include/i_input_client.h b/frameworks/native/inputmethod_controller/include/i_input_client.h index 1eae695a..8b6a8fc7 100644 --- a/frameworks/native/inputmethod_controller/include/i_input_client.h +++ b/frameworks/native/inputmethod_controller/include/i_input_client.h @@ -39,7 +39,7 @@ public: DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.InputClient"); - virtual int32_t OnInputReady(const sptr &agent) = 0; + virtual int32_t OnInputReady(const sptr &agent) = 0; virtual int32_t OnInputStop() = 0; virtual int32_t OnSwitchInput(const Property &property, const SubProperty &subProperty) = 0; virtual int32_t OnPanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info) = 0; diff --git a/frameworks/native/inputmethod_controller/include/input_client_info.h b/frameworks/native/inputmethod_controller/include/input_client_info.h index dce8ae3a..d919fa52 100644 --- a/frameworks/native/inputmethod_controller/include/input_client_info.h +++ b/frameworks/native/inputmethod_controller/include/input_client_info.h @@ -37,7 +37,7 @@ struct InputClientInfo { uint32_t eventFlag{ NO_EVENT_ON }; // the flag of the all listen event InputAttribute attribute; // the input client attribute sptr client{ nullptr }; // the remote object handler for service to callback input client - sptr channel{ nullptr }; // the remote object handler for ime to callback input client + sptr channel{ nullptr }; // the remote object handler for ime to callback input client sptr deathRecipient{ nullptr }; // death recipient of client ClientState state{ ClientState::INACTIVE }; // the state of input client bool isNotifyInputStart { true }; diff --git a/frameworks/native/inputmethod_controller/include/input_client_proxy.h b/frameworks/native/inputmethod_controller/include/input_client_proxy.h index ee0f9e80..ac9bb3d0 100644 --- a/frameworks/native/inputmethod_controller/include/input_client_proxy.h +++ b/frameworks/native/inputmethod_controller/include/input_client_proxy.h @@ -20,7 +20,6 @@ #include #include "i_input_client.h" -#include "i_input_method_agent.h" #include "iremote_broker.h" #include "iremote_object.h" #include "iremote_proxy.h" @@ -35,7 +34,7 @@ public: ~InputClientProxy() = default; DISALLOW_COPY_AND_MOVE(InputClientProxy); - int32_t OnInputReady(const sptr &agent) override; + int32_t OnInputReady(const sptr &agent) override; int32_t OnInputStop() override; int32_t OnSwitchInput(const Property &property, const SubProperty &subProperty) override; int32_t OnPanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info) override; diff --git a/frameworks/native/inputmethod_controller/include/input_client_stub.h b/frameworks/native/inputmethod_controller/include/input_client_stub.h index 6af4140e..73170022 100644 --- a/frameworks/native/inputmethod_controller/include/input_client_stub.h +++ b/frameworks/native/inputmethod_controller/include/input_client_stub.h @@ -19,7 +19,6 @@ #include #include "i_input_client.h" -#include "i_input_method_agent.h" #include "ime_event_monitor_manager.h" #include "iremote_stub.h" #include "message_handler.h" @@ -37,7 +36,7 @@ public: InputClientStub(); ~InputClientStub(); - int32_t OnInputReady(const sptr &agent) override; + int32_t OnInputReady(const sptr &agent) override; int32_t OnInputStop() override; int32_t OnSwitchInput(const Property &property, const SubProperty &subProperty) override; int32_t OnPanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info) override; diff --git a/frameworks/native/inputmethod_controller/include/input_method_system_ability_proxy.h b/frameworks/native/inputmethod_controller/include/input_method_system_ability_proxy.h index ffc85e49..e765f488 100644 --- a/frameworks/native/inputmethod_controller/include/input_method_system_ability_proxy.h +++ b/frameworks/native/inputmethod_controller/include/input_method_system_ability_proxy.h @@ -60,7 +60,7 @@ public: int32_t ListInputMethod(InputMethodStatus status, std::vector &props) override; int32_t SwitchInputMethod(const std::string &name, const std::string &subName, SwitchTrigger trigger) override; int32_t DisplayOptionalInputMethod() override; - int32_t SetCoreAndAgent(const sptr &core, const sptr &agent) override; + int32_t SetCoreAndAgent(const sptr &core, const sptr &agent) override; int32_t UnRegisteredProxyIme(UnRegisteredType type, const sptr &core) override; int32_t ListCurrentInputMethodSubtype(std::vector &subProps) override; int32_t ListInputMethodSubtype(const std::string &name, std::vector &subProps) override; @@ -73,7 +73,7 @@ public: int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown) override; int32_t GetSecurityMode(int32_t &security) override; int32_t IsDefaultIme() override; - int32_t ConnectSystemCmd(const sptr &channel, sptr &agent) override; + int32_t ConnectSystemCmd(const sptr &channel, sptr &agent) override; // Deprecated because of no permission check, kept for compatibility int32_t HideCurrentInputDeprecated() override; int32_t ShowCurrentInputDeprecated() override; diff --git a/frameworks/native/inputmethod_controller/src/input_client_proxy.cpp b/frameworks/native/inputmethod_controller/src/input_client_proxy.cpp index 41c017c9..5d02e739 100644 --- a/frameworks/native/inputmethod_controller/src/input_client_proxy.cpp +++ b/frameworks/native/inputmethod_controller/src/input_client_proxy.cpp @@ -27,10 +27,9 @@ InputClientProxy::InputClientProxy(const sptr &object) : IRemoteP { } -int32_t InputClientProxy::OnInputReady(const sptr &agent) +int32_t InputClientProxy::OnInputReady(const sptr &agent) { - return SendRequest( - ON_INPUT_READY, [agent](MessageParcel &data) { return ITypesUtil::Marshal(data, agent->AsObject()); }); + return SendRequest(ON_INPUT_READY, [agent](MessageParcel &data) { return ITypesUtil::Marshal(data, agent); }); } int32_t InputClientProxy::OnInputStop() diff --git a/frameworks/native/inputmethod_controller/src/input_client_stub.cpp b/frameworks/native/inputmethod_controller/src/input_client_stub.cpp index ccef1a5a..b2cb9f80 100644 --- a/frameworks/native/inputmethod_controller/src/input_client_stub.cpp +++ b/frameworks/native/inputmethod_controller/src/input_client_stub.cpp @@ -110,7 +110,7 @@ int32_t InputClientStub::DeactivateClientOnRemote(MessageParcel &data, MessagePa return reply.WriteInt32(ErrorCode::NO_ERROR) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE; } -int32_t InputClientStub::OnInputReady(const sptr &agent) +int32_t InputClientStub::OnInputReady(const sptr &agent) { return ErrorCode::NO_ERROR; } diff --git a/frameworks/native/inputmethod_controller/src/input_method_controller.cpp b/frameworks/native/inputmethod_controller/src/input_method_controller.cpp index 7caa070b..6bd7eb9a 100644 --- a/frameworks/native/inputmethod_controller/src/input_method_controller.cpp +++ b/frameworks/native/inputmethod_controller/src/input_method_controller.cpp @@ -115,19 +115,18 @@ void InputMethodController::SetControllerListener(std::shared_ptr client = new (std::nothrow) InputClientStub(); if (client == nullptr) { IMSA_HILOGE("failed to new client"); return ErrorCode::ERROR_NULL_POINTER; } - auto channel = new (std::nothrow) InputDataChannelStub(); + sptr channel = new (std::nothrow) InputDataChannelStub(); if (channel == nullptr) { - delete client; IMSA_HILOGE("failed to new channel"); return ErrorCode::ERROR_NULL_POINTER; } InputAttribute attribute = { .inputPattern = InputAttribute::PATTERN_TEXT }; - clientInfo_ = { .attribute = attribute, .client = client, .channel = channel }; + clientInfo_ = { .attribute = attribute, .client = client, .channel = channel->AsObject() }; // make AppExecFwk::EventHandler handler handler_ = std::make_shared(AppExecFwk::EventRunner::GetMainEventRunner()); diff --git a/frameworks/native/inputmethod_controller/src/input_method_system_ability_proxy.cpp b/frameworks/native/inputmethod_controller/src/input_method_system_ability_proxy.cpp index d0edcec8..2765c8a5 100644 --- a/frameworks/native/inputmethod_controller/src/input_method_system_ability_proxy.cpp +++ b/frameworks/native/inputmethod_controller/src/input_method_system_ability_proxy.cpp @@ -34,22 +34,22 @@ int32_t InputMethodSystemAbilityProxy::StartInput(InputClientInfo &inputClientIn { return SendRequest( static_cast(InputMethodInterfaceCode::START_INPUT), - [&inputClientInfo](MessageParcel &data) { return ITypesUtil::Marshal(data, inputClientInfo); }, + [&inputClientInfo](MessageParcel &data) { + return ITypesUtil::Marshal( + data, inputClientInfo, inputClientInfo.client->AsObject(), inputClientInfo.channel); + }, [&agent](MessageParcel &reply) { agent = reply.ReadRemoteObject(); return true; }); } -int32_t InputMethodSystemAbilityProxy::ConnectSystemCmd( - const sptr &channel, sptr &agent) +int32_t InputMethodSystemAbilityProxy::ConnectSystemCmd(const sptr &channel, sptr &agent) { return SendRequest( static_cast(InputMethodInterfaceCode::CONNECT_SYSTEM_CMD), - [channel](MessageParcel &data) { return data.WriteRemoteObject(channel->AsObject()); }, - [&agent](MessageParcel &reply) { - return ITypesUtil::Unmarshal(reply, agent); - }); + [channel](MessageParcel &data) { return data.WriteRemoteObject(channel); }, + [&agent](MessageParcel &reply) { return ITypesUtil::Unmarshal(reply, agent); }); } int32_t InputMethodSystemAbilityProxy::ShowCurrentInput() @@ -101,11 +101,11 @@ int32_t InputMethodSystemAbilityProxy::DisplayOptionalInputMethod() } int32_t InputMethodSystemAbilityProxy::SetCoreAndAgent( - const sptr &core, const sptr &agent) + const sptr &core, const sptr &agent) { return SendRequest( static_cast(InputMethodInterfaceCode::SET_CORE_AND_AGENT), [core, agent](MessageParcel &data) { - return data.WriteRemoteObject(core->AsObject()) && data.WriteRemoteObject(agent->AsObject()); + return data.WriteRemoteObject(core->AsObject()) && data.WriteRemoteObject(agent); }); } @@ -215,7 +215,9 @@ int32_t InputMethodSystemAbilityProxy::PanelStatusChange(const InputWindowStatus int32_t InputMethodSystemAbilityProxy::UpdateListenEventFlag(InputClientInfo &clientInfo, uint32_t eventFlag) { return SendRequest(static_cast(InputMethodInterfaceCode::UPDATE_LISTEN_EVENT_FLAG), - [&clientInfo, eventFlag](MessageParcel &data) { return ITypesUtil::Marshal(data, clientInfo, eventFlag); }); + [&clientInfo, eventFlag](MessageParcel &data) { + return ITypesUtil::Marshal(data, clientInfo, clientInfo.client->AsObject(), clientInfo.channel, eventFlag); + }); } bool InputMethodSystemAbilityProxy::IsCurrentIme() diff --git a/interfaces/inner_api/inputmethod_ability/BUILD.gn b/interfaces/inner_api/inputmethod_ability/BUILD.gn index 089b089c..07688599 100644 --- a/interfaces/inner_api/inputmethod_ability/BUILD.gn +++ b/interfaces/inner_api/inputmethod_ability/BUILD.gn @@ -31,6 +31,7 @@ config("inputmethod_ability_native_public_config") { "include", "${inputmethod_path}/frameworks/native/inputmethod_ability/include", "${inputmethod_path}/frameworks/common", + "${inputmethod_path}/interfaces/inner_api/inputmethod_controller/include", "${inputmethod_path}/services/include", "${windowmanager_path}/interfaces/innerkits/dm", "${windowmanager_path}/interfaces/innerkits/wm", @@ -56,7 +57,6 @@ ohos_shared_library("inputmethod_ability") { "${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_method_system_ability_proxy.cpp", "${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_proxy.cpp", "${inputmethod_path}/frameworks/native/inputmethod_controller/src/system_cmd_channel_proxy.cpp", - "${inputmethod_path}/services/src/global.cpp", "${inputmethod_path}/services/src/input_control_channel_proxy.cpp", ] cflags_cc = [ @@ -91,3 +91,47 @@ ohos_shared_library("inputmethod_ability") { innerapi_tags = [ "platformsdk" ] part_name = "imf" } + +ohos_static_library("inputmethod_ability_static") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + sources = [ + "${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_ability.cpp", + "${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_ability_interface.cpp", + "${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_ability_utils.cpp", + "${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_agent_stub.cpp", + "${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_core_stub.cpp", + "${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_panel.cpp", + "${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_data_channel_proxy.cpp", + "${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_method_system_ability_proxy.cpp", + "${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_proxy.cpp", + "${inputmethod_path}/frameworks/native/inputmethod_controller/src/system_cmd_channel_proxy.cpp", + "${inputmethod_path}/services/src/input_control_channel_proxy.cpp", + ] + + external_deps = [ + "ability_base:configuration", + "ability_base:want", + "ability_runtime:ability_context_native", + "c_utils:utils", + "graphic_2d:window_animation", + "hilog:libhilog", + "input:libmmi-client", + "ipc:ipc_single", + "napi:ace_napi", + "samgr:samgr_proxy", + "window_manager:libdm", + "window_manager:libwm", + ] + + public_deps = [ "${inputmethod_path}/common:inputmethod_common" ] + + public_configs = [ ":inputmethod_ability_native_public_config" ] + + subsystem_name = "inputmethod" + part_name = "imf" +} diff --git a/interfaces/inner_api/inputmethod_controller/BUILD.gn b/interfaces/inner_api/inputmethod_controller/BUILD.gn index 8e172ae7..8c0cabb8 100644 --- a/interfaces/inner_api/inputmethod_controller/BUILD.gn +++ b/interfaces/inner_api/inputmethod_controller/BUILD.gn @@ -58,9 +58,6 @@ ohos_shared_library("inputmethod_client") { "${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_method_utils.cpp", "${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_stub.cpp", "${inputmethod_path}/frameworks/native/inputmethod_controller/src/system_cmd_channel_stub.cpp", - "${inputmethod_path}/services/src/global.cpp", - "${inputmethod_path}/services/src/message.cpp", - "${inputmethod_path}/services/src/message_handler.cpp", ] cflags_cc = [ diff --git a/services/BUILD.gn b/services/BUILD.gn index aecc74ab..6d0280fa 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -110,3 +110,77 @@ ohos_shared_library("inputmethod_service") { subsystem_name = "inputmethod" part_name = "imf" } + +ohos_static_library("inputmethod_service_static") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + cflags_cc = [ + "-fdata-sections", + "-ffunction-sections", + "-Os", + ] + sources = [ + "${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_core_proxy.cpp", + "${inputmethod_path}/frameworks/native/inputmethod_controller/src/input_client_proxy.cpp", + "${inputmethod_path}/services/adapter/focus_monitor/src/focus_change_listener.cpp", + "${inputmethod_path}/services/adapter/focus_monitor/src/focus_monitor_manager.cpp", + "${inputmethod_path}/services/adapter/system_language_observer/src/system_language_observer.cpp", + "${inputmethod_path}/services/adapter/wms_connection_monitor/src/wms_connection_monitor_manager.cpp", + "${inputmethod_path}/services/adapter/wms_connection_monitor/src/wms_connection_observer.cpp", + "${inputmethod_path}/services/identity_checker/src/identity_checker_impl.cpp", + "src/freeze_manager.cpp", + "src/im_common_event_manager.cpp", + "src/ime_cfg_manager.cpp", + "src/ime_info_inquirer.cpp", + "src/input_control_channel_stub.cpp", + "src/input_method_system_ability.cpp", + "src/input_method_system_ability_stub.cpp", + "src/input_type_manager.cpp", + "src/peruser_session.cpp", + "src/sys_cfg_parser.cpp", + ] + + public_configs = [ ":inputmethod_services_native_config" ] + + public_deps = [ + "${inputmethod_path}/services/adapter/keyboard:keboard_event_static", + "${inputmethod_path}/services/adapter/settings_data_provider:settings_data_static", + "${inputmethod_path}/common:inputmethod_common", + "${inputmethod_path}/services/file:imf_file_static", + "${inputmethod_path}/services/json:imf_json_static", + "//third_party/cJSON:cjson", + ] + + external_deps = [ + "ability_base:want", + "ability_runtime:ability_manager", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "eventhandler:libeventhandler", + "hilog:libhilog", + "init:libbeget_proxy", + "init:libbegetutil", + "input:libmmi-client", + "ipc:ipc_single", + "os_account:os_account_innerkits", + "resource_schedule_service:ressched_client", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + "window_manager:libwsutils", + ] + + subsystem_name = "inputmethod" + part_name = "imf" +} diff --git a/services/include/i_input_method_system_ability.h b/services/include/i_input_method_system_ability.h index 9f1e3b49..e463fca1 100644 --- a/services/include/i_input_method_system_ability.h +++ b/services/include/i_input_method_system_ability.h @@ -25,7 +25,6 @@ #include "event_status_manager.h" #include "global.h" #include "i_input_client.h" -#include "i_input_data_channel.h" #include "i_input_method_core.h" #include "i_system_cmd_channel.h" #include "input_attribute.h" @@ -59,7 +58,7 @@ public: virtual std::shared_ptr GetCurrentInputMethodSubtype() = 0; virtual int32_t ListInputMethod(InputMethodStatus status, std::vector &props) = 0; virtual int32_t DisplayOptionalInputMethod() = 0; - virtual int32_t SetCoreAndAgent(const sptr &core, const sptr &agent) = 0; + virtual int32_t SetCoreAndAgent(const sptr &core, const sptr &agent) = 0; virtual int32_t UnRegisteredProxyIme(UnRegisteredType type, const sptr &core) = 0; virtual int32_t ListCurrentInputMethodSubtype(std::vector &subProps) = 0; virtual int32_t ListInputMethodSubtype(const std::string &name, std::vector &subProps) = 0; @@ -74,7 +73,7 @@ public: virtual int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown) = 0; virtual int32_t GetSecurityMode(int32_t &security) = 0; virtual int32_t IsDefaultIme() = 0; - virtual int32_t ConnectSystemCmd(const sptr &channel, sptr &agent) = 0; + virtual int32_t ConnectSystemCmd(const sptr &channel, sptr &agent) = 0; // Deprecated because of no permission check, and keep for compatibility virtual int32_t HideCurrentInputDeprecated() = 0; diff --git a/services/include/input_method_system_ability.h b/services/include/input_method_system_ability.h index 4db217d7..58ba8296 100644 --- a/services/include/input_method_system_ability.h +++ b/services/include/input_method_system_ability.h @@ -69,7 +69,7 @@ public: int32_t SwitchInputMethod( const std::string &bundleName, const std::string &subName, SwitchTrigger trigger) override; int32_t DisplayOptionalInputMethod() override; - int32_t SetCoreAndAgent(const sptr &core, const sptr &agent) override; + int32_t SetCoreAndAgent(const sptr &core, const sptr &agent) override; int32_t UnRegisteredProxyIme(UnRegisteredType type, const sptr &core) override; int32_t PanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info) override; int32_t UpdateListenEventFlag(InputClientInfo &clientInfo, uint32_t eventFlag) override; @@ -79,7 +79,7 @@ public: int32_t ExitCurrentInputType() override; int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown) override; int32_t GetSecurityMode(int32_t &security) override; - int32_t ConnectSystemCmd(const sptr &channel, sptr &agent) override; + int32_t ConnectSystemCmd(const sptr &channel, sptr &agent) override; // Deprecated because of no permission check, kept for compatibility int32_t HideCurrentInputDeprecated() override; int32_t ShowCurrentInputDeprecated() override; diff --git a/services/include/peruser_session.h b/services/include/peruser_session.h index 41671249..ca1ac0e9 100644 --- a/services/include/peruser_session.h +++ b/services/include/peruser_session.h @@ -52,10 +52,10 @@ namespace OHOS { namespace MiscServices { struct ImeData { sptr core{ nullptr }; - sptr agent{ nullptr }; + sptr agent{ nullptr }; sptr deathRecipient{ nullptr }; std::shared_ptr freezeMgr; - ImeData(sptr core, sptr agent, sptr deathRecipient, + ImeData(sptr core, sptr agent, sptr deathRecipient, pid_t imePid) : core(std::move(core)), agent(std::move(agent)), deathRecipient(std::move(deathRecipient)), freezeMgr(std::make_shared(imePid)) @@ -76,7 +76,7 @@ public: int32_t OnPrepareInput(const InputClientInfo &clientInfo); int32_t OnStartInput(const InputClientInfo &inputClientInfo, sptr &agent); int32_t OnReleaseInput(const sptr &client); - int32_t OnSetCoreAndAgent(const sptr &core, const sptr &agent); + int32_t OnSetCoreAndAgent(const sptr &core, const sptr &agent); int32_t OnHideCurrentInput(); int32_t OnShowCurrentInput(); int32_t OnShowInput(sptr client); @@ -93,7 +93,7 @@ public: int64_t GetCurrentClientPid(); int32_t OnPanelStatusChange(const InputWindowStatus &status, const ImeWindowInfo &info); int32_t OnUpdateListenEventFlag(const InputClientInfo &clientInfo); - int32_t OnRegisterProxyIme(const sptr &core, const sptr &agent); + int32_t OnRegisterProxyIme(const sptr &core, const sptr &agent); int32_t OnUnRegisteredProxyIme(UnRegisteredType type, const sptr &core); bool StartCurrentIme(int32_t userId, bool isRetry); void StopCurrentIme(); @@ -104,7 +104,7 @@ public: int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown); bool CheckSecurityMode(); bool IsWmsReady(); - int32_t OnConnectSystemCmd(const sptr &channel, sptr &agent); + int32_t OnConnectSystemCmd(const sptr &channel, sptr &agent); private: struct ResetManager { @@ -145,7 +145,7 @@ private: const std::unordered_map> &updateInfos); - int32_t AddImeData(ImeType type, sptr core, sptr agent, pid_t pid); + int32_t AddImeData(ImeType type, sptr core, sptr agent, pid_t pid); void RemoveImeData(ImeType type, bool isImeDied); int32_t RemoveIme(const sptr &core, ImeType type); std::shared_ptr GetImeData(ImeType type); @@ -156,7 +156,7 @@ private: void UnBindClientWithIme( const std::shared_ptr ¤tClientInfo, bool isUnbindFromClient = false); void StopClientInput(const sptr ¤tClient); - void StopImeInput(ImeType currentType, const sptr ¤tChannel); + void StopImeInput(ImeType currentType, const sptr ¤tChannel); int32_t HideKeyboard(const sptr ¤tClient); int32_t ShowKeyboard(const sptr ¤tClient); diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index 1e463b00..59543e31 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -271,6 +271,7 @@ int32_t InputMethodSystemAbility::PrepareInput(InputClientInfo &clientInfo) int32_t InputMethodSystemAbility::GenerateClientInfo(InputClientInfo &clientInfo) { if (clientInfo.client == nullptr || clientInfo.channel == nullptr) { + IMSA_HILOGE("client or channel is nullptr"); return ErrorCode::ERROR_NULL_POINTER; } auto deathRecipient = new (std::nothrow) InputDeathRecipient(); @@ -411,8 +412,7 @@ int32_t InputMethodSystemAbility::RequestHideInput() return userSession_->OnRequestHideInput(); } -int32_t InputMethodSystemAbility::SetCoreAndAgent( - const sptr &core, const sptr &agent) +int32_t InputMethodSystemAbility::SetCoreAndAgent(const sptr &core, const sptr &agent) { IMSA_HILOGD("InputMethodSystemAbility run in"); if (IsCurrentIme()) { @@ -1240,7 +1240,7 @@ bool InputMethodSystemAbility::IsStartInputTypePermitted() return identityChecker_->IsFocused(IPCSkeleton::GetCallingPid(), tokenId) && userSession_->IsBoundToClient(); } -int32_t InputMethodSystemAbility::ConnectSystemCmd(const sptr &channel, sptr &agent) +int32_t InputMethodSystemAbility::ConnectSystemCmd(const sptr &channel, sptr &agent) { auto tokenId = IPCSkeleton::GetCallingTokenID(); if (!identityChecker_->HasPermission(tokenId, PERMISSION_CONNECT_IME_ABILITY)) { diff --git a/services/src/input_method_system_ability_stub.cpp b/services/src/input_method_system_ability_stub.cpp index f64c80ba..d4d61851 100644 --- a/services/src/input_method_system_ability_stub.cpp +++ b/services/src/input_method_system_ability_stub.cpp @@ -43,10 +43,12 @@ int32_t InputMethodSystemAbilityStub::OnRemoteRequest( int32_t InputMethodSystemAbilityStub::StartInputOnRemote(MessageParcel &data, MessageParcel &reply) { InputClientInfo clientInfo; - if (!ITypesUtil::Unmarshal(data, clientInfo)) { + sptr client = nullptr; + if (!ITypesUtil::Unmarshal(data, clientInfo, client, clientInfo.channel)) { IMSA_HILOGE("read clientInfo failed"); return ErrorCode::ERROR_EX_PARCELABLE; } + clientInfo.client = iface_cast(client); sptr agent = nullptr; int32_t ret = StartInput(clientInfo, agent); return reply.WriteInt32(ret) && reply.WriteRemoteObject(agent) ? ErrorCode::NO_ERROR @@ -132,7 +134,7 @@ int32_t InputMethodSystemAbilityStub::SetCoreAndAgentOnRemote(MessageParcel &dat IMSA_HILOGE("agentObject is nullptr"); return ErrorCode::ERROR_EX_PARCELABLE; } - int32_t ret = SetCoreAndAgent(iface_cast(coreObject), iface_cast(agentObject)); + int32_t ret = SetCoreAndAgent(iface_cast(coreObject), agentObject); return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE; } @@ -262,11 +264,13 @@ int32_t InputMethodSystemAbilityStub::PanelStatusChangeOnRemote(MessageParcel &d int32_t InputMethodSystemAbilityStub::UpdateListenEventFlagOnRemote(MessageParcel &data, MessageParcel &reply) { InputClientInfo clientInfo; + sptr client = nullptr; uint32_t eventFlag = 0; - if (!ITypesUtil::Unmarshal(data, clientInfo, eventFlag)) { + if (!ITypesUtil::Unmarshal(data, clientInfo, client, clientInfo.channel, eventFlag)) { IMSA_HILOGE("Unmarshal failed"); return ErrorCode::ERROR_EX_PARCELABLE; } + clientInfo.client = iface_cast(client); int32_t ret = UpdateListenEventFlag(clientInfo, eventFlag); return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE; } @@ -352,7 +356,7 @@ int32_t InputMethodSystemAbilityStub::ConnectSystemCmdOnRemote(MessageParcel &da return ErrorCode::ERROR_EX_PARCELABLE; } sptr agent = nullptr; - int32_t ret = ConnectSystemCmd(iface_cast(systemCmdStub), agent); + int32_t ret = ConnectSystemCmd(systemCmdStub, agent); return reply.WriteInt32(ret) && reply.WriteRemoteObject(agent) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE; } diff --git a/services/src/peruser_session.cpp b/services/src/peruser_session.cpp index d163a96b..54072270 100644 --- a/services/src/peruser_session.cpp +++ b/services/src/peruser_session.cpp @@ -489,7 +489,7 @@ int32_t PerUserSession::OnStartInput(const InputClientInfo &inputClientInfo, spt IMSA_HILOGE("data or agent is nullptr."); return ErrorCode::ERROR_IME_NOT_STARTED; } - agent = data->agent->AsObject(); + agent = data->agent; return ErrorCode::NO_ERROR; } @@ -545,7 +545,7 @@ void PerUserSession::StopClientInput(const sptr ¤tClient) IMSA_HILOGI("stop client input, ret: %{public}d", ret); } -void PerUserSession::StopImeInput(ImeType currentType, const sptr ¤tChannel) +void PerUserSession::StopImeInput(ImeType currentType, const sptr ¤tChannel) { auto data = GetImeData(currentType); if (data == nullptr) { @@ -568,7 +568,7 @@ void PerUserSession::OnSecurityChange(int32_t security) IMSA_HILOGD("on security change, ret: %{public}d", ret); } -int32_t PerUserSession::OnSetCoreAndAgent(const sptr &core, const sptr &agent) +int32_t PerUserSession::OnSetCoreAndAgent(const sptr &core, const sptr &agent) { IMSA_HILOGI("run in"); auto imeType = ImeType::IME; @@ -589,7 +589,7 @@ int32_t PerUserSession::OnSetCoreAndAgent(const sptr &core, co return ErrorCode::NO_ERROR; } -int32_t PerUserSession::OnRegisterProxyIme(const sptr &core, const sptr &agent) +int32_t PerUserSession::OnRegisterProxyIme(const sptr &core, const sptr &agent) { IMSA_HILOGD("run in"); auto imeType = ImeType::PROXY_IME; @@ -752,7 +752,7 @@ void PerUserSession::NotifyImeChangeToClients(const Property &property, const Su } } -int32_t PerUserSession::AddImeData(ImeType type, sptr core, sptr agent, pid_t pid) +int32_t PerUserSession::AddImeData(ImeType type, sptr core, sptr agent, pid_t pid) { if (core == nullptr || agent == nullptr) { IMSA_HILOGE("core or agent is nullptr"); @@ -1160,7 +1160,7 @@ int32_t PerUserSession::RequestIme(const std::shared_ptr &data, Request return ret; } -int32_t PerUserSession::OnConnectSystemCmd(const sptr &channel, sptr &agent) +int32_t PerUserSession::OnConnectSystemCmd(const sptr &channel, sptr &agent) { auto data = GetImeData(ImeType::IME); if (data == nullptr) { diff --git a/test/fuzztest/agentstub_fuzzer/BUILD.gn b/test/fuzztest/agentstub_fuzzer/BUILD.gn index 1345bff9..23c5e1b3 100644 --- a/test/fuzztest/agentstub_fuzzer/BUILD.gn +++ b/test/fuzztest/agentstub_fuzzer/BUILD.gn @@ -25,6 +25,7 @@ ohos_fuzztest("AgentStubFuzzTest") { fuzz_config_file = "//base/inputmethod/imf/test/fuzztest/agentstub_fuzzer" include_dirs = [ + "${inputmethod_path}/common/include", "${inputmethod_path}/frameworks/native/inputmethod_ability/include", "${inputmethod_path}/frameworks/native/inputmethod_controller/include", ] @@ -41,7 +42,7 @@ ohos_fuzztest("AgentStubFuzzTest") { "agentstub_fuzzer.cpp", ] - deps = [ "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability" ] + deps = [ "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static" ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/agentstub_fuzzer/agentstub_fuzzer.cpp b/test/fuzztest/agentstub_fuzzer/agentstub_fuzzer.cpp index 519f2c10..c8f362d8 100644 --- a/test/fuzztest/agentstub_fuzzer/agentstub_fuzzer.cpp +++ b/test/fuzztest/agentstub_fuzzer/agentstub_fuzzer.cpp @@ -18,7 +18,6 @@ #include #include -#include "global.h" #include "input_method_agent_stub.h" #include "message_parcel.h" diff --git a/test/fuzztest/controlchannelstub_fuzzer/BUILD.gn b/test/fuzztest/controlchannelstub_fuzzer/BUILD.gn index 33b831b9..16d2f08f 100644 --- a/test/fuzztest/controlchannelstub_fuzzer/BUILD.gn +++ b/test/fuzztest/controlchannelstub_fuzzer/BUILD.gn @@ -36,7 +36,7 @@ ohos_fuzztest("ControlChannelStubFuzzTest") { sources = [ "controlchannelstub_fuzzer.cpp" ] - deps = [ "${inputmethod_path}/services:inputmethod_service" ] + deps = [ "${inputmethod_path}/services:inputmethod_service_static" ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/corestub_fuzzer/BUILD.gn b/test/fuzztest/corestub_fuzzer/BUILD.gn index f8ef571f..b71ed7d8 100644 --- a/test/fuzztest/corestub_fuzzer/BUILD.gn +++ b/test/fuzztest/corestub_fuzzer/BUILD.gn @@ -25,6 +25,7 @@ ohos_fuzztest("CoreStubFuzzTest") { fuzz_config_file = "//base/inputmethod/imf/test/fuzztest/corestub_fuzzer" include_dirs = [ + "${inputmethod_path}/common/include", "${inputmethod_path}/frameworks/native/inputmethod_controller/include", "${inputmethod_path}/frameworks/native/inputmethod_ability/include", "${inputmethod_path}/interfaces/inner_api/inputmethod_controller/include", @@ -37,12 +38,9 @@ ohos_fuzztest("CoreStubFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ - "${inputmethod_path}/frameworks/native/inputmethod_controller/src/keyevent_consumer_proxy.cpp", - "corestub_fuzzer.cpp", - ] + sources = [ "corestub_fuzzer.cpp" ] - deps = [ "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability" ] + deps = [ "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static" ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/corestub_fuzzer/corestub_fuzzer.cpp b/test/fuzztest/corestub_fuzzer/corestub_fuzzer.cpp index 870cf161..13807145 100644 --- a/test/fuzztest/corestub_fuzzer/corestub_fuzzer.cpp +++ b/test/fuzztest/corestub_fuzzer/corestub_fuzzer.cpp @@ -18,7 +18,6 @@ #include #include -#include "global.h" #include "input_method_core_stub.h" #include "message_parcel.h" diff --git a/test/fuzztest/inputclientstub_fuzzer/BUILD.gn b/test/fuzztest/inputclientstub_fuzzer/BUILD.gn index f80a8823..f44e63fa 100644 --- a/test/fuzztest/inputclientstub_fuzzer/BUILD.gn +++ b/test/fuzztest/inputclientstub_fuzzer/BUILD.gn @@ -37,7 +37,7 @@ ohos_fuzztest("InputClientStubFuzzTest") { sources = [ "inputclientstub_fuzzer.cpp" ] deps = [ - "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability", + "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static", "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static", "${inputmethod_path}/services:inputmethod_service", ] diff --git a/test/fuzztest/inputclientstub_fuzzer/inputclientstub_fuzzer.cpp b/test/fuzztest/inputclientstub_fuzzer/inputclientstub_fuzzer.cpp index acebec19..0786ad31 100644 --- a/test/fuzztest/inputclientstub_fuzzer/inputclientstub_fuzzer.cpp +++ b/test/fuzztest/inputclientstub_fuzzer/inputclientstub_fuzzer.cpp @@ -62,8 +62,7 @@ void TextOnInputReady() MessageParcel data; data.WriteRemoteObject(mInputMethodAgentStub->AsObject()); auto remoteObject = data.ReadRemoteObject(); - sptr iface = iface_cast(remoteObject); - mClient->OnInputReady(iface); + mClient->OnInputReady(remoteObject); } void TestOnSwitchInput() diff --git a/test/fuzztest/perusersession_fuzzer/BUILD.gn b/test/fuzztest/perusersession_fuzzer/BUILD.gn index 91c62cdb..95ef581f 100644 --- a/test/fuzztest/perusersession_fuzzer/BUILD.gn +++ b/test/fuzztest/perusersession_fuzzer/BUILD.gn @@ -44,11 +44,9 @@ ohos_fuzztest("PerUserSessionFuzzTest") { ] deps = [ - "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability", + "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static", "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static", - "${inputmethod_path}/services:inputmethod_service", - "${inputmethod_path}/services/json:imf_json_static", - "//third_party/cJSON:cjson", + "${inputmethod_path}/services:inputmethod_service_static", ] external_deps = [ diff --git a/test/fuzztest/perusersession_fuzzer/perusersession_fuzzer.cpp b/test/fuzztest/perusersession_fuzzer/perusersession_fuzzer.cpp index d1638a75..7a5db928 100644 --- a/test/fuzztest/perusersession_fuzzer/perusersession_fuzzer.cpp +++ b/test/fuzztest/perusersession_fuzzer/perusersession_fuzzer.cpp @@ -30,10 +30,12 @@ #include "i_input_method_agent.h" #include "i_input_method_core.h" #include "input_client_proxy.h" +#include "input_client_stub.h" #include "input_method_ability.h" #include "input_method_agent_proxy.h" #include "input_method_agent_stub.h" #include "input_method_core_proxy.h" +#include "input_method_core_stub.h" #include "input_method_info.h" #include "input_method_property.h" #include "iremote_broker.h" @@ -56,16 +58,15 @@ uint32_t ConvertToUint32(const uint8_t *ptr) bool InitializeClientInfo(InputClientInfo &clientInfo) { - auto clientStub = new (std::nothrow) InputClientStub(); + sptr clientStub = new (std::nothrow) InputClientStub(); if (clientStub == nullptr) { IMSA_HILOGE("failed to create client"); return false; } - auto deathRecipient = new (std::nothrow) InputDeathRecipient(); + sptr deathRecipient = new (std::nothrow) InputDeathRecipient(); if (deathRecipient == nullptr) { IMSA_HILOGE("failed to new deathRecipient"); - delete clientStub; - return ErrorCode::ERROR_EX_NULL_POINTER; + return false; } clientInfo = { .userID = MAIN_USER_ID, .client = clientStub, .deathRecipient = deathRecipient }; return true; @@ -92,13 +93,13 @@ bool FuzzPerUserSession(const uint8_t *rawData, size_t size) auto agent = iface_cast(agentStub); static std::shared_ptr userSessions = std::make_shared(MAIN_USER_ID); - userSessions->OnRegisterProxyIme(core, agent); + userSessions->OnRegisterProxyIme(core, agent->AsObject()); int32_t type = 4; userSessions->OnUnRegisteredProxyIme(static_cast(type), core); userSessions->IsProxyImeEnable(); userSessions->OnPrepareInput(clientInfo); - userSessions->OnSetCoreAndAgent(core, agent); + userSessions->OnSetCoreAndAgent(core, agent->AsObject()); userSessions->OnShowCurrentInput(); sptr agentObject = nullptr; clientInfo.isShowKeyboard = false; diff --git a/test/fuzztest/systemabilitystub_fuzzer/BUILD.gn b/test/fuzztest/systemabilitystub_fuzzer/BUILD.gn index e50860b8..0f37272a 100644 --- a/test/fuzztest/systemabilitystub_fuzzer/BUILD.gn +++ b/test/fuzztest/systemabilitystub_fuzzer/BUILD.gn @@ -41,10 +41,8 @@ ohos_fuzztest("SystemAbilityStubFuzzTest") { deps = [ "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static", - "${inputmethod_path}/services:inputmethod_service", - "${inputmethod_path}/services/adapter/settings_data_provider:settings_data_static", + "${inputmethod_path}/services:inputmethod_service_static", "${inputmethod_path}/test/common:inputmethod_test_common", - "//third_party/cJSON:cjson", ] external_deps = [ diff --git a/test/fuzztest/systemabilitystubfuzztest/common/BUILD.gn b/test/fuzztest/systemabilitystubfuzztest/common/BUILD.gn index a565f3ce..29ac73db 100644 --- a/test/fuzztest/systemabilitystubfuzztest/common/BUILD.gn +++ b/test/fuzztest/systemabilitystubfuzztest/common/BUILD.gn @@ -41,10 +41,8 @@ ohos_static_library("imf_sa_stub_fuzztest_common_static") { public_deps = [ "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static", - "${inputmethod_path}/services:inputmethod_service", - "${inputmethod_path}/services/adapter/settings_data_provider:settings_data_static", + "${inputmethod_path}/services:inputmethod_service_static", "${inputmethod_path}/test/common:inputmethod_test_common", - "//third_party/cJSON:cjson", ] public_configs = [ ":imf_sa_stub_fuzztest_common_config" ] diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index fbb33722..15088fe0 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -32,7 +32,6 @@ group("unittest") { "cpp_test:InputMethodPrivateMemberTest", "cpp_test:InputMethodServiceTest", "cpp_test:InputMethodSwitchTest", - "cpp_test:InputMethodUtilsTest", "cpp_test:JsonOperateTest", "cpp_test:NewImeSwitchTest", "cpp_test:SecurityModeParseTest", diff --git a/test/unittest/cpp_test/BUILD.gn b/test/unittest/cpp_test/BUILD.gn index a216bfd4..4ae23b1b 100644 --- a/test/unittest/cpp_test/BUILD.gn +++ b/test/unittest/cpp_test/BUILD.gn @@ -44,7 +44,7 @@ ohos_unittest("InputMethodControllerTest") { configs = [ ":module_private_config" ] deps = [ - "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability", + "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static", "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static", "${inputmethod_path}/services:inputmethod_service", "${inputmethod_path}/test/common:inputmethod_test_common", @@ -84,7 +84,7 @@ ohos_unittest("InputMethodAttachTest") { configs = [ ":module_private_config" ] deps = [ - "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability", + "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static", "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static", "${inputmethod_path}/services:inputmethod_service", "${inputmethod_path}/test/common:inputmethod_test_common", @@ -114,6 +114,7 @@ ohos_unittest("InputMethodAbilityTest") { module_out_path = module_output_path sources = [ + "${inputmethod_path}/frameworks/native/inputmethod_ability/src/input_method_core_proxy.cpp", "src/input_method_ability_exception_test.cpp", "src/input_method_ability_test.cpp", ] @@ -126,7 +127,7 @@ ohos_unittest("InputMethodAbilityTest") { ] deps = [ - "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability", + "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static", "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static", "${inputmethod_path}/services:inputmethod_service", "${inputmethod_path}/test/common:inputmethod_test_common", @@ -170,7 +171,7 @@ ohos_unittest("InputMethodServiceTest") { ] deps = [ - "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability", + "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static", "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static", "${inputmethod_path}/services:inputmethod_service", "${inputmethod_path}/test/common:inputmethod_test_common", @@ -207,7 +208,7 @@ ohos_unittest("InputMethodDfxTest") { configs = [ ":module_private_config" ] deps = [ - "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability", + "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static", "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client", "${inputmethod_path}/services:inputmethod_service", "${inputmethod_path}/common:inputmethod_common", @@ -253,7 +254,7 @@ ohos_unittest("InputMethodPanelTest") { ] deps = [ - "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability", + "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static", "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static", "${inputmethod_path}/services:inputmethod_service", "${inputmethod_path}/test/common:inputmethod_test_common", @@ -280,32 +281,6 @@ ohos_unittest("InputMethodPanelTest") { ] } -ohos_unittest("InputMethodUtilsTest") { - branch_protector_ret = "pac_ret" - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - module_out_path = module_output_path - - sources = [ - "src/block_queue_test.cpp", - "src/input_method_utils_test.cpp", - ] - - deps = [ - "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "hilog:libhilog", - "ipc:ipc_core", - ] -} - ohos_unittest("InputMethodSwitchTest") { branch_protector_ret = "pac_ret" sanitize = { @@ -355,12 +330,10 @@ ohos_unittest("InputMethodPrivateMemberTest") { configs = [ ":module_private_config" ] deps = [ - "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability", + "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static", "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static", - "${inputmethod_path}/services:inputmethod_service", - "${inputmethod_path}/services/adapter/settings_data_provider:settings_data_static", + "${inputmethod_path}/services:inputmethod_service_static", "${inputmethod_path}/test/unittest/cpp_test/common:inputmethod_tdd_util", - "//third_party/cJSON:cjson", "//third_party/googletest:gtest_main", ] @@ -395,7 +368,7 @@ ohos_unittest("InputMethodEditorTest") { configs = [ ":module_private_config" ] deps = [ - "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability", + "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static", "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static", "${inputmethod_path}/services:inputmethod_service", "${inputmethod_path}/test/common:inputmethod_test_common", @@ -468,19 +441,10 @@ ohos_unittest("IdentityCheckerTest") { configs = [ ":module_private_config" ] - include_dirs = [ - "${windowmanager_path}/interfaces/innerkits/dm", - "${windowmanager_path}/interfaces/innerkits/wm", - ] - deps = [ - "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability", - "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static", - "${inputmethod_path}/services:inputmethod_service", - "${inputmethod_path}/services/adapter/settings_data_provider:settings_data_static", + "${inputmethod_path}/services:inputmethod_service_static", "${inputmethod_path}/test/common:inputmethod_test_common", "${inputmethod_path}/test/unittest/cpp_test/common:inputmethod_tdd_util", - "//third_party/cJSON:cjson", "//third_party/googletest:gtest_main", ] @@ -516,7 +480,7 @@ ohos_unittest("TextListenerInnerApiTest") { configs = [ ":module_private_config" ] deps = [ - "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability", + "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability_static", "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static", "${inputmethod_path}/services:inputmethod_service", "${inputmethod_path}/test/common:inputmethod_test_common", @@ -644,7 +608,6 @@ ohos_unittest("SecurityModeParseTest") { include_dirs = [ "${inputmethod_path}/test/unittest/cpp_test/mock", - "${inputmethod_path}/common", "${inputmethod_path}/services/include", "${inputmethod_path}/services/identity_checker/include", "${inputmethod_path}/services/adapter/settings_data_provider/include", @@ -654,17 +617,13 @@ ohos_unittest("SecurityModeParseTest") { ] sources = [ - "${inputmethod_path}/services/adapter/settings_data_provider/common/src/settings_data_observer.cpp", - "${inputmethod_path}/services/adapter/settings_data_provider/common/src/settings_data_utils.cpp", - "${inputmethod_path}/services/adapter/settings_data_provider/src/security_mode_parser.cpp", "mock/datashare_helper.cpp", "src/security_mode_parser_test.cpp", ] deps = [ - "${inputmethod_path}/services:inputmethod_service", - "${inputmethod_path}/services/json:imf_json_static", - "//third_party/cJSON:cjson", + "${inputmethod_path}/services:inputmethod_service_static", + "${inputmethod_path}/services/adapter/settings_data_provider:settings_data_static", "//third_party/googletest:gmock", "//third_party/googletest:gtest_main", ] @@ -697,12 +656,8 @@ ohos_unittest("ImeFreezeManagerTest") { configs = [ ":module_private_config" ] deps = [ - "${inputmethod_path}/interfaces/inner_api/inputmethod_ability:inputmethod_ability", - "${inputmethod_path}/interfaces/inner_api/inputmethod_controller:inputmethod_client_static", - "${inputmethod_path}/services:inputmethod_service", - "${inputmethod_path}/services/adapter/settings_data_provider:settings_data_static", + "${inputmethod_path}/services:inputmethod_service_static", "${inputmethod_path}/test/unittest/cpp_test/common:inputmethod_tdd_util", - "//third_party/cJSON:cjson", "//third_party/googletest:gtest_main", ] @@ -735,9 +690,8 @@ ohos_unittest("JsonOperateTest") { sources = [ "src/json_operate_test.cpp" ] deps = [ - "${inputmethod_path}/services:inputmethod_service", + "${inputmethod_path}/services:inputmethod_service_static", "${inputmethod_path}/services/adapter/settings_data_provider:settings_data_static", - "${inputmethod_path}/services/file:imf_file_static", "${inputmethod_path}/services/json:imf_json_static", "//third_party/cJSON:cjson", "//third_party/googletest:gtest_main", diff --git a/test/unittest/cpp_test/src/input_method_ability_test.cpp b/test/unittest/cpp_test/src/input_method_ability_test.cpp index 8938b953..4a19bbdb 100644 --- a/test/unittest/cpp_test/src/input_method_ability_test.cpp +++ b/test/unittest/cpp_test/src/input_method_ability_test.cpp @@ -145,7 +145,7 @@ public: auto agent = inputMethodAbility_->agentStub_->AsObject(); imc_->SetAgent(agent); - sptr channel = iface_cast(imc_->clientInfo_.channel->AsObject()); + sptr channel = iface_cast(imc_->clientInfo_.channel); inputMethodAbility_->SetInputDataChannel(channel->AsObject()); IMSA_HILOGI("end"); } diff --git a/test/unittest/cpp_test/src/input_method_panel_test.cpp b/test/unittest/cpp_test/src/input_method_panel_test.cpp index cdb5628f..c2333a01 100644 --- a/test/unittest/cpp_test/src/input_method_panel_test.cpp +++ b/test/unittest/cpp_test/src/input_method_panel_test.cpp @@ -32,6 +32,7 @@ #include "common_event_support.h" #include "display_manager.h" #include "global.h" +#include "ime_event_monitor_manager.h" #include "input_method_ability.h" #include "input_method_controller.h" #include "input_method_engine_listener_impl.h" diff --git a/test/unittest/cpp_test/src/input_method_private_member_test.cpp b/test/unittest/cpp_test/src/input_method_private_member_test.cpp index 424e5008..735ed5bc 100644 --- a/test/unittest/cpp_test/src/input_method_private_member_test.cpp +++ b/test/unittest/cpp_test/src/input_method_private_member_test.cpp @@ -43,6 +43,7 @@ using namespace testing::ext; namespace OHOS { namespace MiscServices { +using namespace AppExecFwk; class InputMethodPrivateMemberTest : public testing::Test { public: static void SetUpTestCase(void); diff --git a/test/unittest/cpp_test/src/input_method_switch_test.cpp b/test/unittest/cpp_test/src/input_method_switch_test.cpp index 8931fe66..f0ef1680 100644 --- a/test/unittest/cpp_test/src/input_method_switch_test.cpp +++ b/test/unittest/cpp_test/src/input_method_switch_test.cpp @@ -22,7 +22,6 @@ #include "global.h" #include "ime_event_monitor_manager_impl.h" -#include "ime_info_inquirer.h" #include "ime_setting_listener_test_impl.h" #include "input_method_controller.h" #include "input_method_property.h" @@ -71,15 +70,11 @@ constexpr const char *ENABLE_IME_KEYWORD = "settings.inputmethod.enable_ime"; void InputMethodSwitchTest::SetUpTestCase(void) { IMSA_HILOGI("InputMethodSwitchTest::SetUpTestCase"); - ImeInfoInquirer::GetInstance().InitSystemConfig(); - enableOn = ImeInfoInquirer::GetInstance().IsEnableInputMethod(); TddUtil::GrantNativePermission(); - if (enableOn == true) { + int32_t ret = TddUtil::GetEnableData(beforeValue); + if (ret == ErrorCode::NO_ERROR) { IMSA_HILOGI("Enable ime switch test."); - int32_t ret = TddUtil::GetEnableData(beforeValue); - if (ret == ErrorCode::NO_ERROR) { - TddUtil::PushEnableImeValue(ENABLE_IME_KEYWORD, allEnableIme); - } + TddUtil::PushEnableImeValue(ENABLE_IME_KEYWORD, allEnableIme); } TddUtil::StorageSelfTokenID(); TddUtil::SetTestTokenID( diff --git a/test/unittest/cpp_test/src/input_method_utils_test.cpp b/test/unittest/cpp_test/src/input_method_utils_test.cpp deleted file mode 100644 index 82f07535..00000000 --- a/test/unittest/cpp_test/src/input_method_utils_test.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "input_method_utils.h" - -#include -#include -#include -#include -#include - -#include "global.h" - -using namespace testing::ext; -namespace OHOS { -namespace MiscServices { -class InputMethodUtilsTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); -}; - -void InputMethodUtilsTest::SetUpTestCase(void) -{ - IMSA_HILOGI("InputMethodUtilsTest::SetUpTestCase"); -} - -void InputMethodUtilsTest::TearDownTestCase(void) -{ - IMSA_HILOGI("InputMethodUtilsTest::TearDownTestCase"); -} - -void InputMethodUtilsTest::SetUp(void) -{ - IMSA_HILOGI("InputMethodUtilsTest::SetUp"); -} - -void InputMethodUtilsTest::TearDown(void) -{ - IMSA_HILOGI("InputMethodUtilsTest::TearDown"); -} - -/** -* @tc.name: inputMethodUtils_functionKey_001 -* @tc.desc: Checkout FunctionKey. -* @tc.type: FUNC -*/ -HWTEST_F(InputMethodUtilsTest, inputMethodUtils_functionKey_001, TestSize.Level0) -{ - FunctionKey info; - info.SetEnterKeyType(EnterKeyType::UNSPECIFIED); - EnterKeyType keyType = info.GetEnterKeyType(); - EXPECT_EQ(keyType, EnterKeyType::UNSPECIFIED); -} -} // namespace MiscServices -} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/cpp_test/src/newIme_switch_test.cpp b/test/unittest/cpp_test/src/newIme_switch_test.cpp index 78b6c988..5eb4be20 100644 --- a/test/unittest/cpp_test/src/newIme_switch_test.cpp +++ b/test/unittest/cpp_test/src/newIme_switch_test.cpp @@ -21,7 +21,6 @@ #include "global.h" #include "ime_event_monitor_manager_impl.h" -#include "ime_info_inquirer.h" #include "ime_setting_listener_test_impl.h" #include "input_method_controller.h" #include "input_method_property.h" @@ -64,15 +63,11 @@ constexpr const char *ENABLE_IME_KEYWORD = "settings.inputmethod.enable_ime"; void NewImeSwitchTest::SetUpTestCase(void) { IMSA_HILOGI("NewImeSwitchTest::SetUpTestCase"); - ImeInfoInquirer::GetInstance().InitSystemConfig(); - enableOn = ImeInfoInquirer::GetInstance().IsEnableInputMethod(); TddUtil::GrantNativePermission(); - if (enableOn == true) { + int32_t ret = TddUtil::GetEnableData(beforeValue); + if (ret == ErrorCode::NO_ERROR) { IMSA_HILOGI("Enable ime switch test."); - int32_t ret = TddUtil::GetEnableData(beforeValue); - if (ret == ErrorCode::NO_ERROR) { - TddUtil::PushEnableImeValue(ENABLE_IME_KEYWORD, allEnableIme); - } + TddUtil::PushEnableImeValue(ENABLE_IME_KEYWORD, allEnableIme); } TddUtil::StorageSelfTokenID(); TddUtil::SetTestTokenID( diff --git a/test/unittest/cpp_test/src/security_mode_parser_test.cpp b/test/unittest/cpp_test/src/security_mode_parser_test.cpp index 9799aa1c..304739a2 100644 --- a/test/unittest/cpp_test/src/security_mode_parser_test.cpp +++ b/test/unittest/cpp_test/src/security_mode_parser_test.cpp @@ -17,8 +17,6 @@ #define protected public #include "security_mode_parser.h" -#include "ime_cfg_manager.h" -#include "ime_info_inquirer.h" #include "input_method_system_ability.h" #undef private