From 8dac508bdc06caa03bd966890c40748a28a204bb Mon Sep 17 00:00:00 2001 From: zhouyongfei Date: Mon, 27 Sep 2021 19:38:28 +0800 Subject: [PATCH] fix warning Signed-off-by: zhouyongfei --- .../include/input_client_stub.h | 6 +- .../include/input_data_channel_stub.h | 2 +- .../src/input_method_system_ability_proxy.cpp | 3 +- services/include/input_attribute.h | 2 +- services/include/input_channel.h | 2 +- services/include/input_method_property.h | 2 +- services/include/input_method_setting.h | 2 +- services/include/keyboard_type.h | 2 +- services/include/message.h | 4 +- services/include/message_handler.h | 6 +- services/include/peruser_session.h | 5 +- services/include/peruser_setting.h | 4 +- services/include/platform.h | 4 +- services/src/global.cpp | 2 +- services/src/input_control_channel_stub.cpp | 2 +- .../input_method_ability_connection_stub.cpp | 6 +- services/src/input_method_agent_proxy.cpp | 2 +- services/src/input_method_property.cpp | 17 +- services/src/input_method_setting.cpp | 44 ++-- services/src/input_method_system_ability.cpp | 30 +-- .../src/input_method_system_ability_stub.cpp | 9 +- services/src/keyboard_type.cpp | 2 +- services/src/message.cpp | 2 +- services/src/peruser_session.cpp | 163 +++++-------- services/src/peruser_setting.cpp | 215 ++++++------------ services/src/platform_callback_stub.cpp | 2 +- 26 files changed, 194 insertions(+), 346 deletions(-) diff --git a/frameworks/inputmethod_controller/include/input_client_stub.h b/frameworks/inputmethod_controller/include/input_client_stub.h index b75c223..70fb510 100644 --- a/frameworks/inputmethod_controller/include/input_client_stub.h +++ b/frameworks/inputmethod_controller/include/input_client_stub.h @@ -26,12 +26,14 @@ namespace MiscServices { class InputClientStub : public IRemoteStub { public: DISALLOW_COPY_AND_MOVE(InputClientStub); - int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; + int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, + MessageParcel &reply, MessageOption &option) override; InputClientStub(); ~InputClientStub(); void SetHandler(MessageHandler *handler); - int32_t onInputReady(int32_t retValue, const sptr& agent, const InputChannel *channel) 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: diff --git a/frameworks/inputmethod_controller/include/input_data_channel_stub.h b/frameworks/inputmethod_controller/include/input_data_channel_stub.h index 4b6eee8..1e0b548 100644 --- a/frameworks/inputmethod_controller/include/input_data_channel_stub.h +++ b/frameworks/inputmethod_controller/include/input_data_channel_stub.h @@ -23,7 +23,7 @@ namespace OHOS { namespace MiscServices { -class InputDataChannelStub : public IRemoteStub { + class InputDataChannelStub : public IRemoteStub { public: DISALLOW_COPY_AND_MOVE(InputDataChannelStub); int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) 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 85bf021..96161a9 100644 --- a/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp +++ b/frameworks/inputmethod_controller/src/input_method_system_ability_proxy.cpp @@ -302,8 +302,7 @@ namespace MiscServices { } KeyboardType *keyType = reply.ReadParcelable(); - if (keyType == nullptr) - { + if (keyType == nullptr) { return ERROR_STATUS_BAD_INDEX; } *retType = *keyType; diff --git a/services/include/input_attribute.h b/services/include/input_attribute.h index ec780c3..a291239 100644 --- a/services/include/input_attribute.h +++ b/services/include/input_attribute.h @@ -23,7 +23,7 @@ namespace MiscServices { public: InputAttribute(); InputAttribute(const InputAttribute& attribute); - InputAttribute& operator = (const InputAttribute& attribute); + InputAttribute& operator =(const InputAttribute& attribute); ~InputAttribute(); virtual bool Marshalling(Parcel &parcel) const override; static InputAttribute *Unmarshalling(Parcel &parcel); diff --git a/services/include/input_channel.h b/services/include/input_channel.h index 4b27bad..c22a79d 100644 --- a/services/include/input_channel.h +++ b/services/include/input_channel.h @@ -32,7 +32,7 @@ namespace MiscServices { std::u16string name; MessageParcel inputChannelParcel; InputChannel(const InputChannel& channel); - InputChannel& operator = (const InputChannel& channel); + InputChannel& operator =(const InputChannel& channel); }; } } diff --git a/services/include/input_method_property.h b/services/include/input_method_property.h index 4b98bf8..eed6bc1 100644 --- a/services/include/input_method_property.h +++ b/services/include/input_method_property.h @@ -35,7 +35,7 @@ namespace MiscServices { InputMethodProperty(); ~InputMethodProperty(); InputMethodProperty(const InputMethodProperty& property); - InputMethodProperty& operator = (const InputMethodProperty& property); + InputMethodProperty& operator =(const InputMethodProperty& property); virtual bool Marshalling(Parcel &parcel) const override; static InputMethodProperty *Unmarshalling(Parcel &parcel); }; diff --git a/services/include/input_method_setting.h b/services/include/input_method_setting.h index a17422a..589fa65 100644 --- a/services/include/input_method_setting.h +++ b/services/include/input_method_setting.h @@ -36,7 +36,7 @@ namespace MiscServices { InputMethodSetting(); ~InputMethodSetting(); InputMethodSetting(const InputMethodSetting& inputMethodSetting); - InputMethodSetting& operator = (const InputMethodSetting& inputMethodSetting); + InputMethodSetting& operator =(const InputMethodSetting& inputMethodSetting); void SetValue(const std::u16string& key, const std::u16string& value); std::u16string GetValue(const std::u16string& key) const; diff --git a/services/include/keyboard_type.h b/services/include/keyboard_type.h index 5583d6b..abd5b8e 100644 --- a/services/include/keyboard_type.h +++ b/services/include/keyboard_type.h @@ -27,7 +27,7 @@ namespace MiscServices { KeyboardType(); KeyboardType(const KeyboardType& type); ~KeyboardType(); - KeyboardType& operator = (const KeyboardType& type); + KeyboardType& operator =(const KeyboardType& type); virtual bool Marshalling(Parcel &parcel) const override; static KeyboardType *Unmarshalling(Parcel &parcel); void setId(int32_t typeId); diff --git a/services/include/message.h b/services/include/message.h index 6bc425d..9f7cc3a 100644 --- a/services/include/message.h +++ b/services/include/message.h @@ -27,11 +27,11 @@ namespace MiscServices { MessageParcel *msgContent_ = nullptr; // message content Message(int32_t msgId, MessageParcel *msgContent); explicit Message(const Message& msg); - Message& operator = (const Message& msg); + Message& operator =(const Message& msg); ~Message(); private: Message(const Message&&); - Message& operator = (const Message&&); + Message& operator =(const Message&&); }; } } diff --git a/services/include/message_handler.h b/services/include/message_handler.h index 6a50512..56ca14e 100644 --- a/services/include/message_handler.h +++ b/services/include/message_handler.h @@ -87,12 +87,12 @@ class MessageHandler { private: std::mutex mMutex; // a mutex to guard message queue std::condition_variable mCV; // condition variable to work with mMutex - std::queue mQueue ; // Message queue, guarded by mMutex; + std::queue mQueue; // Message queue, guarded by mMutex; MessageHandler(const MessageHandler&); - MessageHandler& operator = (const MessageHandler&); + MessageHandler& operator =(const MessageHandler&); MessageHandler(const MessageHandler&&); - MessageHandler& operator = (const MessageHandler&&); + MessageHandler& operator =(const MessageHandler&&); }; } } diff --git a/services/include/peruser_session.h b/services/include/peruser_session.h index 668f894..28c0a20 100644 --- a/services/include/peruser_session.h +++ b/services/include/peruser_session.h @@ -94,6 +94,7 @@ namespace MiscServices { DEFAULT_IME = 0, // index for default input method service SECURITY_IME = 1, // index for security input method service MAX_IME = 2, // the maximum count of ims started for a user + MIN_IME = 2, }; public: @@ -148,9 +149,9 @@ namespace MiscServices { sptr inputMethodAbility_; PerUserSession(const PerUserSession&); - PerUserSession& operator = (const PerUserSession&); + PerUserSession& operator =(const PerUserSession&); PerUserSession(const PerUserSession&&); - PerUserSession& operator = (const PerUserSession&&); + PerUserSession& operator =(const PerUserSession&&); int IncreaseOrResetImeError(bool resetFlag, int imeIndex); KeyboardType *GetKeyboardType(int imeIndex, int typeIndex); void ResetCurrentKeyboardType(int imeIndex); diff --git a/services/include/peruser_setting.h b/services/include/peruser_setting.h index 5b38f97..a6daf8b 100644 --- a/services/include/peruser_setting.h +++ b/services/include/peruser_setting.h @@ -60,9 +60,9 @@ namespace MiscServices { InputMethodSetting inputMethodSetting; // the object to manage the setting data for this user PerUserSetting(const PerUserSetting&); - PerUserSetting& operator = (const PerUserSetting&); + PerUserSetting& operator =(const PerUserSetting&); PerUserSetting(const PerUserSetting&&); - PerUserSetting& operator = (const PerUserSetting&&); + PerUserSetting& operator =(const PerUserSetting&&); void InitInputMethodSetting(); void ResetCurrentInputMethod(); std::u16string GetKeyboardTypeLanguage(const InputMethodProperty *property, int32_t hashCode); diff --git a/services/include/platform.h b/services/include/platform.h index ad07416..15c64ca 100644 --- a/services/include/platform.h +++ b/services/include/platform.h @@ -56,9 +56,9 @@ namespace MiscServices { Platform(); ~Platform(); Platform(const Platform&); - Platform& operator = (const Platform&); + Platform& operator =(const Platform&); Platform(const Platform&&); - Platform& operator = (const Platform&&); + Platform& operator =(const Platform&&); }; } } diff --git a/services/src/global.cpp b/services/src/global.cpp index f4d4249..7db5989 100644 --- a/services/src/global.cpp +++ b/services/src/global.cpp @@ -26,7 +26,7 @@ namespace MiscServices { localtime_r(&tv.tv_sec, &nowTime); int32_t millSec = 1000; printf("%02d-%02d %02d:%02d:%02d.%03d\t", nowTime.tm_mon, nowTime.tm_mday, - nowTime.tm_hour, nowTime.tm_min, nowTime.tm_sec, (int)tv.tv_usec/millSec); + nowTime.tm_hour, nowTime.tm_min, nowTime.tm_sec, (int)tv.tv_usec / millSec); } namespace ErrorCode { diff --git a/services/src/input_control_channel_stub.cpp b/services/src/input_control_channel_stub.cpp index 84f51d4..903b990 100644 --- a/services/src/input_control_channel_stub.cpp +++ b/services/src/input_control_channel_stub.cpp @@ -106,7 +106,7 @@ namespace MiscServices { \param channel channel for sending physical keyboard event from input client to input method service */ void InputControlChannelStub::onAgentCreated(sptr < IInputMethodAgent >& agent, InputChannel *channel) -{ + { IMSA_HILOGI("InputControlChannelStub::onAgentCreated"); { std::unique_lock lck(mtx); diff --git a/services/src/input_method_ability_connection_stub.cpp b/services/src/input_method_ability_connection_stub.cpp index 16e9581..88dc892 100644 --- a/services/src/input_method_ability_connection_stub.cpp +++ b/services/src/input_method_ability_connection_stub.cpp @@ -32,8 +32,7 @@ namespace MiscServices { const sptr &remoteObject, int resultCode) { IMSA_HILOGE("ConnectAbility: OnAbilityConnectDone."); - if (messageHandler != nullptr) - { + if (messageHandler != nullptr) { MessageParcel *data = new MessageParcel(); data->WriteParcelable(&element); data->WriteRemoteObject(remoteObject); @@ -47,8 +46,7 @@ namespace MiscServices { int resultCode) { IMSA_HILOGE("ConnectAbility: OnAbilityDisconnectDone."); - if (messageHandler != nullptr) - { + if (messageHandler != nullptr) { MessageParcel *data = new MessageParcel(); data->WriteParcelable(&element); data->WriteInt32(mIndex); diff --git a/services/src/input_method_agent_proxy.cpp b/services/src/input_method_agent_proxy.cpp index bd24834..03da4ec 100644 --- a/services/src/input_method_agent_proxy.cpp +++ b/services/src/input_method_agent_proxy.cpp @@ -33,7 +33,7 @@ namespace MiscServices { } ~InputMethodAgentProxy() - { + { } int32_t dispatchKey(int key, int status) diff --git a/services/src/input_method_property.cpp b/services/src/input_method_property.cpp index 5730361..349f821 100644 --- a/services/src/input_method_property.cpp +++ b/services/src/input_method_property.cpp @@ -28,8 +28,7 @@ namespace MiscServices { */ InputMethodProperty::~InputMethodProperty() { - for (int32_t i = 0; i < (int32_t)mTypes.size(); i++) - { + for (int32_t i = 0; i < (int32_t)mTypes.size(); i++) { delete mTypes[i]; } mTypes.clear(); @@ -47,8 +46,7 @@ namespace MiscServices { isSystemIme = property.isSystemIme; mDefaultImeId = property.mDefaultImeId; - for (int i = 0; i < (int)mTypes.size(); i++) - { + for (int i = 0; i < (int)mTypes.size(); i++) { KeyboardType *type = new KeyboardType(*property.mTypes[i]); mTypes.push_back(type); } @@ -58,7 +56,7 @@ namespace MiscServices { \param property the source property will be copied to this instance. \return return this */ - InputMethodProperty& InputMethodProperty::operator = (const InputMethodProperty& property) + InputMethodProperty& InputMethodProperty::operator =(const InputMethodProperty& property) { if (this == &property) { return *this; @@ -70,8 +68,7 @@ namespace MiscServices { isSystemIme = property.isSystemIme; mDefaultImeId = property.mDefaultImeId; - for (int i = 0; i < (int)mTypes.size(); i++) - { + for (int i = 0; i < (int)mTypes.size(); i++) { KeyboardType *type = new KeyboardType(*property.mTypes[i]); mTypes.push_back(type); } @@ -94,12 +91,10 @@ namespace MiscServices { return false; int32_t size = (int32_t)mTypes.size(); parcel.WriteInt32(size); - if (size == 0) - { + if (size == 0) { return true; } - for (int i = 0; i < size; i++) - { + for (int i = 0; i < size; i++) { parcel.WriteParcelable(mTypes[i]); } return true; diff --git a/services/src/input_method_setting.cpp b/services/src/input_method_setting.cpp index 75deca5..0222eb8 100644 --- a/services/src/input_method_setting.cpp +++ b/services/src/input_method_setting.cpp @@ -49,7 +49,7 @@ namespace MiscServices { \param inputMethodSetting the source InputMethodSetting copied to this instance \return return this instance */ - InputMethodSetting& InputMethodSetting::operator = (const InputMethodSetting& inputMethodSetting) + InputMethodSetting& InputMethodSetting::operator =(const InputMethodSetting& inputMethodSetting) { if (this == &inputMethodSetting) { return *this; @@ -67,8 +67,7 @@ namespace MiscServices { int32_t size = setting.size(); parcel.WriteInt32(size); std::map::const_iterator it; - for (it = setting.cbegin(); it != setting.cend(); ++it) - { + for (it = setting.cbegin(); it != setting.cend(); ++it) { parcel.WriteString16(it->first); parcel.WriteString16(it->second); } @@ -83,8 +82,7 @@ namespace MiscServices { { auto ims = new InputMethodSetting(); int32_t size = parcel.ReadInt32(); - for (int i = 0; i < size; i++) - { + for (int i = 0; i < size; i++) { std::u16string key = parcel.ReadString16(); std::u16string value = parcel.ReadString16(); ims->setting.insert(std::pair(key, value)); @@ -139,8 +137,7 @@ namespace MiscServices { std::u16string value = GetValue(ENABLED_INPUT_METHODS_TAG); std::vector tmp1 = Split(value, DELIM_IME); std::vector imeList; - for (int i = 0; i < (int)tmp1.size(); i++) - { + for (int i = 0; i < (int)tmp1.size(); i++) { std::vector tmp2 = Split(tmp1[i], DELIM_KBD_TYPE); imeList.push_back(tmp2[0]); tmp2.clear(); @@ -160,14 +157,12 @@ namespace MiscServices { std::vector imeList = Split(str, DELIM_IME); std::u16string typeStr; - for (int i = 0; i < (int)types.size(); i++) - { + for (int i = 0; i < (int)types.size(); i++) { typeStr = typeStr + u";" + Utils::to_utf16(std::to_string(types[i])); } std::u16string imeStr = imeId + typeStr; bool flag = false; - for (int i = 0; i < (int)imeList.size(); i++) - { + for (int i = 0; i < (int)imeList.size(); i++) { if (imeList[i] == imeStr) { return false; } @@ -198,8 +193,7 @@ namespace MiscServices { std::vector imeList = Split(str, DELIM_IME); bool flag = false; std::vector::iterator it; - for (it = imeList.begin(); it < imeList.end(); ++it) - { + for (it = imeList.begin(); it < imeList.end(); ++it) { if (it->find_first_of(imeId)) { imeList.erase(it); flag = true; @@ -225,10 +219,8 @@ namespace MiscServices { std::vector tmpVector = Split(value, DELIM_IME); bool flag = false; std::u16string imeStr; - for (int i = 0; i < (int)tmpVector.size(); i++) - { - if (tmpVector[i].find_first_of(imeId) != std::u16string::npos) - { + for (int i = 0; i < (int)tmpVector.size(); i++) { + if (tmpVector[i].find_first_of(imeId) != std::u16string::npos) { flag = true; imeStr = tmpVector[i]; break; @@ -240,8 +232,7 @@ namespace MiscServices { } std::vector tmp2 = Split(imeStr, DELIM_KBD_TYPE); - for (int i = 1; i < (int)tmp2.size(); i++) - { + for (int i = 1; i < (int)tmp2.size(); i++) { std::u16string str = tmp2[i]; retValue.push_back(std::atoi(Utils::to_utf8(str).c_str())); } @@ -318,18 +309,15 @@ namespace MiscServices { std::u16string::size_type left, right; left = 0; right = str.find(delim, 0); - while(right != std::u16string::npos) - { - if (right - left) - { + while(right != std::u16string::npos) { + if (right - left) { retValue.emplace_back(str.substr(left, right-left)); } left = right + 1; right = str.find(delim,left); } - if (left != str.size()) - { + if (left != str.size()) { retValue.emplace_back(str.substr(left)); } return retValue; @@ -344,11 +332,9 @@ namespace MiscServices { { std::u16string retValue = u""; char16_t delimStr[] = {delim, 0}; - for (int i = 0; i < (int)vector.size(); i++) - { + for (int i = 0; i < (int)vector.size(); i++) { retValue += vector[i]; - if (i < (int)vector.size()-1) - { + if (i < (int)vector.size()-1) { retValue += std::u16string(delimStr); } } diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index 4cc8f42..d9f490c 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -58,8 +58,7 @@ namespace MiscServices { } std::map::const_iterator it; - for (it = userSessions.cbegin(); it != userSessions.cend();) - { + for (it = userSessions.cbegin(); it != userSessions.cend();) { PerUserSession *session = it->second; it = userSessions.erase(it); delete session; @@ -67,8 +66,7 @@ namespace MiscServices { } userSessions.clear(); std::map::const_iterator it1; - for (it1 = userSettings.cbegin(); it1 != userSettings.cend();) - { + for (it1 = userSettings.cbegin(); it1 != userSettings.cend();) { PerUserSetting *setting = it1->second; it1 = userSettings.erase(it1); delete setting; @@ -76,8 +74,7 @@ namespace MiscServices { } userSettings.clear(); std::map::const_iterator it2; - for (it2 = msgHandlers.cbegin(); it2 != msgHandlers.cend();) - { + for (it2 = msgHandlers.cbegin(); it2 != msgHandlers.cend();) { MessageHandler *handler = it2->second; it2 = msgHandlers.erase(it2); delete handler; @@ -260,8 +257,7 @@ namespace MiscServices { } PerUserSession *userSession = GetUserSession(userId); - if (userSession == nullptr) - { + if (userSession == nullptr) { return ErrorCode::ERROR_NULL_POINTER; } KeyboardType *type = userSession->GetCurrentKeyboardType(); @@ -290,8 +286,7 @@ namespace MiscServices { setting->ListInputMethodEnabled(properties); std::vector::iterator it; - for (it = properties->begin(); it != properties->end();) - { + for (it = properties->begin(); it != properties->end();) { if (*it && (*it)->isSystemIme) { it = properties->erase(it); } else { @@ -318,8 +313,7 @@ namespace MiscServices { } setting->ListInputMethod(properties); std::vector::iterator it; - for (it = properties->begin(); it != properties->end();) - { + for (it = properties->begin(); it != properties->end();) { if (*it && (*it)->isSystemIme) { it = properties->erase(it); } else { @@ -365,8 +359,7 @@ namespace MiscServices { std::map::const_iterator it; int32_t index = 0; dprintf(fd, "* User count = %d\n", userSettings.size()); - for (it = userSettings.cbegin(); it != userSettings.cend(); ++it) - { + for (it = userSettings.cbegin(); it != userSettings.cend(); ++it) { PerUserSetting *setting = it->second; int32_t userId = it->first; int32_t userState = setting->GetUserState(); @@ -475,14 +468,12 @@ namespace MiscServices { } case MSG_ID_EXIT_SERVICE: { std::map::const_iterator it; - for (it = msgHandlers.cbegin(); it != msgHandlers.cend();) - { + for (it = msgHandlers.cbegin(); it != msgHandlers.cend();) { MessageHandler *handler = it->second; Message *destMsg = new Message(MSG_ID_EXIT_SERVICE, nullptr); handler->SendMessage(destMsg); PerUserSession *userSession = GetUserSession(it->first); - if (userSession == nullptr) - { + if (userSession == nullptr) { IMSA_HILOGE("getUserSession fail."); return; } @@ -661,8 +652,7 @@ namespace MiscServices { if (it == msgHandlers.end()) { PerUserSession *session = GetUserSession(userId); MessageHandler *handler = new MessageHandler(); - if (session == nullptr) - { + if (session == nullptr) { IMSA_HILOGE("InputMethodSystemAbility::OnPrepareInput session is nullptr"); } session->CreateWorkThread(*handler); diff --git a/services/src/input_method_system_ability_stub.cpp b/services/src/input_method_system_ability_stub.cpp index 86417d9..81ceaea 100644 --- a/services/src/input_method_system_ability_stub.cpp +++ b/services/src/input_method_system_ability_stub.cpp @@ -116,8 +116,7 @@ namespace MiscServices { reply.WriteInt32(NO_ERROR); int32_t size = properties.size(); reply.WriteInt32(size); - for (int32_t i = 0; i < size; i++) - { + for (int32_t i = 0; i < size; i++) { reply.WriteParcelable(properties[i]); } properties.clear(); @@ -135,8 +134,7 @@ namespace MiscServices { reply.WriteInt32(NO_ERROR); int32_t size = properties.size(); reply.WriteInt32(size); - for (int32_t i = 0; i < size; i++) - { + for (int32_t i = 0; i < size; i++) { reply.WriteParcelable(properties[i]); } properties.clear(); @@ -154,8 +152,7 @@ namespace MiscServices { reply.WriteInt32(NO_ERROR); int32_t size = kbdTypes.size(); reply.WriteInt32(size); - for (int32_t i = 0; i < size; i++) - { + for (int32_t i = 0; i < size; i++) { reply.WriteParcelable(kbdTypes[i]); } kbdTypes.clear(); diff --git a/services/src/keyboard_type.cpp b/services/src/keyboard_type.cpp index 1105608..5956659 100644 --- a/services/src/keyboard_type.cpp +++ b/services/src/keyboard_type.cpp @@ -49,7 +49,7 @@ namespace MiscServices { \param type source instance \return return this */ - KeyboardType& KeyboardType::operator = (const KeyboardType& type) + KeyboardType& KeyboardType::operator =(const KeyboardType& type) { if (this == &type) { return *this; diff --git a/services/src/message.cpp b/services/src/message.cpp index 3e59c9a..22935d5 100644 --- a/services/src/message.cpp +++ b/services/src/message.cpp @@ -47,7 +47,7 @@ namespace MiscServices { } } - Message& Message::operator = (const Message& msg) + Message& Message::operator =(const Message& msg) { if (this == &msg) { return *this; diff --git a/services/src/peruser_session.cpp b/services/src/peruser_session.cpp index cbada65..88a4829 100644 --- a/services/src/peruser_session.cpp +++ b/services/src/peruser_session.cpp @@ -123,7 +123,7 @@ namespace MiscServices { void PerUserSession::WorkThread() { if (msgHandler == nullptr) { - return ; + return; } while(1) { Message *msg = msgHandler->GetMessage(); @@ -239,22 +239,17 @@ namespace MiscServices { IMSA_HILOGI("PerUserSession::ResetIme"); std::unique_lock lock(mtx); InputMethodProperty *ime[] = {defaultIme, securityIme}; - for (int i = 0; i < 2; i++) - { - if (currentIme[i] == ime[i] && ime[i] != nullptr) - { + for (int i = 0; i < MIN_IME; i++) { + if (currentIme[i] == ime[i] && ime[i] != nullptr) { continue; } - if (imsCore[i]) - { + if (imsCore[i]) { StopInputMethod(i); } IncreaseOrResetImeError(true, i); currentIme[i] = ime[i]; - if (currentIme[i] == nullptr) - { - if (needReshowClient && GetImeIndex(needReshowClient) == i) - { + if (currentIme[i] == nullptr) { + if (needReshowClient && GetImeIndex(needReshowClient) == i) { needReshowClient = nullptr; } continue; @@ -262,22 +257,17 @@ namespace MiscServices { std::map, ClientInfo*>::const_iterator it; bool flag = false; - for (it = mapClients.cbegin(); it != mapClients.cend(); ++it) - { + for (it = mapClients.cbegin(); it != mapClients.cend(); ++it) { if ((i == DEFAULT_IME && it->second->attribute.GetSecurityFlag() == false) || - (i == SECURITY_IME && it->second->attribute.GetSecurityFlag() == true)) - { + (i == SECURITY_IME && it->second->attribute.GetSecurityFlag() == true)) { flag = true; break; } } - if (flag) - { + if (flag) { int ret = StartInputMethod(i); - if (needReshowClient && GetImeIndex(needReshowClient) == i) - { - if (ret == ErrorCode::NO_ERROR) - { + if (needReshowClient && GetImeIndex(needReshowClient) == i) { + if (ret == ErrorCode::NO_ERROR) { ShowKeyboard(needReshowClient); } needReshowClient = nullptr; @@ -295,19 +285,15 @@ namespace MiscServices { InputMethodSetting tmpSetting; bool flag = false; std::unique_lock lock(mtx); - for (int i = 0; i < MAX_IME; i++) - { - if (currentIme[i] && currentIme[i]->mPackageName == packageName) - { - if (currentClient && GetImeIndex(currentClient) == i) - { + for (int i = 0; i < MAX_IME; i++) { + if (currentIme[i] && currentIme[i]->mPackageName == packageName) { + if (currentClient && GetImeIndex(currentClient) == i) { needReshowClient = currentClient; HideKeyboard(currentClient); } StopInputMethod(i); currentIme[i] = nullptr; - if (i == DEFAULT_IME) - { + if (i == DEFAULT_IME) { tmpSetting.SetCurrentKeyboardType(-1); inputMethodSetting->SetCurrentKeyboardType(-1); } else if (i == SECURITY_IME) { @@ -318,8 +304,7 @@ namespace MiscServices { flag = true; } } - if (flag) - { + if (flag) { Platform::Instance()->SetInputMethodSetting(userId_, tmpSetting); } } @@ -392,10 +377,8 @@ namespace MiscServices { mapClients.erase(it); remainClientNum = 0; - for (it = mapClients.begin(); it != mapClients.end(); ++it) - { - if (it->second->attribute.GetSecurityFlag() == flag) - { + for (it = mapClients.begin(); it != mapClients.end(); ++it) { + if (it->second->attribute.GetSecurityFlag() == flag) { remainClientNum++; } } @@ -528,8 +511,7 @@ namespace MiscServices { return ErrorCode::ERROR_KBD_SHOW_FAILED; } - if (clientInfo->client == nullptr) - { + if (clientInfo->client == nullptr) { IMSA_HILOGI("PerUserSession::ShowKeyboard clientInfo->client is nullptr"); } @@ -560,8 +542,7 @@ namespace MiscServices { return ErrorCode::ERROR_CLIENT_NOT_FOUND; } ClientInfo *clientInfo = GetClientInfo(inputClient); - if (clientInfo == nullptr) - { + if (clientInfo == nullptr) { IMSA_HILOGE("PerUserSession::HideKeyboard GetClientInfo pointer nullptr"); } if (imsCore[index] == nullptr) { @@ -576,8 +557,7 @@ namespace MiscServices { return ErrorCode::ERROR_KBD_IS_NOT_SHOWING; } bool ret = imsCore[index]->hideKeyboard(1); - if (!ret) - { + if (!ret) { IMSA_HILOGE("PerUserSession::HideKeyboard [imsCore->hideKeyboard] failed"); ret = ErrorCode::ERROR_KBD_HIDE_FAILED; } @@ -646,10 +626,8 @@ namespace MiscServices { hashCode = hashCodeList[0]; } - for (int i = 0; i < (int)currentIme[DEFAULT_IME]->mTypes.size(); i++) - { - if (currentIme[DEFAULT_IME]->mTypes[i]->getHashCode() == hashCode) - { + for (int i = 0; i < (int)currentIme[DEFAULT_IME]->mTypes.size(); i++) { + if (currentIme[DEFAULT_IME]->mTypes[i]->getHashCode() == hashCode) { return currentIme[DEFAULT_IME]->mTypes[i]; } } @@ -694,33 +672,27 @@ namespace MiscServices { (void) who; // temporary void it, as we will add support for security IME. IMSA_HILOGI("Start...[%{public}d]\n", userId_); int index = 0; - for (int i = 0; i < MAX_IME; i++) - { - if (imsCore[i] == nullptr) - { + for (int i = 0; i < MAX_IME; i++) { + if (imsCore[i] == nullptr) { continue; } sptr b = imsCore[i]->AsObject(); - if (b == who) - { + if (b == who) { index = i; break; } } if (currentClient && (GetImeIndex(currentClient) == index || - currentIme[index] == currentIme[1 - index])) - { + currentIme[index] == currentIme[1 - index])) { needReshowClient = currentClient; HideKeyboard(currentClient); } StopInputMethod(index); - if (currentIme[index] == currentIme[1 - index]) - { + if (currentIme[index] == currentIme[1 - index]) { StopInputMethod(1 - index); } - if (IncreaseOrResetImeError(false, index) == 3) - { + if (IncreaseOrResetImeError(false, index) == 3) { // call to disable the current input method. MessageParcel *parcel = new MessageParcel(); parcel->WriteInt32(userId_); @@ -818,10 +790,8 @@ namespace MiscServices { if (currentIme[index]->mTypes[num]->getHashCode() == hashCode) { return ErrorCode::ERROR_SETTING_SAME_VALUE; } - for (int i = 0; i < (int)currentIme[index]->mTypes.size(); i++) - { - if (currentIme[index]->mTypes[i]->getHashCode() == hashCode) - { + for (int i = 0; i < (int)currentIme[index]->mTypes.size(); i++) { + if (currentIme[index]->mTypes[i]->getHashCode() == hashCode) { currentKbdIndex[index] = i; break; } @@ -833,10 +803,8 @@ namespace MiscServices { if (currentKbdTypes[num] == hashCode) { return ErrorCode::ERROR_SETTING_SAME_VALUE; } - for (int i = 0; i < (int)currentKbdTypes.size(); i++) - { - if (currentKbdTypes[i] == hashCode) - { + for (int i = 0; i < (int)currentKbdTypes.size(); i++) { + if (currentKbdTypes[i] == hashCode) { currentKbdIndex[index] = i; break; } @@ -880,7 +848,7 @@ namespace MiscServices { int index = GetImeIndex(currentClient); if (index == -1) { IMSA_HILOGW("%{public}s [%{public}d]\n", ErrorCode::ToString(ErrorCode::ERROR_CLIENT_NOT_FOUND), userId_); - return ; + return; } int size = 0; if (index == SECURITY_IME || currentIme[DEFAULT_IME] == currentIme[SECURITY_IME] ) { @@ -890,9 +858,9 @@ namespace MiscServices { std::vector currentKbdTypes = inputMethodSetting->GetEnabledKeyboardTypes(imeId); size = currentKbdTypes.size(); } - if (size < 2) { + if (size < MIN_IME) { IMSA_HILOGW("No next keyboard is available. [%{public}d]\n", userId_); - return ; + return; } int num = currentKbdIndex[index]+1; @@ -925,7 +893,7 @@ namespace MiscServices { ClientInfo *clientInfo = GetClientInfo(currentClient); if (clientInfo == nullptr) { IMSA_HILOGE("%{public}s [%{public}d]\n", ErrorCode::ToString(ErrorCode::ERROR_CLIENT_NOT_FOUND), userId_); - return ; + return; } int ret = clientInfo->client->setDisplayMode(mode); if (ret != ErrorCode::NO_ERROR) { @@ -940,7 +908,7 @@ namespace MiscServices { void PerUserSession::OnRestartIms(int index, const std::u16string& imeId) { if (index < 0 || index >= MAX_IME) { - return ; + return; } IMSA_HILOGI("Start...[%{public}d]\n", userId_); if (currentIme[index] && currentIme[index]->mImeId == imeId) { @@ -966,27 +934,22 @@ namespace MiscServices { } userState = UserState::USER_STATE_STARTED; // hide current keyboard - if (currentClient != nullptr) - { + if (currentClient != nullptr) { HideKeyboard(currentClient); } - for (int i = 0; i < 2; i++) - { + for (int i = 0; i < MIN_IME; i++) { StopInputMethod(i); currentIme[i] = nullptr; } // disconnect all clients. std::map, ClientInfo*>::iterator it; - for (it = mapClients.begin(); it != mapClients.end();) - { + for (it = mapClients.begin(); it != mapClients.end();) { sptr b = it->first; b->RemoveDeathRecipient(clientDeathRecipient); ClientInfo *clientInfo = it->second; - if (clientInfo != nullptr) - { + if (clientInfo != nullptr) { int ret = clientInfo->client->onInputReleased(0); - if (ret != ErrorCode::NO_ERROR) - { + if (ret != ErrorCode::NO_ERROR) { IMSA_HILOGE("2-onInputReleased return : %{public}s", ErrorCode::ToString(ret)); } delete clientInfo; @@ -1017,11 +980,9 @@ namespace MiscServices { dprintf(fd, "\n - User Session State :\n"); dprintf(fd, " * Client count = %d\n", mapClients.size()); int index = 0; - for (it = mapClients.cbegin(); it != mapClients.cend(); ++it) - { + for (it = mapClients.cbegin(); it != mapClients.cend(); ++it) { if (currentClient != nullptr && - Platform::RemoteBrokerToObject(currentClient) == it->first) - { + Platform::RemoteBrokerToObject(currentClient) == it->first) { dprintf(fd, " *[%d] Client Information: (current client)\n", index++); } else { dprintf(fd, " [%d] Client Information:\n", index++); @@ -1029,17 +990,14 @@ namespace MiscServices { DumpClientInfo(fd, *(it->second)); } std::string header[2] = {"Current", "Security"}; - for (int i = 0; i < 2; i++) - { - if (currentIme[i] != nullptr) - { + for (int i = 0; i < 2; i++) { + if (currentIme[i] != nullptr) { dprintf(fd, "\n * %s IME mImeId = %s\n", header[i].c_str(), Utils::to_utf8(currentIme[i]->mImeId).c_str()); KeyboardType *type = currentIme[i]->mTypes.at(currentKbdIndex[i]); dprintf(fd, " %s KeyboardType mHashCode = %d, mLanguage = %s\n", header[i].c_str(), type->getHashCode(), Utils::to_utf8(type->getLanguage()).c_str()); - if (imsCore[i] != nullptr) - { + if (imsCore[i] != nullptr) { sptr b = imsCore[i]->AsObject(); dprintf(fd, " %s IME Service = %s#%p\n", header[i].c_str(), Utils::to_utf8(b->GetObjectDescriptor()).c_str(), b.GetRefPtr()); @@ -1069,8 +1027,7 @@ namespace MiscServices { sptr b = Platform::RemoteBrokerToObject(currentClient); std::map, ClientInfo*>::iterator it = mapClients.find(b); int index = GetImeIndex(currentClient); - if (index < 0 || index > MAX_IME) - { + if (index < 0 || index > MAX_IME) { dprintf(fd, "\n * PerUserSession::DumpCurrentSession: invalid index\n"); } dprintf(fd, "\n * Current Session State :\n"); @@ -1123,8 +1080,8 @@ namespace MiscServices { */ int PerUserSession::IncreaseOrResetImeError(bool resetFlag, int imeIndex) { - static int errorNum[2] = {0, 0}; - static time_t past[2] = {time(0), time(0)}; + static int errorNum[MIN_IME] = {0, 0}; + static time_t past[MIN_IME] = {time(0), time(0)}; if (resetFlag == true) { errorNum[imeIndex] = 0; past[imeIndex] = 0; @@ -1168,10 +1125,8 @@ namespace MiscServices { return nullptr; } int hashCode = currentKbdTypes[typeIndex]; - for (int i = 0; i < (int)currentIme[imeIndex]->mTypes.size(); i++) - { - if (currentIme[imeIndex]->mTypes[i]->getHashCode() == hashCode) - { + for (int i = 0; i < (int)currentIme[imeIndex]->mTypes.size(); i++) { + if (currentIme[imeIndex]->mTypes[i]->getHashCode() == hashCode) { return currentIme[imeIndex]->mTypes[i]; } } @@ -1197,10 +1152,8 @@ namespace MiscServices { } else { bool flag = false; if (imeIndex == SECURITY_IME || currentIme[DEFAULT_IME] == currentIme[SECURITY_IME]) { - for (int i = 0; i < (int)currentIme[imeIndex]->mTypes.size(); i++) - { - if (currentIme[imeIndex]->mTypes[i]->getHashCode() == hashCode) - { + for (int i = 0; i < (int)currentIme[imeIndex]->mTypes.size(); i++) { + if (currentIme[imeIndex]->mTypes[i]->getHashCode() == hashCode) { currentKbdIndex[imeIndex] = i; flag = true; break; @@ -1208,10 +1161,8 @@ namespace MiscServices { } } else { std::vector hashCodeList = inputMethodSetting->GetEnabledKeyboardTypes(currentIme[imeIndex]->mImeId); - for (int i = 0; i < (int)hashCodeList.size(); i++) - { - if (hashCode == hashCodeList[i]) - { + for (int i = 0; i < (int)hashCodeList.size(); i++) { + if (hashCode == hashCodeList[i]) { currentKbdIndex[imeIndex] = i; flag = true; break; diff --git a/services/src/peruser_setting.cpp b/services/src/peruser_setting.cpp index 9186654..69e1efd 100644 --- a/services/src/peruser_setting.cpp +++ b/services/src/peruser_setting.cpp @@ -33,8 +33,7 @@ namespace MiscServices { */ PerUserSetting::~PerUserSetting() { - if (userState == UserState::USER_STATE_UNLOCKED) - { + if (userState == UserState::USER_STATE_UNLOCKED) { OnUserLocked(); } } @@ -50,23 +49,19 @@ namespace MiscServices { inputMethodProperties.clear(); int ret = Platform::Instance()->ListInputMethod(userId_, &inputMethodProperties); - if (ret != ErrorCode::NO_ERROR) - { + if (ret != ErrorCode::NO_ERROR) { IMSA_HILOGE("Failed to listInputMethod [%d]\n", userId_); } int size = inputMethodProperties.size(); - if (size == 0) - { + if (size == 0) { currentImeId = Utils::to_utf16(""); } ret = Platform::Instance()->GetInputMethodSetting(userId_, &inputMethodSetting); - if (ret != ErrorCode::NO_ERROR) - { + if (ret != ErrorCode::NO_ERROR) { IMSA_HILOGE("Failed to getInputMethodSetting [%d]\n", userId_); } else { - if (size > 0) - { + if (size > 0) { InitInputMethodSetting(); } } @@ -82,39 +77,33 @@ namespace MiscServices { */ int PerUserSetting::OnPackageAdded(std::u16string& packageName, bool isSecurityIme) { - if (isSecurityIme) - { + if (isSecurityIme) { isSecurityIme = false; } std::u16string imeId = GetImeId(packageName); - if (imeId.size() != 0) - { + if (imeId.size() != 0) { IMSA_HILOGI("%s [%d]\n", ErrorCode::ToString(ErrorCode::ERROR_IME_PACKAGE_DUPLICATED), userId_); return ErrorCode::ERROR_IME_PACKAGE_DUPLICATED; } // retake the input method list installed in the system. InputMethodProperty *property = new InputMethodProperty(); int ret = Platform::Instance()->GetInputMethodProperty(userId_, packageName, property); - if (ret != ErrorCode::NO_ERROR) - { + if (ret != ErrorCode::NO_ERROR) { delete property; property = nullptr; IMSA_HILOGI("%s [%d]\n", ErrorCode::ToString(ErrorCode::ERROR_NOT_IME_PACKAGE), userId_); return ErrorCode::ERROR_NOT_IME_PACKAGE; } inputMethodProperties.push_back(property); - if (CheckIfSecurityIme(*property)) - { - if (isSecurityIme) - { + if (CheckIfSecurityIme(*property)) { + if (isSecurityIme) { isSecurityIme = true; } return ErrorCode::NO_ERROR; } std::vector types; - for (int i = 0; i < (int)property->mTypes.size(); i++) - { + for (int i = 0; i < (int)property->mTypes.size(); i++) { types.push_back(property->mTypes[i]->getHashCode()); } @@ -136,24 +125,20 @@ namespace MiscServices { */ int PerUserSetting::OnPackageRemoved(std::u16string& packageName, bool isSecurityIme) { - if (isSecurityIme) - { + if (isSecurityIme) { isSecurityIme = false; } std::u16string imeId = GetImeId(packageName); - if (imeId.size() == 0) - { + if (imeId.size() == 0) { IMSA_HILOGI("%s [%d]\n", ErrorCode::ToString(ErrorCode::ERROR_NOT_IME_PACKAGE), userId_); return ErrorCode::ERROR_NOT_IME_PACKAGE; } bool securityFlag = false; std::vector::iterator it; - for (it = inputMethodProperties.begin(); it < inputMethodProperties.end(); ++it) - { + for (it = inputMethodProperties.begin(); it < inputMethodProperties.end(); ++it) { InputMethodProperty *node = (InputMethodProperty*)*it; if (node->mImeId == imeId) { - if (CheckIfSecurityIme(*node) == true) - { + if (CheckIfSecurityIme(*node) == true) { securityFlag = true; } inputMethodProperties.erase(it); @@ -162,10 +147,8 @@ namespace MiscServices { break; } } - if (securityFlag) - { - if (isSecurityIme) - { + if (securityFlag) { + if (isSecurityIme) { isSecurityIme = true; } return ErrorCode::NO_ERROR; @@ -176,8 +159,7 @@ namespace MiscServices { imSetting.SetValue(key, inputMethodSetting.GetValue(key)); int flag = imSetting.RemoveEnabledInputMethod(imeId); - if (flag == false) - { + if (flag == false) { IMSA_HILOGI("The package removed is not an enabled IME. [%d]\n", userId_); return ErrorCode::NO_ERROR; } @@ -199,21 +181,17 @@ namespace MiscServices { { std::u16string currentValue = inputMethodSetting.GetValue(key); - if (currentValue == value) - { + if (currentValue == value) { return ErrorCode::ERROR_SETTING_SAME_VALUE; } inputMethodSetting.SetValue(key, value); - if (key == InputMethodSetting::CURRENT_INPUT_METHOD_TAG) - { + if (key == InputMethodSetting::CURRENT_INPUT_METHOD_TAG) { currentImeId = inputMethodSetting.GetCurrentInputMethod(); - } else if (key == InputMethodSetting::ENABLED_INPUT_METHODS_TAG) - { + } else if (key == InputMethodSetting::ENABLED_INPUT_METHODS_TAG) { if ((currentImeId.size() > 0 && value.find(currentImeId) == std::string::npos) || - currentImeId.size() == 0) - { + currentImeId.size() == 0) { ResetCurrentInputMethod(); InputMethodSetting tmpSetting; tmpSetting.ClearData(); @@ -234,35 +212,28 @@ namespace MiscServices { std::u16string imeId; std::u16string nextImeId = Utils::to_utf16(""); InputMethodProperty *firstEnabledProperty = nullptr; - for (int i = 0; i < (int)inputMethodProperties.size(); i++) - { + for (int i = 0; i < (int)inputMethodProperties.size(); i++) { imeId = inputMethodProperties[i]->mImeId; - if (imeId == currentImeId) - { + if (imeId == currentImeId) { flag = true; - } else if (enabledInputMethods.find(imeId) != std::string::npos) - { - if (flag == true) - { + } else if (enabledInputMethods.find(imeId) != std::string::npos) { + if (flag == true) { nextImeId = imeId; break; - } else if (firstEnabledProperty == nullptr) - { + } else if (firstEnabledProperty == nullptr) { firstEnabledProperty = inputMethodProperties[i]; } } } - if (nextImeId.size() == 0 && firstEnabledProperty) - { + if (nextImeId.size() == 0 && firstEnabledProperty) { nextImeId = firstEnabledProperty->mImeId; } // next enabled ime is not available. - if (nextImeId.size() == 0) - { + if (nextImeId.size() == 0) { IMSA_HILOGW("No next IME is available. [%d]\n", userId_); - return ; + return; } InputMethodSetting tmpSetting; @@ -278,8 +249,7 @@ namespace MiscServices { */ void PerUserSetting::OnUserLocked() { - if (userState == UserState::USER_STATE_STARTED) - { + if (userState == UserState::USER_STATE_STARTED) { return; } userState = UserState::USER_STATE_STARTED; @@ -287,11 +257,9 @@ namespace MiscServices { // release input method properties std::vector::iterator it; - for (it = inputMethodProperties.begin(); it < inputMethodProperties.end();) - { + for (it = inputMethodProperties.begin(); it < inputMethodProperties.end();) { InputMethodProperty *node = (InputMethodProperty*)*it; - if (node != nullptr) - { + if (node != nullptr) { it = inputMethodProperties.erase(it); delete node; node = nullptr; @@ -317,16 +285,13 @@ namespace MiscServices { std::vector imeList = inputMethodSetting.GetEnabledInputMethodList(); size = imeList.size(); dprintf(fd, "\n * Enabled IME count : %d\n", size); - for (int i = 0; i < size; i++) - { + for (int i = 0; i < size; i++) { dprintf(fd, " [%d] ImeId = %s\n", i, Utils::to_utf8(imeList[i]).c_str()); std::vector hashCodeList = inputMethodSetting.GetEnabledKeyboardTypes(imeList[i]); dprintf(fd, " Enabled keyboard count = %d, hashcode list : ", hashCodeList.size()); - for (int j = 0; j < (int)hashCodeList.size(); j++) - { + for (int j = 0; j < (int)hashCodeList.size(); j++) { dprintf(fd, "%d", hashCodeList[j]); - if (j < (int)hashCodeList.size()-1) - { + if (j < (int)hashCodeList.size()-1) { dprintf(fd, ", "); } } @@ -370,27 +335,21 @@ namespace MiscServices { { InputMethodProperty *ime = nullptr; std::u16string systemLocales = inputMethodSetting.GetValue(InputMethodSetting::SYSTEM_LOCALE_TAG); - for (int i = 0; i < (int)inputMethodProperties.size(); i++) - { - if (CheckIfSecurityIme(*inputMethodProperties[i]) == false) - { + for (int i = 0; i < (int)inputMethodProperties.size(); i++) { + if (CheckIfSecurityIme(*inputMethodProperties[i]) == false) { continue; } // if systemLocales is not setting, return the first security ime - if (systemLocales.size() == 0) - { + if (systemLocales.size() == 0) { return inputMethodProperties[i]; } - if (ime == nullptr) - { + if (ime == nullptr) { ime = inputMethodProperties[i]; } - for (int j = 0; j < (int)inputMethodProperties[i]->mTypes.size(); j++) - { + for (int j = 0; j < (int)inputMethodProperties[i]->mTypes.size(); j++) { std::u16string language = inputMethodProperties[i]->mTypes[j]->getLanguage(); // if the keyboard language is in the list of system locales, return the ime - if (systemLocales.find(language) != std::string::npos) - { + if (systemLocales.find(language) != std::string::npos) { return inputMethodProperties[i]; } } @@ -409,19 +368,14 @@ namespace MiscServices { std::u16string enabledInputMethods = inputMethodSetting.GetValue(InputMethodSetting::ENABLED_INPUT_METHODS_TAG); std::u16string imeId; InputMethodProperty *firstEnabledProperty = nullptr; - for (int i = 0; i < (int)inputMethodProperties.size(); i++) - { + for (int i = 0; i < (int)inputMethodProperties.size(); i++) { imeId = inputMethodProperties[i]->mImeId; - if (imeId == currentImeId) - { + if (imeId == currentImeId) { flag = true; - } else if (enabledInputMethods.find(imeId) != std::string::npos) - { - if (flag == true) - { + } else if (enabledInputMethods.find(imeId) != std::string::npos) { + if (flag == true) { return inputMethodProperties[i]; - } else if (firstEnabledProperty == nullptr) - { + } else if (firstEnabledProperty == nullptr) { firstEnabledProperty = inputMethodProperties[i]; } } @@ -445,10 +399,8 @@ namespace MiscServices { int32_t PerUserSetting::ListInputMethodEnabled(std::vector *properties) { std::u16string enabledInputMethods = inputMethodSetting.GetValue(InputMethodSetting::ENABLED_INPUT_METHODS_TAG); - for (int i = 0; i < (int)inputMethodProperties.size(); i++) - { - if (enabledInputMethods.find(inputMethodProperties[i]->mImeId) != std::string::npos) - { + for (int i = 0; i < (int)inputMethodProperties.size(); i++) { + if (enabledInputMethods.find(inputMethodProperties[i]->mImeId) != std::string::npos) { properties->push_back(inputMethodProperties[i]); } } @@ -461,8 +413,7 @@ namespace MiscServices { */ int32_t PerUserSetting::ListInputMethod(std::vector *properties) { - for (int i = 0; i < (int)inputMethodProperties.size(); i++) - { + for (int i = 0; i < (int)inputMethodProperties.size(); i++) { properties->push_back(inputMethodProperties[i]); } return ErrorCode::NO_ERROR; @@ -475,12 +426,9 @@ namespace MiscServices { */ int32_t PerUserSetting::ListKeyboardType(const std::u16string& imeId, std::vector *types) { - for (int i = 0; i < (int)inputMethodProperties.size(); i++) - { - if (imeId == inputMethodProperties[i]->mImeId) - { - for (int j = 0; j < (int)inputMethodProperties[i]->mTypes.size(); j++) - { + for (int i = 0; i < (int)inputMethodProperties.size(); i++) { + if (imeId == inputMethodProperties[i]->mImeId) { + for (int j = 0; j < (int)inputMethodProperties[i]->mTypes.size(); j++) { types->push_back(inputMethodProperties[i]->mTypes[j]); } break; @@ -497,8 +445,7 @@ namespace MiscServices { */ InputMethodProperty *PerUserSetting::GetInputMethodProperty(const std::u16string& imeId) { - for (int i = 0; i < (int)inputMethodProperties.size(); i++) - { + for (int i = 0; i < (int)inputMethodProperties.size(); i++) { if (inputMethodProperties[i]->mImeId == imeId) { return inputMethodProperties[i]; } @@ -514,10 +461,8 @@ namespace MiscServices { */ std::u16string PerUserSetting::GetKeyboardTypeLanguage(const InputMethodProperty *property, int hashCode) { - for (int i = 0; i < (int)property->mTypes.size(); i++) - { - if (property->mTypes[i]->getHashCode() == hashCode) - { + for (int i = 0; i < (int)property->mTypes.size(); i++) { + if (property->mTypes[i]->getHashCode() == hashCode) { return property->mTypes[i]->getLanguage(); } } @@ -529,17 +474,13 @@ namespace MiscServices { void PerUserSetting::InitInputMethodSetting() { bool flag = inputMethodSetting.FindKey(InputMethodSetting::ENABLED_INPUT_METHODS_TAG); - if (flag == false) - { - for (int i = 0; i < (int)inputMethodProperties.size(); i++) - { - if (CheckIfSecurityIme(*inputMethodProperties[i]) == true) - { + if (flag == false) { + for (int i = 0; i < (int)inputMethodProperties.size(); i++) { + if (CheckIfSecurityIme(*inputMethodProperties[i]) == true) { continue; } std::vector types; - for (int j = 0; j < (int)inputMethodProperties[i]->mTypes.size(); j++) - { + for (int j = 0; j < (int)inputMethodProperties[i]->mTypes.size(); j++) { types.push_back(inputMethodProperties[i]->mTypes[j]->getHashCode()); } inputMethodSetting.AddEnabledInputMethod(inputMethodProperties[i]->mImeId, types); @@ -549,15 +490,13 @@ namespace MiscServices { flag = inputMethodSetting.FindKey(InputMethodSetting::CURRENT_INPUT_METHOD_TAG); std::u16string imeId = inputMethodSetting.GetCurrentInputMethod(); - if (flag == false) - { + if (flag == false) { ResetCurrentInputMethod(); } else { currentImeId = imeId; } flag = inputMethodSetting.FindKey(InputMethodSetting::CURRENT_SYS_KEYBOARD_TYPE_TAG); - if (flag == false) - { + if (flag == false) { inputMethodSetting.SetCurrentSysKeyboardType(-1); } Platform::Instance()->SetInputMethodSetting(userId_, inputMethodSetting); @@ -577,41 +516,33 @@ namespace MiscServices { InputMethodProperty *firstEnabledIme = nullptr; bool flag = false; - for (int i = 0; i < (int)inputMethodProperties.size(); i++) - { + for (int i = 0; i < (int)inputMethodProperties.size(); i++) { imeId = inputMethodProperties[i]->mImeId; - if (enabledInputMethods.find(imeId) == std::string::npos) - { + if (enabledInputMethods.find(imeId) == std::string::npos) { continue; } - if (firstEnabledIme == nullptr) - { + if (firstEnabledIme == nullptr) { firstEnabledIme = inputMethodProperties[i]; } std::vector hashCodeList = inputMethodSetting.GetEnabledKeyboardTypes(imeId); - for (int j = 0; j < (int)hashCodeList.size(); j++) - { + for (int j = 0; j < (int)hashCodeList.size(); j++) { std::u16string language = GetKeyboardTypeLanguage(inputMethodProperties[i], hashCodeList[j]); - if (systemLocales.find(language) != std::string::npos) - { + if (systemLocales.find(language) != std::string::npos) { currentImeId = imeId; flag = true; break; } } - if (flag) - { + if (flag) { break; } } // if we cannot find any keyboard type which belongs to system locales, // we will use the first enabled ime as current ime. - if (flag == false) - { - if (firstEnabledIme) - { + if (flag == false) { + if (firstEnabledIme) { currentImeId = firstEnabledIme->mImeId; } else { currentImeId = Utils::to_utf16(""); @@ -627,10 +558,8 @@ namespace MiscServices { */ std::u16string PerUserSetting::GetImeId(const std::u16string& packageName) { - for (int i = 0; i < (int)inputMethodProperties.size(); i++) - { - if (inputMethodProperties[i]->mPackageName == packageName) - { + for (int i = 0; i < (int)inputMethodProperties.size(); i++) { + if (inputMethodProperties[i]->mPackageName == packageName) { return inputMethodProperties[i]->mImeId; } } diff --git a/services/src/platform_callback_stub.cpp b/services/src/platform_callback_stub.cpp index cce681e..e90a4e7 100644 --- a/services/src/platform_callback_stub.cpp +++ b/services/src/platform_callback_stub.cpp @@ -86,7 +86,7 @@ namespace MiscServices { break; } default: { - return ; + return; } }