IssueNo:#IA89FS

Description:fix multi-UIAbility bug
Sig:SIG_ApplicaitonFramework
Feature or Bugfix:Bugfix
Binary Source:No
Signed-off-by: wangtiantian <wangtiantian19@huawei.com>
This commit is contained in:
wangtiantian 2024-06-25 20:13:05 +08:00
parent 66143d0847
commit 27a17800ee
4 changed files with 29 additions and 58 deletions

View File

@ -1799,34 +1799,25 @@ void BundleDataMgr::GetMatchLauncherAbilityInfos(const Want& want,
APP_LOGD("response user id is invalid");
return;
}
bool isExist = false;
bool isStage = info.GetIsNewVersion();
// get clone bundle info
InnerBundleUserInfo bundleUserInfo;
(void)info.GetInnerBundleUserInfo(responseUserId, bundleUserInfo);
std::map<std::string, std::vector<Skill>> skillInfos = info.GetInnerSkillInfos();
for (const auto& abilityInfoPair : info.GetInnerAbilityInfos()) {
auto skillsPair = skillInfos.find(abilityInfoPair.first);
if (skillsPair == skillInfos.end()) {
continue;
}
for (const Skill& skill : skillsPair->second) {
if (skill.MatchLauncher(want) && (abilityInfoPair.second.type == AbilityType::PAGE)) {
isExist = true;
AbilityInfo abilityinfo = abilityInfoPair.second;
info.GetApplicationInfo(ApplicationFlag::GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT,
responseUserId, abilityinfo.applicationInfo);
abilityinfo.installTime = installTime;
// fix labelId or iconId is equal 0
ModifyLauncherAbilityInfo(isStage, abilityinfo);
abilityInfos.emplace_back(abilityinfo);
GetMatchLauncherAbilityInfosForCloneInfos(info, abilityInfoPair.second, bundleUserInfo, abilityInfos);
break;
}
}
AbilityInfo mainAbilityInfo;
info.GetMainAbilityInfo(mainAbilityInfo);
if (!mainAbilityInfo.name.empty()) {
APP_LOGD("bundleName %{public}s exist mainAbility", info.GetBundleName().c_str());
info.GetApplicationInfo(ApplicationFlag::GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT,
responseUserId, mainAbilityInfo.applicationInfo);
mainAbilityInfo.installTime = installTime;
// fix labelId or iconId is equal 0
ModifyLauncherAbilityInfo(info.GetIsNewVersion(), mainAbilityInfo);
abilityInfos.emplace_back(mainAbilityInfo);
GetMatchLauncherAbilityInfosForCloneInfos(info, mainAbilityInfo, bundleUserInfo,
abilityInfos);
return;
}
// add app detail ability
if (!isExist && info.GetBaseApplicationInfo().needAppDetail) {
if (info.GetBaseApplicationInfo().needAppDetail) {
LOG_D(BMS_TAG_QUERY_ABILITY, "bundleName: %{public}s add detail ability info.", info.GetBundleName().c_str());
std::string moduleName = "";
auto ability = info.FindAbilityInfo(moduleName, ServiceConstants::APP_DETAIL_ABILITY, responseUserId);
@ -1839,6 +1830,7 @@ void BundleDataMgr::GetMatchLauncherAbilityInfos(const Want& want,
}
ability->installTime = installTime;
abilityInfos.emplace_back(*ability);
GetMatchLauncherAbilityInfosForCloneInfos(info, *ability, bundleUserInfo, abilityInfos);
}
}
@ -1854,7 +1846,7 @@ void BundleDataMgr::GetMatchLauncherAbilityInfosForCloneInfos(
info.GetApplicationInfo(ApplicationFlag::GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT,
bundleUserInfo.bundleUserInfo.userId, cloneAbilityInfo.applicationInfo, item.second.appIndex);
cloneAbilityInfo.installTime = item.second.installTime;
cloneAbilityInfo.uid = item.second.uid;
cloneAbilityInfo.uid = item.second.uid;
cloneAbilityInfo.appIndex = item.second.appIndex;
// fix labelId or iconId is equal 0
ModifyLauncherAbilityInfo(info.GetIsNewVersion(), cloneAbilityInfo);

View File

@ -3764,31 +3764,18 @@ void InnerBundleInfo::AdaptMainLauncherResourceInfo(ApplicationInfo &application
APP_LOGI("com.ohos.contacts no need to process");
return;
}
OHOS::AAFwk::Want want;
want.SetAction(OHOS::AAFwk::Want::ACTION_HOME);
want.AddEntity(OHOS::AAFwk::Want::ENTITY_HOME);
for (const auto& abilityInfoPair : baseAbilityInfos_) {
auto skillsPair = skillInfos_.find(abilityInfoPair.first);
if (skillsPair == skillInfos_.end()) {
continue;
}
for (const Skill& skill : skillsPair->second) {
if (skill.MatchLauncher(want) && (abilityInfoPair.second.type == AbilityType::PAGE)) {
if (abilityInfoPair.second.labelId != 0) {
applicationInfo.labelId = abilityInfoPair.second.labelId;
applicationInfo.labelResource.id = abilityInfoPair.second.labelId;
applicationInfo.labelResource.moduleName = abilityInfoPair.second.moduleName;
applicationInfo.labelResource.bundleName = abilityInfoPair.second.bundleName;
}
if (abilityInfoPair.second.iconId != 0) {
applicationInfo.iconId = abilityInfoPair.second.iconId;
applicationInfo.iconResource.id = abilityInfoPair.second.iconId;
applicationInfo.iconResource.moduleName = abilityInfoPair.second.moduleName;
applicationInfo.iconResource.bundleName = abilityInfoPair.second.bundleName;
}
return;
}
}
AbilityInfo mainAbilityInfo;
GetMainAbilityInfo(mainAbilityInfo);
if ((mainAbilityInfo.labelId != 0) && (mainAbilityInfo.iconId != 0)) {
applicationInfo.labelId = mainAbilityInfo.labelId ;
applicationInfo.labelResource.id = mainAbilityInfo.labelId;
applicationInfo.labelResource.moduleName = mainAbilityInfo.moduleName;
applicationInfo.labelResource.bundleName = mainAbilityInfo.bundleName;
applicationInfo.iconId = mainAbilityInfo.iconId ;
applicationInfo.labelResource.id = mainAbilityInfo.iconId;
applicationInfo.labelResource.moduleName = mainAbilityInfo.moduleName;
applicationInfo.labelResource.bundleName = mainAbilityInfo.bundleName;
}
}
} // namespace AppExecFwk

View File

@ -8569,11 +8569,6 @@ HWTEST_F(BmsBundleKitServiceTest, QueryBundleStatsInfoByInterval_0100, Function
bool ret = bundleAgingMgr.QueryBundleStatsInfoByInterval(results);
EXPECT_EQ(ret, false);
AppExecFwk::BundleAgingMgr::AgingTriggertype type =
AppExecFwk::BundleAgingMgr::AgingTriggertype::PREIOD;
ret = bundleAgingMgr.CheckPrerequisite(type);
EXPECT_EQ(ret, true);
}
/**

View File

@ -49,7 +49,7 @@ const std::string BUNDLE_UPDATE = "Bundle Update Success";
const std::string BUNDLE_REMOVE = "Bundle Remove Success";
constexpr uint32_t WAIT_SECONDS = 10;
constexpr uint32_t USERID = 100;
const unsigned int LIST_SIZE = 2;
const unsigned int LIST_SIZE = 1;
static const int APP_LABELID = 16777216;
static const int APP_ICONID = 16777218;
} // namespace
@ -679,9 +679,6 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetAbilityList_0400, Function | Mediu
EXPECT_TRUE(result) << "Get ability list failed";
EXPECT_FALSE(launcherAbilityInfos.empty()) << "Launcher ability infos is empty";
EXPECT_EQ(launcherAbilityInfos.size(), LIST_SIZE);
if (!launcherAbilityInfos.empty()) {
EXPECT_EQ(launcherAbilityInfos[0].elementName.GetAbilityName(), abilityName1);
}
Uninstall(bundleName, message);
EXPECT_EQ(message, "Success") << "uninstall fail!";