From 14446d01545258eb9c06742abfe8667b8e8fded0 Mon Sep 17 00:00:00 2001 From: ming-yue-liu1 Date: Mon, 25 Aug 2025 17:46:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=9C=E6=B9=96=E9=9A=90?= =?UTF-8?q?=E7=A7=81=E7=A9=BA=E9=97=B4=E5=A4=9A=E7=94=A8=E6=88=B7=E9=80=82?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ming-yue-liu1 --- interfaces/inner_api/appexecfwk_core/IBundleMgrExt.idl | 3 ++- .../include/bundlemgr_ext/bundle_mgr_ext_client.h | 2 +- .../src/bundlemgr_ext/bundle_mgr_ext_client.cpp | 5 +++-- .../bundlemgr_extension/include/bms_extension_data_mgr.h | 4 ++-- .../bundlemgr_extension/include/bundle_mgr_ext.h | 4 ++-- .../bundlemgr_extension/src/bms_extension_data_mgr.cpp | 9 +++++---- .../include/bundlemgr_ext/bundle_mgr_ext_host_impl.h | 2 +- .../bundlemgr/src/bms_extension/bms_extension_client.cpp | 4 ++-- services/bundlemgr/src/bundle_mgr_host_impl.cpp | 3 ++- .../src/bundlemgr_ext/bundle_mgr_ext_host_impl.cpp | 4 ++-- 10 files changed, 22 insertions(+), 18 deletions(-) diff --git a/interfaces/inner_api/appexecfwk_core/IBundleMgrExt.idl b/interfaces/inner_api/appexecfwk_core/IBundleMgrExt.idl index 928c68d181..11fb05aa02 100644 --- a/interfaces/inner_api/appexecfwk_core/IBundleMgrExt.idl +++ b/interfaces/inner_api/appexecfwk_core/IBundleMgrExt.idl @@ -17,5 +17,6 @@ option_stub_hooks on; interface_token ohos.bundleManager.ext; interface OHOS.AppExecFwk.IBundleMgrExt { - [ipccode 0] void GetBundleNamesForUidExt([in] int uid, [out] String[] bundleNames, [out] int funcResult); + [ipccode 0] void GetBundleNamesForUidExt([in] int uid, [out] String[] bundleNames, [in] int userId, + [out] int funcResult); } diff --git a/interfaces/inner_api/appexecfwk_core/include/bundlemgr_ext/bundle_mgr_ext_client.h b/interfaces/inner_api/appexecfwk_core/include/bundlemgr_ext/bundle_mgr_ext_client.h index 2e50b250ea..eccd7dd05f 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundlemgr_ext/bundle_mgr_ext_client.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundlemgr_ext/bundle_mgr_ext_client.h @@ -27,7 +27,7 @@ namespace AppExecFwk { class BundleMgrExtClient { public: static BundleMgrExtClient &GetInstance(); - ErrCode GetBundleNamesForUidExt(const int32_t uid, std::vector &bundleNames); + ErrCode GetBundleNamesForUidExt(const int32_t uid, std::vector &bundleNames, int32_t userId); private: class BundleMgrExtDeathRecipient : public IRemoteObject::DeathRecipient { diff --git a/interfaces/inner_api/appexecfwk_core/src/bundlemgr_ext/bundle_mgr_ext_client.cpp b/interfaces/inner_api/appexecfwk_core/src/bundlemgr_ext/bundle_mgr_ext_client.cpp index bea45ecfe1..84c5cbb086 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundlemgr_ext/bundle_mgr_ext_client.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/bundlemgr_ext/bundle_mgr_ext_client.cpp @@ -29,7 +29,8 @@ BundleMgrExtClient &BundleMgrExtClient::GetInstance() return instance; } -ErrCode BundleMgrExtClient::GetBundleNamesForUidExt(const int32_t uid, std::vector &bundleNames) +ErrCode BundleMgrExtClient::GetBundleNamesForUidExt(const int32_t uid, std::vector &bundleNames, + int32_t userId) { APP_LOGD("GetBundleNamesForUidExt begin"); auto proxy = GetBundleMgrExtProxy(); @@ -39,7 +40,7 @@ ErrCode BundleMgrExtClient::GetBundleNamesForUidExt(const int32_t uid, std::vect } int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; - ErrCode res = proxy->GetBundleNamesForUidExt(uid, bundleNames, funcResult); + ErrCode res = proxy->GetBundleNamesForUidExt(uid, bundleNames, userId, funcResult); if (res != ERR_OK) { APP_LOGE("ipc failed, errCode is %{public}d", res); funcResult = res; diff --git a/interfaces/inner_api/bundlemgr_extension/include/bms_extension_data_mgr.h b/interfaces/inner_api/bundlemgr_extension/include/bms_extension_data_mgr.h index 68f50d11a1..c46c5d4c3a 100644 --- a/interfaces/inner_api/bundlemgr_extension/include/bms_extension_data_mgr.h +++ b/interfaces/inner_api/bundlemgr_extension/include/bms_extension_data_mgr.h @@ -53,7 +53,7 @@ public: ErrCode ClearData(const std::string &bundleName, int32_t userId); ErrCode ClearCache(const std::string &bundleName, sptr callback, int32_t userId); ErrCode GetUidByBundleName(const std::string &bundleName, int32_t userId, int32_t &uid); - ErrCode GetBundleNameByUid(int32_t uid, std::string &bundleName); + ErrCode GetBundleNameByUid(int32_t uid, std::string &bundleName, int32_t userId); ErrCode VerifyActivationLock(bool &res); ErrCode GetBackupUninstallList(int32_t userId, std::set &uninstallBundles); ErrCode ClearBackupUninstallFile(int32_t userId); @@ -80,7 +80,7 @@ public: std::string GetCompatibleDeviceType(const std::string &bundleName); ErrCode VerifyActivationLockToken(bool &res); bool IsNeedToSkipPreBundleInstall(); - ErrCode GetBundleNamesForUidExt(const int32_t uid, std::vector &bundleNames); + ErrCode GetBundleNamesForUidExt(const int32_t uid, std::vector &bundleNames, int32_t userId); ErrCode BmsExtensionInit(); bool IsMCFlagSet(); private: diff --git a/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext.h b/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext.h index d464f871a8..abe9f27d07 100644 --- a/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext.h +++ b/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext.h @@ -84,7 +84,7 @@ public: { return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; } - virtual ErrCode GetBundleNameByUid(int32_t uid, std::string &bundleName) + virtual ErrCode GetBundleNameByUid(int32_t uid, std::string &bundleName, int32_t userId) { return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; } @@ -179,7 +179,7 @@ public: { return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; } - virtual ErrCode GetBundleNamesForUidExt(const int32_t uid, std::vector &bundleNames) + virtual ErrCode GetBundleNamesForUidExt(const int32_t uid, std::vector &bundleNames, int32_t userId) { return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; } diff --git a/interfaces/inner_api/bundlemgr_extension/src/bms_extension_data_mgr.cpp b/interfaces/inner_api/bundlemgr_extension/src/bms_extension_data_mgr.cpp index 090cde4a6a..397d20ab9d 100644 --- a/interfaces/inner_api/bundlemgr_extension/src/bms_extension_data_mgr.cpp +++ b/interfaces/inner_api/bundlemgr_extension/src/bms_extension_data_mgr.cpp @@ -280,7 +280,7 @@ ErrCode BmsExtensionDataMgr::GetUidByBundleName(const std::string &bundleName, i return bundleMgrExtPtr->GetUidByBundleName(bundleName, userId, uid); } -ErrCode BmsExtensionDataMgr::GetBundleNameByUid(int32_t uid, std::string &bundleName) +ErrCode BmsExtensionDataMgr::GetBundleNameByUid(int32_t uid, std::string &bundleName, int32_t userId) { if ((Init() != ERR_OK) || handler_ == nullptr) { APP_LOGW("link failed"); @@ -292,7 +292,7 @@ ErrCode BmsExtensionDataMgr::GetBundleNameByUid(int32_t uid, std::string &bundle APP_LOGW("GetBundleMgrExt failed"); return ERR_BUNDLE_MANAGER_EXTENSION_INTERNAL_ERR; } - return bundleMgrExtPtr->GetBundleNameByUid(uid, bundleName); + return bundleMgrExtPtr->GetBundleNameByUid(uid, bundleName, userId); } ErrCode BmsExtensionDataMgr::VerifyActivationLock(bool &res) @@ -645,7 +645,8 @@ bool BmsExtensionDataMgr::IsNeedToSkipPreBundleInstall() return bundleMgrExtPtr->IsNeedToSkipPreBundleInstall(); } -ErrCode BmsExtensionDataMgr::GetBundleNamesForUidExt(const int32_t uid, std::vector &bundleNames) +ErrCode BmsExtensionDataMgr::GetBundleNamesForUidExt(const int32_t uid, std::vector &bundleNames, + int32_t userId) { if ((Init() != ERR_OK) || handler_ == nullptr) { APP_LOGW("link failed"); @@ -657,7 +658,7 @@ ErrCode BmsExtensionDataMgr::GetBundleNamesForUidExt(const int32_t uid, std::vec APP_LOGW("GetBundleMgrExt failed"); return ERR_BUNDLE_MANAGER_EXTENSION_INTERNAL_ERR; } - return bundleMgrExtPtr->GetBundleNamesForUidExt(uid, bundleNames); + return bundleMgrExtPtr->GetBundleNamesForUidExt(uid, bundleNames, userId); } ErrCode BmsExtensionDataMgr::BmsExtensionInit() diff --git a/services/bundlemgr/include/bundlemgr_ext/bundle_mgr_ext_host_impl.h b/services/bundlemgr/include/bundlemgr_ext/bundle_mgr_ext_host_impl.h index c322f6455c..f0439e7197 100644 --- a/services/bundlemgr/include/bundlemgr_ext/bundle_mgr_ext_host_impl.h +++ b/services/bundlemgr/include/bundlemgr_ext/bundle_mgr_ext_host_impl.h @@ -36,7 +36,7 @@ public: * @param bundleNames Indicates the bundleNames. * @return Returns ERR_OK if execute success; returns errCode otherwise. */ - ErrCode GetBundleNamesForUidExt(const int32_t uid, std::vector &bundleNames, + ErrCode GetBundleNamesForUidExt(const int32_t uid, std::vector &bundleNames, int32_t userId, int32_t &funcResult) override; }; } diff --git a/services/bundlemgr/src/bms_extension/bms_extension_client.cpp b/services/bundlemgr/src/bms_extension/bms_extension_client.cpp index a20c2a56b3..7562973596 100644 --- a/services/bundlemgr/src/bms_extension/bms_extension_client.cpp +++ b/services/bundlemgr/src/bms_extension/bms_extension_client.cpp @@ -353,14 +353,14 @@ ErrCode BmsExtensionClient::GetUidByBundleName(const std::string &bundleName, in } return bmsExtensionImpl_->GetUidByBundleName(bundleName, userId, uid); } -ErrCode BmsExtensionClient::GetBundleNameByUid(int32_t uid, std::string &bundleName) +ErrCode BmsExtensionClient::GetBundleNameByUid(int32_t uid, std::string &bundleName, int32_t userId) { HITRACE_METER_NAME_EX(HITRACE_LEVEL_INFO, HITRACE_TAG_APP, __PRETTY_FUNCTION__, nullptr); if (bmsExtensionImpl_ == nullptr) { APP_LOGW("bmsExtensionImpl_ is null"); return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; } - return bmsExtensionImpl_->GetBundleNameByUid(uid, bundleName); + return bmsExtensionImpl_->GetBundleNameByUid(uid, bundleName, userId); } ErrCode BmsExtensionClient::AddResourceInfoByBundleName(const std::string &bundleName, const int32_t userId) diff --git a/services/bundlemgr/src/bundle_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_mgr_host_impl.cpp index 550c9eda3d..fcc49fe9e3 100644 --- a/services/bundlemgr/src/bundle_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_mgr_host_impl.cpp @@ -713,7 +713,8 @@ ErrCode BundleMgrHostImpl::GetNameForUid(const int uid, std::string &name) auto ret = dataMgr->GetNameForUid(uid, name); if (ret != ERR_OK && isBrokerServiceExisted_) { auto bmsExtensionClient = std::make_shared(); - ret = bmsExtensionClient->GetBundleNameByUid(uid, name); + int32_t userId = BundleUtil::GetUserIdByCallingUid(); + ret = bmsExtensionClient->GetBundleNameByUid(uid, name, userId); if (ret != ERR_OK) { QueryEventInfo info = PrepareQueryEvent(ret, "None", "GetNameForUid", uid, -1, 0, -1); diff --git a/services/bundlemgr/src/bundlemgr_ext/bundle_mgr_ext_host_impl.cpp b/services/bundlemgr/src/bundlemgr_ext/bundle_mgr_ext_host_impl.cpp index 8da2202e94..ac6b51427f 100644 --- a/services/bundlemgr/src/bundlemgr_ext/bundle_mgr_ext_host_impl.cpp +++ b/services/bundlemgr/src/bundlemgr_ext/bundle_mgr_ext_host_impl.cpp @@ -45,7 +45,7 @@ int32_t BundleMgrExtHostImpl::CallbackExit([[maybe_unused]] uint32_t code, [[may } ErrCode BundleMgrExtHostImpl::GetBundleNamesForUidExt(const int32_t uid, std::vector &bundleNames, - int32_t &funcResult) + int32_t userId, int32_t &funcResult) { HITRACE_METER_NAME_EX(HITRACE_LEVEL_INFO, HITRACE_TAG_APP, __PRETTY_FUNCTION__, nullptr); LOG_D(BMS_TAG_EXT, "start uid:%{public}d", uid); @@ -54,7 +54,7 @@ ErrCode BundleMgrExtHostImpl::GetBundleNamesForUidExt(const int32_t uid, std::ve return ERR_OK; } BmsExtensionDataMgr bmsExtensionDataMgr; - ErrCode ret = bmsExtensionDataMgr.GetBundleNamesForUidExt(uid, bundleNames); + ErrCode ret = bmsExtensionDataMgr.GetBundleNamesForUidExt(uid, bundleNames, userId); if (ret != ERR_OK) { LOG_E(BMS_TAG_EXT, "uid:%{public}d err:%{public}d", uid, ret); } -- Gitee