Signed-off-by: wkljy <wangkailong6@huawei.com>
This commit is contained in:
wkljy
2026-01-30 19:10:56 +08:00
parent 5965e1c85c
commit 79c4152333
25 changed files with 250 additions and 86 deletions
@@ -613,6 +613,20 @@ ErrCode BundleMgrHelper::GetBundleInfoV9(
return bundleMgr->GetBundleInfoV9(bundleName, flags, bundleInfo, userId);
}
ErrCode BundleMgrHelper::GetBundleInfosV9(int32_t flags,
std::vector<BundleInfo> &bundleInfos, int32_t userId)
{
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "called");
auto bundleMgr = Connect();
if (bundleMgr == nullptr) {
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "null bundleMgr");
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
}
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
return bundleMgr->GetBundleInfos(flags, bundleInfos, userId);
}
bool BundleMgrHelper::GetApplicationInfo(
const std::string &appName, const ApplicationFlag flag, const int32_t userId, ApplicationInfo &appInfo)
{
@@ -72,6 +72,7 @@ public:
std::vector<ExtensionAbilityInfo> &extensionInfos);
ErrCode GetBundleInfoV9(
const std::string &bundleName, int32_t flags, BundleInfo &bundleInfo, int32_t userId);
ErrCode GetBundleInfosV9(int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId);
bool GetApplicationInfo(
const std::string &appName, const ApplicationFlag flag, const int32_t userId, ApplicationInfo &appInfo);
bool GetApplicationInfo(const std::string &appName, int32_t flags, int32_t userId, ApplicationInfo &appInfo);
@@ -48,16 +48,18 @@ public:
void GetConfigInsightIntentInfo(const std::string &bundleName, const std::string &moduleName,
const std::string &intentName, const int32_t userId, InsightIntentInfo &info);
int32_t SaveInsightIntentTotalInfo(const std::string &bundleName, const std::string &moduleName,
const int32_t userId, ExtractInsightIntentProfileInfoVec profileInfos,
const int32_t userId, uint32_t versionCode, ExtractInsightIntentProfileInfoVec profileInfos,
std::vector<InsightIntentInfo> configInfos);
int32_t DeleteInsightIntentTotalInfo(const std::string &bundleName,
const std::string &moduleName, const int32_t userId);
int32_t DeleteInsightIntentByUserId(const int32_t userId);
bool HasInsightIntentByName(uint32_t versionCode, const std::string &bundleName, const int32_t userId);
void BackupRdb();
private:
int32_t userId_ = -1;
mutable std::mutex genericInfosMutex_;
std::map<std::string, std::vector<ExtractInsightIntentGenericInfo>> intentGenericInfos_;
std::map<std::string, std::string> bundleVersionMap_;
};
} // namespace AbilityRuntime
} // namespace OHOS
@@ -28,7 +28,7 @@ namespace AbilityRuntime {
class InsightRdbStorageMgr : public std::enable_shared_from_this<InsightRdbStorageMgr> {
DECLARE_DELAYED_SINGLETON(InsightRdbStorageMgr)
public:
int32_t LoadInsightIntentInfos(const int32_t userId,
int32_t LoadInsightIntentInfos(const int32_t userId, std::map<std::string, std::string> &bundleVersionMap,
std::vector<ExtractInsightIntentInfo> &totalInfos, std::vector<InsightIntentInfo> &configInfos);
int32_t LoadConfigInsightIntentInfos(
const int32_t userId, std::vector<InsightIntentInfo> &configInfos);
@@ -41,7 +41,7 @@ public:
int32_t LoadConfigInsightIntentInfo(const std::string &bundleName, const std::string &moduleName,
const std::string &intentName, const int32_t userId, InsightIntentInfo &totalInfo);
int32_t SaveStorageInsightIntentData(const std::string &bundleName, const std::string &moduleName,
const int32_t userId, ExtractInsightIntentProfileInfoVec &profileInfos,
const int32_t userId, uint32_t versionCode, ExtractInsightIntentProfileInfoVec &profileInfos,
std::vector<InsightIntentInfo> &configInfos);
int32_t DeleteStorageInsightIntentData(const std::string &bundleName,
const std::string &moduleName, const int32_t userId);
@@ -31,7 +31,8 @@ public:
void OnReceiveEvent(const EventFwk::CommonEventData &data) override;
private:
void SaveInsightIntentInfos(const std::string &bundleName, const std::string &moduleName, int32_t userId);
void SaveInsightIntentInfos(const std::string &bundleName, const std::string &moduleName,
uint32_t versionCode, int32_t userId);
void LoadInsightIntentInfos(int32_t userId = -1);
void DeleteInsightIntentInfoByUserId(int32_t userId);
void HandleBundleScanFinished();
@@ -654,7 +654,7 @@ bool ExtractInsightIntentProfile::TransformTo(const std::string &profileStr,
}
}
TAG_LOGI(AAFwkTag::INTENT, "transform success, size: %{public}zu", intentInfos.insightIntents.size());
TAG_LOGD(AAFwkTag::INTENT, "transform success, size: %{public}zu", intentInfos.insightIntents.size());
return true;
}
@@ -33,7 +33,7 @@ int32_t InsightIntentDbCache::InitInsightIntentCache(const int32_t userId)
configInfos.clear();
intentGenericInfos_.clear();
if (DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadInsightIntentInfos(
userId, totalInfos, configInfos) != ERR_OK) {
userId, bundleVersionMap_, totalInfos, configInfos) != ERR_OK) {
TAG_LOGE(AAFwkTag::INTENT, "Load All IntentData failed");
return ERR_INVALID_VALUE;
}
@@ -55,7 +55,8 @@ InsightIntentDbCache::~InsightIntentDbCache()
{}
int32_t InsightIntentDbCache::SaveInsightIntentTotalInfo(const std::string &bundleName, const std::string &moduleName,
const int32_t userId, ExtractInsightIntentProfileInfoVec profileInfos, std::vector<InsightIntentInfo> configInfos)
const int32_t userId, uint32_t versionCode, ExtractInsightIntentProfileInfoVec profileInfos,
std::vector<InsightIntentInfo> configInfos)
{
std::lock_guard<std::mutex> lock(genericInfosMutex_);
if (userId != userId_) {
@@ -83,6 +84,7 @@ int32_t InsightIntentDbCache::SaveInsightIntentTotalInfo(const std::string &bund
} else {
intentGenericInfos_[bundleName] = genericInfos;
}
bundleVersionMap_[bundleName] = std::to_string(versionCode);
int32_t res = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->DeleteStorageInsightIntentData(bundleName,
moduleName, userId);
if (res != ERR_OK) {
@@ -90,7 +92,7 @@ int32_t InsightIntentDbCache::SaveInsightIntentTotalInfo(const std::string &bund
return res;
}
return DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->SaveStorageInsightIntentData(
bundleName, moduleName, userId, profileInfos, configInfos);
bundleName, moduleName, userId, versionCode, profileInfos, configInfos);
}
int32_t InsightIntentDbCache::DeleteInsightIntentTotalInfo(const std::string &bundleName,
@@ -103,7 +105,8 @@ int32_t InsightIntentDbCache::DeleteInsightIntentTotalInfo(const std::string &bu
}
if (moduleName.empty()) {
intentGenericInfos_.erase(bundleName);
} else {
bundleVersionMap_.erase(bundleName);
} else if (intentGenericInfos_.find(bundleName) != intentGenericInfos_.end()) {
for (auto iter = intentGenericInfos_[bundleName].begin(); iter != intentGenericInfos_[bundleName].end();) {
if (iter->moduleName == moduleName) {
iter = intentGenericInfos_[bundleName].erase(iter);
@@ -111,6 +114,10 @@ int32_t InsightIntentDbCache::DeleteInsightIntentTotalInfo(const std::string &bu
iter++;
}
}
if (intentGenericInfos_[bundleName].size() == 0) {
intentGenericInfos_.erase(bundleName);
bundleVersionMap_.erase(bundleName);
}
}
return DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->DeleteStorageInsightIntentData(bundleName,
moduleName, userId);
@@ -126,6 +133,22 @@ int32_t InsightIntentDbCache::DeleteInsightIntentByUserId(const int32_t userId)
return DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->DeleteStorageInsightIntentByUserId(userId);
}
bool InsightIntentDbCache::HasInsightIntentByName(uint32_t versionCode,
const std::string &bundleName, const int32_t userId)
{
std::lock_guard<std::mutex> lock(genericInfosMutex_);
if (userId != userId_) {
TAG_LOGW(AAFwkTag::INTENT, "error userId %{public}d.", userId_);
return false;
}
if (bundleVersionMap_.find(bundleName) != bundleVersionMap_.end() &&
bundleVersionMap_[bundleName].compare(std::to_string(versionCode)) == 0) {
return true;
}
TAG_LOGD(AAFwkTag::INTENT, "null bundleName %{public}s", bundleName.c_str());
return false;
}
void InsightIntentDbCache::GetAllInsightIntentGenericInfo(const int32_t userId,
std::vector<ExtractInsightIntentGenericInfo> &genericInfos)
{
@@ -139,8 +162,9 @@ void InsightIntentDbCache::GetAllInsightIntentGenericInfo(const int32_t userId,
std::vector<ExtractInsightIntentInfo> totalInfos;
std::vector<InsightIntentInfo> configInfos;
if (DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadInsightIntentInfos(userId, totalInfos,
configInfos) != ERR_OK) {
std::map<std::string, std::string> bundleVersionMap;
if (DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadInsightIntentInfos(userId,
bundleVersionMap, totalInfos, configInfos) != ERR_OK) {
TAG_LOGE(AAFwkTag::INTENT, "Load All IntentData failed");
return;
}
@@ -155,7 +179,9 @@ void InsightIntentDbCache::GetInsightIntentGenericInfoByName(const std::string &
{
if (userId == userId_) {
std::lock_guard<std::mutex> lock(genericInfosMutex_);
genericInfos = intentGenericInfos_[bundleName];
if (intentGenericInfos_.find(bundleName) != intentGenericInfos_.end()) {
genericInfos = intentGenericInfos_[bundleName];
}
return;
}
@@ -177,6 +203,9 @@ void InsightIntentDbCache::GetInsightIntentGenericInfo(const std::string &bundle
{
if (userId == userId_) {
std::lock_guard<std::mutex> lock(genericInfosMutex_);
if (intentGenericInfos_.find(bundleName) == intentGenericInfos_.end()) {
return;
}
for (auto info : intentGenericInfos_[bundleName]) {
if (info.moduleName == moduleName && info.intentName == intentName) {
genericInfo = info;
@@ -198,8 +227,9 @@ void InsightIntentDbCache::GetAllInsightIntentInfo(const int32_t userId, std::ve
std::vector<InsightIntentInfo> &configInfos)
{
std::lock_guard<std::mutex> lock(genericInfosMutex_);
if (DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadInsightIntentInfos(
userId, infos, configInfos) != ERR_OK) {
std::map<std::string, std::string> bundleVersionMap;
if (DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadInsightIntentInfos(userId,
bundleVersionMap, infos, configInfos) != ERR_OK) {
TAG_LOGE(AAFwkTag::INTENT, "LoadIntentData failed");
return;
}
@@ -73,7 +73,12 @@ void InsightIntentEventMgr::UpdateInsightIntentEvent(const AppExecFwk::ElementNa
TAG_LOGE(AAFwkTag::INTENT, "get bundleMgrHelper instance failed");
return;
}
AppExecFwk::BundleInfo bundleInfo;
if (!IN_PROCESS_CALL(bundleMgrHelper->GetBundleInfoV9(bundleName,
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_DEFAULT), bundleInfo, userId))) {
TAG_LOGE(AAFwkTag::INTENT, "get bundle info failed");
return;
}
OHOS::SplitStr(moduleName, ",", moduleNameVec);
for (std::string moduleNameLocal : moduleNameVec) { // Get json profile firstly
ret = IN_PROCESS_CALL(bundleMgrHelper->GetJsonProfile(AppExecFwk::INTENT_PROFILE,
@@ -97,7 +102,7 @@ void InsightIntentEventMgr::UpdateInsightIntentEvent(const AppExecFwk::ElementNa
// save database
DelayedSingleton<AbilityRuntime::InsightIntentDbCache>::GetInstance()->SaveInsightIntentTotalInfo(
bundleName, moduleNameLocal, userId, infos, configIntentInfos);
bundleName, moduleNameLocal, userId, bundleInfo.versionCode, infos, configIntentInfos);
}
DelayedSingleton<AbilityRuntime::InsightIntentDbCache>::GetInstance()->BackupRdb();
});
@@ -15,9 +15,13 @@
#include "insight_intent_rdb_storage_mgr.h"
#include "nlohmann/json.hpp"
#include <sstream>
namespace OHOS {
namespace AbilityRuntime {
const int32_t BUNDLE_NAME = 1;
const int32_t VERSION = 4;
const int32_t INTENT_KEY_LENGTH = 5;
InsightRdbStorageMgr::InsightRdbStorageMgr()
{
}
@@ -27,8 +31,21 @@ InsightRdbStorageMgr::~InsightRdbStorageMgr()
TAG_LOGD(AAFwkTag::INTENT, "InsightRdbStorageMgr is deleted");
}
std::vector<std::string> SplitStringBySlash(const std::string& inputStr)
{
std::vector<std::string> result;
std::stringstream ss(inputStr);
std::string tempStr;
while (std::getline(ss, tempStr, '/')) {
result.push_back(tempStr);
}
return result;
}
int32_t InsightRdbStorageMgr::LoadInsightIntentInfos(const int32_t userId,
std::vector<ExtractInsightIntentInfo> &totalInfos, std::vector<InsightIntentInfo> &configInfos)
std::map<std::string, std::string> &bundleVersionMap, std::vector<ExtractInsightIntentInfo> &totalInfos,
std::vector<InsightIntentInfo> &configInfos)
{
TAG_LOGD(AAFwkTag::INTENT, "InsightRdbStorageMgr load all intent total infos");
std::unordered_map<std::string, std::string> value;
@@ -39,6 +56,13 @@ int32_t InsightRdbStorageMgr::LoadInsightIntentInfos(const int32_t userId,
return ERR_INVALID_VALUE;
}
Transform(value, totalInfos, configInfos);
for (const auto &item : value) {
std::vector<std::string> res = SplitStringBySlash(item.first);
if (res.size() < INTENT_KEY_LENGTH) {
continue;
}
bundleVersionMap[res[BUNDLE_NAME]] = res[VERSION];
}
return ERR_OK;
}
@@ -92,18 +116,19 @@ int32_t InsightRdbStorageMgr::LoadInsightIntentInfo(const std::string &bundleNam
const std::string &intentName, const int32_t userId, ExtractInsightIntentInfo &totalInfo)
{
TAG_LOGD(AAFwkTag::INTENT, "InsightRdbStorageMgr load intent total info");
std::string value;
std::unordered_map<std::string, std::string> value;
std::string key = std::to_string(userId).append("/").append(bundleName).append("/")
.append(moduleName).append("/").append(intentName);
bool result = DelayedSingleton<InsightIntentRdbDataMgr>::GetInstance()->QueryData(key, value);
if (!result) {
bool result = DelayedSingleton<InsightIntentRdbDataMgr>::GetInstance()->QueryDataBeginWithKey(key, value);
if (!result || value.size() == 0) {
TAG_LOGW(AAFwkTag::INTENT, "get entries error");
return ERR_INVALID_VALUE;
}
ExtractInsightIntentProfileInfoVec profileInfos;
if (!ExtractInsightIntentProfile::TransformTo(value, profileInfos)) {
//only one intent
if (!ExtractInsightIntentProfile::TransformTo(value.begin()->second, profileInfos)) {
TAG_LOGE(AAFwkTag::INTENT, "error key: %{private}s", key.c_str());
DelayedSingleton<InsightIntentRdbDataMgr>::GetInstance()->DeleteData(key);
DelayedSingleton<InsightIntentRdbDataMgr>::GetInstance()->DeleteDataBeginWithKey(key);
}
for (const auto &profileInfo : profileInfos.insightIntents) {
if (!ExtractInsightIntentProfile::ProfileInfoFormat(profileInfo, totalInfo)) {
@@ -117,18 +142,19 @@ int32_t InsightRdbStorageMgr::LoadConfigInsightIntentInfo(const std::string &bun
const std::string &intentName, const int32_t userId, InsightIntentInfo &totalInfo)
{
TAG_LOGD(AAFwkTag::INTENT, "InsightRdbStorageMgr load intent total info");
std::string value;
std::unordered_map<std::string, std::string> value;
std::string key = std::to_string(userId).append("/").append(bundleName).append("/")
.append(moduleName).append("/").append(intentName);
bool result = DelayedSingleton<InsightIntentRdbDataMgr>::GetInstance()->QueryData(key, value);
if (!result) {
bool result = DelayedSingleton<InsightIntentRdbDataMgr>::GetInstance()->QueryDataBeginWithKey(key, value);
if (!result || value.size() == 0) {
TAG_LOGW(AAFwkTag::INTENT, "get entries error");
return ERR_INVALID_VALUE;
}
std::vector<InsightIntentInfo> configIntentInfos;
if (!InsightIntentProfile::TransformTo(value, configIntentInfos)) {
//only one intent
if (!InsightIntentProfile::TransformTo(value.begin()->second, configIntentInfos)) {
TAG_LOGE(AAFwkTag::INTENT, "error key: %{private}s", key.c_str());
DelayedSingleton<InsightIntentRdbDataMgr>::GetInstance()->DeleteData(key);
DelayedSingleton<InsightIntentRdbDataMgr>::GetInstance()->DeleteDataBeginWithKey(key);
}
for (const auto &configInfo : configIntentInfos) {
totalInfo = configInfo;
@@ -144,7 +170,7 @@ void InsightRdbStorageMgr::TransformConfigIntent(std::unordered_map<std::string,
std::vector<InsightIntentInfo> configIntentInfos;
if (!InsightIntentProfile::TransformTo(item.second, configIntentInfos)) {
TAG_LOGE(AAFwkTag::INTENT, "error key: %{private}s", item.first.c_str());
DelayedSingleton<InsightIntentRdbDataMgr>::GetInstance()->DeleteData(item.first);
DelayedSingleton<InsightIntentRdbDataMgr>::GetInstance()->DeleteDataBeginWithKey(item.first);
}
for (const auto &configIntentInfo : configIntentInfos) {
configInfos.emplace_back(configIntentInfo);
@@ -159,7 +185,8 @@ void InsightRdbStorageMgr::Transform(std::unordered_map<std::string, std::string
ExtractInsightIntentProfileInfoVec profileInfos;
if (!ExtractInsightIntentProfile::TransformTo(item.second, profileInfos)) {
TAG_LOGE(AAFwkTag::INTENT, "error key: %{private}s", item.first.c_str());
DelayedSingleton<InsightIntentRdbDataMgr>::GetInstance()->DeleteData(item.first);
DelayedSingleton<InsightIntentRdbDataMgr>::GetInstance()->DeleteDataBeginWithKey(item.first);
continue;
}
for (const auto &profileInfo : profileInfos.insightIntents) {
ExtractInsightIntentInfo totalInfo;
@@ -173,7 +200,8 @@ void InsightRdbStorageMgr::Transform(std::unordered_map<std::string, std::string
std::vector<InsightIntentInfo> configIntentInfos;
if (!InsightIntentProfile::TransformTo(item.second, configIntentInfos)) {
TAG_LOGE(AAFwkTag::INTENT, "error key: %{private}s", item.first.c_str());
DelayedSingleton<InsightIntentRdbDataMgr>::GetInstance()->DeleteData(item.first);
DelayedSingleton<InsightIntentRdbDataMgr>::GetInstance()->DeleteDataBeginWithKey(item.first);
continue;
}
for (const auto &configIntentInfo : configIntentInfos) {
configInfos.emplace_back(configIntentInfo);
@@ -182,12 +210,13 @@ void InsightRdbStorageMgr::Transform(std::unordered_map<std::string, std::string
}
int32_t InsightRdbStorageMgr::SaveStorageInsightIntentData(const std::string &bundleName, const std::string &moduleName,
const int32_t userId, ExtractInsightIntentProfileInfoVec &profileInfos, std::vector<InsightIntentInfo> &configInfos)
const int32_t userId, uint32_t versionCode, ExtractInsightIntentProfileInfoVec &profileInfos,
std::vector<InsightIntentInfo> &configInfos)
{
std::lock_guard<std::mutex> lock(rdbStorePtrMutex_);
for (auto profileInfo : profileInfos.insightIntents) {
std::string key = std::to_string(userId).append("/").append(bundleName).append("/")
.append(moduleName).append("/").append(profileInfo.intentName);
std::string key = std::to_string(userId).append("/").append(bundleName).append("/").append(moduleName).
append("/").append(profileInfo.intentName).append("/").append(std::to_string(versionCode));
nlohmann::json jsonObject;
if (!ExtractInsightIntentProfile::ToJson(profileInfo, jsonObject)) {
TAG_LOGE(AAFwkTag::INTENT, "Transform error, key: %{private}s", key.c_str());
@@ -199,8 +228,8 @@ int32_t InsightRdbStorageMgr::SaveStorageInsightIntentData(const std::string &bu
}
}
for (auto configInfo : configInfos) {
std::string key = std::to_string(userId).append("/").append(bundleName).append("/")
.append(moduleName).append("/").append(configInfo.intentName);
std::string key = std::to_string(userId).append("/").append(bundleName).append("/").append(moduleName).
append("/").append(configInfo.intentName).append("/").append(std::to_string(versionCode));
nlohmann::json jsonObject;
configInfo.moduleName = moduleName;
configInfo.bundleName = bundleName;
@@ -37,7 +37,7 @@ InsightIntentSysEventReceiver::InsightIntentSysEventReceiver(const EventFwk::Com
}
void InsightIntentSysEventReceiver::SaveInsightIntentInfos(const std::string &bundleName, const std::string &moduleName,
int32_t userId)
uint32_t versionCode, int32_t userId)
{
std::vector<std::string> moduleNameVec;
std::string profile;
@@ -75,7 +75,7 @@ void InsightIntentSysEventReceiver::SaveInsightIntentInfos(const std::string &bu
// save database
ret = DelayedSingleton<AbilityRuntime::InsightIntentDbCache>::GetInstance()->SaveInsightIntentTotalInfo(
bundleName, moduleNameLocal, userId, infos, configIntentInfos);
bundleName, moduleNameLocal, userId, versionCode, infos, configIntentInfos);
if (ret != ERR_OK) {
TAG_LOGE(AAFwkTag::INTENT, "save intent info failed, bundleName: %{public}s, moduleName: %{public}s, "
"userId: %{public}d", bundleName.c_str(), moduleNameLocal.c_str(), userId);
@@ -103,7 +103,6 @@ void InsightIntentSysEventReceiver::LoadInsightIntentInfos(int32_t userId)
if (DelayedSingleton<AbilityRuntime::InsightIntentDbCache>::GetInstance()->
InitInsightIntentCache(userId) == ERR_OK) {
TAG_LOGI(AAFwkTag::INTENT, "Load intent from db success");
return;
}
auto bundleMgrHelper = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
@@ -113,24 +112,29 @@ void InsightIntentSysEventReceiver::LoadInsightIntentInfos(int32_t userId)
}
std::vector<AppExecFwk::BundleInfo> bundleInfos {};
if (!IN_PROCESS_CALL(bundleMgrHelper->GetBundleInfos(AppExecFwk::BundleFlag::GET_BUNDLE_WITH_ABILITIES, bundleInfos,
userId))) {
if (!IN_PROCESS_CALL(bundleMgrHelper->GetBundleInfosV9(
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE),
bundleInfos, userId))) {
TAG_LOGE(AAFwkTag::INTENT, "get bundle info failed");
return;
}
TAG_LOGI(AAFwkTag::INTENT, "bundleInfos size: %{public}zu", bundleInfos.size());
bool hasIntent = false;
bool hasNewIntent = false;
for (auto &bundleInfo : bundleInfos) {
if (DelayedSingleton<AbilityRuntime::InsightIntentDbCache>::GetInstance()->
HasInsightIntentByName(bundleInfo.versionCode, bundleInfo.name, userId)) {
continue;
}
for (const auto &hapInfo : bundleInfo.hapModuleInfos) {
if (!hapInfo.hasIntent) {
continue;
}
SaveInsightIntentInfos(bundleInfo.name, hapInfo.moduleName, userId);
hasIntent = true;
SaveInsightIntentInfos(bundleInfo.name, hapInfo.moduleName, bundleInfo.versionCode, userId);
hasNewIntent = true;
}
}
if (hasIntent) {
if (hasNewIntent) {
DelayedSingleton<AbilityRuntime::InsightIntentDbCache>::GetInstance()->BackupRdb();
}
}
@@ -29,6 +29,7 @@ using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace {
constexpr size_t STRING_MAX_LENGTH = 128;
constexpr size_t U32_AT_SIZE = 4;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
@@ -51,12 +52,13 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
moduleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
intentName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
uint32_t versionCode = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
profileInfos.insightIntents.push_back(info);
AbilityFuzzUtil::GetRandomExtractInsightIntentGenericInfo(fdp, genericInfo);
AbilityFuzzUtil::GetRandomExtractInsightIntentInfo(fdp, intentInfo);
DelayedSingleton<InsightIntentDbCache>::GetInstance()->InitInsightIntentCache(userId);
DelayedSingleton<InsightIntentDbCache>::GetInstance()->SaveInsightIntentTotalInfo(bundleName, moduleName,
userId, profileInfos, configIntentInfos);
userId, versionCode, profileInfos, configIntentInfos);
DelayedSingleton<InsightIntentDbCache>::GetInstance()->DeleteInsightIntentTotalInfo(bundleName, moduleName,
userId);
DelayedSingleton<InsightIntentDbCache>::GetInstance()->DeleteInsightIntentByUserId(userId);
@@ -40,6 +40,7 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
int32_t userId = 100;
int32_t userId2 = 101;
int32_t userId3 = 102;
uint32_t versionCode = 0;
ExtractInsightIntentProfileInfo profileInfo;
ExtractInsightIntentProfileInfoVec profileInfos;
@@ -72,8 +73,10 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
insightIntentDbCache->InitInsightIntentCache(userId);
insightIntentDbCache->InitInsightIntentCache(userId2);
insightIntentDbCache->SaveInsightIntentTotalInfo(bundleName, moduleName, userId2, profileInfos, configIntentInfos);
insightIntentDbCache->SaveInsightIntentTotalInfo(bundleName, moduleName, userId, profileInfos, configIntentInfos);
insightIntentDbCache->SaveInsightIntentTotalInfo(bundleName, moduleName, userId2,
versionCode, profileInfos, configIntentInfos);
insightIntentDbCache->SaveInsightIntentTotalInfo(bundleName, moduleName, userId,
versionCode, profileInfos, configIntentInfos);
insightIntentDbCache->DeleteInsightIntentTotalInfo(bundleName, moduleName, userId2);
insightIntentDbCache->DeleteInsightIntentTotalInfo(bundleName, emptyModuleName, userId2);
@@ -33,6 +33,7 @@ using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace {
constexpr size_t STRING_MAX_LENGTH = 128;
constexpr size_t U32_AT_SIZE = 4;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
@@ -44,6 +45,7 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
std::unordered_map<std::string, std::string> valueVec;
std::string key = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
std::string value = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
uint32_t versionCode = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
valueVec[key] = value;
userId = fdp.ConsumeIntegral<int32_t>();
std::vector<InsightIntentInfo> configInfos;
@@ -51,7 +53,9 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
std::vector<ExtractInsightIntentInfo> totalInfos;
ExtractInsightIntentInfo totalInfo;
ExtractInsightIntentProfileInfoVec profileInfos;
DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadInsightIntentInfos(userId, totalInfos, configInfos);
std::map<std::string, std::string> bundleVersionMap;
DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->
LoadInsightIntentInfos(userId, bundleVersionMap, totalInfos, configInfos);
DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadConfigInsightIntentInfos(userId, configInfos);
DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadConfigInsightIntentInfoByName(bundleName, userId, configInfos);
DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadInsightIntentInfoByName(bundleName, userId, totalInfos);
@@ -59,7 +63,8 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadConfigInsightIntentInfo(bundleName, moduleName, intentName, userId, configInfo);
DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->TransformConfigIntent(valueVec, configInfos);
DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->Transform(valueVec, totalInfos, configInfos);
DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->SaveStorageInsightIntentData(bundleName, moduleName, userId, profileInfos, configInfos);
DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->
SaveStorageInsightIntentData(bundleName, moduleName, userId, versionCode, profileInfos, configInfos);
DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->DeleteStorageInsightIntentByUserId(userId);
DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->DeleteStorageInsightIntentData(bundleName, moduleName, userId);
return true;
@@ -44,6 +44,9 @@ public:
bool GetApplicationInfo(const std::string &appName, int32_t flags, int32_t userId, ApplicationInfo &appInfo);
ErrCode GetNameForUid(const int32_t uid, std::string &name);
bool QueryAppGalleryBundleName(std::string &bundleName);
ErrCode GetBundleInfoV9(
const std::string &bundleName, int32_t flags, BundleInfo &bundleInfo, int32_t userId);
ErrCode GetBundleInfosV9(int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId);
private:
DECLARE_DELAYED_SINGLETON(BundleMgrHelper)
@@ -106,6 +106,18 @@ bool BundleMgrHelper::GetBundleInfo(
return true;
}
ErrCode BundleMgrHelper::GetBundleInfoV9(
const std::string &bundleName, int32_t flags, BundleInfo &bundleInfo, int32_t userId)
{
return ERR_OK;
}
ErrCode BundleMgrHelper::GetBundleInfosV9(int32_t flags,
std::vector<BundleInfo> &bundleInfos, int32_t userId)
{
return ERR_OK;
}
ErrCode BundleMgrHelper::GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appCloneIndex,
BundleInfo &bundleInfo, int32_t userId)
{
@@ -50,16 +50,18 @@ public:
void GetConfigInsightIntentInfo(const std::string &bundleName, const std::string &moduleName,
const std::string &intentName, const int32_t userId, InsightIntentInfo &info);
int32_t SaveInsightIntentTotalInfo(const std::string &bundleName, const std::string &moduleName,
const int32_t userId, ExtractInsightIntentProfileInfoVec profileInfos,
const int32_t userId, uint32_t versionCode, ExtractInsightIntentProfileInfoVec profileInfos,
std::vector<InsightIntentInfo> configInfos);
int32_t DeleteInsightIntentTotalInfo(const std::string &bundleName,
const std::string &moduleName, const int32_t userId);
int32_t DeleteInsightIntentByUserId(const int32_t userId);
bool HasInsightIntentByName(uint32_t versionCode, const std::string &bundleName, const int32_t userId);
void BackupRdb();
private:
int32_t userId_ = -1;
mutable std::mutex genericInfosMutex_;
std::map<std::string, std::vector<ExtractInsightIntentGenericInfo>> intentGenericInfos_;
std::map<std::string, std::string> bundleVersionMap_;
};
} // namespace AbilityRuntime
} // namespace OHOS
@@ -30,11 +30,12 @@ int32_t InsightIntentDbCache::InitInsightIntentCache(const int32_t userId)
}
std::vector<ExtractInsightIntentInfo> totalInfos;
std::vector<InsightIntentInfo> configInfos;
std::map<std::string, std::string> bundleVersionMap;
totalInfos.clear();
configInfos.clear();
intentGenericInfos_.clear();
if (DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadInsightIntentInfos(
userId, totalInfos, configInfos) != ERR_OK) {
userId, bundleVersionMap, totalInfos, configInfos) != ERR_OK) {
TAG_LOGE(AAFwkTag::INTENT, "Load All IntentData failed");
return ERR_INVALID_VALUE;
}
@@ -55,7 +56,8 @@ InsightIntentDbCache::~InsightIntentDbCache()
{}
int32_t InsightIntentDbCache::SaveInsightIntentTotalInfo(const std::string &bundleName, const std::string &moduleName,
const int32_t userId, ExtractInsightIntentProfileInfoVec profileInfos, std::vector<InsightIntentInfo> configInfos)
const int32_t userId, uint32_t versionCode, ExtractInsightIntentProfileInfoVec profileInfos,
std::vector<InsightIntentInfo> configInfos)
{
std::lock_guard<std::mutex> lock(genericInfosMutex_);
if (userId != userId_) {
@@ -83,13 +85,31 @@ int32_t InsightIntentDbCache::SaveInsightIntentTotalInfo(const std::string &bund
} else {
intentGenericInfos_[bundleName] = genericInfos;
}
bundleVersionMap_[bundleName] = std::to_string(versionCode);
int32_t res = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->DeleteStorageInsightIntentData(bundleName,
moduleName, userId);
if (res != ERR_OK) {
TAG_LOGW(AAFwkTag::INTENT, "Save before delete key error");
}
return DelayedSingleton<InsightRdbStorageMgr>::GetInstance()
->SaveStorageInsightIntentData(bundleName, moduleName, userId, profileInfos, configInfos);
return DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->SaveStorageInsightIntentData(
bundleName, moduleName, userId, versionCode, profileInfos, configInfos);
}
bool InsightIntentDbCache::HasInsightIntentByName(uint32_t versionCode,
const std::string &bundleName, const int32_t userId)
{
std::lock_guard<std::mutex> lock(genericInfosMutex_);
if (userId != userId_) {
TAG_LOGW(AAFwkTag::INTENT, "error userId %{public}d.", userId_);
return false;
}
if (intentGenericInfos_.find(bundleName) != intentGenericInfos_.end() &&
bundleVersionMap_.find(bundleName) != bundleVersionMap_.end() &&
bundleVersionMap_[bundleName].compare(std::to_string(versionCode)) == 0) {
return true;
}
TAG_LOGW(AAFwkTag::INTENT, "null bundleName %{public}s", bundleName.c_str());
return false;
}
int32_t InsightIntentDbCache::DeleteInsightIntentTotalInfo(const std::string &bundleName,
@@ -203,6 +203,12 @@ ErrCode BundleMgrHelper::GetBundleInfoV9(const std::string& bundleName,
return ERR_OK;
}
ErrCode BundleMgrHelper::GetBundleInfosV9(int32_t flags,
std::vector<BundleInfo> &bundleInfos, int32_t userId)
{
return ERR_OK;
}
bool BundleMgrHelper::GetApplicationInfo(
const std::string& appName, const ApplicationFlag flag, const int32_t userId, ApplicationInfo& appInfo)
{
@@ -199,6 +199,12 @@ ErrCode BundleMgrHelper::GetBundleInfoV9(const std::string& bundleName,
return AAFwk::MyStatus::GetInstance().getBundleInfoV9_;
}
ErrCode BundleMgrHelper::GetBundleInfosV9(int32_t flags,
std::vector<BundleInfo> &bundleInfos, int32_t userId)
{
return ERR_OK;
}
bool BundleMgrHelper::GetApplicationInfo(
const std::string& appName, const ApplicationFlag flag, const int32_t userId, ApplicationInfo& appInfo)
{
@@ -199,6 +199,12 @@ ErrCode BundleMgrHelper::GetBundleInfoV9(const std::string& bundleName,
return AAFwk::MyStatus::GetInstance().getBundleInfoV9_;
}
ErrCode BundleMgrHelper::GetBundleInfosV9(int32_t flags,
std::vector<BundleInfo> &bundleInfos, int32_t userId)
{
return ERR_OK;
}
bool BundleMgrHelper::GetApplicationInfo(
const std::string& appName, const ApplicationFlag flag, const int32_t userId, ApplicationInfo& appInfo)
{
@@ -197,6 +197,12 @@ ErrCode BundleMgrHelper::GetBundleInfoV9(const std::string& bundleName,
return AAFwk::MyStatus::GetInstance().getBundleInfoV9_;
}
ErrCode BundleMgrHelper::GetBundleInfosV9(int32_t flags,
std::vector<BundleInfo> &bundleInfos, int32_t userId)
{
return ERR_OK;
}
bool BundleMgrHelper::GetApplicationInfo(
const std::string& appName, const ApplicationFlag flag, const int32_t userId, ApplicationInfo& appInfo)
{
@@ -106,26 +106,27 @@ HWTEST_F(InsightIntentSysEventReceiverTest, SaveInsightIntentInfos_0002, TestSiz
{
// 局部变量定义
EventFwk::CommonEventSubscribeInfo subscribeInfo;
uint32_t ver = 0;
auto sysEventReceiver = std::make_shared<AbilityRuntime::InsightIntentSysEventReceiver>(subscribeInfo);
// 测试1: 无效bundle名称
sysEventReceiver->SaveInsightIntentInfos(INVALID_BUNDLE_NAME, TEST_MODULE_NAME, MAIN_USER_ID);
sysEventReceiver->SaveInsightIntentInfos(INVALID_BUNDLE_NAME, TEST_MODULE_NAME, ver, MAIN_USER_ID);
EXPECT_EQ(sysEventReceiver->lastUserId_, 0); // 验证对象状态正常,未被异常影响
// 测试2: 空模块名称
sysEventReceiver->SaveInsightIntentInfos(TEST_BUNDLE_NAME, EMPTY_MODULE_NAME, MAIN_USER_ID);
sysEventReceiver->SaveInsightIntentInfos(TEST_BUNDLE_NAME, EMPTY_MODULE_NAME, ver, MAIN_USER_ID);
EXPECT_EQ(sysEventReceiver->lastUserId_, 0);
// 测试3: 多模块名称
sysEventReceiver->SaveInsightIntentInfos(TEST_BUNDLE_NAME, MULTI_MODULE_NAME, MAIN_USER_ID);
sysEventReceiver->SaveInsightIntentInfos(TEST_BUNDLE_NAME, MULTI_MODULE_NAME, ver, MAIN_USER_ID);
EXPECT_EQ(sysEventReceiver->lastUserId_, 0);
// 测试4: 无效用户ID
sysEventReceiver->SaveInsightIntentInfos(TEST_BUNDLE_NAME, TEST_MODULE_NAME, INVALID_USER_ID);
sysEventReceiver->SaveInsightIntentInfos(TEST_BUNDLE_NAME, TEST_MODULE_NAME, ver, INVALID_USER_ID);
EXPECT_EQ(sysEventReceiver->lastUserId_, 0);
// 测试5: 合法参数
sysEventReceiver->SaveInsightIntentInfos(TEST_BUNDLE_NAME, TEST_MODULE_NAME, MAIN_USER_ID);
sysEventReceiver->SaveInsightIntentInfos(TEST_BUNDLE_NAME, TEST_MODULE_NAME, ver, MAIN_USER_ID);
EXPECT_EQ(sysEventReceiver->lastUserId_, 0);
}
@@ -74,14 +74,14 @@ HWTEST_F(InsightIntentDbCacheTest, InsightIntentDbCacheTest_001, TestSize.Level0
DelayedSingleton<InsightIntentDbCache>::GetInstance()->InitInsightIntentCache(userId);
MockSaveData(false);
auto result = DelayedSingleton<InsightIntentDbCache>::GetInstance()->SaveInsightIntentTotalInfo(bundleName,
moduleName, 100, profileInfos, configInfos);
moduleName, 100, 0, profileInfos, configInfos);
EXPECT_EQ(result, ERR_INVALID_VALUE);
result = DelayedSingleton<InsightIntentDbCache>::GetInstance()->SaveInsightIntentTotalInfo(bundleName,
moduleName, userId, profileInfos, configInfos);
moduleName, userId, 0, profileInfos, configInfos);
EXPECT_EQ(result, ERR_INVALID_VALUE);
MockSaveData(true);
result = DelayedSingleton<InsightIntentDbCache>::GetInstance()->SaveInsightIntentTotalInfo(bundleName,
moduleName, userId, profileInfos, configInfos);
moduleName, userId, 0, profileInfos, configInfos);
EXPECT_EQ(result, ERR_OK);
@@ -121,7 +121,7 @@ HWTEST_F(InsightIntentDbCacheTest, InsightIntentDbCacheTest_002, TestSize.Level0
EXPECT_EQ(result, ERR_OK);
moduleName = "qwe";
DelayedSingleton<InsightIntentDbCache>::GetInstance()->SaveInsightIntentTotalInfo(bundleName,
moduleName, userId, profileInfos, configInfos);
moduleName, userId, 0, profileInfos, configInfos);
result = DelayedSingleton<InsightIntentDbCache>::GetInstance()->DeleteInsightIntentTotalInfo(bundleName,
moduleName, userId);
EXPECT_EQ(result, ERR_OK);
@@ -156,14 +156,14 @@ HWTEST_F(InsightIntentDbCacheTest, InsightIntentDbCacheTest_003, TestSize.Level0
DelayedSingleton<InsightIntentDbCache>::GetInstance()->InitInsightIntentCache(userId);
MockSaveData(false);
auto result = DelayedSingleton<InsightIntentDbCache>::GetInstance()->SaveInsightIntentTotalInfo(bundleName,
moduleName, 100, profileInfos, configInfos);
moduleName, 100, 0, profileInfos, configInfos);
EXPECT_EQ(result, ERR_INVALID_VALUE);
result = DelayedSingleton<InsightIntentDbCache>::GetInstance()->SaveInsightIntentTotalInfo(bundleName,
moduleName, userId, profileInfos, configInfos);
moduleName, userId, 0, profileInfos, configInfos);
EXPECT_EQ(result, ERR_INVALID_VALUE);
MockSaveData(true);
result = DelayedSingleton<InsightIntentDbCache>::GetInstance()->SaveInsightIntentTotalInfo(bundleName,
moduleName, userId, profileInfos, configInfos);
moduleName, userId, 0, profileInfos, configInfos);
EXPECT_EQ(result, ERR_OK);
std::vector<InsightIntentInfo> configInfos1;
DelayedSingleton<InsightIntentDbCache>::GetInstance()->GetConfigInsightIntentInfoByName(bundleName,
@@ -209,15 +209,15 @@ HWTEST_F(InsightIntentDbCacheTest, InsightIntentDbCacheTest_004, TestSize.Level0
DelayedSingleton<InsightIntentDbCache>::GetInstance()->InitInsightIntentCache(userId);
MockSaveData(false);
auto result = DelayedSingleton<InsightIntentDbCache>::GetInstance()->SaveInsightIntentTotalInfo(bundleName,
moduleName, 100, profileInfos, configInfos);
moduleName, 100, 0, profileInfos, configInfos);
EXPECT_EQ(result, ERR_INVALID_VALUE);
result = DelayedSingleton<InsightIntentDbCache>::GetInstance()->SaveInsightIntentTotalInfo(bundleName,
moduleName, userId, profileInfos, configInfos);
moduleName, userId, 0, profileInfos, configInfos);
DelayedSingleton<InsightIntentDbCache>::GetInstance()->BackupRdb();
EXPECT_EQ(result, ERR_INVALID_VALUE);
MockSaveData(true);
result = DelayedSingleton<InsightIntentDbCache>::GetInstance()->SaveInsightIntentTotalInfo(bundleName,
moduleName, userId, profileInfos, configInfos);
moduleName, userId, 0, profileInfos, configInfos);
EXPECT_EQ(result, ERR_OK);
std::vector<ExtractInsightIntentGenericInfo> genericInfos;
@@ -88,6 +88,7 @@ InsightRdbStorageMgr::~InsightRdbStorageMgr()
}
int32_t InsightRdbStorageMgr::LoadInsightIntentInfos(const int32_t userId,
std::map<std::string, std::string> &bundleVersionMap,
std::vector<ExtractInsightIntentInfo> &totalInfos, std::vector<InsightIntentInfo> &configInfos)
{
ExtractInsightIntentInfo totalInfo;
@@ -147,8 +148,8 @@ int32_t InsightRdbStorageMgr::LoadInsightIntentInfo(const std::string &bundleNa
}
int32_t InsightRdbStorageMgr::SaveStorageInsightIntentData(const std::string &bundleName,
const std::string &moduleName, const int32_t userId, ExtractInsightIntentProfileInfoVec &profileInfos,
std::vector<InsightIntentInfo> &configInfos)
const std::string &moduleName, const int32_t userId, uint32_t versionCode,
ExtractInsightIntentProfileInfoVec &profileInfos, std::vector<InsightIntentInfo> &configInfos)
{
if (g_mockSaveStorageInsightIntentDataRet) {
return ERR_OK;
@@ -92,14 +92,15 @@ HWTEST_F(InsightIntentRdbStorageMgrTest, InsightIntentRdbStorageMgrTest_003, Tes
int32_t userId = 0;
std::string bundleName;
std::string moduleName;
uint32_t versionCode = 0;
ExtractInsightIntentProfileInfoVec profileInfos;
std::vector<InsightIntentInfo> configInfos;
MockInsertData(false);
auto result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->SaveStorageInsightIntentData(bundleName,
moduleName, userId, profileInfos, configInfos);
moduleName, userId, versionCode, profileInfos, configInfos);
MockInsertData(true);
result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->SaveStorageInsightIntentData(bundleName,
moduleName, userId, profileInfos, configInfos);
moduleName, userId, versionCode, profileInfos, configInfos);
EXPECT_EQ(result, ERR_OK);
}
@@ -113,11 +114,14 @@ HWTEST_F(InsightIntentRdbStorageMgrTest, InsightIntentRdbStorageMgrTest_004, Tes
int32_t userId = 0;
std::vector<ExtractInsightIntentInfo> infos;
std::vector<InsightIntentInfo> configInfos;
std::map<std::string, std::string> bundleVersionMap;
MockQueryDataBeginWithKey(false);
auto result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadInsightIntentInfos(
userId, infos, configInfos);
userId, bundleVersionMap, infos, configInfos);
MockQueryDataBeginWithKey(true);
result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadInsightIntentInfos(userId, infos, configInfos);
result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->
LoadInsightIntentInfos(userId, bundleVersionMap, infos, configInfos);
EXPECT_EQ(result, ERR_OK);
}
@@ -152,10 +156,10 @@ HWTEST_F(InsightIntentRdbStorageMgrTest, InsightIntentRdbStorageMgrTest_006, Tes
std::string moduleName;
std::string intentName;
ExtractInsightIntentInfo infos;
MockQueryData(false);
MockQueryDataBeginWithKey(false);
auto result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadInsightIntentInfo(bundleName,
moduleName, intentName, userId, infos);
MockQueryData(true);
MockQueryDataBeginWithKey(true);
result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadInsightIntentInfo(bundleName,
moduleName, intentName, userId, infos);
EXPECT_EQ(result, ERR_OK);
@@ -210,10 +214,10 @@ HWTEST_F(InsightIntentRdbStorageMgrTest, InsightIntentRdbStorageMgrTest_009, Tes
std::string moduleName;
std::string intentName;
InsightIntentInfo infos;
MockQueryData(false);
MockQueryDataBeginWithKey(false);
auto result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadConfigInsightIntentInfo(bundleName,
moduleName, intentName, userId, infos);
MockQueryData(true);
MockQueryDataBeginWithKey(true);
result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadConfigInsightIntentInfo(bundleName,
moduleName, intentName, userId, infos);
EXPECT_EQ(result, ERR_OK);
@@ -259,7 +263,7 @@ HWTEST_F(InsightIntentRdbStorageMgrTest, InsightIntentRdbStorageMgrTest_011, Tes
profileInfos.insightIntents.push_back(profileInfo);
auto result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->SaveStorageInsightIntentData(
bundleName, moduleName, userId, profileInfos, configInfos);
bundleName, moduleName, userId, 0, profileInfos, configInfos);
EXPECT_EQ(result, ERR_OK);
}
@@ -281,7 +285,7 @@ HWTEST_F(InsightIntentRdbStorageMgrTest, InsightIntentRdbStorageMgrTest_012, Tes
configInfos.push_back(configInfo);
auto result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->SaveStorageInsightIntentData(
bundleName, moduleName, userId, profileInfos, configInfos);
bundleName, moduleName, userId, 0, profileInfos, configInfos);
EXPECT_EQ(result, ERR_OK);
}
@@ -298,7 +302,7 @@ HWTEST_F(InsightIntentRdbStorageMgrTest, InsightIntentRdbStorageMgrTest_013, Tes
std::string intentName = "testIntent";
ExtractInsightIntentInfo totalInfo;
MockQueryData(true);
MockQueryDataBeginWithKey(true);
auto result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadInsightIntentInfo(
bundleName, moduleName, intentName, userId, totalInfo);
EXPECT_EQ(result, ERR_OK);
@@ -317,7 +321,7 @@ HWTEST_F(InsightIntentRdbStorageMgrTest, InsightIntentRdbStorageMgrTest_014, Tes
std::string intentName = "testIntent";
InsightIntentInfo totalInfo;
MockQueryData(true);
MockQueryDataBeginWithKey(true);
auto result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadConfigInsightIntentInfo(
bundleName, moduleName, intentName, userId, totalInfo);
EXPECT_EQ(result, ERR_OK);
@@ -349,10 +353,11 @@ HWTEST_F(InsightIntentRdbStorageMgrTest, InsightIntentRdbStorageMgrTest_016, Tes
int32_t userId = 0;
std::vector<ExtractInsightIntentInfo> totalInfos;
std::vector<InsightIntentInfo> configInfos;
std::map<std::string, std::string> bundleVersionMap;
MockQueryDataBeginWithKey(true);
auto result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->LoadInsightIntentInfos(
userId, totalInfos, configInfos);
userId, bundleVersionMap, totalInfos, configInfos);
EXPECT_EQ(result, ERR_OK);
}
@@ -375,7 +380,7 @@ HWTEST_F(InsightIntentRdbStorageMgrTest, InsightIntentRdbStorageMgrTest_018, Tes
MockInsertData(false);
auto result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->SaveStorageInsightIntentData(
bundleName, moduleName, userId, profileInfos, configInfos);
bundleName, moduleName, userId, 0, profileInfos, configInfos);
EXPECT_EQ(result, ERR_OK);
}
@@ -398,7 +403,7 @@ HWTEST_F(InsightIntentRdbStorageMgrTest, InsightIntentRdbStorageMgrTest_019, Tes
MockInsertData(false);
auto result = DelayedSingleton<InsightRdbStorageMgr>::GetInstance()->SaveStorageInsightIntentData(
bundleName, moduleName, userId, profileInfos, configInfos);
bundleName, moduleName, userId, 0, profileInfos, configInfos);
EXPECT_EQ(result, ERR_OK);
}
}