diff --git a/interfaces/inner_api/appexecfwk_core/IBundleMgrExt.idl b/interfaces/inner_api/appexecfwk_core/IBundleMgrExt.idl index 928c68d181c5c018c7e540bc61221e752877ba5c..11fb05aa02bc6e621167078243b499251450fea9 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 2e50b250ea865aaee16e24805769333ed5feba14..eccd7dd05f544b78e56689cc71f5e166f0cfd30c 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 bea45ecfe1d673668b1c1170a2733942eea1ba05..84c5cbb0860ea4368bf84cef88fa4aad9a0d5c62 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 68f50d11a168564de66f6973c393249e52000f60..c46c5d4c3ac81b35f3acf9a50c54d3da40d212f4 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 d464f871a8b7aa541454e0066abcbc184f9d6fdd..abe9f27d07eb97526a7a0e8c395b0500405a2ad2 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 090cde4a6a425033695f416431fbc2c9a78e28b4..397d20ab9d7b574f424bc3c9abf1639f7c59a554 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 c322f6455c0517714a229b5fbd9b46a084e24847..f0439e7197212a2da5bf4ce156cdd528099f88cb 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 a20c2a56b30c8788d172f7665ef2e5cc9d75b360..7562973596748f56563f7c014b8c0cf6cedc1223 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 550c9eda3d7aa2a2a82b0122a5b9f5a87cfe7db1..fcc49fe9e3c64345d892f241ebb75a4c7e1c9fb1 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 8da2202e942394c2ed7bedf0c9ead28a3d6b8842..ac6b51427f30910182188b3a933cc5ab3f173684 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); }