fix warning

Signed-off-by: zhouyongfei <zhouyongfei@huawei.com>
This commit is contained in:
zhouyongfei
2021-09-27 19:38:28 +08:00
parent 54fa4803ab
commit 8dac508bdc
26 changed files with 194 additions and 346 deletions
@@ -26,12 +26,14 @@ namespace MiscServices {
class InputClientStub : public IRemoteStub<IInputClient> {
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<IInputMethodAgent>& agent, const InputChannel *channel) override;
int32_t onInputReady(int32_t retValue, const sptr<IInputMethodAgent>& agent,
const InputChannel *channel) override;
int32_t onInputReleased(int32_t retValue) override;
int32_t setDisplayMode(int32_t mode) override;
private:
@@ -23,7 +23,7 @@
namespace OHOS {
namespace MiscServices {
class InputDataChannelStub : public IRemoteStub<IInputDataChannel> {
class InputDataChannelStub : public IRemoteStub<IInputDataChannel> {
public:
DISALLOW_COPY_AND_MOVE(InputDataChannelStub);
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
@@ -302,8 +302,7 @@ namespace MiscServices {
}
KeyboardType *keyType = reply.ReadParcelable<KeyboardType>();
if (keyType == nullptr)
{
if (keyType == nullptr) {
return ERROR_STATUS_BAD_INDEX;
}
*retType = *keyType;
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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);
};
}
}
+1 -1
View File
@@ -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);
};
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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);
+2 -2
View File
@@ -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&&);
};
}
}
+3 -3
View File
@@ -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<Message*> mQueue ; // Message queue, guarded by mMutex;
std::queue<Message*> 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&&);
};
}
}
+3 -2
View File
@@ -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> 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);
+2 -2
View File
@@ -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);
+2 -2
View File
@@ -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&&);
};
}
}
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -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<std::mutex> lck(mtx);
@@ -32,8 +32,7 @@ namespace MiscServices {
const sptr<IRemoteObject> &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);
+1 -1
View File
@@ -33,7 +33,7 @@ namespace MiscServices {
}
~InputMethodAgentProxy()
{
{
}
int32_t dispatchKey(int key, int status)
+6 -11
View File
@@ -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;
+15 -29
View File
@@ -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<std::u16string, std::u16string>::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<std::u16string, std::u16string>(key, value));
@@ -139,8 +137,7 @@ namespace MiscServices {
std::u16string value = GetValue(ENABLED_INPUT_METHODS_TAG);
std::vector<std::u16string> tmp1 = Split(value, DELIM_IME);
std::vector<std::u16string> imeList;
for (int i = 0; i < (int)tmp1.size(); i++)
{
for (int i = 0; i < (int)tmp1.size(); i++) {
std::vector<std::u16string> tmp2 = Split(tmp1[i], DELIM_KBD_TYPE);
imeList.push_back(tmp2[0]);
tmp2.clear();
@@ -160,14 +157,12 @@ namespace MiscServices {
std::vector<std::u16string> 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<std::u16string> imeList = Split(str, DELIM_IME);
bool flag = false;
std::vector<std::u16string>::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<std::u16string> 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<std::u16string> 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);
}
}
+10 -20
View File
@@ -58,8 +58,7 @@ namespace MiscServices {
}
std::map<int32_t, PerUserSession*>::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<int32_t, PerUserSetting*>::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<int32_t, MessageHandler*>::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<InputMethodProperty*>::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<InputMethodProperty*>::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<int32_t, PerUserSetting*>::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<int32_t, MessageHandler*>::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);
@@ -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();
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -47,7 +47,7 @@ namespace MiscServices {
}
}
Message& Message::operator = (const Message& msg)
Message& Message::operator =(const Message& msg)
{
if (this == &msg) {
return *this;
+57 -106
View File
@@ -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<std::mutex> 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<sptr<IRemoteObject>, 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<std::mutex> 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<IRemoteObject> 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<int> 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<sptr<IRemoteObject>, ClientInfo*>::iterator it;
for (it = mapClients.begin(); it != mapClients.end();)
{
for (it = mapClients.begin(); it != mapClients.end();) {
sptr<IRemoteObject> 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<IRemoteObject> 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<IRemoteObject> b = Platform::RemoteBrokerToObject(currentClient);
std::map<sptr<IRemoteObject>, 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<int> 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;
+72 -143
View File
@@ -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<int> 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<InputMethodProperty*>::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<InputMethodProperty*>::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<std::u16string> 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<int> 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<InputMethodProperty*> *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<InputMethodProperty*> *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<KeyboardType*> *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<int> 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<int> 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;
}
}
+1 -1
View File
@@ -86,7 +86,7 @@ namespace MiscServices {
break;
}
default: {
return ;
return;
}
}