mirror of
https://gitee.com/openharmony/bundlemanager_bundle_framework
synced 2024-11-27 01:11:15 +00:00
!7324 【bug】更新时异常退出,导致hap未拷贝问题
Merge pull request !7324 from wangtiantian/fix_hap_loss
This commit is contained in:
commit
eb4b8e6918
@ -547,6 +547,8 @@ private:
|
||||
bool GetSystemParameter(const std::string &key, std::string &value);
|
||||
void SaveSystemFingerprint();
|
||||
void HandlePreInstallException();
|
||||
static bool IsHapPathExist(const BundleInfo &bundleInfo);
|
||||
static bool IsHspPathExist(const InnerBundleInfo &innerBundleInfo);
|
||||
|
||||
bool FetchInnerBundleInfo(const std::string &bundleName, InnerBundleInfo &innerBundleInfo);
|
||||
void GetPreInstallDirFromLoadProFile(std::vector<std::string> &bundleDirs);
|
||||
|
@ -3594,7 +3594,7 @@ void BMSEventHandler::PatchSystemHspInstall(const std::string &path, bool isOta)
|
||||
LOG_W(BMS_TAG_DEFAULT, "bundleName %{public}s not exist", bundleName.c_str());
|
||||
continue;
|
||||
}
|
||||
if (versionCode <= hasInstalledInfo.GetVersionCode()) {
|
||||
if ((versionCode <= hasInstalledInfo.GetVersionCode()) && IsHspPathExist(hasInstalledInfo)) {
|
||||
LOG_W(BMS_TAG_DEFAULT, "bundleName: %{public}s downgrade",
|
||||
bundleName.c_str());
|
||||
continue;
|
||||
@ -3644,7 +3644,7 @@ void BMSEventHandler::PatchSystemBundleInstall(const std::string &path, bool isO
|
||||
LOG_W(BMS_TAG_DEFAULT, "obtain bundleInfo failed, bundleName :%{public}s not exist", bundleName.c_str());
|
||||
continue;
|
||||
}
|
||||
if (hapVersionCode <= hasInstalledInfo.versionCode) {
|
||||
if ((hapVersionCode <= hasInstalledInfo.versionCode) && IsHapPathExist(hasInstalledInfo)) {
|
||||
LOG_W(BMS_TAG_DEFAULT, "bundleName: %{public}s: hapVersionCode is less than old hap versionCode",
|
||||
bundleName.c_str());
|
||||
continue;
|
||||
@ -3664,6 +3664,40 @@ void BMSEventHandler::PatchSystemBundleInstall(const std::string &path, bool isO
|
||||
LOG_I(BMS_TAG_DEFAULT, "end");
|
||||
}
|
||||
|
||||
bool BMSEventHandler::IsHapPathExist(const BundleInfo &bundleInfo)
|
||||
{
|
||||
LOG_I(BMS_TAG_DEFAULT, "-n %{public}s need to check hap path exist", bundleInfo.name.c_str());
|
||||
if (bundleInfo.hapModuleInfos.empty()) {
|
||||
LOG_E(BMS_TAG_DEFAULT, "-n %{public}s has no moduleInfo", bundleInfo.name.c_str());
|
||||
return false;
|
||||
}
|
||||
for (const auto &moduleInfo : bundleInfo.hapModuleInfos) {
|
||||
if ((moduleInfo.hapPath.find(Constants::BUNDLE_CODE_DIR) == 0) &&
|
||||
!BundleUtil::IsExistFile(moduleInfo.hapPath)) {
|
||||
LOG_E(BMS_TAG_DEFAULT, "-p %{public}s hap path not exist", moduleInfo.hapPath.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BMSEventHandler::IsHspPathExist(const InnerBundleInfo &innerBundleInfo)
|
||||
{
|
||||
LOG_I(BMS_TAG_DEFAULT, "-n %{public}s need to check hsp path exist", innerBundleInfo.GetBundleName().c_str());
|
||||
if (innerBundleInfo.GetInnerModuleInfos().empty()) {
|
||||
LOG_E(BMS_TAG_DEFAULT, "-n %{public}s has no moduleInfo", innerBundleInfo.GetBundleName().c_str());
|
||||
return false;
|
||||
}
|
||||
for (const auto &moduleInfoIter : innerBundleInfo.GetInnerModuleInfos()) {
|
||||
if ((moduleInfoIter.second.hapPath.find(Constants::BUNDLE_CODE_DIR) == 0) &&
|
||||
!BundleUtil::IsExistFile(moduleInfoIter.second.hapPath)) {
|
||||
LOG_E(BMS_TAG_DEFAULT, "-p %{public}s hsp path not exist", moduleInfoIter.second.hapPath.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void BMSEventHandler::CheckALLResourceInfo()
|
||||
{
|
||||
LOG_I(BMS_TAG_DEFAULT, "start");
|
||||
|
@ -707,6 +707,16 @@ void BMSEventHandler::CheckALLResourceInfo() {}
|
||||
|
||||
void BMSEventHandler::ProcessBundleResourceInfo() {}
|
||||
|
||||
bool BMSEventHandler::IsHapPathExist(const BundleInfo &bundleInfo)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BMSEventHandler::IsHspPathExist(const InnerBundleInfo &innerBundleInfo)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void BMSEventHandler::SendBundleUpdateFailedEvent(const BundleInfo& bundleInfo) {}
|
||||
|
||||
bool BMSEventHandler::IsQuickfixFlagExsit(const BundleInfo& bundleInfo)
|
||||
|
@ -1291,6 +1291,58 @@ HWTEST_F(BmsEventHandlerTest, InnerProcessUninstallForExistPreBundle_0500, Funct
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: IsHapPathExist_0010
|
||||
* @tc.name: IsHapPathExist
|
||||
* @tc.desc: test IsHapPathExist
|
||||
*/
|
||||
HWTEST_F(BmsEventHandlerTest, IsHapPathExist_0010, Function | SmallTest | Level0)
|
||||
{
|
||||
std::shared_ptr<BMSEventHandler> handler = std::make_shared<BMSEventHandler>();
|
||||
EXPECT_NE(handler, nullptr);
|
||||
if (handler) {
|
||||
BundleInfo bundleInfo;
|
||||
bool ret = handler->IsHapPathExist(bundleInfo);
|
||||
EXPECT_FALSE(ret);
|
||||
HapModuleInfo moduleInfo_1;
|
||||
moduleInfo_1.hapPath = "/data/app/el1/bundle/public/xxx.hap";
|
||||
bundleInfo.hapModuleInfos.emplace_back(moduleInfo_1);
|
||||
ret = handler->IsHapPathExist(bundleInfo);
|
||||
EXPECT_FALSE(ret);
|
||||
bundleInfo.hapModuleInfos.clear();
|
||||
moduleInfo_1.hapPath = "/system/app/xxx.hap";
|
||||
bundleInfo.hapModuleInfos.emplace_back(moduleInfo_1);
|
||||
ret = handler->IsHapPathExist(bundleInfo);
|
||||
EXPECT_TRUE(ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: IsHspPathExist_0010
|
||||
* @tc.name: IsHspPathExist
|
||||
* @tc.desc: test IsHspPathExist
|
||||
*/
|
||||
HWTEST_F(BmsEventHandlerTest, IsHspPathExist_0010, Function | SmallTest | Level0)
|
||||
{
|
||||
std::shared_ptr<BMSEventHandler> handler = std::make_shared<BMSEventHandler>();
|
||||
EXPECT_NE(handler, nullptr);
|
||||
if (handler) {
|
||||
InnerBundleInfo bundleInfo;
|
||||
bool ret = handler->IsHspPathExist(bundleInfo);
|
||||
EXPECT_FALSE(ret);
|
||||
InnerModuleInfo moduleInfo_1;
|
||||
moduleInfo_1.hapPath = "/data/app/el1/bundle/public/xxx.hsp";
|
||||
bundleInfo.innerModuleInfos_["test"] = moduleInfo_1;
|
||||
ret = handler->IsHspPathExist(bundleInfo);
|
||||
EXPECT_FALSE(ret);
|
||||
bundleInfo.innerModuleInfos_.clear();
|
||||
moduleInfo_1.hapPath = "/system/app/xxx.hap";
|
||||
bundleInfo.innerModuleInfos_["test"] = moduleInfo_1;
|
||||
ret = handler->IsHspPathExist(bundleInfo);
|
||||
EXPECT_TRUE(ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetValueFromJson_0100
|
||||
* @tc.name: GetValueFromJson
|
||||
|
Loading…
Reference in New Issue
Block a user