diff --git a/frameworks/inputmethod_ability/include/input_method_core_stub.h b/frameworks/inputmethod_ability/include/input_method_core_stub.h index d7b8f977bcfea1572452e2d1f6bf54016b7478af..72dea34e58f8d89172d9989e937789ff439cf8d2 100644 --- a/frameworks/inputmethod_ability/include/input_method_core_stub.h +++ b/frameworks/inputmethod_ability/include/input_method_core_stub.h @@ -22,7 +22,7 @@ #include "input_channel.h" #include #include -#include +#include #include "message_parcel.h" #include "input_attribute.h" #include "i_input_data_channel.h" diff --git a/frameworks/inputmethod_ability/src/input_method_ability.cpp b/frameworks/inputmethod_ability/src/input_method_ability.cpp index a24f64c73c458e58f0c57d89a21e59a9b20d202e..15e52462ae6fa0f3321a807da89724dc09a33a16 100644 --- a/frameworks/inputmethod_ability/src/input_method_ability.cpp +++ b/frameworks/inputmethod_ability/src/input_method_ability.cpp @@ -81,7 +81,7 @@ namespace MiscServices { mImms = GetImsaProxy(); sptr stub = new InputMethodCoreStub(0); stub->SetMessageHandler(msgHandler); - sptr stub2=stub; + sptr stub2 = stub; if (mImms != nullptr) { mImms->setInputMethodCore(stub2); } @@ -94,7 +94,10 @@ namespace MiscServices { IMSA_HILOGI("InputMethodAbility::Initialize"); InitialInputWindow(); msgHandler = new MessageHandler(); - workThreadHandler = std::thread([this]{WorkThread();}); + workThreadHandler = std::thread([this] + { + WorkThread(); + }); } void InputMethodAbility::setEventTarget(sptr &eventTarget) { @@ -104,7 +107,8 @@ namespace MiscServices { void InputMethodAbility::WorkThread() { - while(1){ + while(1) + { Message *msg = msgHandler->GetMessage(); switch(msg->msgId_) { case MSG_ID_INITIALIZE_INPUT: { @@ -132,7 +136,7 @@ namespace MiscServices { break; } - case MSG_ID_DISPATCH_KEY : { + case MSG_ID_DISPATCH_KEY: { DispatchKey(msg); break; } @@ -155,9 +159,10 @@ namespace MiscServices { IMSA_HILOGI("InputMethodAbility::OnInitialInput channelObject is nullptr"); return; } - sptr channelProxy=new InputControlChannelProxy(channelObject); + sptr channelProxy = new InputControlChannelProxy(channelObject); inputControlChannel = channelProxy; - if(inputControlChannel == nullptr) { + if (inputControlChannel == nullptr) + { IMSA_HILOGI("InputMethodAbility::OnInitialInput inputControlChannel is nullptr"); return; } @@ -170,17 +175,20 @@ namespace MiscServices { MessageParcel *data = msg->msgContent_; sptr channalProxy = new InputDataChannelProxy(data->ReadRemoteObject()); inputDataChannel = channalProxy; - if(inputDataChannel == nullptr) { + if (inputDataChannel == nullptr) + { IMSA_HILOGI("InputMethodAbility::OnStartInput inputDataChannel is nullptr"); } editorAttribute = data->ReadParcelable(); - if(editorAttribute == nullptr) { + if (editorAttribute == nullptr) + { IMSA_HILOGI("InputMethodAbility::OnStartInput editorAttribute is nullptr"); } mSupportPhysicalKbd = data->ReadBool(); CreateInputMethodAgent(mSupportPhysicalKbd); - if (inputControlChannel != nullptr) { + if (inputControlChannel != nullptr) + { IMSA_HILOGI("InputMethodAbility::OnStartInput inputControlChannel is not nullptr"); inputControlChannel->onAgentCreated(inputMethodAgent, nullptr); } @@ -232,13 +240,13 @@ namespace MiscServices { void InputMethodAbility::ShowInputWindow() { IMSA_HILOGI("InputMethodAbility::ShowInputWindow"); - eventTarget_->Emit("keyboardShow",nullptr); + eventTarget_->Emit("keyboardShow", nullptr); } void InputMethodAbility::DissmissInputWindow() { IMSA_HILOGI("InputMethodAbility::DissmissInputWindow"); - eventTarget_->Emit("keyboardHide",nullptr); + eventTarget_->Emit("keyboardHide", nullptr); } bool InputMethodAbility::InsertText(const std::string text) diff --git a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp index 581df3be93e483ffa3dbc7fb6a4ea3665c12ede6..ca2387c516ec80d28e178ae002dada2c9d4afa02 100644 --- a/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp +++ b/frameworks/inputmethod_ability/src/input_method_core_proxy.cpp @@ -52,7 +52,10 @@ namespace MiscServices { } else { IMSA_HILOGI("InputMethodCoreProxy::initializeInput Failed to write inputControlChannel"); } - MessageOption option { MessageOption::TF_SYNC }; + MessageOption option + { + MessageOption::TF_SYNC + }; int32_t status = Remote()->SendRequest(INITIALIZE_INPUT, data, reply, option); if (status != ErrorCode::NO_ERROR) { IMSA_HILOGI("InputMethodCoreProxy::initializeInput status = %{public}d", status); @@ -79,7 +82,10 @@ namespace MiscServices { return false; } MessageParcel reply; - MessageOption option { MessageOption::TF_SYNC }; + MessageOption option + { + MessageOption::TF_SYNC + }; int32_t status = Remote()->SendRequest(START_INPUT, data, reply, option); if (status != ErrorCode::NO_ERROR) { @@ -96,15 +102,18 @@ namespace MiscServices { IMSA_HILOGI("InputMethodCoreProxy::stopInput"); MessageParcel data, reply; data.WriteInterfaceToken(GetDescriptor()); - MessageOption option { MessageOption::TF_SYNC }; + MessageOption option + { + MessageOption::TF_SYNC + }; int32_t status = Remote()->SendRequest(STOP_INPUT, data, reply, option); if (status != ErrorCode::NO_ERROR) { - IMSA_HILOGI("InputMethodCoreProxy::stopInput status = %{public}d",status); + IMSA_HILOGI("InputMethodCoreProxy::stopInput status = %{public}d", status); return status; } int code = reply.ReadException(); if (code != ErrorCode::NO_ERROR) { - IMSA_HILOGI("InputMethodCoreProxy::stopInput code = %{public}d",code); + IMSA_HILOGI("InputMethodCoreProxy::stopInput code = %{public}d", code); return code; } return reply.ReadInt32(); @@ -114,7 +123,7 @@ namespace MiscServices { { IMSA_HILOGI("InputMethodCoreProxy::showKeyboard"); auto remote = Remote(); - if (remote == nullptr){ + if (remote == nullptr) { IMSA_HILOGI("InputMethodCoreProxy::showKeyboard remote is nullptr"); return false; } @@ -124,7 +133,10 @@ namespace MiscServices { return false; } MessageParcel reply; - MessageOption option{ MessageOption::TF_SYNC }; + MessageOption option + { + MessageOption::TF_SYNC + }; int32_t res = remote->SendRequest(SHOW_KEYBOARD, data, reply, option); if (res != ErrorCode::NO_ERROR) { @@ -146,7 +158,10 @@ namespace MiscServices { return false; } MessageParcel reply; - MessageOption option{ MessageOption::TF_SYNC }; + MessageOption option + { + MessageOption::TF_SYNC + }; int32_t res = remote->SendRequest(HIDE_KEYBOARD, data, reply, option); if (res != ErrorCode::NO_ERROR) { @@ -161,7 +176,10 @@ namespace MiscServices { MessageParcel data, reply; data.WriteInterfaceToken(GetDescriptor()); data.WriteParcelable(&type); - MessageOption option{ MessageOption::TF_SYNC }; + MessageOption option + { + MessageOption::TF_SYNC + }; int32_t status = Remote()->SendRequest(SET_KEYBOARD_TYPE, data, reply, option); if (status != ErrorCode::NO_ERROR) { return status; @@ -175,7 +193,10 @@ namespace MiscServices { IMSA_HILOGI("InputMethodCoreProxy::getKeyboardWindowHeight"); MessageParcel data, reply; data.WriteInterfaceToken(GetDescriptor()); - MessageOption option { MessageOption::TF_SYNC }; + MessageOption option + { + MessageOption::TF_SYNC + }; int32_t status = Remote()->SendRequest(GET_KEYBOARD_WINDOW_HEIGHT, data, reply, option); if (status != ErrorCode::NO_ERROR) { return status; diff --git a/frameworks/inputmethod_ability/src/input_method_core_stub.cpp b/frameworks/inputmethod_ability/src/input_method_core_stub.cpp index 3cf80ad0ec40e8ba47b6db1f6f9cdfce1cc7a043..d1d0862dc627389d9a45cb58a91733277106fa9f 100644 --- a/frameworks/inputmethod_ability/src/input_method_core_stub.cpp +++ b/frameworks/inputmethod_ability/src/input_method_core_stub.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ #include -#include +#include #include "message_handler.h" #include "i_input_data_channel.h" #include "input_method_core_stub.h" @@ -118,7 +118,7 @@ namespace MiscServices { sptr& inputControlChannel) { IMSA_HILOGI("InputMethodCoreStub::initializeInput"); - if (msgHandler_==nullptr) { + if (msgHandler_ == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } @@ -145,7 +145,7 @@ namespace MiscServices { return ErrorCode::ERROR_NULL_POINTER; } MessageParcel *data = new MessageParcel(); - if (inputDataChannel !=nullptr) { + if (inputDataChannel != nullptr) { IMSA_HILOGI("InputMethodCoreStub::startInput inputDataChannel is not nullptr"); data->WriteRemoteObject(inputDataChannel->AsObject()); } @@ -171,7 +171,7 @@ namespace MiscServices { bool InputMethodCoreStub::showKeyboard(int32_t flags) { IMSA_HILOGI("InputMethodCoreStub::showKeyboard"); - if (msgHandler_==nullptr) { + if (msgHandler_ == nullptr) { return false; } MessageParcel *data = new MessageParcel(); @@ -186,7 +186,7 @@ namespace MiscServices { bool InputMethodCoreStub::hideKeyboard(int32_t flags) { IMSA_HILOGI("InputMethodCoreStub::hideKeyboard"); - if (msgHandler_==nullptr) { + if (msgHandler_ == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } MessageParcel *data = new MessageParcel(); @@ -201,7 +201,7 @@ namespace MiscServices { int32_t InputMethodCoreStub::setKeyboardType(const KeyboardType& type) { IMSA_HILOGI("InputMethodCoreStub::setKeyboardType"); - if (msgHandler_==nullptr) { + if (msgHandler_ == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } MessageParcel *data = new MessageParcel(); @@ -215,7 +215,7 @@ namespace MiscServices { int32_t InputMethodCoreStub::getKeyboardWindowHeight(int32_t retHeight) { IMSA_HILOGI("InputMethodCoreStub::getKeyboardWindowHeight"); - if (msgHandler_==nullptr) { + if (msgHandler_ == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } MessageParcel *data = new MessageParcel(); @@ -227,7 +227,7 @@ namespace MiscServices { void InputMethodCoreStub::SetMessageHandler(MessageHandler *msgHandler) { - msgHandler_=msgHandler; + msgHandler_ = msgHandler; } } } \ No newline at end of file diff --git a/frameworks/inputmethod_controller/include/input_client_proxy.h b/frameworks/inputmethod_controller/include/input_client_proxy.h index 1cb1c5b4921176d4f42ce4b02928cb41f324d200..a6324edf847d0dc46371f6c09ec09f289d4da39a 100644 --- a/frameworks/inputmethod_controller/include/input_client_proxy.h +++ b/frameworks/inputmethod_controller/include/input_client_proxy.h @@ -23,18 +23,18 @@ namespace OHOS { namespace MiscServices { class InputClientProxy : public IRemoteProxy { -public: - explicit InputClientProxy(const sptr &object); - ~InputClientProxy() = default; - DISALLOW_COPY_AND_MOVE(InputClientProxy); + public: + explicit InputClientProxy(const sptr &object); + ~InputClientProxy() = default; + DISALLOW_COPY_AND_MOVE(InputClientProxy); - int32_t onInputReady(int32_t retValue, const sptr& agent, const InputChannel *channel) override; - int32_t onInputReleased(int32_t retValue) override; - int32_t setDisplayMode(int32_t mode) override; + int32_t onInputReady(int32_t retValue, const sptr& agent, const InputChannel *channel) override; + int32_t onInputReleased(int32_t retValue) override; + int32_t setDisplayMode(int32_t mode) override; -private: - static inline BrokerDelegator delegator_; -}; + private: + static inline BrokerDelegator delegator_; + }; } } #endif \ No newline at end of file diff --git a/frameworks/inputmethod_controller/include/input_method_system_ability_proxy.h b/frameworks/inputmethod_controller/include/input_method_system_ability_proxy.h index 741d25a6d9f6e6cfe5abd219ee4e7f44c081773f..2bda76ed189c2aee8ff77d5478fc31457c605748 100644 --- a/frameworks/inputmethod_controller/include/input_method_system_ability_proxy.h +++ b/frameworks/inputmethod_controller/include/input_method_system_ability_proxy.h @@ -47,7 +47,7 @@ class InputMethodSystemAbilityProxy : public IRemoteProxy &client); int32_t Stop(sptr &client); - virtual int32_t getDisplayMode(int32_t *retMode) override; + virtual int32_t getDisplayMode(int32_t retMode) override; virtual int32_t getKeyboardWindowHeight(int32_t retHeight) override; virtual int32_t getCurrentKeyboardType(KeyboardType *retType) override; virtual int32_t listInputMethodEnabled(std::vector *properties) override; diff --git a/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp b/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp index b596bd826a6949f31c4bd73e4c91dc7d575e039b..325ecbe287cede1771dc7cec856bfed4078aade5 100644 --- a/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp +++ b/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp @@ -226,7 +226,7 @@ namespace MiscServices { return NO_ERROR; } - int32_t InputMethodSystemAbilityProxy::getDisplayMode(int32_t *retMode) + int32_t InputMethodSystemAbilityProxy::getDisplayMode(int32_t retMode) { MessageParcel data, reply; MessageOption option; @@ -245,7 +245,7 @@ namespace MiscServices { return ret; } - if (!reply.ReadInt32(*retMode)) { + if (!reply.ReadInt32(retMode)) { return ERROR_STATUS_BAD_VALUE; } return NO_ERROR; diff --git a/services/include/i_input_method_system_ability.h b/services/include/i_input_method_system_ability.h index ad5657d1e569c71fcca15386800791927f55c28e..41ef2af673b8160a20bcdbd7084bd8d378547b83 100644 --- a/services/include/i_input_method_system_ability.h +++ b/services/include/i_input_method_system_ability.h @@ -54,7 +54,7 @@ namespace MiscServices { virtual void stopInput(MessageParcel& data) = 0; virtual int32_t setInputMethodCore(sptr &core)=0; - virtual int32_t getDisplayMode(int32_t *retMode) = 0; + virtual int32_t getDisplayMode(int32_t retMode) = 0; virtual int32_t getKeyboardWindowHeight(int32_t retHeight) = 0; virtual int32_t getCurrentKeyboardType(KeyboardType *retType) = 0; virtual int32_t listInputMethodEnabled(std::vector *properties) = 0; diff --git a/services/include/input_control_channel_stub.h b/services/include/input_control_channel_stub.h index 2db382e43ebd2fcfb24a93866df7097e36909e52..ef073a5a1d42d923990ebe6b5fe28ca566b0dafc 100644 --- a/services/include/input_control_channel_stub.h +++ b/services/include/input_control_channel_stub.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef FM_IMMS_PROJECT_INPUTCONTROLCHANNEL_SK_H -#define FM_IMMS_PROJECT_INPUTCONTROLCHANNEL_SK_H +#ifndef FM_IMMS_PROJECT_INPUTCONTROLCHANNELSTUB_H +#define FM_IMMS_PROJECT_INPUTCONTROLCHANNELSTUB_H #include "iremote_broker.h" #include "iremote_stub.h" @@ -57,4 +57,4 @@ namespace OHOS { }; } } -#endif // FM_IMMS_PROJECT_INPUTCONTROLCHANNEL_SK_H +#endif // FM_IMMS_PROJECT_INPUTCONTROLCHANNELSTUB_H diff --git a/services/include/input_method_system_ability.h b/services/include/input_method_system_ability.h index b4cca32fac459bb4c1c4263f3665dab588df1ff2..02df7a4c90b78a9b4bf6cb3f74478d667355b11f 100644 --- a/services/include/input_method_system_ability.h +++ b/services/include/input_method_system_ability.h @@ -45,7 +45,7 @@ namespace MiscServices { int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - virtual int32_t getDisplayMode(int32_t *retMode) override; + virtual int32_t getDisplayMode(int32_t retMode) override; virtual int32_t getKeyboardWindowHeight(int32_t retHeight) override; virtual int32_t getCurrentKeyboardType(KeyboardType *retType) override; virtual int32_t listInputMethodEnabled(std::vector *properties) override; diff --git a/services/include/peruser_session.h b/services/include/peruser_session.h index ea0b7997b26677c65d0f6a1710f6454bb59ace0f..6efcef110ee886b8ffe12fa6a8596c63b448b28e 100644 --- a/services/include/peruser_session.h +++ b/services/include/peruser_session.h @@ -174,7 +174,7 @@ namespace MiscServices { int AddClient(int pid, int uid, int displayId, const sptr& inputClient, const sptr& channel, const InputAttribute& attribute); - int RemoveClient(const sptr& inputClient, int *retClientNum); + int RemoveClient(const sptr& inputClient, int retClientNum); int StartInputMethod(int index); int StopInputMethod(int index); int ShowKeyboard(const sptr& inputClient); diff --git a/services/src/global.cpp b/services/src/global.cpp index 41b8c2375de006b90d5e0444799305fc5c43c237..408842a5a67ba17e601ec3027fb81fdf190733dd 100644 --- a/services/src/global.cpp +++ b/services/src/global.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include +#include #include "global.h" namespace OHOS { diff --git a/services/src/input_control_channel_stub.cpp b/services/src/input_control_channel_stub.cpp index 4aa7fa907d41cf297e18541a7ec933f924089a32..84f51d4302e3f621e6e362ded3eb05681a75dc75 100644 --- a/services/src/input_control_channel_stub.cpp +++ b/services/src/input_control_channel_stub.cpp @@ -14,7 +14,7 @@ */ #include -#include +#include #include "message_handler.h" #include "input_control_channel_stub.h" #include "i_input_control_channel.h" diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index e997b114d32790291aa0c38b26db406f5c455b24..5f424db1d729f07ef5cffea768582d1a2d0f9740 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -37,7 +37,7 @@ namespace MiscServices { * @param runOnCreate */ InputMethodSystemAbility::InputMethodSystemAbility(int32_t systemAbilityId, bool runOnCreate) - : SystemAbility(systemAbilityId, runOnCreate), state_(ServiceRunningState::STATE_NOT_START) + : SystemAbility(systemAbilityId, runOnCreate), state_(ServiceRunningState::STATE_NOT_START) { } @@ -200,7 +200,7 @@ namespace MiscServices { \return ErrorCode::NO_ERROR no error \return ErrorCode::ERROR_USER_NOT_UNLOCKED user not unlocked */ - int32_t InputMethodSystemAbility::getDisplayMode(int32_t *retMode) + int32_t InputMethodSystemAbility::getDisplayMode(int32_t retMode) { int32_t uid = IPCSkeleton::GetCallingUid(); int32_t userId = getUserId(uid); @@ -209,7 +209,7 @@ namespace MiscServices { IMSA_HILOGE("%s %d\n", ErrorCode::ToString(ErrorCode::ERROR_USER_NOT_UNLOCKED), userId); return ErrorCode::ERROR_USER_NOT_UNLOCKED; } - *retMode = GetUserSession(userId)->GetDisplayMode(); + retMode = GetUserSession(userId)->GetDisplayMode(); return ErrorCode::NO_ERROR; } diff --git a/services/src/input_method_system_ability_stub.cpp b/services/src/input_method_system_ability_stub.cpp index 8986504b42459b6b31cb4a2af0fb26cbbc7ddab7..e8cb3586b70aded0cb28c6e8e00f5a6a99679949 100644 --- a/services/src/input_method_system_ability_stub.cpp +++ b/services/src/input_method_system_ability_stub.cpp @@ -69,7 +69,7 @@ namespace MiscServices { } case GET_DISPLAY_MODE: { int32_t mode = 0; - int32_t status = getDisplayMode(&mode); + int32_t status = getDisplayMode(mode); if (status == ErrorCode::NO_ERROR) { reply.WriteInt32(NO_ERROR); reply.WriteInt32(mode); diff --git a/services/src/peruser_session.cpp b/services/src/peruser_session.cpp index d1529ed85dcddb7a7d0f7b892d262717c27c2339..d9c51fe5f704372fd6a07c7e73ac07c03c14c5b5 100644 --- a/services/src/peruser_session.cpp +++ b/services/src/peruser_session.cpp @@ -351,7 +351,7 @@ namespace MiscServices { \return ErrorCode::NO_ERROR no error \return ErrorCode::ERROR_CLIENT_NOT_FOUND client is not found */ - int PerUserSession::RemoveClient(const sptr& inputClient, int *remainClientNum) + int PerUserSession::RemoveClient(const sptr& inputClient, int remainClientNum) { IMSA_HILOGE("PerUserSession::RemoveClient"); sptr b = inputClient->AsObject(); @@ -373,12 +373,10 @@ namespace MiscServices { delete clientInfo; mapClients.erase(it); - if(remainClientNum!=nullptr) { - *remainClientNum = 0; - for(it=mapClients.begin(); it!=mapClients.end(); ++it) { - if (it->second->attribute.GetSecurityFlag() == flag) { - (*remainClientNum)++; - } + remainClientNum = 0; + for(it=mapClients.begin(); it!=mapClients.end(); ++it) { + if (it->second->attribute.GetSecurityFlag() == flag) { + remainClientNum++; } } return ErrorCode::NO_ERROR; @@ -659,7 +657,7 @@ namespace MiscServices { if (currentClient != nullptr) { HideKeyboard(client); } - RemoveClient(client, &remainClientNum); + RemoveClient(client, remainClientNum); } /*! Handle the situation a input method service died\n @@ -1345,7 +1343,7 @@ namespace MiscServices { if (currentClient == interface) { HideKeyboard(client); } - int ret = RemoveClient(client, &remainClientNum); + int ret = RemoveClient(client, remainClientNum); if (ret != ErrorCode::NO_ERROR) { IMSA_HILOGE("PerUserSession::OnReleaseInput Aborted! Failed to RemoveClient [%{public}d]\n", userId_); } diff --git a/services/src/platform_api_proxy.cpp b/services/src/platform_api_proxy.cpp index 2b40201fc045d18dc6009332665be438fdb25c15..4e5bce42a27bfa39bda569495e2f66f1d43295c5 100644 --- a/services/src/platform_api_proxy.cpp +++ b/services/src/platform_api_proxy.cpp @@ -22,17 +22,16 @@ #include "peer_holder.h" #include "utils.h" #include -#include +#include /*! \class PlatformApiProxy \brief The proxy implementation of IPlatformApi */ namespace OHOS { namespace MiscServices { - class PlatformApiProxy : public IRemoteProxy < IPlatformApi > { + class PlatformApiProxy : public IRemoteProxy { public: - PlatformApiProxy(const sptr& impl) - : IRemoteProxy < IPlatformApi >(impl) + PlatformApiProxy(const sptr& impl) : IRemoteProxy(impl) { } @@ -40,7 +39,7 @@ namespace MiscServices { { } - int32_t registerCallback(const sptr < IPlatformCallback >& cb) + int32_t registerCallback(const sptr& cb) { MessageParcel data, reply; MessageOption option; @@ -62,7 +61,7 @@ namespace MiscServices { return Utils::to_utf16("20210814"); } - sptr < IInputMethodCore > bindInputMethodService(const std::u16string& packageName, + sptr bindInputMethodService(const std::u16string& packageName, const std::u16string& intention, int userId) { MessageParcel data, reply; @@ -104,7 +103,7 @@ namespace MiscServices { return ErrorCode::NO_ERROR; } - sptr < IRemoteObject > createWindowToken(int userId, int displayId, const std::u16string& packageName) + sptr createWindowToken(int userId, int displayId, const std::u16string& packageName) { MessageParcel data, reply; MessageOption option; diff --git a/services/src/platform_callback_proxy.cpp b/services/src/platform_callback_proxy.cpp index 4bc3871e9b4c74d3ea0109d1fc94e3023df390b3..0d9834268fac0e3b1ea59cf44c980158f502268e 100644 --- a/services/src/platform_callback_proxy.cpp +++ b/services/src/platform_callback_proxy.cpp @@ -26,8 +26,7 @@ namespace OHOS { namespace MiscServices { class PlatformCallbackProxy : public IRemoteProxy { public: - PlatformCallbackProxy(const sptr < IRemoteObject >& impl) - : IRemoteProxy < IPlatformCallback >(impl) + PlatformCallbackProxy(const sptr& impl) : IRemoteProxy(impl) { } @@ -35,7 +34,7 @@ namespace MiscServices { { } - void notifyEvent(int eventId, int userId, const std::vector < std::u16string >& eventContent) + void notifyEvent(int eventId, int userId, const std::vector& eventContent) { (void)eventId; (void)userId; diff --git a/unitest/src/input_method_ability_test.cpp b/unitest/src/input_method_ability_test.cpp index 8dc78bc9550fe240519c750f1b52196ae48825f9..8270a8a98e74079934f14c181b795878ee82a493 100644 --- a/unitest/src/input_method_ability_test.cpp +++ b/unitest/src/input_method_ability_test.cpp @@ -20,21 +20,16 @@ #include #include #include "global.h" -#include "ability_manager_interface.h" -#include "ability_connect_callback_proxy.h" -#include "system_ability_definition.h" -#include "want.h" -#include "input_method_ability_connection_stub.h" -#include "ability_connect_callback_proxy.h" -#include "sa_mgr_client.h" -#include "element_name.h" #include "input_method_ability.h" +#include "input_method_agent_stub.h" +#include "input_method_core_stub.h" +#include "input_control_channel_stub.h" +#include "input_attribute.h" #include "message_handler.h" using namespace testing::ext; using namespace OHOS; using namespace OHOS::MiscServices; -using namespace OHOS::AAFwk; class InputMethodAbilityTest : public testing::Test { public: @@ -62,4 +57,98 @@ void InputMethodAbilityTest::SetUp(void) void InputMethodAbilityTest::TearDown(void) { IMSA_HILOGI("InputMethodAbilityTest::TearDown"); +} + +/** +* @tc.name: Ima001 +* @tc.desc: Checkout IInputMethodAgent. +* @tc.type: FUNC +*/ +HWTEST_F(InputMethodAbilityTest, Ima001, TestSize.Level0) +{ + sptr mInputMethodAgentStub = new InputMethodAgentStub(); + MessageParcel data; + auto ret = data.WriteRemoteObject(mInputMethodAgentStub->AsObject()); + ASSERT_TRUE(ret); + auto remoteObject = data.ReadRemoteObject(); + sptr iface = iface_cast(remoteObject); + ASSERT_TRUE(iface != nullptr); +} + +/** +* @tc.name: Ima002 +* @tc.desc: Checkout IInputMethodCore. +* @tc.type: FUNC +*/ +HWTEST_F(InputMethodAbilityTest, Ima002, TestSize.Level0) +{ + sptr mInputMethodCoreStub = new InputMethodCoreStub(0); + MessageParcel data; + auto ret = data.WriteRemoteObject(mInputMethodCoreStub->AsObject()); + ASSERT_TRUE(ret); + auto remoteObject = data.ReadRemoteObject(); + sptr iface = iface_cast(remoteObject); + ASSERT_TRUE(iface != nullptr); +} + +/** +* @tc.name: Ima003 +* @tc.desc: Checkout IInputControlChannel. +* @tc.type: FUNC +*/ +HWTEST_F(InputMethodAbilityTest, Ima003, TestSize.Level0) +{ + sptr mInputControlChannelStub = new InputControlChannelStub(0); + MessageParcel data; + auto ret = data.WriteRemoteObject(mInputControlChannelStub->AsObject()); + ASSERT_TRUE(ret); + auto remoteObject = data.ReadRemoteObject(); + sptr iface = iface_cast(remoteObject); + ASSERT_TRUE(iface != nullptr); +} + +/** +* @tc.name: Ima004 +* @tc.desc: Checkout the function of getInstance. +* @tc.type: FUNC +*/ +HWTEST_F(InputMethodAbilityTest, Ima004, TestSize.Level0) +{ + auto ima = InputMethodAbility::GetInstance(); + ASSERT_TRUE(ima != nullptr); +} + +/** +* @tc.name: Ima005 +* @tc.desc: Checkout the serialization of InputAttribute. +* @tc.type: FUNC +*/ +HWTEST_F(InputMethodAbilityTest, Ima005, TestSize.Level0) +{ + sptr mInputAttribute = new InputAttribute(); + mInputAttribute->SetInputPattern(InputAttribute::PATTERN_PASSWORD); + MessageParcel data; + auto ret = data.WriteParcelable(mInputAttribute); + ASSERT_TRUE(ret); + sptr deserialization = data.ReadParcelable(); + ASSERT_TRUE(deserialization != nullptr); + ASSERT_TRUE(deserialization->GetSecurityFlag()); +} + +/** +* @tc.name: Ima006 +* @tc.desc: Checkout the serialization of KeyboardType. +* @tc.type: FUNC +*/ +HWTEST_F(InputMethodAbilityTest, Ima006, TestSize.Level0) +{ + int32_t def_value = 2021; + sptr mKeyboardType = new KeyboardType(); + mKeyboardType->setId(def_value); + MessageParcel data; + auto ret = data.WriteParcelable(mKeyboardType); + ASSERT_TRUE(ret); + sptr deserialization = data.ReadParcelable(); + ASSERT_TRUE(deserialization != nullptr); + ASSERT_TRUE(deserialization->getId() == def_value); } \ No newline at end of file diff --git a/unitest/src/input_method_controller_test.cpp b/unitest/src/input_method_controller_test.cpp index 9cf0bc82c108d22ea975931f5c69714b5c911d63..3c9b7e44a2b2104e09e84cb8ce7dca0a0da099f7 100644 --- a/unitest/src/input_method_controller_test.cpp +++ b/unitest/src/input_method_controller_test.cpp @@ -29,6 +29,7 @@ #include "input_client_stub.h" #include "iservice_registry.h" #include "system_ability_definition.h" +#include "input_method_setting.h" using namespace testing::ext; using namespace OHOS; @@ -83,10 +84,114 @@ void InputMethodControllerTest::TearDown(void) /** * @tc.name: Imc001 -* @tc.desc: Bind IMSA. +* @tc.desc: Get Imsa Proxy. * @tc.type: FUNC */ HWTEST_F(InputMethodControllerTest, Imc001, TestSize.Level0) +{ + auto systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_TRUE(systemAbilityManager != nullptr); + auto systemAbility = systemAbilityManager->GetSystemAbility(INPUT_METHOD_SYSTEM_ABILITY_ID, ""); + ASSERT_TRUE(systemAbility != nullptr); +} + +/** +* @tc.name: Imc002 +* @tc.desc: Checkout IInputDataChannel. +* @tc.type: FUNC +*/ +HWTEST_F(InputMethodControllerTest, Imc002, TestSize.Level0) +{ + sptr mInputDataChannel = new InputDataChannelStub(); + MessageParcel data; + auto ret = data.WriteRemoteObject(mInputDataChannel->AsObject()); + ASSERT_TRUE(ret); + auto remoteObject = data.ReadRemoteObject(); + sptr iface = iface_cast(remoteObject); + ASSERT_TRUE(iface != nullptr); +} + +/** +* @tc.name: Imc003 +* @tc.desc: Bind IMSA. +* @tc.type: FUNC +*/ +HWTEST_F(InputMethodControllerTest, Imc003, TestSize.Level0) +{ + sptr mClient = new InputClientStub(); + MessageParcel data; + auto ret = data.WriteRemoteObject(mClient->AsObject()); + ASSERT_TRUE(ret); + auto remoteObject = data.ReadRemoteObject(); + sptr iface = iface_cast(remoteObject); + ASSERT_TRUE(iface != nullptr); +} + +/** +* @tc.name: Imc004 +* @tc.desc: Checkout setting. +* @tc.type: FUNC +*/ +HWTEST_F(InputMethodControllerTest, Imc004, TestSize.Level0) +{ + InputMethodSetting setting; + std::u16string key = InputMethodSetting::CURRENT_INPUT_METHOD_TAG; + std::u16string oldValue = setting.GetValue(key); + std::u16string newValue = u"testCurrentImeId"; + setting.SetValue(key, newValue); + ASSERT_TRUE(newValue == setting.GetValue(key)); + + setting.SetValue(key, oldValue); + ASSERT_TRUE(oldValue == setting.GetValue(key)); +} + +/** +* @tc.name: Imc005 +* @tc.desc: Checkout setting. +* @tc.type: FUNC +*/ +HWTEST_F(InputMethodControllerTest, Imc005, TestSize.Level0) +{ + InputMethodSetting setting; + std::u16string curIme = setting.GetCurrentInputMethod(); + std::u16string testIme = u"testCurrentImeId"; + setting.SetCurrentInputMethod(testIme); + ASSERT_TRUE(testIme == setting.GetCurrentInputMethod()); + + setting.SetCurrentInputMethod(curIme); + ASSERT_TRUE(curIme == setting.GetCurrentInputMethod()); +} + +/** +* @tc.name: Imc006 +* @tc.desc: Checkout setting. +* @tc.type: FUNC +*/ +HWTEST_F(InputMethodControllerTest, Imc006, TestSize.Level0) +{ + InputMethodSetting setting; + int32_t curType = setting.GetCurrentKeyboardType(); + int32_t testType = 10; + setting.SetCurrentKeyboardType(testType); + ASSERT_TRUE(testType == setting.GetCurrentKeyboardType()); + + setting.SetCurrentKeyboardType(curType); + ASSERT_TRUE(curType == setting.GetCurrentKeyboardType()); + + curType = setting.GetCurrentKeyboardType(); + setting.SetCurrentKeyboardType(testType); + ASSERT_TRUE(testType == setting.GetCurrentKeyboardType()); + + setting.SetCurrentKeyboardType(curType); + ASSERT_TRUE(curType == setting.GetCurrentKeyboardType()); +} + +/** +* @tc.name: Imc007 +* @tc.desc: Bind IMSA. +* @tc.type: FUNC +*/ +HWTEST_F(InputMethodControllerTest, Imc007, TestSize.Level0) { IMSA_HILOGI("IMC TEST START"); sptr imc = InputMethodController::GetInstance();