安装最后一次拷贝改为move

Signed-off-by: Zhou Shihui <zhoushihui4@huawei.com>
This commit is contained in:
Zhou Shihui 2024-10-21 18:52:42 +08:00
parent ff0a13c7ff
commit 5f8d06d3de
40 changed files with 147 additions and 189 deletions

View File

@ -76,7 +76,8 @@ enum class InstalldInterfaceCode : uint32_t {
IS_EXIST_EXTENSION_DIR,
CREATE_EXTENSION_DATA_DIR,
GET_EXTENSION_SANDBOX_TYPE_LIST,
ADD_USER_DIR_DELETE_DFX
ADD_USER_DIR_DELETE_DFX,
MOVE_HAP_TO_CODE_DIR,
};
} // namespace AppExecFwk

View File

@ -232,6 +232,8 @@ public:
virtual ErrCode AddUserDirDeleteDfx(int32_t userId) override;
virtual ErrCode MoveHapToCodeDir(const std::string &originPath, const std::string &targetPath) override;
private:
std::string GetExtensionConfigPath() const;
void LoadNeedCreateSandbox(const nlohmann::json &object, std::vector<std::string> &typeList);

View File

@ -235,6 +235,8 @@ public:
ErrCode AddUserDirDeleteDfx(int32_t userId);
ErrCode MoveHapToCodeDir(const std::string &originPath, const std::string &targetPath);
private:
sptr<IInstalld> GetInstalldProxy();
bool LoadInstalldService();

View File

@ -214,6 +214,8 @@ private:
bool HandleAddUserDirDeleteDfx(MessageParcel &data, MessageParcel &reply);
bool HandleMoveHapToCodeDir(MessageParcel &data, MessageParcel &reply);
void AddCloseInstalldTask();
void RemoveCloseInstalldTask();

View File

@ -421,6 +421,11 @@ public:
{
return ERR_OK;
}
virtual ErrCode MoveHapToCodeDir(const std::string &originPath, const std::string &targetPath)
{
return ERR_OK;
}
};
#define INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(parcel, token) \

View File

@ -229,6 +229,8 @@ public:
virtual ErrCode GetExtensionSandboxTypeList(std::vector<std::string> &typeList) override;
virtual ErrCode AddUserDirDeleteDfx(int32_t userId) override;
virtual ErrCode MoveHapToCodeDir(const std::string &originPath, const std::string &targetPath) override;
private:
ErrCode TransactInstalldCmd(InstalldInterfaceCode code, MessageParcel &data, MessageParcel &reply,
MessageOption &option);

View File

