From 315253888aead0feb599512a8402ec60cc68edf7 Mon Sep 17 00:00:00 2001 From: zhangkaixiang5 Date: Tue, 14 Mar 2023 16:01:44 +0800 Subject: [PATCH] Update GetBundleInfoForSelf Interface Signed-off-by: zhangkaixiang5 --- interfaces/kits/js/BUILD.gn | 1 + interfaces/kits/js/src/mod_fs/properties/open.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/js/BUILD.gn b/interfaces/kits/js/BUILD.gn index dfb6f3eee..8fa5ee4d0 100644 --- a/interfaces/kits/js/BUILD.gn +++ b/interfaces/kits/js/BUILD.gn @@ -151,6 +151,7 @@ ohos_shared_library("fs") { "ability_base:zuri", "ability_runtime:abilitykit_native", "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", "data_share:datashare_common", diff --git a/interfaces/kits/js/src/mod_fs/properties/open.cpp b/interfaces/kits/js/src/mod_fs/properties/open.cpp index 1bb4350f0..a066a41a7 100644 --- a/interfaces/kits/js/src/mod_fs/properties/open.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/open.cpp @@ -20,6 +20,7 @@ #include #include "ability.h" +#include "bundle_info.h" #include "bundle_mgr_proxy.h" #include "class_file/file_entity.h" #include "class_file/file_n_exporter.h" @@ -126,12 +127,13 @@ static string GetBundleNameSelf() HILOGE("Bundle mgr proxy is null ptr."); return nullptr; } - string bundleName; - if (!bundleMgrProxy->GetBundleNameForUid(uid, bundleName)) { - HILOGE("Failed to get bundleNameSelf. uid is %{public}d", uid); + AppExecFwk::BundleInfo bundleInfo; + auto ret = bundleMgrProxy->GetBundleInfoForSelf(uid, bundleInfo); + if (ret != ERR_OK) { + HILOGE("Failed to get bundleNameSelf."); return nullptr; } - return bundleName; + return bundleInfo.name; } static string GetPathFromFileUri(string path, string bundleName, unsigned int mode) -- Gitee