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."); }