mirror of
https://gitee.com/openharmony/bundlemanager_bundle_framework
synced 2024-11-23 07:09:53 +00:00
OTA预置应用未更新时同步预置数据库信息
Signed-off-by: 张欣宇 <zhangxinyu74@huawei.com> Change-Id: I72ff012cf62922aaf1d248fd3ade552d7d409b65
This commit is contained in:
parent
63f4da87da
commit
69b62f0ee3
@ -627,7 +627,8 @@ private:
|
||||
void static ProcessBundleResourceInfo();
|
||||
// Used to send update failed event
|
||||
void SendBundleUpdateFailedEvent(const BundleInfo &bundleInfo);
|
||||
void UpdatePreinstallDBForUninstalledBundle(const std::string &bundleName,
|
||||
void UpdatePreinstallDB(const std::unordered_map<std::string, std::pair<std::string, bool>> &needInstallMap);
|
||||
void UpdatePreinstallDBForNotUpdatedBundle(const std::string &bundleName,
|
||||
const std::unordered_map<std::string, InnerBundleInfo> &innerBundleInfos);
|
||||
void InnerProcessRebootUninstallWrongBundle();
|
||||
void ProcessCheckAppEl1Dir();
|
||||
|
@ -1728,7 +1728,6 @@ void BMSEventHandler::InnerProcessRebootBundleInstall(
|
||||
LOG_E(BMS_TAG_DEFAULT, "OTA Install new bundle(%{public}s) error", bundleName.c_str());
|
||||
SavePreInstallException(scanPathIter);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1746,8 +1745,6 @@ void BMSEventHandler::InnerProcessRebootBundleInstall(
|
||||
LOG_E(BMS_TAG_DEFAULT, "OTA Install prefab bundle(%{public}s) error", bundleName.c_str());
|
||||
SavePreInstallException(scanPathIter);
|
||||
}
|
||||
} else {
|
||||
UpdatePreinstallDBForUninstalledBundle(bundleName, infos);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -1842,6 +1839,7 @@ void BMSEventHandler::InnerProcessRebootBundleInstall(
|
||||
if (!InnerMultiProcessBundleInstall(needInstallMap, appType)) {
|
||||
LOG_E(BMS_TAG_DEFAULT, "multi install failed");
|
||||
}
|
||||
UpdatePreinstallDB(needInstallMap);
|
||||
}
|
||||
|
||||
bool BMSEventHandler::InnerMultiProcessBundleInstall(
|
||||
@ -3784,7 +3782,26 @@ void BMSEventHandler::SendBundleUpdateFailedEvent(const BundleInfo &bundleInfo)
|
||||
EventReport::SendBundleSystemEvent(BundleEventType::UPDATE, eventInfo);
|
||||
}
|
||||
|
||||
void BMSEventHandler::UpdatePreinstallDBForUninstalledBundle(const std::string &bundleName,
|
||||
void BMSEventHandler::UpdatePreinstallDB(
|
||||
const std::unordered_map<std::string, std::pair<std::string, bool>> &needInstallMap)
|
||||
{
|
||||
for (const auto &existInfo : loadExistData_) {
|
||||
std::string bundleName = existInfo.first;
|
||||
auto it = needInstallMap.find(bundleName);
|
||||
if (it != needInstallMap.end()) {
|
||||
LOG_NOFUNC_I(BMS_TAG_DEFAULT, "%{public}s installed already update", bundleName.c_str());
|
||||
continue;
|
||||
}
|
||||
auto hapParseInfoMapIter = hapParseInfoMap_.find(bundleName);
|
||||
if (hapParseInfoMapIter == hapParseInfoMap_.end()) {
|
||||
LOG_NOFUNC_I(BMS_TAG_DEFAULT, "%{public}s not preinstalled", bundleName.c_str());
|
||||
continue;
|
||||
}
|
||||
UpdatePreinstallDBForNotUpdatedBundle(bundleName, hapParseInfoMapIter->second);
|
||||
}
|
||||
}
|
||||
|
||||
void BMSEventHandler::UpdatePreinstallDBForNotUpdatedBundle(const std::string &bundleName,
|
||||
const std::unordered_map<std::string, InnerBundleInfo> &innerBundleInfos)
|
||||
{
|
||||
if (innerBundleInfos.empty()) {
|
||||
@ -3801,11 +3818,7 @@ void BMSEventHandler::UpdatePreinstallDBForUninstalledBundle(const std::string &
|
||||
LOG_W(BMS_TAG_DEFAULT, "get preinstalled bundle info failed :%{public}s", bundleName.c_str());
|
||||
return;
|
||||
}
|
||||
if (innerBundleInfos.begin()->second.GetBaseBundleInfo().versionCode <= preInstallBundleInfo.GetVersionCode()) {
|
||||
LOG_I(BMS_TAG_DEFAULT, "bundle no change");
|
||||
return;
|
||||
}
|
||||
LOG_I(BMS_TAG_DEFAULT, "begin update preinstall DB for %{public}s", bundleName.c_str());
|
||||
LOG_NOFUNC_I(BMS_TAG_DEFAULT, "begin update preinstall DB for %{public}s", bundleName.c_str());
|
||||
preInstallBundleInfo.ClearBundlePath();
|
||||
bool findEntry = false;
|
||||
for (const auto &item : innerBundleInfos) {
|
||||
@ -3823,7 +3836,9 @@ void BMSEventHandler::UpdatePreinstallDBForUninstalledBundle(const std::string &
|
||||
findEntry = true;
|
||||
}
|
||||
}
|
||||
dataMgr->SavePreInstallBundleInfo(bundleName, preInstallBundleInfo);
|
||||
if (!dataMgr->SavePreInstallBundleInfo(bundleName, preInstallBundleInfo)) {
|
||||
LOG_NOFUNC_I(BMS_TAG_DEFAULT, "update preinstall DB fail -n %{public}s", bundleName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
bool BMSEventHandler::IsQuickfixFlagExsit(const BundleInfo &bundleInfo)
|
||||
|
@ -731,7 +731,7 @@ bool BMSEventHandler::GetValueFromJson(nlohmann::json& jsonObject)
|
||||
|
||||
void BMSEventHandler::ProcessRebootQuickFixUnInstallAndRecover(const std::string& path) {}
|
||||
|
||||
void BMSEventHandler::UpdatePreinstallDBForUninstalledBundle(
|
||||
void BMSEventHandler::UpdatePreinstallDBForNotUpdatedBundle(
|
||||
const std::string& bundleName, const std::unordered_map<std::string, InnerBundleInfo>& innerBundleInfos)
|
||||
{}
|
||||
|
||||
|
@ -1369,20 +1369,20 @@ HWTEST_F(BmsEventHandlerTest, GetValueFromJson_0100, Function | SmallTest | Leve
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: UpdatePreinstallDBForUninstalledBundle_0100
|
||||
* @tc.name: UpdatePreinstallDBForUninstalledBundle
|
||||
* @tc.desc: test UpdatePreinstallDBForUninstalledBundle
|
||||
* @tc.number: UpdatePreinstallDBForNotUpdatedBundle_0100
|
||||
* @tc.name: UpdatePreinstallDBForNotUpdatedBundle
|
||||
* @tc.desc: test UpdatePreinstallDBForNotUpdatedBundle
|
||||
*/
|
||||
HWTEST_F(BmsEventHandlerTest, UpdatePreinstallDBForUninstalledBundle_0100, Function | SmallTest | Level0)
|
||||
HWTEST_F(BmsEventHandlerTest, UpdatePreinstallDBForNotUpdatedBundle_0100, Function | SmallTest | Level0)
|
||||
{
|
||||
std::shared_ptr<BMSEventHandler> handler = std::make_shared<BMSEventHandler>();
|
||||
ASSERT_NE(handler, nullptr);
|
||||
std::unordered_map<std::string, InnerBundleInfo> innerBundleInfos;
|
||||
InnerBundleInfo innerBundleInfo;
|
||||
handler->UpdatePreinstallDBForUninstalledBundle(BUNDLE_NAME, innerBundleInfos);
|
||||
handler->UpdatePreinstallDBForNotUpdatedBundle(BUNDLE_NAME, innerBundleInfos);
|
||||
EXPECT_NE(innerBundleInfo.baseBundleInfo_, nullptr);
|
||||
innerBundleInfos.insert({ BUNDLE_NAME, innerBundleInfo });
|
||||
handler->UpdatePreinstallDBForUninstalledBundle(BUNDLE_NAME, innerBundleInfos);
|
||||
handler->UpdatePreinstallDBForNotUpdatedBundle(BUNDLE_NAME, innerBundleInfos);
|
||||
EXPECT_NE(innerBundleInfo.baseBundleInfo_, nullptr);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user