diff --git a/common/imf_hisysevent/src/imf_hisysevent_util.cpp b/common/imf_hisysevent/src/imf_hisysevent_util.cpp index ab791650ba7a8317058dc76ebc75b24714b9d0f5..9cae6c94aa7b5c9cee27833ad3e41671e2adf394 100644 --- a/common/imf_hisysevent/src/imf_hisysevent_util.cpp +++ b/common/imf_hisysevent/src/imf_hisysevent_util.cpp @@ -22,6 +22,7 @@ #include "hisysevent.h" #include "ipc_skeleton.h" #include "running_process_info.h" +#include "singleton.h" namespace OHOS { namespace MiscServices { using namespace OHOS::AppExecFwk; @@ -117,8 +118,8 @@ std::string ImfHiSysEventUtil::GetAppName(uint64_t fullTokenId) case ATokenTypeEnum::TOKEN_HAP: { if (fullTokenId == IPCSkeleton::GetSelfTokenID()) { RunningProcessInfo info; - AppMgrClient client; - if (client.GetProcessRunningInformation(info) == 0) { + auto appMgrClient = DelayedSingleton::GetInstance(); + if (appMgrClient != nullptr && appMgrClient->GetProcessRunningInformation(info) == 0) { name = info.processName_; } break; diff --git a/services/src/ime_info_inquirer.cpp b/services/src/ime_info_inquirer.cpp index 4dbeb1d4b6164918c62ba08250710a129815f900..619d170926f24036757b6f7f3254f6da02bb27d4 100644 --- a/services/src/ime_info_inquirer.cpp +++ b/services/src/ime_info_inquirer.cpp @@ -15,7 +15,7 @@ #include "ime_info_inquirer.h" #include "app_mgr_client.h" -#include "bundle_mgr_client_impl.h" +#include "bundle_mgr_client.h" #include "full_ime_info_manager.h" #include "input_type_manager.h" #include "iservice_registry.h" @@ -23,6 +23,7 @@ #include "locale_info.h" #include "os_account_adapter.h" #include "parameter.h" +#include "singleton.h" #include "system_ability_definition.h" namespace OHOS { @@ -598,9 +599,9 @@ int32_t ImeInfoInquirer::ParseSubtype(const OHOS::AppExecFwk::ExtensionAbilityIn IMSA_HILOGE("find metadata name: SUBTYPE_PROFILE_METADATA_NAME failed!"); return ErrorCode::ERROR_BAD_PARAMETERS; } - OHOS::AppExecFwk::BundleMgrClientImpl clientImpl; + OHOS::AppExecFwk::BundleMgrClient client; std::vector profiles; - if (!clientImpl.GetResConfigFile(extInfo, iter->name, profiles)) { + if (!client.GetResConfigFile(extInfo, iter->name, profiles)) { IMSA_HILOGE("failed to GetProfileFromExtension!"); return ErrorCode::ERROR_PACKAGE_MANAGER; } @@ -1112,8 +1113,12 @@ std::vector ImeInfoInquirer::GetRunningIme(int32_t userId) { std::vector bundleNames; std::vector infos; - AppMgrClient client; - auto ret = client.GetProcessRunningInfosByUserId(infos, userId); + auto appMgrClient = DelayedSingleton::GetInstance(); + if (appMgrClient == nullptr) { + IMSA_HILOGE("appMgrClient is nullptr."); + return bundleNames; + } + auto ret = appMgrClient->GetProcessRunningInfosByUserId(infos, userId); if (ret != ErrorCode::NO_ERROR) { IMSA_HILOGE("GetAllRunningProcesses failed, ret: %{public}d!", ret); return bundleNames; @@ -1212,8 +1217,12 @@ std::string ImeInfoInquirer::GetTargetString( bool ImeInfoInquirer::IsInputMethodExtension(pid_t pid) { RunningProcessInfo info; - AppMgrClient client; - client.GetRunningProcessInfoByPid(pid, info); + auto appMgrClient = DelayedSingleton::GetInstance(); + if (appMgrClient == nullptr) { + IMSA_HILOGE("appMgrClient is nullptr."); + return false; + } + appMgrClient->GetRunningProcessInfoByPid(pid, info); return info.extensionType_ == ExtensionAbilityType::INPUTMETHOD; } } // namespace MiscServices