From 859029d62577fe7ab0e36409487ac0bcc49e7923 Mon Sep 17 00:00:00 2001 From: zhouyongfei Date: Mon, 11 Oct 2021 12:00:04 +0800 Subject: [PATCH] fix warning Signed-off-by: zhouyongfei --- .../include/input_method_core_stub.h | 6 ++-- .../src/input_method_ability.cpp | 3 +- .../input_method_system_ability_proxy.h | 2 +- .../src/input_method_controller.cpp | 2 +- services/include/i_platform_callback.h | 22 ++++++------- services/include/input_control_channel_stub.h | 4 +-- .../input_method_system_ability_stub.h | 1 + services/include/message_handler.h | 2 +- services/include/peruser_session.h | 1 + services/include/platform_callback_stub.h | 21 ++++++------- services/include/utils.h | 14 ++++----- services/src/input_control_channel_stub.cpp | 2 -- services/src/input_method_system_ability.cpp | 2 +- .../src/input_method_system_ability_stub.cpp | 3 +- services/src/keyboard_type.cpp | 4 +-- services/src/message_handler.cpp | 4 +-- services/src/peruser_session.cpp | 31 +++++++++++-------- services/src/peruser_setting.cpp | 19 ++++++------ services/src/platform_api_proxy.cpp | 1 - 19 files changed, 73 insertions(+), 71 deletions(-) diff --git a/frameworks/inputmethod_ability/include/input_method_core_stub.h b/frameworks/inputmethod_ability/include/input_method_core_stub.h index 72dea34..4bf35db 100644 --- a/frameworks/inputmethod_ability/include/input_method_core_stub.h +++ b/frameworks/inputmethod_ability/include/input_method_core_stub.h @@ -16,13 +16,13 @@ #ifndef FM_IMMS_PROJECT_INPUTCONTROLCHANNEL_SK_H #define FM_IMMS_PROJECT_INPUTCONTROLCHANNEL_SK_H +#include +#include +#include #include "iremote_broker.h" #include "iremote_stub.h" #include "i_input_method_agent.h" #include "input_channel.h" -#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 3ceaad6..6be1a4d 100644 --- a/frameworks/inputmethod_ability/src/input_method_ability.cpp +++ b/frameworks/inputmethod_ability/src/input_method_ability.cpp @@ -97,8 +97,7 @@ namespace MiscServices { IMSA_HILOGI("InputMethodAbility::Initialize"); InitialInputWindow(); msgHandler = new MessageHandler(); - workThreadHandler = std::thread([this] - { + workThreadHandler = std::thread([this] { WorkThread(); }); } 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 2bda76e..fcd4e59 100644 --- a/frameworks/inputmethod_controller/include/input_method_system_ability_proxy.h +++ b/frameworks/inputmethod_controller/include/input_method_system_ability_proxy.h @@ -29,7 +29,7 @@ namespace OHOS { namespace MiscServices { -class InputMethodSystemAbilityProxy : public IRemoteProxy { + class InputMethodSystemAbilityProxy : public IRemoteProxy { public: explicit InputMethodSystemAbilityProxy(const sptr &object); ~InputMethodSystemAbilityProxy() = default; diff --git a/frameworks/inputmethod_controller/src/input_method_controller.cpp b/frameworks/inputmethod_controller/src/input_method_controller.cpp index 23c6948..f695006 100644 --- a/frameworks/inputmethod_controller/src/input_method_controller.cpp +++ b/frameworks/inputmethod_controller/src/input_method_controller.cpp @@ -64,7 +64,7 @@ using namespace MessageID; mInputDataChannel = new InputDataChannelStub(); mInputDataChannel->SetHandler(msgHandler); - workThreadHandler = std::thread([this]{WorkThread();}); + workThreadHandler = std::thread([this] {WorkThread();}); mAttribute.SetInputPattern(InputAttribute::PATTERN_TEXT); textListener = nullptr; diff --git a/services/include/i_platform_callback.h b/services/include/i_platform_callback.h index e455486..2c94b53 100644 --- a/services/include/i_platform_callback.h +++ b/services/include/i_platform_callback.h @@ -23,17 +23,17 @@ #include "global.h" namespace OHOS { - namespace MiscServices { - class IPlatformCallback : public IRemoteBroker { - public: - enum { - NOTIFY_EVENT = OHOS::FIRST_CALL_TRANSACTION, - }; - - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.IPlatformCallback"); - - virtual void notifyEvent(int eventId, int userId, const std::vector& eventContent) = 0; +namespace MiscServices { + class IPlatformCallback : public IRemoteBroker { + public: + enum { + NOTIFY_EVENT = OHOS::FIRST_CALL_TRANSACTION, }; - } + + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.IPlatformCallback"); + + virtual void notifyEvent(int eventId, int userId, const std::vector& eventContent) = 0; + }; +} } #endif // FM_IMMS_PROJECT_IPLATFORMCALLBACK_H diff --git a/services/include/input_control_channel_stub.h b/services/include/input_control_channel_stub.h index b1addd9..bcaa1df 100644 --- a/services/include/input_control_channel_stub.h +++ b/services/include/input_control_channel_stub.h @@ -16,12 +16,12 @@ #ifndef FM_IMMS_PROJECT_INPUTCONTROLCHANNELSTUB_H #define FM_IMMS_PROJECT_INPUTCONTROLCHANNELSTUB_H +#include +#include #include "iremote_broker.h" #include "iremote_stub.h" #include "i_input_method_agent.h" #include "input_channel.h" -#include -#include #include "message_parcel.h" #include "i_input_control_channel.h" diff --git a/services/include/input_method_system_ability_stub.h b/services/include/input_method_system_ability_stub.h index df9c38e..ad4d819 100644 --- a/services/include/input_method_system_ability_stub.h +++ b/services/include/input_method_system_ability_stub.h @@ -35,6 +35,7 @@ namespace MiscServices { void setInputMethodCoreFromHap(MessageParcel& data); protected: int32_t getUserId(int32_t uid); + int USER_ID_CHANGE_VALUE = 1000000; }; } } diff --git a/services/include/message_handler.h b/services/include/message_handler.h index 56ca14e..b370193 100644 --- a/services/include/message_handler.h +++ b/services/include/message_handler.h @@ -76,7 +76,7 @@ namespace MessageID { }; } -class MessageHandler { + class MessageHandler { public: MessageHandler(); ~MessageHandler(); diff --git a/services/include/peruser_session.h b/services/include/peruser_session.h index 75bd340..edfb3b8 100644 --- a/services/include/peruser_session.h +++ b/services/include/peruser_session.h @@ -122,6 +122,7 @@ namespace MiscServices { int currentIndex; std::map, ClientInfo*> mapClients; int MIN_IME = 2; + int IME_ERROR_CODE = 3; int COMMON_COUNT_THREE_HUNDRED = 300; InputMethodProperty *currentIme[MAX_IME]; // 0 - the default ime. 1 - security ime diff --git a/services/include/platform_callback_stub.h b/services/include/platform_callback_stub.h index 504f1d6..b20b514 100644 --- a/services/include/platform_callback_stub.h +++ b/services/include/platform_callback_stub.h @@ -23,17 +23,16 @@ #include "i_platform_callback.h" namespace OHOS { - namespace MiscServices { - class PlatformCallbackStub : public IRemoteStub { - public: - PlatformCallbackStub(); - ~PlatformCallbackStub(); +namespace MiscServices { + class PlatformCallbackStub : public IRemoteStub { + public: + PlatformCallbackStub(); + ~PlatformCallbackStub(); - virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option) override; - virtual void notifyEvent(int eventId, int userId, const std::vector& eventContent) override; - }; - - } + virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, + MessageOption &option) override; + virtual void notifyEvent(int eventId, int userId, const std::vector& eventContent) override; + }; +} } #endif // FM_IMMS_PROJECT_PLATFORMCALLBACK_SK_H diff --git a/services/include/utils.h b/services/include/utils.h index 4e24b67..8312017 100644 --- a/services/include/utils.h +++ b/services/include/utils.h @@ -26,13 +26,13 @@ namespace OHOS { namespace MiscServices { class Utils { - public: - static std::string to_utf8(std::u16string str16) { - return std::wstring_convert, char16_t>{}.to_bytes(str16); - } - static std::u16string to_utf16(std::string str) { - return std::wstring_convert, char16_t>{}.from_bytes(str); - } + public: + static std::string to_utf8(std::u16string str16) { + return std::wstring_convert, char16_t> {}.to_bytes(str16); + } + static std::u16string to_utf16(std::string str) { + return std::wstring_convert, char16_t> {}.from_bytes(str); + } }; } } diff --git a/services/src/input_control_channel_stub.cpp b/services/src/input_control_channel_stub.cpp index 903b990..4fb9204 100644 --- a/services/src/input_control_channel_stub.cpp +++ b/services/src/input_control_channel_stub.cpp @@ -13,8 +13,6 @@ * limitations under the License. */ -#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 fee4092..246dc98 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -582,7 +582,7 @@ namespace MiscServices { std::map::iterator it = msgHandlers.find(userId); if (it != msgHandlers.end()) { MessageHandler *handler = it->second; - Message *destMsg = new Message(MSG_ID_USER_LOCK , nullptr); + Message *destMsg = new Message(MSG_ID_USER_LOCK, nullptr); if (destMsg != nullptr) { handler->SendMessage(destMsg); PerUserSession *userSession = GetUserSession(userId); diff --git a/services/src/input_method_system_ability_stub.cpp b/services/src/input_method_system_ability_stub.cpp index 81ceaea..9532c57 100644 --- a/services/src/input_method_system_ability_stub.cpp +++ b/services/src/input_method_system_ability_stub.cpp @@ -207,7 +207,6 @@ namespace MiscServices { Message *msg = new Message(MSG_ID_RELEASE_INPUT, parcel); MessageHandler::Instance()->SendMessage(msg); - } /*! Start input @@ -271,7 +270,7 @@ namespace MiscServices { */ int32_t InputMethodSystemAbilityStub::getUserId(int32_t uid) { - return uid/1000000; + return uid/USER_ID_CHANGE_VALUE; } } } \ No newline at end of file diff --git a/services/src/keyboard_type.cpp b/services/src/keyboard_type.cpp index 5956659..c92fe77 100644 --- a/services/src/keyboard_type.cpp +++ b/services/src/keyboard_type.cpp @@ -106,9 +106,9 @@ namespace MiscServices { { mId = typeId; if (typeId != ID_NONE) { - mHashCode = typeId; + mHashCode = typeId; } else { - mHashCode = ID_NONE; + mHashCode = ID_NONE; } } diff --git a/services/src/message_handler.cpp b/services/src/message_handler.cpp index 46ab8de..d69fe04 100644 --- a/services/src/message_handler.cpp +++ b/services/src/message_handler.cpp @@ -46,7 +46,7 @@ namespace MiscServices { std::unique_lock lock(mMutex); mQueue.push(msg); } - mCV.notify_one(); + mCV.notify_one(); } /*! Get a message @@ -56,7 +56,7 @@ namespace MiscServices { Message *MessageHandler::GetMessage() { std::unique_lock lock(mMutex); - mCV.wait(lock, [this]{ + mCV.wait(lock, [this] { return !this->mQueue.empty(); }); diff --git a/services/src/peruser_session.cpp b/services/src/peruser_session.cpp index 9abfba4..51aec8a 100644 --- a/services/src/peruser_session.cpp +++ b/services/src/peruser_session.cpp @@ -13,15 +13,14 @@ * limitations under the License. */ -#include -#include "unistd.h" //usleep -#include "peruser_session.h" #include "platform.h" #include "parcel.h" #include "message_parcel.h" #include "utils.h" #include "want.h" #include "input_method_ability_connection_stub.h" +#include +#include "peruser_session.h" #include "ability_connect_callback_proxy.h" #include "ability_manager_interface.h" #include "sa_mgr_client.h" @@ -101,7 +100,7 @@ namespace MiscServices { void PerUserSession::CreateWorkThread(MessageHandler& handler) { msgHandler = &handler; - workThreadHandler = std::thread([this]{WorkThread();}); + workThreadHandler = std::thread([this] {WorkThread();}); } /*! Wait till work thread exits @@ -266,10 +265,12 @@ namespace MiscServices { } if (flag) { int ret = StartInputMethod(i); + if (ret != ErrorCode::NO_ERROR) { + needReshowClient = nullptr; + break; + } if (needReshowClient && GetImeIndex(needReshowClient) == i) { - if (ret == ErrorCode::NO_ERROR) { - ShowKeyboard(needReshowClient); - } + ShowKeyboard(needReshowClient); needReshowClient = nullptr; } } @@ -502,11 +503,13 @@ namespace MiscServices { ret = imsCore[index]->showKeyboard(1); if (!ret) { - IMSA_HILOGE("PerUserSession::ShowKeyboard Aborted! showKeyboard has error : %{public}s", ErrorCode::ToString(ret)); + IMSA_HILOGE("PerUserSession::ShowKeyboard Aborted! showKeyboard has error : %{public}s", + ErrorCode::ToString(ret)); int ret_client = clientInfo->client->onInputReady(1, nullptr, nullptr); if (ret_client != ErrorCode::NO_ERROR) { - IMSA_HILOGE("PerUserSession::ShowKeyboard onInputReady has error : %{public}s", ErrorCode::ToString(ret_client)); + IMSA_HILOGE("PerUserSession::ShowKeyboard onInputReady has error : %{public}s", + ErrorCode::ToString(ret_client)); } return ErrorCode::ERROR_KBD_SHOW_FAILED; } @@ -517,7 +520,8 @@ namespace MiscServices { int result = clientInfo->client->onInputReady(0, imsAgent, imsChannel); if (result != ErrorCode::NO_ERROR) { - IMSA_HILOGE("PerUserSession::ShowKeyboard Aborted! onInputReady return : %{public}s", ErrorCode::ToString(ret)); + IMSA_HILOGE("PerUserSession::ShowKeyboard Aborted! onInputReady return : %{public}s", + ErrorCode::ToString(ret)); return result; } currentClient = inputClient; @@ -564,7 +568,8 @@ namespace MiscServices { int ret_client_stop = clientInfo->client->onInputReady(1, nullptr, nullptr); if (ret_client_stop != ErrorCode::NO_ERROR) { - IMSA_HILOGE("PerUserSession::HideKeyboard onInputReady return : %{public}s", ErrorCode::ToString(ret_client_stop)); + IMSA_HILOGE("PerUserSession::HideKeyboard onInputReady return : %{public}s", + ErrorCode::ToString(ret_client_stop)); } currentClient = nullptr; imsAgent = nullptr; @@ -692,7 +697,7 @@ namespace MiscServices { StopInputMethod(1 - index); } - if (IncreaseOrResetImeError(false, index) == 3) { + if (IncreaseOrResetImeError(false, index) == IME_ERROR_CODE) { // call to disable the current input method. MessageParcel *parcel = new MessageParcel(); parcel->WriteInt32(userId_); @@ -851,7 +856,7 @@ namespace MiscServices { return; } int size = 0; - if (index == SECURITY_IME || currentIme[DEFAULT_IME] == currentIme[SECURITY_IME] ) { + if (index == SECURITY_IME || currentIme[DEFAULT_IME] == currentIme[SECURITY_IME]) { size = currentIme[index]->mTypes.size(); } else { std::u16string imeId = currentIme[index]->mImeId; diff --git a/services/src/peruser_setting.cpp b/services/src/peruser_setting.cpp index 4a8b884..6b241c3 100644 --- a/services/src/peruser_setting.cpp +++ b/services/src/peruser_setting.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "unistd.h" //usleep +#include "unistd.h" #include "peruser_setting.h" #include "platform.h" #include "utils.h" @@ -67,14 +67,15 @@ namespace MiscServices { } } - /*! Add an input method engine. - \n It's called when a package is installed in the system. - \param packageName the package name of installed package. - \param[out] isSecurityIme check if the added ime is a security ime. - \return ErrorCode::NO_ERROR The installed package is an IME package, and is added in the input method management system - \return ErrorCode::ERROR_NOT_IME_PACKAGE The installed package is not an IME package. - \return ErrorCode::ERROR_IME_PACKAGE_DUPLICATED The installed package is duplicated. - */ + /** + * Add an input method engine.It's called when a package is installed in the system. + * @param packageName the package name of installed package. + * @param isSecurityIme check if the added ime is a security ime. + * @return ErrorCode::NO_ERROR The installed package is an IME package, + * and is added in the input method management system + * ErrorCode::ERROR_NOT_IME_PACKAGE The installed package is not an IME package. + * ErrorCode::ERROR_IME_PACKAGE_DUPLICATED The installed package is duplicated. + */ int PerUserSetting::OnPackageAdded(std::u16string& packageName, bool isSecurityIme) { if (isSecurityIme) { diff --git a/services/src/platform_api_proxy.cpp b/services/src/platform_api_proxy.cpp index 674eaf9..4906fad 100644 --- a/services/src/platform_api_proxy.cpp +++ b/services/src/platform_api_proxy.cpp @@ -167,7 +167,6 @@ namespace MiscServices { return ErrorCode::NO_ERROR; } - virtual int32_t getInputMethodProperty(int userId, const std::u16string& packageName, InputMethodProperty *inputMethodProperty) {