!6010 扩展获取appIndex列表的非加锁方法

Merge pull request !6010 from cw/master
This commit is contained in:
openharmony_ci 2024-05-28 07:59:18 +00:00 committed by Gitee
commit cfd79315f3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 41 additions and 4 deletions

View File

@ -1005,6 +1005,7 @@ private:
bool MatchUtd(const Skill &skill, const std::string &utd, int32_t count) const;
bool MatchUtd(const std::string &skillUtd, const std::string &wantUtd) const;
bool MatchTypeWithUtd(const std::string &mimeType, const std::string &wantUtd) const;
std::vector<int32_t> GetCloneAppIndexesUnLock(const std::string &bundleName, int32_t userId) const;
#ifdef GLOBAL_RESMGR_ENABLE
std::shared_ptr<Global::Resource::ResourceManager> GetResourceManager(const std::string &bundleName,
const std::string &moduleName, int32_t userId, const std::string &localeInfo = Constants::EMPTY_STRING) const;

View File

@ -1211,7 +1211,7 @@ bool BundleDataMgr::ImplicitQueryCurCloneAbilityInfos(const Want &want, int32_t
{
LOG_D(BMS_TAG_QUERY_ABILITY, "begin ImplicitQueryCurCloneAbilityInfos.");
std::string bundleName = want.GetElement().GetBundleName();
std::vector<int32_t> cloneAppIndexes = GetCloneAppIndexes(bundleName, userId);
std::vector<int32_t> cloneAppIndexes = GetCloneAppIndexesUnLock(bundleName, userId);
if (cloneAppIndexes.empty()) {
return false;
}
@ -1266,7 +1266,7 @@ bool BundleDataMgr::ImplicitQueryCurCloneAbilityInfosV9(const Want &want, int32_
LOG_D(BMS_TAG_QUERY_ABILITY, "begin ImplicitQueryCurCloneAbilityInfosV9.");
std::string bundleName = want.GetElement().GetBundleName();
std::vector<int32_t> cloneAppIndexes = GetCloneAppIndexes(bundleName, userId);
std::vector<int32_t> cloneAppIndexes = GetCloneAppIndexesUnLock(bundleName, userId);
if (cloneAppIndexes.empty()) {
return false;
}
@ -1349,7 +1349,7 @@ void BundleDataMgr::ImplicitQueryAllCloneAbilityInfos(const Want &want, int32_t
for (const auto &item : bundleInfos_) {
const InnerBundleInfo &innerBundleInfo = item.second;
std::vector<int32_t> cloneAppIndexes = GetCloneAppIndexes(innerBundleInfo.GetBundleName(), userId);
std::vector<int32_t> cloneAppIndexes = GetCloneAppIndexesUnLock(innerBundleInfo.GetBundleName(), userId);
if (cloneAppIndexes.empty()) {
continue;
}
@ -1416,7 +1416,7 @@ void BundleDataMgr::ImplicitQueryAllCloneAbilityInfosV9(const Want &want, int32_
{
LOG_D(BMS_TAG_QUERY_ABILITY, "begin ImplicitQueryAllCloneAbilityInfosV9.");
for (const auto &item : bundleInfos_) {
std::vector<int32_t> cloneAppIndexes = GetCloneAppIndexes(item.second.GetBundleName(), userId);
std::vector<int32_t> cloneAppIndexes = GetCloneAppIndexesUnLock(item.second.GetBundleName(), userId);
if (cloneAppIndexes.empty()) {
continue;
}
@ -1922,6 +1922,42 @@ std::vector<int32_t> BundleDataMgr::GetCloneAppIndexes(const std::string &bundle
return cloneAppIndexes;
}
std::vector<int32_t> BundleDataMgr::GetCloneAppIndexesUnLock(const std::string &bundleName, int32_t userId) const
{
std::vector<int32_t> cloneAppIndexes;
std::vector<InnerBundleUserInfo> innerBundleUserInfos;
if (userId == Constants::UNSPECIFIED_USERID) {
if (!GetInnerBundleUserInfos(bundleName, innerBundleUserInfos)) {
LOG_W(BMS_TAG_QUERY_BUNDLE, "no userInfos for this bundle(%{public}s)", bundleName.c_str());
return cloneAppIndexes;
}
userId = innerBundleUserInfos.begin()->bundleUserInfo.userId;
}
int32_t requestUserId = GetUserId(userId);
if (requestUserId == Constants::INVALID_USERID) {
return cloneAppIndexes;
}
auto infoItem = bundleInfos_.find(bundleName);
if (infoItem == bundleInfos_.end()) {
LOG_W(BMS_TAG_QUERY_ABILITY, "no bundleName %{public}s found", bundleName.c_str());
return cloneAppIndexes;
}
const InnerBundleInfo &bundleInfo = infoItem->second;
InnerBundleUserInfo innerBundleUserInfo;
if (!bundleInfo.GetInnerBundleUserInfo(requestUserId, innerBundleUserInfo)) {
return cloneAppIndexes;
}
const std::map<std::string, InnerBundleCloneInfo> &cloneInfos = innerBundleUserInfo.cloneInfos;
if (cloneInfos.empty()) {
return cloneAppIndexes;
}
for (const auto &cloneInfo : cloneInfos) {
LOG_I(BMS_TAG_QUERY_ABILITY, "get cloneAppIndexes unLock: %{public}d", cloneInfo.second.appIndex);
cloneAppIndexes.emplace_back(cloneInfo.second.appIndex);
}
return cloneAppIndexes;
}
void BundleDataMgr::AddAppDetailAbilityInfo(InnerBundleInfo &info) const
{
AbilityInfo appDetailAbility;