diff --git a/services/dfx/include/inputmethod_dump.h b/services/dfx/include/inputmethod_dump.h index d65519d..466dbfa 100644 --- a/services/dfx/include/inputmethod_dump.h +++ b/services/dfx/include/inputmethod_dump.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/dfx/include/inputmethod_sysevent.h b/services/dfx/include/inputmethod_sysevent.h index 4a46432..bc54ef5 100644 --- a/services/dfx/include/inputmethod_sysevent.h +++ b/services/dfx/include/inputmethod_sysevent.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/dfx/include/inputmethod_trace.h b/services/dfx/include/inputmethod_trace.h index 19f6c55..9ca2ac3 100644 --- a/services/dfx/include/inputmethod_trace.h +++ b/services/dfx/include/inputmethod_trace.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/dfx/src/inputmethod_dump.cpp b/services/dfx/src/inputmethod_dump.cpp index f88750b..db04fa6 100644 --- a/services/dfx/src/inputmethod_dump.cpp +++ b/services/dfx/src/inputmethod_dump.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/dfx/src/inputmethod_sysevent.cpp b/services/dfx/src/inputmethod_sysevent.cpp index 4da6688..51970ee 100644 --- a/services/dfx/src/inputmethod_sysevent.cpp +++ b/services/dfx/src/inputmethod_sysevent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/dfx/src/inputmethod_trace.cpp b/services/dfx/src/inputmethod_trace.cpp index f9a8b46..5617d74 100644 --- a/services/dfx/src/inputmethod_trace.cpp +++ b/services/dfx/src/inputmethod_trace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/include/input_method_system_ability.h b/services/include/input_method_system_ability.h index d980630..09243a7 100644 --- a/services/include/input_method_system_ability.h +++ b/services/include/input_method_system_ability.h @@ -56,6 +56,7 @@ namespace MiscServices { int32_t listInputMethod(std::vector *properties) override; int32_t listInputMethodByUserId(int32_t userId, std::vector *properties) override; int32_t listKeyboardType(const std::u16string& imeId, std::vector *types) override; + void GetInputMethodParam(std::vector properties_, std::string ¶ms_); int Dump(int fd, const std::vector &args) override; void DumpAllMethod(int fd); diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index 09953a9..762bd02 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -139,6 +139,30 @@ namespace MiscServices { return ERR_OK; } + void InputMethodSystemAbility::GetInputMethodParam( + std::vector properties_, std::string ¶ms_) + { + std::string defaultIme = ParaHandle::GetDefaultIme(userId_); + std::vector::iterator it; + for (it = properties_.begin(); it < properties_.end(); ++it) { + if (it == properties_.begin()) { + params_ += "{\"imeList\":["; + } else { + params_ += "},"; + } + InputMethodProperty *property = (InputMethodProperty *)*it; + std::string imeId = Str16ToStr8(property->mPackageName) + "/" + Str16ToStr8(property->mAbilityName); + params_ += "{\"ime\": \"" + imeId + "\","; + params_ += "\"labelId\": \"" + std::to_string(property->labelId) + "\","; + params_ += "\"descriptionId\": \"" + std::to_string(property->descriptionId) + "\","; + std::string isDefaultIme = defaultIme == imeId ? "true" : "false"; + params_ += "\"isDefaultIme\": \"" + isDefaultIme + "\","; + params_ += "\"label\": \"" + Str16ToStr8(property->label) + "\","; + params_ += "\"description\": \"" + Str16ToStr8(property->description) + "\""; + } + params_ += "}]}"; + } + void InputMethodSystemAbility::DumpAllMethod(int fd) { IMSA_HILOGI("InputMethodSystemAbility::DumpAllMethod"); @@ -151,27 +175,8 @@ namespace MiscServices { dprintf(fd, "\n - dump has no ime:\n"); return; } - std::string defaultIme = ParaHandle::GetDefaultIme(userId_); std::string params = ""; - std::vector::iterator it; - for (it = properties.begin(); it < properties.end(); ++it) { - if (it == properties.begin()) { - params += "{\"imeList\":["; - } else { - params += "},"; - } - InputMethodProperty *property = (InputMethodProperty *)*it; - std::string imeId = Str16ToStr8(property->mPackageName) + "/" + Str16ToStr8(property->mAbilityName); - params += "{\"ime\": \"" + imeId + "\","; - params += "\"labelId\": \"" + std::to_string(property->labelId) + "\","; - params += "\"descriptionId\": \"" + std::to_string(property->descriptionId) + "\","; - std::string isDefaultIme = defaultIme == imeId ? "true" : "false"; - params += "\"isDefaultIme\": \"" + isDefaultIme + "\","; - params += "\"label\": \"" + Str16ToStr8(property->label) + "\","; - params += "\"description\": \"" + Str16ToStr8(property->description) + "\""; - } - params += "}]}"; - + GetInputMethodParam(properties,params); dprintf(fd, "\n - dump all input methods:%s\n\n", params.c_str()); IMSA_HILOGI("InputMethodSystemAbility::DumpAllMethod end."); } @@ -1003,28 +1008,8 @@ namespace MiscServices { IMSA_HILOGI("InputMethodSystemAbility::OnDisplayOptionalInputMethod has no ime"); return; } - - std::string defaultIme = ParaHandle::GetDefaultIme(userId_); std::string params = ""; - std::vector::iterator it; - for (it = properties.begin(); it < properties.end(); ++it) { - if (it == properties.begin()) { - params += "{\"imeList\":["; - } else { - params += "},"; - } - InputMethodProperty *property = (InputMethodProperty*)*it; - std::string imeId = Str16ToStr8(property->mPackageName) + "/" + Str16ToStr8(property->mAbilityName); - params += "{\"ime\": \"" + imeId + "\","; - params += "\"labelId\": \"" + std::to_string(property->labelId) + "\","; - params += "\"descriptionId\": \"" + std::to_string(property->descriptionId) + "\","; - std::string isDefaultIme = defaultIme == imeId ? "true" : "false"; - params += "\"isDefaultIme\": \"" + isDefaultIme + "\","; - params += "\"label\": \"" + Str16ToStr8(property->label) + "\","; - params += "\"description\": \"" + Str16ToStr8(property->description) + "\""; - } - params += "}]}"; - + GetInputMethodParam(properties,params); IMSA_HILOGI("InputMethodSystemAbility::OnDisplayOptionalInputMethod param : %{public}s", params.c_str()); const int TITLE_HEIGHT = 62; const int SINGLE_IME_HEIGHT = 66;