From b5ff5e830066501d03dfb67b4acefac0432c2759 Mon Sep 17 00:00:00 2001 From: ming-yue-liu1 Date: Mon, 8 Sep 2025 20:58:14 +0800 Subject: [PATCH] =?UTF-8?q?getBundleNameForUid=E6=A1=A5=E6=8E=A5=E6=B9=96?= =?UTF-8?q?=E5=86=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ming-yue-liu1 --- .../bundlemgr/src/bundle_mgr_host_impl.cpp | 11 ++++++++++- .../acts_bms_kit_system_test.cpp | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/services/bundlemgr/src/bundle_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_mgr_host_impl.cpp index 38da1ca8de..b03fa23bc4 100644 --- a/services/bundlemgr/src/bundle_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_mgr_host_impl.cpp @@ -754,7 +754,16 @@ ErrCode BundleMgrHostImpl::GetNameAndIndexForUid(const int uid, std::string &bun APP_LOGE("DataMgr is nullptr"); return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; } - return dataMgr->GetBundleNameAndIndexForUid(uid, bundleName, appIndex); + auto ret = dataMgr->GetBundleNameAndIndexForUid(uid, bundleName, appIndex); + if (ret != ERR_OK && isBrokerServiceExisted_) { + auto bmsExtensionClient = std::make_shared(); + ret = bmsExtensionClient->GetBundleNameByUid(uid, bundleName); + if (ret != ERR_OK) { + APP_LOGD("GetBundleNameByUidExt failed, uid : %{public}d", uid); + return ERR_BUNDLE_MANAGER_INVALID_UID; + } + } + return ret; } ErrCode BundleMgrHostImpl::GetAppIdentifierAndAppIndex(const uint32_t accessTokenId, diff --git a/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp b/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp index 904780dc0f..feafaf475c 100644 --- a/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp +++ b/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp @@ -10431,6 +10431,24 @@ HWTEST_F(ActsBmsKitSystemTest, GetNameAndIndexForUid_0100, Function | MediumTest std::cout << "END GetNameAndIndexForUid_0100" << std::endl; } +/** + * @tc.number: GetNameAndIndexForUid_0200 + * @tc.name: test get name and appIndex by uid + * @tc.desc: 1.get bundleName and appIndex by uid + */ +HWTEST_F(ActsBmsKitSystemTest, GetNameAndIndexForUid_0200, Function | MediumTest | Level1) +{ + std::cout << "START GetNameAndIndexForUid_0200" << std::endl; + sptr bundleMgrProxy = GetBundleMgrProxy(); + ASSERT_NE(bundleMgrProxy, nullptr); + std::string name; + int32_t testAppIndex = 0; + ErrCode ret = bundleMgrProxy->GetNameAndIndexForUid(10000, name, testAppIndex); + EXPECT_TRUE(ret == ERR_OK || ret == ERR_BUNDLE_MANAGER_INVALID_UID); + EXPECT_EQ(testAppIndex, 0); + std::cout << "END GetNameAndIndexForUid_0200" << std::endl; +} + /** * @tc.number: AddResourceInfoByBundleName_0001 * @tc.name: test BundleResourceProxy -- Gitee