fix by debug

Signed-off-by: lixiangpeng5 <lixiangpeng5@huawei.com>
Change-Id: I09786823f367321e8c2c1bfaa1a0121cc982cb1b
This commit is contained in:
lixiangpeng5 2024-07-27 14:00:58 +00:00
parent f14c4d3afb
commit f6a7e7bb3c
3 changed files with 14 additions and 12 deletions

View File

@ -19,6 +19,8 @@
],
"deps": {
"components": [
"ability_runtime",
"bundle_framework",
"c_utils",
"hilog",
"build_framework",
@ -31,7 +33,8 @@
"memmgr",
"safwk",
"samgr",
"eventhandler"
"eventhandler",
"os_account"
],
"third_party": []
},

View File

@ -39,9 +39,12 @@ ohos_shared_library("libsensor") {
}
deps = [ "$SUBSYSTEM_DIR/frameworks/native:sensor_interface_native" ]
external_deps = [
"ability_runtime:app_manager",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"hilog:libhilog",
"napi:ace_napi",
"os_account:os_account_innerkits"
]
relative_install_dir = "module"
part_name = "sensor"

View File

@ -616,34 +616,30 @@ void EmitPromiseWork(sptr<AsyncCallbackInfo> asyncCallbackInfo)
int32_t GetTargetSDKVersion(int32_t pid)
{
AppExecFwk::RunningProcessInfo processinfo;
appMgrClientPtr_ = DelayedSingleton<AppExecFwk::AppMgrClient>::GetInstance();
if (appMgrClientPtr_ == nullptr) {
MISC_HILOGE("appMgrClientPtr is nullptr");
return INVALID_TARGET_VERSION;
}
int32_t ret = appMgrClientPtr_->AppExecFwk::AppMgrClient::GetRunningProcessInfoByPid(pid, processinfo);
AppExecFwk::AppMgrClient appMgrClient;
int32_t ret = appMgrClient.AppExecFwk::AppMgrClient::GetRunningProcessInfoByPid(pid, processinfo);
if (ret != ERR_OK) {
MISC_HILOGE("Getrunningprocessinfobypid failed");
SEN_HILOGE("Getrunningprocessinfobypid failed");
return INVALID_TARGET_VERSION;
}
std::vector<int32_t> activeUserIds;
int32_t retId = AccountSA::OsAccountManager::QueryActiveOsAccountIds(activeUserIds);
if (retId != 0) {
MISC_HILOGE("QueryActiveOsAccountIds failed %{public}d", retId);
SEN_HILOGE("QueryActiveOsAccountIds failed %{public}d", retId);
return INVALID_TARGET_VERSION;
}
if (activeUserIds.empty()) {
MISC_HILOGE("activeUserId empty");
SEN_HILOGE("activeUserId empty");
return INVALID_TARGET_VERSION;
}
for (const auto &bundleName : processinfo.bundleNames) {
MISC_HILOGD("bundleName = %{public}s", bundleName.c_str());
SEN_HILOGD("bundleName = %{public}s", bundleName.c_str());
AppExecFwk::BundleMgrClient bundleMgrClient;
AppExecFwk::BundleInfo bundleInfo;
auto res = bundleMgrClient.AppExecFwk::BundleMgrClient::GetBundleInfo(bundleName,
AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, activeUserIds[0]);
if (!res) {
MISC_HILOGE("Getbundleinfo fail");
SEN_HILOGE("Getbundleinfo fail");
return INVALID_TARGET_VERSION;
}
return bundleInfo.targetVersion;