@ -4823,10 +4823,10 @@ ErrCode BaseBundleInstaller::SaveHapToInstallPath(const std::unordered_map<std::
signatureFileMap_.at(hapPathRecord.first));
CHECK_RESULT(result, "Copy hap to install path failed or code signature hap failed %{public}d");
} else {
if (InstalldClient::GetInstance()->CopyFile(
if (InstalldClient::GetInstance()->MoveHapToCodeDir(
hapPathRecord.first, hapPathRecord.second) != ERR_OK) {
LOG_E(BMS_TAG_INSTALLER, "Copy hap to install path failed");
return ERR_APPEXECFWK_INSTALL_COPY_HAP_FAILED;
return ERR_APPEXECFWK_INSTALLD_MOVE_FILE_FAILED;
}
if (VerifyCodeSignatureForHap(infos, hapPathRecord.first, hapPathRecord.second) != ERR_OK) {
LOG_E(BMS_TAG_INSTALLER, "enable code signature failed");

View File

@ -41,6 +41,7 @@
#include "directory_ex.h"
#ifdef WITH_SELINUX
#include "hap_restorecon.h"
#include "selinux/selinux.h"
#ifndef SELINUX_HAP_DEBUGGABLE
#define SELINUX_HAP_DEBUGGABLE 2
#endif
@ -1844,5 +1845,36 @@ ErrCode InstalldHostImpl::InnerRemoveBundleDataDir(const std::string &bundleName
}
return ERR_OK;
}
ErrCode InstalldHostImpl::MoveHapToCodeDir(const std::string &originPath, const std::string &targetPath)
{
if (!InstalldPermissionMgr::VerifyCallingPermission(Constants::FOUNDATION_UID)) {
LOG_E(BMS_TAG_INSTALLD, "installd permission denied, only used for foundation process");
return ERR_APPEXECFWK_INSTALLD_PERMISSION_DENIED;
}
if (!InstalldOperator::MoveFile(originPath, targetPath)) {
LOG_E(BMS_TAG_INSTALLD, "move file %{public}s to %{public}s failed errno:%{public}d",
originPath.c_str(), targetPath.c_str(), errno);
return ERR_APPEXECFWK_INSTALLD_MOVE_FILE_FAILED;
}
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
if (!OHOS::ChangeModeFile(targetPath, mode)) {
LOG_E(BMS_TAG_INSTALLD, "change mode failed");
return ERR_APPEXECFWK_INSTALLD_MOVE_FILE_FAILED;
}
if (!InstalldOperator::ChangeFileAttr(targetPath, INSTALLS_UID, INSTALLS_UID)) {
LOG_E(BMS_TAG_INSTALLD, "ChangeAttr %{public}s failed errno:%{public}d", targetPath.c_str(), errno);
return ERR_APPEXECFWK_INSTALLD_MOVE_FILE_FAILED;
}
#ifdef WITH_SELINUX
const char *context = "u:object_r:data_app_el1_file:s0";
if (lsetfilecon(targetPath.c_str(), context) < 0) {
LOG_E(BMS_TAG_INSTALLD, "setcon %{public}s failed errno:%{public}d", targetPath.c_str(), errno);
return ERR_APPEXECFWK_INSTALLD_MOVE_FILE_FAILED;
}
#endif
return ERR_OK;
}
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -570,5 +570,15 @@ ErrCode InstalldClient::AddUserDirDeleteDfx(int32_t userId)
{
return CallService(&IInstalld::AddUserDirDeleteDfx, userId);
}
ErrCode InstalldClient::MoveHapToCodeDir(const std::string &originPath, const std::string &targetPath)
{
if (originPath.empty() || targetPath.empty()) {
APP_LOGE("params are invalid");
return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
}
return CallService(&IInstalld::MoveHapToCodeDir, originPath, targetPath);
}
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -106,6 +106,9 @@ int InstalldHost::OnRemoteRequest(uint32_t code, MessageParcel &data, MessagePar
case static_cast<uint32_t>(InstalldInterfaceCode::COPY_FILE):
result = this->HandleCopyFile(data, reply);
break;
case static_cast<uint32_t>(InstalldInterfaceCode::MOVE_HAP_TO_CODE_DIR):
result = this->HandleMoveHapToCodeDir(data, reply);
break;
case static_cast<uint32_t>(InstalldInterfaceCode::MKDIR):
result = this->HandleMkdir(data, reply);
break;
@ -896,6 +899,16 @@ bool InstalldHost::HandleCreateExtensionDataDir(MessageParcel &data, MessageParc
return true;
}
bool InstalldHost::HandleMoveHapToCodeDir(MessageParcel &data, MessageParcel &reply)
{
std::string originPath = Str16ToStr8(data.ReadString16());
std::string targetPath = Str16ToStr8(data.ReadString16());
ErrCode result = MoveHapToCodeDir(originPath, targetPath);
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, reply, result);
return true;
}
void InstalldHost::RemoveCloseInstalldTask()
{
std::lock_guard<std::mutex> lock(unloadTaskMutex_);

View File

@ -905,6 +905,18 @@ ErrCode InstalldProxy::CreateExtensionDataDir(const CreateDirParam &createDirPar
return TransactInstalldCmd(InstalldInterfaceCode::CREATE_EXTENSION_DATA_DIR, data, reply, option);
}
ErrCode InstalldProxy::MoveHapToCodeDir(const std::string &originPath, const std::string &targetPath)
{
MessageParcel data;
INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(originPath));
INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(targetPath));
MessageParcel reply;
MessageOption option(MessageOption::TF_SYNC);
return TransactInstalldCmd(InstalldInterfaceCode::MOVE_HAP_TO_CODE_DIR, data, reply, option);
}
ErrCode InstalldProxy::TransactInstalldCmd(InstalldInterfaceCode code, MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{

View File

@ -601,7 +601,7 @@ ErrCode InnerSharedBundleInstaller::SaveHspToRealInstallationDir(const std::stri
if (!signatureFileDir_.empty()) {
result = InstalldClient::GetInstance()->CopyFile(bundlePath, tempHspPath, signatureFileDir_);
} else {
result = InstalldClient::GetInstance()->CopyFile(bundlePath, tempHspPath);
result = InstalldClient::GetInstance()->MoveHapToCodeDir(bundlePath, tempHspPath);
CHECK_RESULT(result, "copy hsp to install dir failed %{public}d");
bool isCompileSdkOpenHarmony = (compileSdkType_ == COMPILE_SDK_TYPE_OPEN_HARMONY);
result = VerifyCodeSignatureForHsp(tempHspPath, appIdentifier_, isEnterpriseBundle_,

View File

@ -479,5 +479,15 @@ int64_t InstalldClient::GetDiskUsage(const std::string& dir, bool isRealPath)
{
return 0;
}
ErrCode InstalldClient::MoveHapToCodeDir(const std::string &originPath, const std::string &targetPath)
{
if (originPath.empty() || targetPath.empty()) {
APP_LOGE("params are invalid");
return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
}
return CallService(&IInstalld::MoveHapToCodeDir, originPath, targetPath);
}
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -307,8 +307,12 @@ ErrCode InstalldClient::GetExtensionSandboxTypeList(std::vector<std::string> &ty
ErrCode InstalldClient::AddUserDirDeleteDfx(int32_t userId)
{
return ERR_OK;
return ERR_OK;
}
ErrCode InstalldClient::MoveHapToCodeDir(const std::string &originPath, const std::string &targetPath)
{
return ERR_OK;
}
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -306,5 +306,9 @@ ErrCode InstalldHostImpl::AddUserDirDeleteDfx(int32_t userId)
return ERR_OK;
}
ErrCode InstalldHostImpl::MoveHapToCodeDir(const std::string &originPath, const std::string &targetPath)
{
return ERR_OK;
}
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -141,6 +141,7 @@ ErrCode BmsBundleAccessTokenIdTest::InstallBundle(const std::string &bundlePath)
InstallParam installParam;
installParam.installFlag = InstallFlag::NORMAL;
installParam.userId = USERID;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
@ -164,6 +165,7 @@ ErrCode BmsBundleAccessTokenIdTest::UpdateBundle(const std::string &bundlePath)
InstallParam installParam;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.userId = USERID;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -157,6 +157,7 @@ ErrCode BmsBundleAppControlTest::InstallBundle(const std::string &bundlePath) co
InstallParam installParam;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.userId = USERID;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -130,6 +130,7 @@ ErrCode BmsBundleAppProvisionInfoTest::InstallBundle(const std::string &bundlePa
InstallParam installParam;
installParam.installFlag = InstallFlag::NORMAL;
installParam.userId = USERID;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -127,6 +127,7 @@ ErrCode BmsBundleCrowdtestingTest::InstallBundle(const std::vector<std::string>
installParam.installFlag = InstallFlag::NORMAL;
installParam.userId = USERID;
installParam.crowdtestDeadline = crowdtestDeadline;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
@ -153,6 +154,7 @@ ErrCode BmsBundleCrowdtestingTest::InstallBundle(const std::string &bundlePath,
installParam.userId = USERID;
installParam.crowdtestDeadline = crowdtestDeadline;
installParam.specifiedDistributionType = specifiedDistributeType;
installParam.withCopyHaps = true;
std::vector<std::string> path;
path.emplace_back(bundlePath);
bool result = installer->Install(path, installParam, receiver);
@ -180,6 +182,7 @@ ErrCode BmsBundleCrowdtestingTest::UpdateBundle(const std::string &bundlePath,
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.userId = USERID;
installParam.crowdtestDeadline = crowdtestDeadline;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
@ -206,6 +209,7 @@ ErrCode BmsBundleCrowdtestingTest::UpdateBundle(const std::string &bundlePath,
installParam.userId = USERID;
installParam.crowdtestDeadline = crowdtestDeadline;
installParam.specifiedDistributionType = specifiedDistributeType;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -200,6 +200,7 @@ ErrCode BmsBundleDefaultAppTest::InstallBundle(const std::string &bundlePath) co
InstallParam installParam;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.userId = USER_ID;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -120,6 +120,7 @@ ErrCode BmsBundleDependenciesTest::InstallBundle(const std::string &bundlePath)
InstallParam installParam;
installParam.installFlag = InstallFlag::NORMAL;
installParam.userId = USERID;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
@ -143,6 +144,7 @@ ErrCode BmsBundleDependenciesTest::UpdateBundle(const std::string &bundlePath) c
InstallParam installParam;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.userId = USERID;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -122,6 +122,7 @@ ErrCode BmsBundleHspTest::InstallBundle(const std::string &bundlePath) const
InstallParam installParam;
installParam.installFlag = InstallFlag::NORMAL;
installParam.userId = USERID;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
@ -165,6 +166,7 @@ ErrCode BmsBundleHspTest::UpdateBundle(const std::string &bundlePath) const
InstallParam installParam;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.userId = USERID;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
@ -330,6 +332,7 @@ HWTEST_F(BmsBundleHspTest, BmsBundleHspTest_0800, Function | SmallTest | Level0)
installParam.installFlag = InstallFlag::NORMAL;
installParam.specifiedDistributionType = "specifiedDistributionType";
installParam.additionalInfo = "additionalInfo";
installParam.withCopyHaps = true;
ErrCode installResult = InstallBundle(MODULE_FILE_PATH + HSP_NAME_C, installParam);
EXPECT_EQ(installResult, ERR_OK);

View File

@ -151,6 +151,7 @@ ErrCode BmsBundleSharedLibraryInstallTest::InstallBundle(const std::vector<std::
installParam.installFlag = InstallFlag::NORMAL;
installParam.userId = USERID;
installParam.sharedBundleDirPaths = sharedBundlePaths;
installParam.withCopyHaps = true;
bool result = installer->Install(bundleFilePaths, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -134,6 +134,7 @@ ErrCode BmsBundleSharedLibraryUninstallTest::InstallBundle(const std::vector<std
installParam.installFlag = InstallFlag::NORMAL;
installParam.userId = USERID;
installParam.sharedBundleDirPaths = sharedBundlePaths;
installParam.withCopyHaps = true;
bool result = installer->Install(bundleFilePaths, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -154,6 +154,7 @@ ErrCode BmsDriverInstallerTest::InstallBundle(const std::vector<std::string> &bu
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.withCopyHaps = true;
auto result = installer->Install(bundlePaths, installParam, receiver);
return receiver->GetResultCode();
}

View File

@ -208,6 +208,7 @@ ErrCode BmsBundleInstallerTest::InstallThirdPartyBundle(const std::string &fileP
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = InstallFlag::NORMAL;
installParam.withCopyHaps = true;
bool result = installer->Install(filePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
@ -229,6 +230,7 @@ ErrCode BmsBundleInstallerTest::UpdateThirdPartyBundle(const std::string &filePa
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.withCopyHaps = true;
bool result = installer->Install(filePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
@ -611,6 +613,7 @@ HWTEST_F(BmsBundleInstallerTest, CreateInstallTask_0100, Function | SmallTest |
EXPECT_NE(receiver, nullptr);
InstallParam installParam;
installParam.userId = USERID;
installParam.withCopyHaps = true;
std::string bundleFile = RESOURCE_ROOT_PATH + RIGHT_BUNDLE;
GetBundleInstallerManager()->CreateInstallTask(bundleFile, installParam, receiver);
ErrCode result = receiver->GetResultCode();
@ -631,6 +634,7 @@ HWTEST_F(BmsBundleInstallerTest, CreateInstallTask_0200, Function | SmallTest |
EXPECT_NE(receiver, nullptr);
InstallParam installParam;
installParam.userId = USERID;
installParam.withCopyHaps = true;
std::string bundleFile = RESOURCE_ROOT_PATH + INVALID_BUNDLE;
GetBundleInstallerManager()->CreateInstallTask(bundleFile, installParam, receiver);
ErrCode result = receiver->GetResultCode();
@ -3940,6 +3944,7 @@ HWTEST_F(BmsBundleInstallerTest, baseBundleInstaller_5000, Function | SmallTest
inBundlePaths.emplace_back(bundleFile);
InstallParam installParam;
installParam.isPreInstallApp = false;
installParam.withCopyHaps = true;
auto appType = Constants::AppType::THIRD_PARTY_APP;
int32_t uid = 0;
ErrCode ret = installer.ProcessBundleInstall(

View File

@ -147,6 +147,7 @@ ErrCode BmsMultipleInstallerTest::InstallThirdPartyBundle(const std::string &fil
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = InstallFlag::NORMAL;
installParam.withCopyHaps = true;
bool result = installer->Install(filePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
@ -168,6 +169,7 @@ ErrCode BmsMultipleInstallerTest::InstallThirdPartyMultipleBundles(const std::ve
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = flag ? InstallFlag::NORMAL : InstallFlag::REPLACE_EXISTING;
installParam.withCopyHaps = true;
bool result = installer->Install(filePaths, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
@ -188,6 +190,7 @@ ErrCode BmsMultipleInstallerTest::UpdateThirdPartyBundle(const std::string &file
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.withCopyHaps = true;
bool result = installer->Install(filePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -158,6 +158,7 @@ ErrCode BmsBundleGetWindowPropertiesTest::InstallBundle(const std::vector<std::s
InstallParam installParam;
installParam.userId = DEFAULT_USERID;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.withCopyHaps = true;
bool result = installer->Install(filePaths, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -164,6 +164,7 @@ ErrCode BmsBundleManagerTest::InstallThirdPartyBundle(const std::string &filePat
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.withCopyHaps = true;
bool result = installer->Install(filePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
@ -185,6 +186,7 @@ ErrCode BmsBundleManagerTest::UpdateThirdPartyBundle(const std::string &filePath
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.withCopyHaps = true;
bool result = installer->Install(filePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -108,6 +108,7 @@ ErrCode BmsBundlePermissionGrantTest::InstallBundle(const std::string &bundlePat
InstallParam installParam;
installParam.installFlag = InstallFlag::NORMAL;
installParam.userId = USERID;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -213,6 +213,7 @@ ErrCode BmsBundleQuickFixBootScannerTest::InstallBundle(const std::string &bundl
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = InstallFlag::NORMAL;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -117,6 +117,7 @@ ErrCode BmsBundleQuickFixMgrRdbTest::InstallBundle(const std::string &bundlePath
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = InstallFlag::NORMAL;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -125,6 +125,7 @@ ErrCode BmsBundleQuickFixSwitcherTest::InstallBundle(const std::string &bundlePa
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = InstallFlag::NORMAL;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -191,6 +191,7 @@ ErrCode BmsBundleQuickFixTest::InstallBundle(const std::string &bundlePath) cons
InstallParam installParam;
installParam.installFlag = InstallFlag::NORMAL;
installParam.userId = USERID;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
@ -214,6 +215,7 @@ ErrCode BmsBundleQuickFixTest::UpdateBundle(const std::string &bundlePath) const
InstallParam installParam;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.userId = USERID;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -119,6 +119,7 @@ ErrCode BmsBundleResourceManagerTest::InstallBundle(const std::string &bundlePat
InstallParam installParam;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.userId = USER_ID;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -156,6 +156,7 @@ ErrCode BmsBundleResourceTest::InstallBundle(const std::string &bundlePath) cons
InstallParam installParam;
installParam.installFlag = InstallFlag::NORMAL;
installParam.userId = USERID;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
@ -179,6 +180,7 @@ ErrCode BmsBundleResourceTest::UpdateBundle(const std::string &bundlePath) const
InstallParam installParam;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.userId = USERID;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -266,6 +266,7 @@ ErrCode BmsSandboxAppTest::InstallBundles(const std::vector<std::string> &filePa
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = flag ? InstallFlag::NORMAL : InstallFlag::REPLACE_EXISTING;
installParam.withCopyHaps = true;
bool result = installer->Install(filePaths, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -312,6 +312,7 @@ ErrCode BmsBundleUninstallerTest::InstallMultipleBundles(const std::vector<std::
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = flag ? InstallFlag::NORMAL : InstallFlag::REPLACE_EXISTING;
installParam.withCopyHaps = true;
bool result = installer->Install(filePaths, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();

View File

@ -136,6 +136,7 @@ ErrCode BmsBundleUpdaterTest::InstallBundle(const std::string &bundlePath) const
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = InstallFlag::NORMAL;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
@ -178,6 +179,7 @@ ErrCode BmsBundleUpdaterTest::UpdateBundle(const std::string &bundlePath) const
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
@ -198,6 +200,7 @@ ErrCode BmsBundleUpdaterTest::UpdateBundle(const std::string &bundlePath, const
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.withCopyHaps = true;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
@ -425,6 +428,7 @@ HWTEST_F(BmsBundleUpdaterTest, Update_0700, Function | SmallTest | Level2)
InstallParam installParam;
installParam.userId = USERID;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.withCopyHaps = true;
installer->Install(BUNDLE_FILE_DIR + V2_BUNDLE, installParam, nullptr);
std::this_thread::sleep_for(50ms);

View File

@ -649,112 +649,6 @@ HWTEST_F(BmsInstallMultiUserTest, BMS_Install_multi_user_1100, Function | Medium
std::cout << "END BMS_Install_multi_user_1100" << std::endl;
}
/**
* @tc.number: BMS_Install_multi_user_1200
* @tc.name: test the installation of a third-party bundle for multi users
* @tc.desc: 1.create user 101
* 2.install the bundle under user 100 and user 101
* 3.query bundle info under user 100 and user 101
*/
HWTEST_F(BmsInstallMultiUserTest, BMS_Install_multi_user_1200, Function | MediumTest | Level1)
{
std::cout << "START BMS_Install_multi_user_1200" << std::endl;
int32_t userId = CreateNewUser();
EXPECT_NE(userId, 0);
std::vector<std::string> bundleFilePaths = { THIRD_BUNDLE_PATH + TEST_BUNDLE_HAPA };
auto res = InstallBundle(bundleFilePaths, Constants::ALL_USERID);
EXPECT_EQ(res, ERR_OK);
auto bmsProxy = GetBundleMgrProxy();
EXPECT_NE(bmsProxy, nullptr);
// query bundleInfo under two users respectively
BundleInfo bundleInfo1;
bool ret = bmsProxy->GetBundleInfo(BUNDLE_NAME, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo1, USERID);
EXPECT_TRUE(ret);
BundleInfo bundleInfo2;
ret = bmsProxy->GetBundleInfo(BUNDLE_NAME, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo2, userId);
EXPECT_TRUE(ret);
UninstallBundle(BUNDLE_NAME, Constants::ALL_USERID);
std::cout << "END BMS_Install_multi_user_1200" << std::endl;
}
/**
* @tc.number: BMS_Install_multi_user_1300
* @tc.name: test the installation of a third-party bundle for multi users
* @tc.desc: 1.create user 101
* 2.install the bundle under user 100 and user 101
* 3.query bundle info under user 100 and user 101
*/
HWTEST_F(BmsInstallMultiUserTest, BMS_Install_multi_user_1300, Function | MediumTest | Level1)
{
std::cout << "START BMS_Install_multi_user_1300" << std::endl;
int32_t userId = CreateNewUser();
EXPECT_NE(userId, 0);
std::vector<std::string> bundleFilePaths = { THIRD_BUNDLE_PATH + TEST_BUNDLE_HAPA };
bundleFilePaths.emplace_back(THIRD_BUNDLE_PATH + TEST_BUNDLE_HAPB);
auto res = InstallBundle(bundleFilePaths, Constants::ALL_USERID);
EXPECT_EQ(res, ERR_OK);
auto bmsProxy = GetBundleMgrProxy();
EXPECT_NE(bmsProxy, nullptr);
// query bundleInfo under two users respectively
BundleInfo bundleInfo1;
bool ret = bmsProxy->GetBundleInfo(BUNDLE_NAME, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo1, USERID);
EXPECT_TRUE(ret);
BundleInfo bundleInfo2;
ret = bmsProxy->GetBundleInfo(BUNDLE_NAME, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo2, userId);
EXPECT_TRUE(ret);
UninstallBundle(BUNDLE_NAME, Constants::ALL_USERID);
std::cout << "END BMS_Install_multi_user_1300" << std::endl;
}
/**
* @tc.number: BMS_Install_multi_user_1400
* @tc.name: test the installation of a third-party bundle for multi users
* @tc.desc: 1.install hapA under user 100 successfully
* 2.create user 101 successfully
* 3.updata install the higher version-code hapA under the ALL_USERID successfully
* 4.query bundleInfo under user 100 and 101 successfully
*/
HWTEST_F(BmsInstallMultiUserTest, BMS_Install_multi_user_1400, Function | MediumTest | Level1)
{
std::cout << "START BMS_Install_multi_user_1400" << std::endl;
std::vector<std::string> bundleFilePaths = { THIRD_BUNDLE_PATH + TEST_BUNDLE_HAPA };
auto res = InstallBundle(bundleFilePaths, USERID);
EXPECT_EQ(res, ERR_OK);
int32_t userId = CreateNewUser();
EXPECT_NE(userId, 0);
bundleFilePaths.clear();
bundleFilePaths.emplace_back(THIRD_BUNDLE_PATH + HIGHER_VERSION_CODE_TEST_BUNDLE_HAPA);
res = InstallBundle(bundleFilePaths, Constants::ALL_USERID);
EXPECT_EQ(res, ERR_OK);
auto bmsProxy = GetBundleMgrProxy();
EXPECT_NE(bmsProxy, nullptr);
// query bundleInfo under two users respectively
BundleInfo bundleInfo1;
bool ret = bmsProxy->GetBundleInfo(BUNDLE_NAME, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo1, USERID);
EXPECT_TRUE(ret);
BundleInfo bundleInfo2;
ret = bmsProxy->GetBundleInfo(BUNDLE_NAME, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo2, userId);
EXPECT_TRUE(ret);
UninstallBundle(BUNDLE_NAME, Constants::ALL_USERID);
std::cout << "END BMS_Install_multi_user_1400" << std::endl;
}
/**
* @tc.number: BMS_Install_multi_user_1500
* @tc.name: test the installation of a third-party bundle for multi users
@ -794,45 +688,6 @@ HWTEST_F(BmsInstallMultiUserTest, BMS_Install_multi_user_1500, Function | Medium
std::cout << "END BMS_Install_multi_user_1500" << std::endl;
}
/**
* @tc.number: BMS_Install_multi_user_1600
* @tc.name: test the installation of a third-party bundle for multi users
* @tc.desc: 1.install hapA under user 100 successfully
* 2.create user 101 successfully
* 3.updata install the same version-code hapA under the user ALL_USERID successfully
* 4.query bundleInfo under user 100 and 101 successfully
*/
HWTEST_F(BmsInstallMultiUserTest, BMS_Install_multi_user_1600, Function | MediumTest | Level1)
{
std::cout << "START BMS_Install_multi_user_1600" << std::endl;
std::vector<std::string> bundleFilePaths = { THIRD_BUNDLE_PATH + TEST_BUNDLE_HAPA };
auto res = InstallBundle(bundleFilePaths, USERID);
EXPECT_EQ(res, ERR_OK);
int32_t userId = CreateNewUser();
EXPECT_NE(userId, 0);
bundleFilePaths.clear();
bundleFilePaths.emplace_back(THIRD_BUNDLE_PATH + TEST_BUNDLE_HAPA);
res = InstallBundle(bundleFilePaths, Constants::ALL_USERID);
EXPECT_EQ(res, ERR_OK);
auto bmsProxy = GetBundleMgrProxy();
EXPECT_NE(bmsProxy, nullptr);
// query bundleInfo under two users respectively
BundleInfo bundleInfo1;
bool ret = bmsProxy->GetBundleInfo(BUNDLE_NAME, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo1, USERID);
EXPECT_TRUE(ret);
BundleInfo bundleInfo2;
ret = bmsProxy->GetBundleInfo(BUNDLE_NAME, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo2, userId);
EXPECT_TRUE(ret);
UninstallBundle(BUNDLE_NAME, Constants::ALL_USERID);
std::cout << "END BMS_Install_multi_user_1600" << std::endl;
}
/**
* @tc.number: BMS_Install_multi_user_1700
* @tc.name: test the installation of a third-party bundle for multi users
@ -911,45 +766,6 @@ HWTEST_F(BmsInstallMultiUserTest, BMS_Install_multi_user_1800, Function | Medium
std::cout << "END BMS_Install_multi_user_1800" << std::endl;
}
/**
* @tc.number: BMS_Install_multi_user_1900
* @tc.name: test the installation of a third-party bundle for multi users
* @tc.desc: 1.install hapA under user 100 successfully
* 2.create user 101 successfully
* 3.updata install install the same version-code hapB under the user ALL_USERID successfully
* 4.query bundleInfo under user 100 and 101 successfully
*/
HWTEST_F(BmsInstallMultiUserTest, BMS_Install_multi_user_1900, Function | MediumTest | Level1)
{
std::cout << "START BMS_Install_multi_user_1900" << std::endl;
std::vector<std::string> bundleFilePaths = { THIRD_BUNDLE_PATH + TEST_BUNDLE_HAPA };
auto res = InstallBundle(bundleFilePaths, USERID);
EXPECT_EQ(res, ERR_OK);
int32_t userId = CreateNewUser();
EXPECT_NE(userId, 0);
bundleFilePaths.clear();
bundleFilePaths.emplace_back(THIRD_BUNDLE_PATH + TEST_BUNDLE_HAPB);
res = InstallBundle(bundleFilePaths, Constants::ALL_USERID);
EXPECT_EQ(res, ERR_OK);
auto bmsProxy = GetBundleMgrProxy();
EXPECT_NE(bmsProxy, nullptr);
// query bundleInfo under two users respectively
BundleInfo bundleInfo1;
bool ret = bmsProxy->GetBundleInfo(BUNDLE_NAME, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo1, USERID);
EXPECT_TRUE(ret);
BundleInfo bundleInfo2;
ret = bmsProxy->GetBundleInfo(BUNDLE_NAME, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo2, userId);
EXPECT_TRUE(ret);
UninstallBundle(BUNDLE_NAME, Constants::ALL_USERID);
std::cout << "END BMS_Install_multi_user_1900" << std::endl;
}
/**
* @tc.number: BMS_Install_multi_user_2000
* @tc.name: test the installation of a third-party bundle for multi users