mirror of
https://gitee.com/openharmony/bundlemanager_bundle_framework
synced 2024-11-23 07:09:53 +00:00
!7339 空间统计cache目录变更为指定目录
Merge pull request !7339 from small_leek/addflagtostatistic
This commit is contained in:
commit
6b8112cbb5
@ -136,7 +136,8 @@ public:
|
||||
*/
|
||||
virtual ErrCode GetBundleStats(const std::string &bundleName, const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const int32_t uid = Constants::INVALID_UID,
|
||||
const int32_t appIndex = 0, const uint32_t statFlag = 0) override;
|
||||
const int32_t appIndex = 0, const uint32_t statFlag = 0,
|
||||
const std::vector<std::string> &moduleNameList = {}) override;
|
||||
|
||||
virtual ErrCode GetAllBundleStats(const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const std::vector<int32_t> &uids) override;
|
||||
@ -253,7 +254,7 @@ private:
|
||||
ErrCode InnerRemoveAtomicServiceBundleDataDir(const std::string &bundleName, const int32_t userId);
|
||||
ErrCode InnerRemoveBundleDataDir(const std::string &bundleName, const int32_t userId);
|
||||
int64_t GetAppCacheSize(const std::string &bundleName, const int32_t userId,
|
||||
const int32_t appIndex);
|
||||
const int32_t appIndex, const std::vector<std::string> &moduleNames = {});
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -116,8 +116,9 @@ public:
|
||||
*/
|
||||
ErrCode GetBundleStats(const std::string &bundleName, const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const int32_t uid = Constants::INVALID_UID,
|
||||
const int32_t appIndex = 0, const uint32_t statFlag = 0);
|
||||
|
||||
const int32_t appIndex = 0, const uint32_t statFlag = 0,
|
||||
const std::vector<std::string> &moduleNameList = {});
|
||||
|
||||
ErrCode GetAllBundleStats(const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const std::vector<int32_t> &uids);
|
||||
|
||||
|
@ -196,7 +196,7 @@ public:
|
||||
*/
|
||||
virtual ErrCode GetBundleStats(const std::string &bundleName, const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const int32_t uid, const int32_t appIndex = 0,
|
||||
const uint32_t statFlag = 0)
|
||||
const uint32_t statFlag = 0, const std::vector<std::string> &moduleNameList = {})
|
||||
{
|
||||
return ERR_OK;
|
||||
}
|
||||
|
@ -138,7 +138,8 @@ public:
|
||||
*/
|
||||
virtual ErrCode GetBundleStats(const std::string &bundleName, const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const int32_t uid = Constants::INVALID_UID,
|
||||
const int32_t appIndex = 0, const uint32_t statFlag = 0) override;
|
||||
const int32_t appIndex = 0, const uint32_t statFlag = 0,
|
||||
const std::vector<std::string> &moduleNameList = {}) override;
|
||||
|
||||
virtual ErrCode GetAllBundleStats(const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const std::vector<int32_t> &uids) override;
|
||||
|
@ -3535,6 +3535,7 @@ bool BundleDataMgr::GetBundleStats(const std::string &bundleName,
|
||||
{
|
||||
int32_t responseUserId = -1;
|
||||
int32_t uid = -1;
|
||||
std::vector<std::string> moduleNameList;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(bundleInfoMutex_);
|
||||
const auto infoItem = bundleInfos_.find(bundleName);
|
||||
@ -3543,9 +3544,10 @@ bool BundleDataMgr::GetBundleStats(const std::string &bundleName,
|
||||
}
|
||||
responseUserId = infoItem->second.GetResponseUserId(userId);
|
||||
uid = infoItem->second.GetUid(responseUserId, appIndex);
|
||||
infoItem->second.GetModuleNames(moduleNameList);
|
||||
}
|
||||
ErrCode ret = InstalldClient::GetInstance()->GetBundleStats(
|
||||
bundleName, responseUserId, bundleStats, uid, appIndex, statFlag);
|
||||
bundleName, responseUserId, bundleStats, uid, appIndex, statFlag, moduleNameList);
|
||||
if (ret != ERR_OK) {
|
||||
APP_LOGW("%{public}s getStats failed", bundleName.c_str());
|
||||
return false;
|
||||
|
@ -923,9 +923,34 @@ std::string InstalldHostImpl::GetAppDataPath(const std::string &bundleName, cons
|
||||
}
|
||||
}
|
||||
|
||||
int64_t InstalldHostImpl::GetAppCacheSize(const std::string &bundleName,
|
||||
const int32_t userId, const int32_t appIndex, const std::vector<std::string> &moduleNameList)
|
||||
{
|
||||
std::string bundleNameDir = bundleName;
|
||||
if (appIndex > 0) {
|
||||
bundleNameDir = BundleCloneCommonHelper::GetCloneDataDir(bundleName, appIndex);
|
||||
}
|
||||
std::vector<std::string> cachePaths;
|
||||
std::vector<std::string> elPath(ServiceConstants::BUNDLE_EL);
|
||||
elPath.push_back(ServiceConstants::DIR_EL5);
|
||||
for (const auto &el : elPath) {
|
||||
cachePaths.push_back(std::string(ServiceConstants::BUNDLE_APP_DATA_BASE_DIR) + el +
|
||||
ServiceConstants::PATH_SEPARATOR + std::to_string(userId) + ServiceConstants::BASE +
|
||||
bundleNameDir + ServiceConstants::PATH_SEPARATOR + Constants::CACHE_DIR);
|
||||
for (const auto &moduleName : moduleNameList) {
|
||||
std::string moduleCachePath = std::string(ServiceConstants::BUNDLE_APP_DATA_BASE_DIR) + el +
|
||||
ServiceConstants::PATH_SEPARATOR + std::to_string(userId) + ServiceConstants::BASE + bundleNameDir +
|
||||
ServiceConstants::HAPS + moduleName + ServiceConstants::PATH_SEPARATOR + Constants::CACHE_DIR;
|
||||
cachePaths.push_back(moduleCachePath);
|
||||
LOG_D(BMS_TAG_INSTALLD, "GetBundleStats, add module cache path: %{public}s", moduleCachePath.c_str());
|
||||
}
|
||||
}
|
||||
return InstalldOperator::GetDiskUsageFromPath(cachePaths);
|
||||
}
|
||||
|
||||
ErrCode InstalldHostImpl::GetBundleStats(const std::string &bundleName, const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const int32_t uid, const int32_t appIndex,
|
||||
const uint32_t statFlag)
|
||||
const uint32_t statFlag, const std::vector<std::string> &moduleNameList)
|
||||
{
|
||||
LOG_D(BMS_TAG_INSTALLD,
|
||||
"GetBundleStats, bundleName = %{public}s, userId = %{public}d, uid = %{public}d, appIndex = %{public}d",
|
||||
@ -955,15 +980,7 @@ ErrCode InstalldHostImpl::GetBundleStats(const std::string &bundleName, const in
|
||||
}
|
||||
if ((statFlag & OHOS::AppExecFwk::Constants::GET_BUNDLE_WITHOUT_CACHE_SIZE) !=
|
||||
OHOS::AppExecFwk::Constants::NoGetBundleStatsFlag::GET_BUNDLE_WITHOUT_CACHE_SIZE) {
|
||||
|
||||
std::vector<std::string> cachePath;
|
||||
std::vector<std::string> elPath(ServiceConstants::BUNDLE_EL);
|
||||
elPath.push_back(ServiceConstants::DIR_EL5);
|
||||
for (const auto &el : elPath) {
|
||||
std::string filePath = GetAppDataPath(bundleName, el, userId, appIndex);
|
||||
InstalldOperator::TraverseCacheDirectory(filePath, cachePath);
|
||||
}
|
||||
bundleCacheSize = InstalldOperator::GetDiskUsageFromPath(cachePath);
|
||||
bundleCacheSize = GetAppCacheSize(bundleName, userId, appIndex, moduleNameList);
|
||||
}
|
||||
// index 0 : bundle data size
|
||||
bundleStats[0] = appDataSize;
|
||||
|
@ -181,7 +181,7 @@ ErrCode InstalldClient::CleanBundleDataDirByName(const std::string &bundleName,
|
||||
|
||||
ErrCode InstalldClient::GetBundleStats(const std::string &bundleName, const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const int32_t uid, const int32_t appIndex,
|
||||
const uint32_t statFlag)
|
||||
const uint32_t statFlag, const std::vector<std::string> &moduleNameList)
|
||||
{
|
||||
if (bundleName.empty()) {
|
||||
APP_LOGE("bundleName is empty");
|
||||
@ -189,7 +189,7 @@ ErrCode InstalldClient::GetBundleStats(const std::string &bundleName, const int3
|
||||
}
|
||||
|
||||
return CallService(&IInstalld::GetBundleStats, bundleName, userId, bundleStats,
|
||||
uid, appIndex, statFlag);
|
||||
uid, appIndex, statFlag, moduleNameList);
|
||||
}
|
||||
|
||||
ErrCode InstalldClient::GetAllBundleStats(const int32_t userId,
|
||||
|
@ -452,8 +452,12 @@ bool InstalldHost::HandleGetBundleStats(MessageParcel &data, MessageParcel &repl
|
||||
int32_t uid = data.ReadInt32();
|
||||
int32_t appIndex = data.ReadInt32();
|
||||
uint32_t statFlag = data.ReadUint32();
|
||||
std::vector<std::string> moduleNameList;
|
||||
if (!data.ReadStringVector(&moduleNameList)) {
|
||||
return false;
|
||||
}
|
||||
std::vector<int64_t> bundleStats;
|
||||
ErrCode result = GetBundleStats(bundleName, userId, bundleStats, uid, appIndex, statFlag);
|
||||
ErrCode result = GetBundleStats(bundleName, userId, bundleStats, uid, appIndex, statFlag, moduleNameList);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, reply, result);
|
||||
if (!reply.WriteInt64Vector(bundleStats)) {
|
||||
LOG_E(BMS_TAG_INSTALLD, "HandleGetBundleStats write failed");
|
||||
|
@ -287,7 +287,7 @@ ErrCode InstalldProxy::CleanBundleDataDirByName(const std::string &bundleName, c
|
||||
|
||||
ErrCode InstalldProxy::GetBundleStats(const std::string &bundleName, const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const int32_t uid, const int32_t appIndex,
|
||||
const uint32_t statFlag)
|
||||
const uint32_t statFlag, const std::vector<std::string> &moduleNameList)
|
||||
{
|
||||
MessageParcel data;
|
||||
INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
|
||||
@ -296,6 +296,17 @@ ErrCode InstalldProxy::GetBundleStats(const std::string &bundleName, const int32
|
||||
INSTALLD_PARCEL_WRITE(data, Int32, uid);
|
||||
INSTALLD_PARCEL_WRITE(data, Int32, appIndex);
|
||||
INSTALLD_PARCEL_WRITE(data, Uint32, statFlag);
|
||||
if (!data.WriteInt32(moduleNameList.size())) {
|
||||
LOG_E(BMS_TAG_INSTALLD, "GetBundleStats failed: write module name count fail");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
for (size_t i = 0; i < moduleNameList.size(); i++) {
|
||||
if (!data.WriteString(moduleNameList[i])) {
|
||||
LOG_E(BMS_TAG_INSTALLD, "WriteParcelable moduleNames:[%{public}s] failed",
|
||||
moduleNameList[i].c_str());
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
auto ret = TransactInstalldCmd(InstalldInterfaceCode::GET_BUNDLE_STATS, data, reply, option);
|
||||
|
@ -166,15 +166,14 @@ ErrCode InstalldClient::CleanBundleDataDirByName(
|
||||
|
||||
ErrCode InstalldClient::GetBundleStats(const std::string &bundleName, const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const int32_t uid, const int32_t appIndex,
|
||||
const uint32_t statFlag)
|
||||
const uint32_t statFlag, const std::vector<std::string> &moduleNameList)
|
||||
{
|
||||
if (bundleName.empty()) {
|
||||
APP_LOGE("bundleName is empty");
|
||||
return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
|
||||
}
|
||||
|
||||
return CallService(&IInstalld::GetBundleStats, bundleName, userId, bundleStats,
|
||||
uid, appIndex, statFlag);
|
||||
uid, appIndex, statFlag, moduleNameList);
|
||||
}
|
||||
|
||||
ErrCode InstalldClient::GetAllBundleStats(const int32_t userId,
|
||||
|
@ -120,7 +120,7 @@ ErrCode InstalldClient::CleanBundleDataDirByName(const std::string &bundleName,
|
||||
|
||||
ErrCode InstalldClient::GetBundleStats(const std::string &bundleName, const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const int32_t uid,
|
||||
const int32_t appIndex, const uint32_t statFlag)
|
||||
const int32_t appIndex, const uint32_t statFlag, const std::vector<std::string> &moduleNameList)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -109,7 +109,8 @@ std::string InstalldHostImpl::GetBundleDataDir(const std::string &el, const int
|
||||
|
||||
ErrCode InstalldHostImpl::GetBundleStats(
|
||||
const std::string &bundleName, const int32_t userId, std::vector<int64_t> &bundleStats,
|
||||
const int32_t uid, const int32_t appIndex, const uint32_t statFlag)
|
||||
const int32_t uid, const int32_t appIndex, const uint32_t statFlag,
|
||||
const std::vector<std::string> &moduleNameList)
|
||||
{
|
||||
return ERR_OK;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include <cinttypes>
|
||||
#include "file_ex.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
@ -45,6 +46,11 @@ const std::string TEST_CPU_ABI = "arm64";
|
||||
const std::string HAP_FILE_PATH =
|
||||
"/data/app/el1/bundle/public/com.example.test/entry.hap";
|
||||
const std::string TEST_PATH = "/data/app/el1/bundle/public/com.example.test/";
|
||||
const std::string BUNDLE_NAME_STATS = "com.example.stats";
|
||||
const std::string BUNDLE_EL1_BUNDLE_PUBLIC = "/data/app/el1/bundle/public/com.example.stats";
|
||||
const std::string BUNDLE_EL1_DATA_CACHE = "/data/app/el1/100/base/com.example.stats/cache";
|
||||
const std::string BUNDLE_EL2_DATA_MODULE_CACHE = "/data/app/el2/100/base/com.example.stats/haps/entry2/cache";
|
||||
const std::string BUNDLE_EL5_DATA_MODULE_CACHE = "/data/app/el5/100/base/com.example.stats/haps/entry5/cache";
|
||||
const int32_t USERID = 100;
|
||||
const int32_t UID = 1000;
|
||||
const int32_t GID = 1000;
|
||||
@ -74,9 +80,11 @@ public:
|
||||
bool CheckBundleDataDirExist() const;
|
||||
bool GetBundleStats(const std::string &bundleName, const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const int32_t uid, const int32_t appIndex = 0,
|
||||
const uint32_t statFlag = 0) const;
|
||||
const uint32_t statFlag = 0, const std::vector<std::string> &moduleNames = {}) const;
|
||||
int32_t GetNativeLibraryFileNames(const std::string &filePath, const std::string &cpuAbi,
|
||||
std::vector<std::string> &fileNames) const;
|
||||
void CreateFile(const std::string &filePath, const std::string &content) const;
|
||||
void DeleteFile(const std::string &filePath) const;
|
||||
private:
|
||||
std::shared_ptr<InstalldService> service_ = std::make_shared<InstalldService>();
|
||||
};
|
||||
@ -204,13 +212,13 @@ bool BmsInstallDaemonTest::CheckBundleDataDirExist() const
|
||||
|
||||
bool BmsInstallDaemonTest::GetBundleStats(const std::string &bundleName, const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const int32_t uid, const int32_t appIndex,
|
||||
const uint32_t statFlag) const
|
||||
const uint32_t statFlag, const std::vector<std::string> &moduleNames) const
|
||||
{
|
||||
if (!service_->IsServiceReady()) {
|
||||
service_->Start();
|
||||
}
|
||||
if (InstalldClient::GetInstance()->GetBundleStats(bundleName, userId, bundleStats,
|
||||
uid, appIndex, statFlag) == ERR_OK) {
|
||||
uid, appIndex, statFlag, moduleNames) == ERR_OK) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -225,6 +233,16 @@ int32_t BmsInstallDaemonTest::GetNativeLibraryFileNames(const std::string &fileP
|
||||
return InstalldClient::GetInstance()->GetNativeLibraryFileNames(filePath, cpuAbi, fileNames);
|
||||
}
|
||||
|
||||
void BmsInstallDaemonTest::CreateFile(const std::string &filePath, const std::string &content) const
|
||||
{
|
||||
SaveStringToFile(filePath, content);
|
||||
}
|
||||
|
||||
void BmsInstallDaemonTest::DeleteFile(const std::string &filePath) const
|
||||
{
|
||||
RemoveFile(filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: Startup_0100
|
||||
* @tc.name: test the start function of the installd service when service is not ready
|
||||
@ -883,14 +901,20 @@ HWTEST_F(BmsInstallDaemonTest, GetBundleStats_0400, Function | SmallTest | Level
|
||||
*/
|
||||
HWTEST_F(BmsInstallDaemonTest, GetBundleStats_0500, Function | SmallTest | Level0)
|
||||
{
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
CreateFile(BUNDLE_EL1_BUNDLE_PUBLIC + "/test.ap", "hello world!");
|
||||
CreateFile(BUNDLE_EL1_DATA_CACHE + "/test.ap", "hello world!");
|
||||
std::vector<int64_t> stats;
|
||||
std::string bunaleName1 = "com.ohos.photos";
|
||||
std::string bunaleName1 = BUNDLE_NAME_STATS;
|
||||
bool result = GetBundleStats(bunaleName1, USERID, stats, 0, 0,
|
||||
OHOS::AppExecFwk::Constants::NoGetBundleStatsFlag::GET_BUNDLE_WITHOUT_INSTALL_SIZE);
|
||||
EXPECT_EQ(result, true);
|
||||
APP_LOGI("GetBundleStats appDataSize: %{public}" PRId64, stats[0]);
|
||||
APP_LOGI("GetBundleStats bundleDataSize: %{public}" PRId64, stats[1]);
|
||||
APP_LOGI("GetBundleStats bundleCacheSize: %{public}" PRId64, stats[4]);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -900,14 +924,20 @@ HWTEST_F(BmsInstallDaemonTest, GetBundleStats_0500, Function | SmallTest | Level
|
||||
*/
|
||||
HWTEST_F(BmsInstallDaemonTest, GetBundleStats_0600, Function | SmallTest | Level0)
|
||||
{
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
CreateFile(BUNDLE_EL1_BUNDLE_PUBLIC + "/test.ap", "hello world!");
|
||||
CreateFile(BUNDLE_EL1_DATA_CACHE + "/test.ap", "hello world!");
|
||||
std::vector<int64_t> stats;
|
||||
std::string bunaleName1 = "com.ohos.photos";
|
||||
std::string bunaleName1 = BUNDLE_NAME_STATS;
|
||||
bool result = GetBundleStats(bunaleName1, USERID, stats, 0, 0,
|
||||
OHOS::AppExecFwk::Constants::NoGetBundleStatsFlag::GET_BUNDLE_WITHOUT_DATA_SIZE);
|
||||
EXPECT_EQ(result, true);
|
||||
APP_LOGI("GetBundleStats appDataSize: %{public}" PRId64, stats[0]);
|
||||
APP_LOGI("GetBundleStats bundleDataSize: %{public}" PRId64, stats[1]);
|
||||
APP_LOGI("GetBundleStats bundleCacheSize: %{public}" PRId64, stats[4]);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -917,14 +947,20 @@ HWTEST_F(BmsInstallDaemonTest, GetBundleStats_0600, Function | SmallTest | Level
|
||||
*/
|
||||
HWTEST_F(BmsInstallDaemonTest, GetBundleStats_0700, Function | SmallTest | Level0)
|
||||
{
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
CreateFile(BUNDLE_EL1_BUNDLE_PUBLIC + "/test.ap", "hello world!");
|
||||
CreateFile(BUNDLE_EL1_DATA_CACHE + "/test.ap", "hello world!");
|
||||
std::vector<int64_t> stats;
|
||||
std::string bunaleName1 = "com.ohos.photos";
|
||||
std::string bunaleName1 = BUNDLE_NAME_STATS;
|
||||
bool result = GetBundleStats(bunaleName1, USERID, stats, 0, 0,
|
||||
OHOS::AppExecFwk::Constants::NoGetBundleStatsFlag::GET_BUNDLE_WITHOUT_CACHE_SIZE);
|
||||
EXPECT_EQ(result, true);
|
||||
APP_LOGI("GetBundleStats appDataSize: %{public}" PRId64, stats[0]);
|
||||
APP_LOGI("GetBundleStats bundleDataSize: %{public}" PRId64, stats[1]);
|
||||
APP_LOGI("GetBundleStats bundleCacheSize: %{public}" PRId64, stats[4]);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -934,8 +970,12 @@ HWTEST_F(BmsInstallDaemonTest, GetBundleStats_0700, Function | SmallTest | Level
|
||||
*/
|
||||
HWTEST_F(BmsInstallDaemonTest, GetBundleStats_0800, Function | SmallTest | Level0)
|
||||
{
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
CreateFile(BUNDLE_EL1_BUNDLE_PUBLIC + "/test.ap", "hello world!");
|
||||
CreateFile(BUNDLE_EL1_DATA_CACHE + "/test.ap", "hello world!");
|
||||
std::vector<int64_t> stats;
|
||||
std::string bunaleName1 = "com.ohos.photos";
|
||||
std::string bunaleName1 = BUNDLE_NAME_STATS;
|
||||
bool result = GetBundleStats(bunaleName1, USERID, stats, 0, 0,
|
||||
OHOS::AppExecFwk::Constants::NoGetBundleStatsFlag::GET_BUNDLE_WITHOUT_CACHE_SIZE |
|
||||
OHOS::AppExecFwk::Constants::NoGetBundleStatsFlag::GET_BUNDLE_WITHOUT_DATA_SIZE);
|
||||
@ -943,6 +983,8 @@ HWTEST_F(BmsInstallDaemonTest, GetBundleStats_0800, Function | SmallTest | Level
|
||||
APP_LOGI("GetBundleStats appDataSize: %{public}" PRId64, stats[0]);
|
||||
APP_LOGI("GetBundleStats bundleDataSize: %{public}" PRId64, stats[1]);
|
||||
APP_LOGI("GetBundleStats bundleCacheSize: %{public}" PRId64, stats[4]);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -952,8 +994,12 @@ HWTEST_F(BmsInstallDaemonTest, GetBundleStats_0800, Function | SmallTest | Level
|
||||
*/
|
||||
HWTEST_F(BmsInstallDaemonTest, GetBundleStats_0900, Function | SmallTest | Level0)
|
||||
{
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
CreateFile(BUNDLE_EL1_BUNDLE_PUBLIC + "/test.ap", "hello world!");
|
||||
CreateFile(BUNDLE_EL1_DATA_CACHE + "/test.ap", "hello world!");
|
||||
std::vector<int64_t> stats;
|
||||
std::string bunaleName1 = "com.ohos.photos";
|
||||
std::string bunaleName1 = BUNDLE_NAME_STATS;
|
||||
bool result = GetBundleStats(bunaleName1, USERID, stats, 0, 0,
|
||||
OHOS::AppExecFwk::Constants::NoGetBundleStatsFlag::GET_BUNDLE_WITHOUT_INSTALL_SIZE |
|
||||
OHOS::AppExecFwk::Constants::NoGetBundleStatsFlag::GET_BUNDLE_WITHOUT_DATA_SIZE);
|
||||
@ -961,6 +1007,8 @@ HWTEST_F(BmsInstallDaemonTest, GetBundleStats_0900, Function | SmallTest | Level
|
||||
APP_LOGI("GetBundleStats appDataSize: %{public}" PRId64, stats[0]);
|
||||
APP_LOGI("GetBundleStats bundleDataSize: %{public}" PRId64, stats[1]);
|
||||
APP_LOGI("GetBundleStats bundleCacheSize: %{public}" PRId64, stats[4]);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -970,8 +1018,12 @@ HWTEST_F(BmsInstallDaemonTest, GetBundleStats_0900, Function | SmallTest | Level
|
||||
*/
|
||||
HWTEST_F(BmsInstallDaemonTest, GetBundleStats_1000, Function | SmallTest | Level0)
|
||||
{
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
CreateFile(BUNDLE_EL1_BUNDLE_PUBLIC + "/test.ap", "hello world!");
|
||||
CreateFile(BUNDLE_EL1_DATA_CACHE + "/test.ap", "hello world!");
|
||||
std::vector<int64_t> stats;
|
||||
std::string bunaleName1 = "com.ohos.photos";
|
||||
std::string bunaleName1 = BUNDLE_NAME_STATS;
|
||||
bool result = GetBundleStats(bunaleName1, USERID, stats, 0, 0,
|
||||
OHOS::AppExecFwk::Constants::NoGetBundleStatsFlag::GET_BUNDLE_WITHOUT_INSTALL_SIZE |
|
||||
OHOS::AppExecFwk::Constants::NoGetBundleStatsFlag::GET_BUNDLE_WITHOUT_DATA_SIZE |
|
||||
@ -980,6 +1032,8 @@ HWTEST_F(BmsInstallDaemonTest, GetBundleStats_1000, Function | SmallTest | Level
|
||||
APP_LOGI("GetBundleStats appDataSize: %{public}" PRId64, stats[0]);
|
||||
APP_LOGI("GetBundleStats bundleDataSize: %{public}" PRId64, stats[1]);
|
||||
APP_LOGI("GetBundleStats bundleCacheSize: %{public}" PRId64, stats[4]);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -989,14 +1043,20 @@ HWTEST_F(BmsInstallDaemonTest, GetBundleStats_1000, Function | SmallTest | Level
|
||||
*/
|
||||
HWTEST_F(BmsInstallDaemonTest, GetBundleStats_1100, Function | SmallTest | Level0)
|
||||
{
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
CreateFile(BUNDLE_EL1_BUNDLE_PUBLIC + "/test.ap", "hello world!");
|
||||
CreateFile(BUNDLE_EL1_DATA_CACHE + "/test.ap", "hello world!");
|
||||
std::vector<int64_t> stats;
|
||||
std::string bunaleName1 = "com.ohos.photos";
|
||||
std::string bunaleName1 = BUNDLE_NAME_STATS;
|
||||
bool result = GetBundleStats(bunaleName1, USERID, stats, 0, 0,
|
||||
OHOS::AppExecFwk::Constants::NoGetBundleStatsFlag::GET_BUNDLE_WITH_ALL_SIZE);
|
||||
EXPECT_EQ(result, true);
|
||||
APP_LOGI("GetBundleStats appDataSize: %{public}" PRId64, stats[0]);
|
||||
APP_LOGI("GetBundleStats bundleDataSize: %{public}" PRId64, stats[1]);
|
||||
APP_LOGI("GetBundleStats bundleCacheSize: %{public}" PRId64, stats[4]);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1006,8 +1066,12 @@ HWTEST_F(BmsInstallDaemonTest, GetBundleStats_1100, Function | SmallTest | Level
|
||||
*/
|
||||
HWTEST_F(BmsInstallDaemonTest, GetBundleStats_1200, Function | SmallTest | Level0)
|
||||
{
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
CreateFile(BUNDLE_EL1_BUNDLE_PUBLIC + "/test.ap", "hello world!");
|
||||
CreateFile(BUNDLE_EL1_DATA_CACHE + "/test.ap", "hello world!");
|
||||
std::vector<int64_t> stats;
|
||||
std::string bunaleName1 = "com.ohos.photos";
|
||||
std::string bunaleName1 = BUNDLE_NAME_STATS;
|
||||
bool result = GetBundleStats(bunaleName1, USERID, stats, 0, 0,
|
||||
OHOS::AppExecFwk::Constants::NoGetBundleStatsFlag::GET_BUNDLE_WITH_ALL_SIZE |
|
||||
OHOS::AppExecFwk::Constants::NoGetBundleStatsFlag::GET_BUNDLE_WITHOUT_INSTALL_SIZE);
|
||||
@ -1015,6 +1079,8 @@ HWTEST_F(BmsInstallDaemonTest, GetBundleStats_1200, Function | SmallTest | Level
|
||||
APP_LOGI("GetBundleStats appDataSize: %{public}" PRId64, stats[0]);
|
||||
APP_LOGI("GetBundleStats bundleDataSize: %{public}" PRId64, stats[1]);
|
||||
APP_LOGI("GetBundleStats bundleCacheSize: %{public}" PRId64, stats[4]);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1024,13 +1090,78 @@ HWTEST_F(BmsInstallDaemonTest, GetBundleStats_1200, Function | SmallTest | Level
|
||||
*/
|
||||
HWTEST_F(BmsInstallDaemonTest, GetBundleStats_1300, Function | SmallTest | Level0)
|
||||
{
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
CreateFile(BUNDLE_EL1_BUNDLE_PUBLIC + "/test.ap", "hello world!");
|
||||
CreateFile(BUNDLE_EL1_DATA_CACHE + "/test.ap", "hello world!");
|
||||
std::vector<int64_t> stats;
|
||||
std::string bunaleName1 = "com.ohos.photos";
|
||||
std::string bunaleName1 = BUNDLE_NAME_STATS;
|
||||
bool result = GetBundleStats(bunaleName1, USERID, stats, 0, 0, 0);
|
||||
EXPECT_EQ(result, true);
|
||||
APP_LOGI("GetBundleStats appDataSize: %{public}" PRId64, stats[0]);
|
||||
APP_LOGI("GetBundleStats bundleDataSize: %{public}" PRId64, stats[1]);
|
||||
APP_LOGI("GetBundleStats bundleCacheSize: %{public}" PRId64, stats[4]);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetBundleStats_1400
|
||||
* @tc.name: test the GetBundleStats function of installd service
|
||||
* @tc.desc: 1. the bundle exists,
|
||||
*/
|
||||
HWTEST_F(BmsInstallDaemonTest, GetBundleStats_1400, Function | SmallTest | Level0)
|
||||
{
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL2_DATA_MODULE_CACHE);
|
||||
CreateFile(BUNDLE_EL1_BUNDLE_PUBLIC + "/test.ap", "hello world!");
|
||||
CreateFile(BUNDLE_EL1_DATA_CACHE + "/test.ap", "hello world!");
|
||||
CreateFile(BUNDLE_EL2_DATA_MODULE_CACHE + "/test.ap", "hello world!");
|
||||
std::vector<int64_t> stats;
|
||||
std::string bunaleName1 = BUNDLE_NAME_STATS;
|
||||
std::vector<std::string> moduleNameList = {"entry2"};
|
||||
bool result = GetBundleStats(bunaleName1, USERID, stats, 0, 0,
|
||||
OHOS::AppExecFwk::Constants::NoGetBundleStatsFlag::GET_BUNDLE_WITH_ALL_SIZE,
|
||||
moduleNameList);
|
||||
EXPECT_EQ(result, true);
|
||||
APP_LOGI("GetBundleStats appDataSize: %{public}" PRId64, stats[0]);
|
||||
APP_LOGI("GetBundleStats bundleDataSize: %{public}" PRId64, stats[1]);
|
||||
APP_LOGI("GetBundleStats bundleCacheSize: %{public}" PRId64, stats[4]);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL2_DATA_MODULE_CACHE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetBundleStats_1500
|
||||
* @tc.name: test the GetBundleStats function of installd service
|
||||
* @tc.desc: 1. the bundle exists,
|
||||
*/
|
||||
HWTEST_F(BmsInstallDaemonTest, GetBundleStats_1500, Function | SmallTest | Level0)
|
||||
{
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL2_DATA_MODULE_CACHE);
|
||||
OHOS::ForceCreateDirectory(BUNDLE_EL5_DATA_MODULE_CACHE);
|
||||
CreateFile(BUNDLE_EL1_BUNDLE_PUBLIC + "/test.ap", "hello world!");
|
||||
CreateFile(BUNDLE_EL1_DATA_CACHE + "/test.ap", "hello world!");
|
||||
CreateFile(BUNDLE_EL2_DATA_MODULE_CACHE + "/test.ap", "hello world!");
|
||||
CreateFile(BUNDLE_EL5_DATA_MODULE_CACHE + "/test.ap", "hello world!");
|
||||
std::vector<int64_t> stats;
|
||||
std::string bunaleName1 = BUNDLE_NAME_STATS;
|
||||
std::vector<std::string> moduleNameList = {"entry5", "entry2"};
|
||||
bool result = GetBundleStats(bunaleName1, USERID, stats, 0, 0,
|
||||
OHOS::AppExecFwk::Constants::NoGetBundleStatsFlag::GET_BUNDLE_WITH_ALL_SIZE,
|
||||
moduleNameList);
|
||||
EXPECT_EQ(result, true);
|
||||
APP_LOGI("GetBundleStats appDataSize: %{public}" PRId64, stats[0]);
|
||||
APP_LOGI("GetBundleStats bundleDataSize: %{public}" PRId64, stats[1]);
|
||||
APP_LOGI("GetBundleStats bundleCacheSize: %{public}" PRId64, stats[4]);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_BUNDLE_PUBLIC);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL1_DATA_CACHE);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL2_DATA_MODULE_CACHE);
|
||||
OHOS::ForceRemoveDirectory(BUNDLE_EL5_DATA_MODULE_CACHE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -601,7 +601,7 @@ HWTEST_F(BmsInstalldClientTest, BmsInstalldClientTest_GetBundleStats_0100, TestS
|
||||
std::string bundleName = EMPTY_STRING;
|
||||
int userId = USERID;
|
||||
std::vector<int64_t> bundleStats;
|
||||
ErrCode result = installClient_->GetBundleStats(bundleName, userId, bundleStats, 0, 0);
|
||||
ErrCode result = installClient_->GetBundleStats(bundleName, userId, bundleStats, 0, 0, 0, {});
|
||||
EXPECT_EQ(result, ERR_APPEXECFWK_INSTALLD_PARAM_ERROR);
|
||||
GTEST_LOG_(INFO) << "BmsInstalldClientTest_GetBundleStats_0100 end";
|
||||
}
|
||||
@ -617,9 +617,10 @@ HWTEST_F(BmsInstalldClientTest, BmsInstalldClientTest_GetBundleStats_0200, TestS
|
||||
std::string bundleName = BUNDLE_NAME;
|
||||
int userId = USERID;
|
||||
std::vector<int64_t> bundleStats;
|
||||
ErrCode result = installClient_->GetBundleStats(bundleName, userId, bundleStats, 0, 0);
|
||||
std::vector<std::string> moduleNameList = {};
|
||||
ErrCode result = installClient_->GetBundleStats(bundleName, userId, bundleStats, 0, 0, 0);
|
||||
EXPECT_EQ(result, installClient_->CallService(&IInstalld::GetBundleStats,
|
||||
bundleName, userId, bundleStats, 0, 0, 0));
|
||||
bundleName, userId, bundleStats, 0, 0, 0, moduleNameList));
|
||||
GTEST_LOG_(INFO) << "BmsInstalldClientTest_GetBundleStats_0200 end";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user