Signed-off-by: GlaryCastle <yangpeng190@huawei.com>

Changes to be committed:
	modified:   services/BUILD.gn
	modified:   services/include/input_method_system_ability.h
	modified:   services/src/input_method_system_ability.cpp
This commit is contained in:
GlaryCastle
2022-07-11 17:46:19 +08:00
parent 830a58e613
commit 62ad5d0323
3 changed files with 19 additions and 13 deletions
+1
View File
@@ -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"
@@ -56,7 +56,6 @@ namespace MiscServices {
int32_t listInputMethod(std::vector<InputMethodProperty*> *properties) override;
int32_t listInputMethodByUserId(int32_t userId, std::vector<InputMethodProperty*> *properties) override;
int32_t listKeyboardType(const std::u16string& imeId, std::vector<KeyboardType*> *types) override;
void GetInputMethodParam(std::vector<InputMethodProperty *> properties, std::string &params);
int Dump(int fd, const std::vector<std::u16string> &args) override;
void DumpAllMethod(int fd);
@@ -96,7 +95,7 @@ namespace MiscServices {
OHOS::sptr<OHOS::AppExecFwk::IBundleMgr> GetBundleMgr();
void StartUserIdListener();
int32_t OnSwitchInputMethod(int32_t userId, InputMethodProperty *target);
void GetInputMethodParam(std::vector<InputMethodProperty *> properties, std::string &params);
ServiceRunningState state_;
void InitServiceHandler();
static std::mutex instanceLock_;
+17 -11
View File
@@ -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<InputMethodProperty *> 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<int32_t> 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<InputMethodProperty *> 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.");
}