From 719e0bb6b9fc2f5e142f07e4446b70013b55cb82 Mon Sep 17 00:00:00 2001 From: zhangkaixiang5 Date: Tue, 14 Mar 2023 15:07:07 +0800 Subject: [PATCH] Update GetBundleInfoForSelf Interface Signed-off-by: zhangkaixiang5 --- interfaces/innerkits/native/common/log.h | 2 +- interfaces/kits/js/BUILD.gn | 1 + interfaces/kits/js/common/log.h | 2 +- interfaces/kits/js/file_uri/get_uri_from_path.cpp | 8 +++++--- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/interfaces/innerkits/native/common/log.h b/interfaces/innerkits/native/common/log.h index 7353db72b..7504b3f37 100644 --- a/interfaces/innerkits/native/common/log.h +++ b/interfaces/innerkits/native/common/log.h @@ -20,7 +20,7 @@ namespace OHOS { namespace AppFileService { const unsigned int APP_LOG_DOMAIN = 0xD004313; const char APP_LOG_TAG[] = "AppFileService"; -static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, APP_LOG_DOMAIN, APP_LOG_TAG}; +static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, APP_LOG_DOMAIN, APP_LOG_TAG }; #define PRINT_LOG(Level, fmt, ...) \ OHOS::HiviewDFX::HiLog::Level(OHOS::AppFileService::LOG_LABEL, "[%{public}s:%{public}d] " fmt, \ diff --git a/interfaces/kits/js/BUILD.gn b/interfaces/kits/js/BUILD.gn index 2fba1d617..fbdd483cf 100644 --- a/interfaces/kits/js/BUILD.gn +++ b/interfaces/kits/js/BUILD.gn @@ -79,6 +79,7 @@ ohos_shared_library("fileuri") { external_deps = [ "ability_runtime:abilitykit_native", + "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", "file_api:filemgmt_libn", diff --git a/interfaces/kits/js/common/log.h b/interfaces/kits/js/common/log.h index 683e30355..f9d3ece92 100644 --- a/interfaces/kits/js/common/log.h +++ b/interfaces/kits/js/common/log.h @@ -20,7 +20,7 @@ namespace OHOS { namespace AppFileService { const unsigned int APP_LOG_DOMAIN = 0xD004313; const char APP_LOG_TAG[] = "AppFileService"; -static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, APP_LOG_DOMAIN, APP_LOG_TAG}; +static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, APP_LOG_DOMAIN, APP_LOG_TAG }; #define PRINT_LOG(Level, fmt, ...) \ OHOS::HiviewDFX::HiLog::Level(OHOS::AppFileService::LOG_LABEL, "[%{public}s:%{public}d] " fmt, \ diff --git a/interfaces/kits/js/file_uri/get_uri_from_path.cpp b/interfaces/kits/js/file_uri/get_uri_from_path.cpp index 30c77385a..b2e930955 100644 --- a/interfaces/kits/js/file_uri/get_uri_from_path.cpp +++ b/interfaces/kits/js/file_uri/get_uri_from_path.cpp @@ -14,6 +14,7 @@ */ #include "get_uri_from_path.h" +#include "bundle_info.h" #include "bundle_mgr_proxy.h" #include "ipc_skeleton.h" #include "iservice_registry.h" @@ -56,13 +57,14 @@ static string GetBundleName() return nullptr; } - string bundleName; - if (!bundleMgrProxy->GetBundleNameForUid(uid, bundleName)) { + BundleInfo bundleInfo; + auto ret = bundleMgrProxy->GetBundleInfoForSelf(uid, bundleInfo); + if (ret != ERR_OK) { LOGE("GetBundleName: bundleName get fail. uid is %{public}d", uid); return nullptr; } - return bundleName; + return bundleInfo.name; } napi_value GetUriFromPath::Sync(napi_env env, napi_callback_info info) -- Gitee