mirror of
https://gitee.com/openharmony/bundlemanager_bundle_framework
synced 2025-02-22 00:51:28 +00:00
!4027 【代码优化】应用更新流程中对libs目录的处理
Merge pull request !4027 from wangtiantian/ap_stats
This commit is contained in:
commit
f0b9bab1b8
@ -578,6 +578,8 @@ private:
|
||||
bool CheckDuplicateProxyData(const std::vector<ProxyData> &proxyDatas);
|
||||
ErrCode InnerProcessNativeLibs(InnerBundleInfo &info, const std::string &modulePath);
|
||||
bool ExtractSoFiles(const std::string &soPath, const std::string &cpuAbi) const;
|
||||
void ProcessOldNativeLibraryPath(const std::unordered_map<std::string, InnerBundleInfo> &newInfos,
|
||||
int32_t oldVersionCode, const std::string &oldNativeLibraryPath) const;
|
||||
InstallerState state_ = InstallerState::INSTALL_START;
|
||||
std::shared_ptr<BundleDataMgr> dataMgr_ = nullptr; // this pointer will get when public functions called
|
||||
std::string bundleName_;
|
||||
|
@ -923,6 +923,7 @@ ErrCode BaseBundleInstaller::ProcessBundleInstall(const std::vector<std::string>
|
||||
OnSingletonChange(installParam.noSkipsKill);
|
||||
GetInstallEventInfo(newInfos, sysEventInfo_);
|
||||
AddAppProvisionInfo(bundleName_, hapVerifyResults[0].GetProvisionInfo(), installParam);
|
||||
ProcessOldNativeLibraryPath(newInfos, oldInfo.GetVersionCode(), oldInfo.GetNativeLibraryPath());
|
||||
sync();
|
||||
return result;
|
||||
}
|
||||
@ -3497,5 +3498,27 @@ ErrCode BaseBundleInstaller::InnerProcessNativeLibs(InnerBundleInfo &info, const
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void BaseBundleInstaller::ProcessOldNativeLibraryPath(const std::unordered_map<std::string, InnerBundleInfo> &newInfos,
|
||||
int32_t oldVersionCode, const std::string &oldNativeLibraryPath) const
|
||||
{
|
||||
if ((oldVersionCode >= versionCode_) || oldNativeLibraryPath.empty()) {
|
||||
return;
|
||||
}
|
||||
for (const auto &item : newInfos) {
|
||||
const auto &moduleInfos = item.second.GetInnerModuleInfos();
|
||||
for (const auto &moduleItem: moduleInfos) {
|
||||
if (moduleItem.second.compressNativeLibs) {
|
||||
// no need to delete library path
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::string oldLibPath = Constants::BUNDLE_CODE_DIR + Constants::PATH_SEPARATOR + bundleName_ +
|
||||
Constants::PATH_SEPARATOR + Constants::LIBS;
|
||||
if (InstalldClient::GetInstance()->RemoveDir(oldLibPath) != ERR_OK) {
|
||||
APP_LOGW("bundleNmae: %{public}s remove old libs dir failed.", bundleName_.c_str());
|
||||
}
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -89,6 +89,7 @@ const std::string APPID = "com.third.hiworld.example1_BNtg4JBClbl92Rgc3jm/"
|
||||
const std::string NORMAL_BUNDLE_NAME = "bundleName";
|
||||
const std::string FIRST_RIGHT_HAP = "first_right.hap";
|
||||
#endif
|
||||
const std::string BUNDLE_LIBRARY_PATH_DIR = "/data/app/el1/bundle/public/com.example.l3jsdemo/libs/arm";
|
||||
} // namespace
|
||||
|
||||
class BmsBundleInstallerTest : public testing::Test {
|
||||
@ -240,6 +241,7 @@ void BmsBundleInstallerTest::TearDown()
|
||||
{
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_DATA_DIR);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_CODE_DIR);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_LIBRARY_PATH_DIR);
|
||||
}
|
||||
|
||||
void BmsBundleInstallerTest::CheckFileExist() const
|
||||
@ -3688,7 +3690,7 @@ HWTEST_F(BmsBundleInstallerTest, BmsBundleInstallerTest_0020, TestSize.Level1)
|
||||
/**
|
||||
* @tc.number: BmsBundleInstallerTest_0030
|
||||
* @tc.name: ExtractSoFiles
|
||||
* @tc.desc: test InnerProcessNativeLibs isLibIsolated true
|
||||
* @tc.desc: test ExtractSoFiles
|
||||
*/
|
||||
HWTEST_F(BmsBundleInstallerTest, BmsBundleInstallerTest_0030, TestSize.Level1)
|
||||
{
|
||||
@ -3700,4 +3702,55 @@ HWTEST_F(BmsBundleInstallerTest, BmsBundleInstallerTest_0030, TestSize.Level1)
|
||||
ret = installer.ExtractSoFiles("/data/test", "libs/arm");
|
||||
EXPECT_TRUE(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: ProcessOldNativeLibraryPath_0010
|
||||
* @tc.name: ExtractSoFiles
|
||||
* @tc.desc: test ProcessOldNativeLibraryPath
|
||||
*/
|
||||
HWTEST_F(BmsBundleInstallerTest, ProcessOldNativeLibraryPath_0010, TestSize.Level1)
|
||||
{
|
||||
bool ret = OHOS::ForceCreateDirectory(BUNDLE_LIBRARY_PATH_DIR);
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
BaseBundleInstaller installer;
|
||||
installer.bundleName_ = BUNDLE_NAME;
|
||||
std::unordered_map<std::string, InnerBundleInfo> newInfos;
|
||||
int32_t oldVersionCode = 1000;
|
||||
std::string nativeLibraryPath = "";
|
||||
installer.ProcessOldNativeLibraryPath(newInfos, oldVersionCode, nativeLibraryPath);
|
||||
auto exist = access(BUNDLE_LIBRARY_PATH_DIR.c_str(), F_OK);
|
||||
EXPECT_EQ(exist, 0);
|
||||
|
||||
nativeLibraryPath = "libs/arm";
|
||||
installer.ProcessOldNativeLibraryPath(newInfos, oldVersionCode, nativeLibraryPath);
|
||||
exist = access(BUNDLE_LIBRARY_PATH_DIR.c_str(), F_OK);
|
||||
EXPECT_EQ(exist, 0);
|
||||
|
||||
installer.versionCode_ = 2000;
|
||||
nativeLibraryPath = "";
|
||||
installer.ProcessOldNativeLibraryPath(newInfos, oldVersionCode, nativeLibraryPath);
|
||||
exist = access(BUNDLE_LIBRARY_PATH_DIR.c_str(), F_OK);
|
||||
EXPECT_EQ(exist, 0);
|
||||
|
||||
nativeLibraryPath = "libs/arm";
|
||||
InnerBundleInfo innerBundleInfo;
|
||||
InnerModuleInfo moduleInfo;
|
||||
moduleInfo.compressNativeLibs = true;
|
||||
innerBundleInfo.innerModuleInfos_["aaa"] = moduleInfo;
|
||||
moduleInfo.compressNativeLibs = false;
|
||||
innerBundleInfo.innerModuleInfos_["bbb"] = moduleInfo;
|
||||
newInfos["a"] = innerBundleInfo;
|
||||
installer.ProcessOldNativeLibraryPath(newInfos, oldVersionCode, nativeLibraryPath);
|
||||
exist = access(BUNDLE_LIBRARY_PATH_DIR.c_str(), F_OK);
|
||||
EXPECT_EQ(exist, 0);
|
||||
|
||||
moduleInfo.compressNativeLibs = false;
|
||||
innerBundleInfo.innerModuleInfos_["aaa"] = moduleInfo;
|
||||
newInfos["a"] = innerBundleInfo;
|
||||
|
||||
installer.ProcessOldNativeLibraryPath(newInfos, oldVersionCode, nativeLibraryPath);
|
||||
exist = access(BUNDLE_LIBRARY_PATH_DIR.c_str(), F_OK);
|
||||
EXPECT_NE(exist, 0);
|
||||
}
|
||||
} // OHOS
|
||||
|
Loading…
x
Reference in New Issue
Block a user