From 278ed0804b2256161b4f4c39d4e727b2e0fb95e4 Mon Sep 17 00:00:00 2001 From: GlaryCastle Date: Fri, 8 Jul 2022 18:22:07 +0800 Subject: [PATCH 1/9] Signed-off-by: GlaryCastle Changes to be committed: modified: services/dfx/include/inputmethod_dump.h modified: services/dfx/include/inputmethod_sysevent.h modified: services/dfx/include/inputmethod_trace.h modified: services/dfx/src/inputmethod_dump.cpp modified: services/dfx/src/inputmethod_sysevent.cpp modified: services/dfx/src/inputmethod_trace.cpp modified: services/include/input_method_system_ability.h modified: services/src/input_method_system_ability.cpp --- services/dfx/include/inputmethod_dump.h | 2 +- services/dfx/include/inputmethod_sysevent.h | 2 +- services/dfx/include/inputmethod_trace.h | 2 +- services/dfx/src/inputmethod_dump.cpp | 2 +- services/dfx/src/inputmethod_sysevent.cpp | 2 +- services/dfx/src/inputmethod_trace.cpp | 2 +- .../include/input_method_system_ability.h | 1 + services/src/input_method_system_ability.cpp | 67 +++++++------------ 8 files changed, 33 insertions(+), 47 deletions(-) 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; From aa78e0ef07c57431c6adc7b708ba5ce34cb98fb8 Mon Sep 17 00:00:00 2001 From: GlaryCastle Date: Fri, 8 Jul 2022 18:27:37 +0800 Subject: [PATCH 2/9] Signed-off-by: GlaryCastle Changes to be committed: modified: services/dfx/src/inputmethod_dump.cpp --- services/dfx/src/inputmethod_dump.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/services/dfx/src/inputmethod_dump.cpp b/services/dfx/src/inputmethod_dump.cpp index db04fa6..98a11b3 100644 --- a/services/dfx/src/inputmethod_dump.cpp +++ b/services/dfx/src/inputmethod_dump.cpp @@ -14,7 +14,6 @@ */ #include "inputmethod_dump.h" -#include "global.h" namespace OHOS { namespace MiscServices { From 287af1224cce492ff83a3f5110d0a93b94ae68dc Mon Sep 17 00:00:00 2001 From: GlaryCastle Date: Fri, 8 Jul 2022 19:21:45 +0800 Subject: [PATCH 3/9] Signed-off-by: GlaryCastle Changes to be committed: modified: services/src/input_method_system_ability.cpp --- services/src/input_method_system_ability.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index 762bd02..ebf703c 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -176,7 +176,7 @@ namespace MiscServices { return; } std::string params = ""; - GetInputMethodParam(properties,params); + GetInputMethodParam(properties, params); dprintf(fd, "\n - dump all input methods:%s\n\n", params.c_str()); IMSA_HILOGI("InputMethodSystemAbility::DumpAllMethod end."); } @@ -1002,14 +1002,14 @@ namespace MiscServices { void InputMethodSystemAbility::OnDisplayOptionalInputMethod(int32_t userId) { IMSA_HILOGI("InputMethodSystemAbility::OnDisplayOptionalInputMethod"); - std::vector properties; + std::vector properties; listInputMethodByUserId(userId, &properties); if (!properties.size()) { IMSA_HILOGI("InputMethodSystemAbility::OnDisplayOptionalInputMethod has no ime"); return; } std::string params = ""; - GetInputMethodParam(properties,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; From 1d5d0dc32361705d6b006886270c61a2e7834ef1 Mon Sep 17 00:00:00 2001 From: GlaryCastle Date: Fri, 8 Jul 2022 19:27:54 +0800 Subject: [PATCH 4/9] Signed-off-by: GlaryCastle Changes to be committed: modified: services/dfx/src/inputmethod_dump.cpp --- services/dfx/src/inputmethod_dump.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/dfx/src/inputmethod_dump.cpp b/services/dfx/src/inputmethod_dump.cpp index 98a11b3..db04fa6 100644 --- a/services/dfx/src/inputmethod_dump.cpp +++ b/services/dfx/src/inputmethod_dump.cpp @@ -14,6 +14,7 @@ */ #include "inputmethod_dump.h" +#include "global.h" namespace OHOS { namespace MiscServices { From 6b2070a34b5e26b4c681e5258907a8f43e18bb05 Mon Sep 17 00:00:00 2001 From: GlaryCastle Date: Fri, 8 Jul 2022 19:42:44 +0800 Subject: [PATCH 5/9] Signed-off-by: GlaryCastle Changes to be committed: modified: services/include/input_method_system_ability.h modified: services/src/input_method_system_ability.cpp --- .../include/input_method_system_ability.h | 2 +- services/src/input_method_system_ability.cpp | 22 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/services/include/input_method_system_ability.h b/services/include/input_method_system_ability.h index 09243a7..95db58a 100644 --- a/services/include/input_method_system_ability.h +++ b/services/include/input_method_system_ability.h @@ -56,7 +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_); + 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 ebf703c..f11fe4c 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -140,27 +140,27 @@ namespace MiscServices { } void InputMethodSystemAbility::GetInputMethodParam( - std::vector properties_, std::string ¶ms_) + 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()) { + for (it = properties.begin(); it < properties.end(); ++it) { + if (it == properties.begin()) { params_ += "{\"imeList\":["; } else { - params_ += "},"; + 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) + "\","; + 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 += "\"isDefaultIme\": \"" + isDefaultIme + "\","; + params += "\"label\": \"" + Str16ToStr8(property->label) + "\","; + params += "\"description\": \"" + Str16ToStr8(property->description) + "\""; } - params_ += "}]}"; + params += "}]}"; } void InputMethodSystemAbility::DumpAllMethod(int fd) From 830a58e61301a68c52ac380289a32cb447fed6aa Mon Sep 17 00:00:00 2001 From: GlaryCastle Date: Fri, 8 Jul 2022 20:02:17 +0800 Subject: [PATCH 6/9] Signed-off-by: GlaryCastle Changes to be committed: modified: services/src/input_method_system_ability.cpp --- services/src/input_method_system_ability.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index f11fe4c..50d77aa 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -146,7 +146,7 @@ namespace MiscServices { std::vector::iterator it; for (it = properties.begin(); it < properties.end(); ++it) { if (it == properties.begin()) { - params_ += "{\"imeList\":["; + params += "{\"imeList\":["; } else { params += "},"; } From 62ad5d0323c7a4baf72d22b4d0bedaa328c5f5c2 Mon Sep 17 00:00:00 2001 From: GlaryCastle Date: Mon, 11 Jul 2022 17:46:19 +0800 Subject: [PATCH 7/9] Signed-off-by: GlaryCastle Changes to be committed: modified: services/BUILD.gn modified: services/include/input_method_system_ability.h modified: services/src/input_method_system_ability.cpp --- services/BUILD.gn | 1 + .../include/input_method_system_ability.h | 3 +- services/src/input_method_system_ability.cpp | 28 +++++++++++-------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/services/BUILD.gn b/services/BUILD.gn index fcd2efd..ef34e1d 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -87,6 +87,7 @@ ohos_shared_library("inputmethod_service") { "hitrace_native:hitrace_meter", "hitrace_native:libhitrace", "hiviewdfx_hilog_native:libhilog", + "os_account:os_account_innerkits", ] subsystem_name = "miscservices" diff --git a/services/include/input_method_system_ability.h b/services/include/input_method_system_ability.h index 95db58a..f843727 100644 --- a/services/include/input_method_system_ability.h +++ b/services/include/input_method_system_ability.h @@ -56,7 +56,6 @@ 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); @@ -96,7 +95,7 @@ namespace MiscServices { OHOS::sptr GetBundleMgr(); void StartUserIdListener(); int32_t OnSwitchInputMethod(int32_t userId, InputMethodProperty *target); - + void GetInputMethodParam(std::vector properties, std::string ¶ms); ServiceRunningState state_; void InitServiceHandler(); static std::mutex instanceLock_; diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index 50d77aa..bba4664 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -30,10 +30,12 @@ #include "common_event_support.h" #include "im_common_event_manager.h" #include "resource_manager.h" +#include "os_account_manager.h" namespace OHOS { namespace MiscServices { using namespace MessageID; + using namespace AccountSA; REGISTER_SYSTEM_ABILITY_BY_ID(InputMethodSystemAbility, INPUT_METHOD_SYSTEM_ABILITY_ID, true); const std::int32_t INIT_INTERVAL = 10000L; const std::int32_t MAIN_USER_ID = 100; @@ -166,18 +168,22 @@ namespace MiscServices { void InputMethodSystemAbility::DumpAllMethod(int fd) { IMSA_HILOGI("InputMethodSystemAbility::DumpAllMethod"); - int32_t uid = IPCSkeleton::GetCallingUid(); - int32_t userId = getUserId(uid); - std::vector properties; - listInputMethodByUserId(userId, &properties); - if (!properties.size()) { - IMSA_HILOGI("InputMethodSystemAbility::DumpAllMethod has no ime"); - dprintf(fd, "\n - dump has no ime:\n"); - return; + std::vector ids; + OsAccountManager::QueryActiveOsAccountIds(ids); + dprintf(fd, "\n - DumpAllMethod Active Id count=%d", ids.size()); + for (int i = 0; i < ids.size(); i++) { + int32_t userId = getUserId(ids.at(i)); + std::vector properties; + listInputMethodByUserId(userId, &properties); + if (properties.empty()) { + IMSA_HILOGI("InputMethodSystemAbility::DumpAllMethod has no ime"); + dprintf(fd, "\n - dump has no ime:\n"); + return; + } + std::string params = ""; + GetInputMethodParam(properties, params); + dprintf(fd, "\n - the userId %d dump input methods:\n%s\n", userId, params.c_str()); } - std::string params = ""; - GetInputMethodParam(properties, params); - dprintf(fd, "\n - dump all input methods:%s\n\n", params.c_str()); IMSA_HILOGI("InputMethodSystemAbility::DumpAllMethod end."); } From e38fc1f48b6963c264e67a6269101c2d53b7fc93 Mon Sep 17 00:00:00 2001 From: GlaryCastle Date: Mon, 11 Jul 2022 21:27:17 +0800 Subject: [PATCH 8/9] Signed-off-by: GlaryCastle Changes to be committed: modified: services/src/input_method_system_ability.cpp --- services/src/input_method_system_ability.cpp | 30 +++++++++++--------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index bba4664..6c29835 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -169,20 +169,24 @@ namespace MiscServices { { IMSA_HILOGI("InputMethodSystemAbility::DumpAllMethod"); std::vector ids; - OsAccountManager::QueryActiveOsAccountIds(ids); - dprintf(fd, "\n - DumpAllMethod Active Id count=%d", ids.size()); - for (int i = 0; i < ids.size(); i++) { - int32_t userId = getUserId(ids.at(i)); - std::vector properties; - listInputMethodByUserId(userId, &properties); - if (properties.empty()) { - IMSA_HILOGI("InputMethodSystemAbility::DumpAllMethod has no ime"); - dprintf(fd, "\n - dump has no ime:\n"); - return; + int errCode = OsAccountManager::QueryActiveOsAccountIds(ids); + if (errCode == 0) { + dprintf(fd, "\n - DumpAllMethod get Active Id succeed,count=%d,", ids.size()); + for (auto it : ids) { + int32_t userId = getUserId(it); + std::vector properties; + listInputMethodByUserId(userId, &properties); + if (properties.empty()) { + IMSA_HILOGI("The IME properties is empty."); + dprintf(fd, "\n - The IME properties is empty.\n"); + return; + } + std::string params; + GetInputMethodParam(properties, params); + dprintf(fd, "\n - The userId %d get input method:\n%s\n", userId, params.c_str()); } - std::string params = ""; - GetInputMethodParam(properties, params); - dprintf(fd, "\n - the userId %d dump input methods:\n%s\n", userId, params.c_str()); + } else { + dprintf(fd, "\n - InputMethodSystemAbility::DumpAllMethod get Active Id failed.\n"); } IMSA_HILOGI("InputMethodSystemAbility::DumpAllMethod end."); } From 89a4b70c4750ee93e379ebd9f84b4a89c928bfb5 Mon Sep 17 00:00:00 2001 From: GlaryCastle Date: Tue, 12 Jul 2022 15:30:50 +0800 Subject: [PATCH 9/9] Signed-off-by: GlaryCastle Changes to be committed: modified: services/src/input_method_system_ability.cpp --- services/src/input_method_system_ability.cpp | 32 ++++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index 6c29835..67778c0 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -19,6 +19,7 @@ #include "system_ability_definition.h" #include "iservice_registry.h" #include "ipc_skeleton.h" +#include "errors.h" #include "global.h" #include "ui_service_mgr_client.h" #include "bundle_mgr_proxy.h" @@ -170,23 +171,22 @@ namespace MiscServices { IMSA_HILOGI("InputMethodSystemAbility::DumpAllMethod"); std::vector ids; int errCode = OsAccountManager::QueryActiveOsAccountIds(ids); - if (errCode == 0) { - dprintf(fd, "\n - DumpAllMethod get Active Id succeed,count=%d,", ids.size()); - for (auto it : ids) { - int32_t userId = getUserId(it); - std::vector properties; - listInputMethodByUserId(userId, &properties); - if (properties.empty()) { - IMSA_HILOGI("The IME properties is empty."); - dprintf(fd, "\n - The IME properties is empty.\n"); - return; - } - std::string params; - GetInputMethodParam(properties, params); - dprintf(fd, "\n - The userId %d get input method:\n%s\n", userId, params.c_str()); - } - } else { + if (errCode != ERR_OK) { dprintf(fd, "\n - InputMethodSystemAbility::DumpAllMethod get Active Id failed.\n"); + return; + } + dprintf(fd, "\n - DumpAllMethod get Active Id succeed,count=%d,", ids.size()); + for (auto it : ids) { + std::vector properties; + listInputMethodByUserId(it, &properties); + if (properties.empty()) { + IMSA_HILOGI("The IME properties is empty."); + dprintf(fd, "\n - The IME properties is empty.\n"); + continue; + } + std::string params; + GetInputMethodParam(properties, params); + dprintf(fd, "\n - The Active Id:%d get input method:\n%s\n", it, params.c_str()); } IMSA_HILOGI("InputMethodSystemAbility::DumpAllMethod end."); }