mirror of
https://gitee.com/openharmony/global_resource_management
synced 2024-11-23 16:09:52 +00:00
dfx质量需求,解决字典覆盖率不达100%问题,降低日志重复率和日志超限次数
Signed-off-by: Runner_wx_new_blue_compute_cloud <runner_wx@163.com>
This commit is contained in:
parent
07924fac88
commit
4ac9f3ee5c
@ -28,7 +28,7 @@ void ReportInitResourceManagerFail(const std::string& bundleName, const std::str
|
||||
"BUNDLENAME", bundleName,
|
||||
"ERROR_MSG", errMsg);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("hisysevent write failed! ret %{public}d, bundleName %{public}s, errMsg %{public}s",
|
||||
RESMGR_HILOGE(RESMGR_TAG, "hisysevent write failed! ret %{public}d, bundleName %{public}s, errMsg %{public}s",
|
||||
ret, bundleName.c_str(), errMsg.c_str());
|
||||
}
|
||||
}
|
||||
@ -41,7 +41,8 @@ void ReportGetResourceByIdFail(int32_t resId, const std::string& result, const s
|
||||
"RESULT", result,
|
||||
"ERROR_MSG", errMsg);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("hisysevent write failed! ret %{public}d, resId %{public}d, result %{public}s, errMsg %{public}s.",
|
||||
RESMGR_HILOGE(RESMGR_TAG,
|
||||
"hisysevent write failed! ret %{public}d, resId %{public}d, result %{public}s, errMsg %{public}s.",
|
||||
ret, resId, result.c_str(), errMsg.c_str());
|
||||
}
|
||||
}
|
||||
@ -54,7 +55,8 @@ void ReportGetResourceByNameFail(const std::string& resName, const std::string&
|
||||
"RESULT", result,
|
||||
"ERROR_MSG", errMsg);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("hisysevent write failed! ret %{public}d, resName %{public}s, result %{public}s, errMsg %{public}s",
|
||||
RESMGR_HILOGE(RESMGR_TAG,
|
||||
"hisysevent write failed! ret %{public}d, resName %{public}s, result %{public}s, errMsg %{public}s",
|
||||
ret, resName.c_str(), result.c_str(), errMsg.c_str());
|
||||
}
|
||||
}
|
||||
@ -66,7 +68,8 @@ void ReportAddResourcePathFail(const char* resourcePath, const std::string& errM
|
||||
"PATH", resourcePath,
|
||||
"ERROR_MSG", errMsg);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("hisysevent write failed! ret %{public}d, resourcePath %{public}s, errMsg %{public}s.",
|
||||
RESMGR_HILOGE(RESMGR_TAG,
|
||||
"hisysevent write failed! ret %{public}d, resourcePath %{public}s, errMsg %{public}s.",
|
||||
ret, resourcePath, errMsg.c_str());
|
||||
}
|
||||
}
|
||||
|
@ -229,6 +229,8 @@ ohos_shared_library("librawfile") {
|
||||
public_configs = [ ":rawfile_public_config" ]
|
||||
sources = [ "src/raw_file_manager.cpp" ]
|
||||
|
||||
defines = [ "CONFIG_HILOG" ]
|
||||
|
||||
include_dirs = [
|
||||
"./include",
|
||||
"../../interfaces/native/resource/include",
|
||||
@ -264,6 +266,8 @@ ohos_shared_library("ohresmgr") {
|
||||
output_extension = "so"
|
||||
output_name = "ohresmgr"
|
||||
|
||||
defines = [ "CONFIG_HILOG" ]
|
||||
|
||||
include_dirs = [
|
||||
"./include",
|
||||
"../../interfaces/native/resource/include",
|
||||
|
@ -16,29 +16,29 @@
|
||||
#ifndef HILOG_WRAPPER_H
|
||||
#define HILOG_WRAPPER_H
|
||||
|
||||
#undef RESMGR_TAG
|
||||
#define RESMGR_TAG "ResourceManager"
|
||||
|
||||
#undef RESMGR_JS_TAG
|
||||
#define RESMGR_JS_TAG "ResourceManagerJs"
|
||||
|
||||
#undef RESMGR_NATIVE_TAG
|
||||
#define RESMGR_NATIVE_TAG "ResourceManagerNative"
|
||||
|
||||
#undef RESMGR_RAWFILE_TAG
|
||||
#define RESMGR_RAWFILE_TAG "ResourceManagerRawFile"
|
||||
|
||||
#ifdef CONFIG_HILOG
|
||||
|
||||
#include "hilog/log.h"
|
||||
|
||||
#ifdef HILOG_FATAL
|
||||
#undef HILOG_FATAL
|
||||
#endif
|
||||
|
||||
#ifdef HILOG_ERROR
|
||||
#undef HILOG_ERROR
|
||||
#endif
|
||||
|
||||
#ifdef HILOG_WARN
|
||||
#undef HILOG_WARN
|
||||
#endif
|
||||
|
||||
#ifdef HILOG_INFO
|
||||
#undef HILOG_INFO
|
||||
#endif
|
||||
|
||||
#ifdef HILOG_DEBUG
|
||||
#undef HILOG_DEBUG
|
||||
#endif
|
||||
namespace OHOS::HiviewDFX {
|
||||
#define RESMGR_HILOGE(tag, fmt, ...) HILOG_IMPL(LOG_CORE, LOG_ERROR, 0xD001E00, tag, fmt, ##__VA_ARGS__)
|
||||
#define RESMGR_HILOGW(tag, fmt, ...) HILOG_IMPL(LOG_CORE, LOG_WARN, 0xD001E00, tag, fmt, ##__VA_ARGS__)
|
||||
#define RESMGR_HILOGI(tag, fmt, ...) HILOG_IMPL(LOG_CORE, LOG_INFO, 0xD001E00, tag, fmt, ##__VA_ARGS__)
|
||||
#define RESMGR_HILOGD(tag, fmt, ...) HILOG_IMPL(LOG_CORE, LOG_DEBUG, 0xD001E00, tag, fmt, ##__VA_ARGS__)
|
||||
#define RESMGR_HILOGF(tag, fmt, ...) HILOG_IMPL(LOG_CORE, LOG_FATAL, 0xD001E00, tag, fmt, ##__VA_ARGS__)
|
||||
}
|
||||
|
||||
namespace OHOS {
|
||||
namespace Global {
|
||||
@ -48,35 +48,14 @@ extern LogLevel g_logLevel;
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, 0xD001E00, "ResourceManager"};
|
||||
|
||||
#define HILOG_FATAL(...) (void)OHOS::HiviewDFX::HiLog::Fatal(LOG_LABEL, __VA_ARGS__)
|
||||
#define HILOG_ERROR(...) (void)OHOS::HiviewDFX::HiLog::Error(LOG_LABEL, __VA_ARGS__)
|
||||
#define HILOG_WARN(...) { \
|
||||
if (OHOS::Global::Resource::g_logLevel <= LOG_WARN) { \
|
||||
(void)OHOS::HiviewDFX::HiLog::Warn(LOG_LABEL, __VA_ARGS__); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define HILOG_INFO(...) { \
|
||||
if (OHOS::Global::Resource::g_logLevel <= LOG_INFO) { \
|
||||
(void)OHOS::HiviewDFX::HiLog::Info(LOG_LABEL, __VA_ARGS__); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define HILOG_DEBUG(...) { \
|
||||
if (OHOS::Global::Resource::g_logLevel <= LOG_DEBUG) { \
|
||||
(void)OHOS::HiviewDFX::HiLog::Debug(LOG_LABEL, __VA_ARGS__); \
|
||||
} \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define HILOG_FATAL(...)
|
||||
#define HILOG_ERROR(...)
|
||||
#define HILOG_WARN(...)
|
||||
#define HILOG_INFO(...)
|
||||
#define HILOG_DEBUG(...)
|
||||
#define RESMGR_HILOGE(tag, fmt, ...)
|
||||
#define RESMGR_HILOGW(tag, fmt, ...)
|
||||
#define RESMGR_HILOGI(tag, fmt, ...)
|
||||
#define RESMGR_HILOGD(tag, fmt, ...)
|
||||
#define RESMGR_HILOGF(tag, fmt, ...)
|
||||
|
||||
#endif // CONFIG_HILOG
|
||||
|
||||
#endif // HILOG_WRAPPER_H
|
@ -110,7 +110,7 @@ std::string HapManager::GetPluralRulesAndSelect(int quantity, bool isGetOverride
|
||||
std::shared_ptr<ResConfigImpl> config = getCompleteOverrideConfig(isGetOverrideResource);
|
||||
if (config == nullptr || config->GetResLocale() == nullptr ||
|
||||
config->GetResLocale()->GetLanguage() == nullptr) {
|
||||
HILOG_ERROR("GetPluralRules language is null!");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "GetPluralRules language is null!");
|
||||
return defaultRet;
|
||||
}
|
||||
std::string language = config->GetResLocale()->GetLanguage();
|
||||
@ -129,18 +129,18 @@ std::string HapManager::GetPluralRulesAndSelect(int quantity, bool isGetOverride
|
||||
// no cache hit
|
||||
icu::Locale locale(language.c_str());
|
||||
if (locale.isBogus()) {
|
||||
HILOG_ERROR("icu::Locale init error : %s", language.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "icu::Locale init error : %s", language.c_str());
|
||||
return defaultRet;
|
||||
}
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
pluralRules = icu::PluralRules::forLocale(locale, status);
|
||||
if (status != U_ZERO_ERROR) {
|
||||
HILOG_ERROR("icu::PluralRules::forLocale error : %d", status);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "icu::PluralRules::forLocale error : %d", status);
|
||||
return defaultRet;
|
||||
}
|
||||
// after PluralRules created, we add it to cache, if > 3 delete oldest one
|
||||
if (plurRulesCache_.size() >= PLURAL_CACHE_MAX_COUNT) {
|
||||
HILOG_DEBUG("cache rotate delete plurRulesMap_ %s", plurRulesCache_[0].first.c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "cache rotate delete plurRulesMap_ %s", plurRulesCache_[0].first.c_str());
|
||||
delete (plurRulesCache_[0].second);
|
||||
plurRulesCache_.erase(plurRulesCache_.begin());
|
||||
}
|
||||
@ -205,18 +205,18 @@ std::shared_ptr<ResConfigImpl> HapManager::getCompleteOverrideConfig(bool isGetO
|
||||
|
||||
std::shared_ptr<ResConfigImpl> completeOverrideConfig = std::make_shared<ResConfigImpl>();
|
||||
if (!completeOverrideConfig || !this->resConfig_ || !this->overrideResConfig_) {
|
||||
HILOG_ERROR("completeOverrideConfig or resConfig_ or overrideResConfig_ is nullptr");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "completeOverrideConfig or resConfig_ or overrideResConfig_ is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!completeOverrideConfig->Copy(*this->resConfig_, true)) {
|
||||
HILOG_ERROR("getCompleteOverrideConfig copy failed");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "getCompleteOverrideConfig copy failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->overrideResConfig_->isLocaleInfoSet()
|
||||
&& !completeOverrideConfig->CopyLocaleAndPreferredLocale(*this->overrideResConfig_)) {
|
||||
HILOG_ERROR("getCompleteOverrideConfig CopyLocaleAndPreferredLocale failed");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "getCompleteOverrideConfig CopyLocaleAndPreferredLocale failed");
|
||||
return nullptr;
|
||||
}
|
||||
if (this->overrideResConfig_->GetDeviceType() != DEVICE_NOT_SET) {
|
||||
@ -308,7 +308,7 @@ RState HapManager::FindRawFile(const std::string &name, std::string &outValue)
|
||||
std::string indexPath = (*iter)->GetIndexPath();
|
||||
auto index = indexPath.rfind(seperator);
|
||||
if (index == std::string::npos) {
|
||||
HILOG_ERROR("index path format error, %s", indexPath.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "index path format error, %s", indexPath.c_str());
|
||||
continue;
|
||||
}
|
||||
std::string resourcesIndexPath = indexPath.substr(0, index);
|
||||
@ -325,7 +325,7 @@ RState HapManager::FindRawFile(const std::string &name, std::string &outValue)
|
||||
}
|
||||
#else
|
||||
if (realpath((resourcesIndexPath + "/resources/" + tempName).c_str(), tmpPath) == nullptr) {
|
||||
HILOG_ERROR("FindRawFile path to realpath error");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "FindRawFile path to realpath error");
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
@ -377,7 +377,7 @@ bool HapManager::AddResource(const std::string &path, const std::vector<std::str
|
||||
AutoMutex mutex(this->lock_);
|
||||
std::vector<std::string> targetOverlay = loadedHapPaths_[path];
|
||||
if (!targetOverlay.empty() && targetOverlay == overlayPaths) {
|
||||
HILOG_INFO("the overlay for %{public}s already been loaded", path.c_str());
|
||||
RESMGR_HILOGI(RESMGR_TAG, "the overlay for %{public}s already been loaded", path.c_str());
|
||||
return true;
|
||||
}
|
||||
loadedHapPaths_[path] = overlayPaths;
|
||||
@ -407,11 +407,11 @@ std::string HapManager::GetValidAppPath()
|
||||
|
||||
bool HapManager::AddAppOverlay(const std::string &overlayPath)
|
||||
{
|
||||
HILOG_INFO("AddAppOverlay overlayPath = %{public}s", overlayPath.c_str());
|
||||
RESMGR_HILOGI(RESMGR_TAG, "AddAppOverlay overlayPath = %{public}s", overlayPath.c_str());
|
||||
char outPath[PATH_MAX + 1] = {0};
|
||||
Utils::CanonicalizePath(overlayPath.c_str(), outPath, PATH_MAX);
|
||||
if (outPath[0] == '\0') {
|
||||
HILOG_ERROR("invalid overlayPath, %{public}s", overlayPath.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "invalid overlayPath, %{public}s", overlayPath.c_str());
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> overlayPaths;
|
||||
@ -422,11 +422,11 @@ bool HapManager::AddAppOverlay(const std::string &overlayPath)
|
||||
|
||||
bool HapManager::RemoveAppOverlay(const std::string &overlayPath)
|
||||
{
|
||||
HILOG_INFO("RemoveAppOverlay overlayPath = %{public}s", overlayPath.c_str());
|
||||
RESMGR_HILOGI(RESMGR_TAG, "RemoveAppOverlay overlayPath = %{public}s", overlayPath.c_str());
|
||||
char outPath[PATH_MAX + 1] = {0};
|
||||
Utils::CanonicalizePath(overlayPath.c_str(), outPath, PATH_MAX);
|
||||
if (outPath[0] == '\0') {
|
||||
HILOG_ERROR("invalid overlayPath, %{public}s", overlayPath.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "invalid overlayPath, %{public}s", overlayPath.c_str());
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> overlayPaths;
|
||||
@ -442,7 +442,7 @@ HapManager::~HapManager()
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
auto iter = plurRulesCache_.begin();
|
||||
for (; iter != plurRulesCache_.end(); iter++) {
|
||||
HILOG_DEBUG("delete plurRulesMap_ %s", iter->first.c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "delete plurRulesMap_ %s", iter->first.c_str());
|
||||
if (iter->second != nullptr) {
|
||||
auto ptr = iter->second;
|
||||
delete (ptr);
|
||||
@ -535,7 +535,7 @@ std::vector<std::string> HapManager::GetResourcePaths()
|
||||
std::string indexPath = (*iter)->GetIndexPath();
|
||||
auto index = indexPath.rfind('/');
|
||||
if (index == std::string::npos) {
|
||||
HILOG_ERROR("index path format error, %s", indexPath.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "index path format error, %s", indexPath.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -563,7 +563,7 @@ std::string GetFilePathFromHap(std::shared_ptr<AbilityBase::Extractor> &extracto
|
||||
const std::shared_ptr<IdItem> idItem = qd->GetIdItem();
|
||||
if (idItem == nullptr || idItem->resType_ != resType) {
|
||||
std::string hapPath = qd->GetIndexPath();
|
||||
HILOG_ERROR("actual resType = %{public}d, expect resType = %{public}d, hapPath = %{public}s",
|
||||
RESMGR_HILOGE(RESMGR_TAG, "actual resType = %{public}d, expect resType = %{public}d, hapPath = %{public}s",
|
||||
idItem == nullptr ? -1 : idItem->resType_, resType, hapPath.c_str());
|
||||
return filePath;
|
||||
}
|
||||
@ -571,7 +571,7 @@ std::string GetFilePathFromHap(std::shared_ptr<AbilityBase::Extractor> &extracto
|
||||
std::string tempFilePath(idItem->value_);
|
||||
auto index = tempFilePath.find('/');
|
||||
if (index == std::string::npos) {
|
||||
HILOG_ERROR("resource path format error, %s", tempFilePath.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "resource path format error, %s", tempFilePath.c_str());
|
||||
return filePath;
|
||||
}
|
||||
filePath = idItem->value_.substr(index + 1);
|
||||
@ -600,17 +600,17 @@ RState HapManager::GetProfileData(const std::shared_ptr<HapResource::ValueUnderQ
|
||||
#if !defined(__WINNT__) && !defined(__IDE_PREVIEW__) && !defined(__ARKUI_CROSS__)
|
||||
auto extractor = GetAbilityExtractor(qd);
|
||||
if (extractor == nullptr) {
|
||||
HILOG_ERROR("failed to get extractor from ability");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get extractor from ability");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
std::string filePath = GetFilePathFromHap(extractor, qd, ResType::PROF);
|
||||
if (filePath.empty()) {
|
||||
HILOG_ERROR("get file path failed in GetProfileData");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "get file path failed in GetProfileData");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
bool ret = extractor->ExtractToBufByName(filePath, outValue, len);
|
||||
if (!ret) {
|
||||
HILOG_ERROR("failed to get config data from ability");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get config data from ability");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
#endif
|
||||
@ -637,17 +637,17 @@ RState HapManager::GetMediaDataFromHap(const std::shared_ptr<HapResource::ValueU
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
auto extractor = GetAbilityExtractor(qd);
|
||||
if (extractor == nullptr) {
|
||||
HILOG_ERROR("failed to get extractor from ability");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get extractor from ability");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
std::string filePath = GetFilePathFromHap(extractor, qd, ResType::MEDIA);
|
||||
if (filePath.empty()) {
|
||||
HILOG_ERROR("get file path failed in GetMediaDataFromHap");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "get file path failed in GetMediaDataFromHap");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
bool ret = extractor->ExtractToBufByName(filePath, outValue, len);
|
||||
if (!ret) {
|
||||
HILOG_ERROR("failed to get media data from ability");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get media data from ability");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
#endif
|
||||
@ -685,7 +685,7 @@ RState HapManager::GetMediaBase64DataFromHap(const std::shared_ptr<HapResource::
|
||||
#if !defined(__WINNT__) && !defined(__IDE_PREVIEW__) && !defined(__ARKUI_CROSS__)
|
||||
auto extractor = GetAbilityExtractor(qd);
|
||||
if (extractor == nullptr) {
|
||||
HILOG_ERROR("failed to get extractor from ability");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get extractor from ability");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
std::string filePath = GetFilePathFromHap(extractor, qd, ResType::MEDIA);
|
||||
@ -693,7 +693,7 @@ RState HapManager::GetMediaBase64DataFromHap(const std::shared_ptr<HapResource::
|
||||
size_t tmpLen;
|
||||
bool ret = extractor->ExtractToBufByName(filePath, buffer, tmpLen);
|
||||
if (!ret) {
|
||||
HILOG_ERROR("failed to get mediabase64 data from ability");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get mediabase64 data from ability");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
std::string imgType = GetImageType(filePath);
|
||||
@ -838,7 +838,7 @@ RState HapManager::GetFilePath(const std::shared_ptr<HapResource::ValueUnderQual
|
||||
#if defined(__ARKUI_CROSS__)
|
||||
auto index = idItem->value_.find('/');
|
||||
if (index == std::string::npos) {
|
||||
HILOG_ERROR("resource path format error, %s", idItem->value_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "resource path format error, %s", idItem->value_.c_str());
|
||||
return NOT_FOUND;
|
||||
}
|
||||
auto nameWithoutModule = idItem->value_.substr(index + 1);
|
||||
@ -850,7 +850,7 @@ RState HapManager::GetFilePath(const std::shared_ptr<HapResource::ValueUnderQual
|
||||
}
|
||||
auto index = idItem->value_.find('/');
|
||||
if (index == std::string::npos) {
|
||||
HILOG_ERROR("resource path format error, %s", idItem->value_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "resource path format error, %s", idItem->value_.c_str());
|
||||
return NOT_FOUND;
|
||||
}
|
||||
auto nameWithoutModule = idItem->value_.substr(index + 1);
|
||||
@ -912,20 +912,20 @@ RState HapManager::CloseRawFileDescriptor(const std::string &name)
|
||||
bool HapManager::RemoveResource(const std::string &path, const std::vector<std::string> &overlayPaths)
|
||||
{
|
||||
AutoMutex mutex(this->lock_);
|
||||
HILOG_INFO("remove overlay for path, %{public}s", path.c_str());
|
||||
RESMGR_HILOGI(RESMGR_TAG, "remove overlay for path, %{public}s", path.c_str());
|
||||
if (loadedHapPaths_.find(path) == loadedHapPaths_.end()) {
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> targetOverlay = loadedHapPaths_[path];
|
||||
if (targetOverlay.empty()) {
|
||||
HILOG_ERROR("the %{public}s have not overlay", path.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "the %{public}s have not overlay", path.c_str());
|
||||
return false;
|
||||
}
|
||||
char outPath[PATH_MAX] = {0};
|
||||
for (auto iter = overlayPaths.begin(); iter != overlayPaths.end(); iter++) {
|
||||
Utils::CanonicalizePath((*iter).c_str(), outPath, PATH_MAX);
|
||||
if (outPath[0] == '\0') {
|
||||
HILOG_ERROR("invalid overlayPath, %{public}s", (*iter).c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "invalid overlayPath, %{public}s", (*iter).c_str());
|
||||
continue;
|
||||
}
|
||||
if (std::find(targetOverlay.begin(), targetOverlay.end(), outPath) != targetOverlay.end()) {
|
||||
@ -934,7 +934,7 @@ bool HapManager::RemoveResource(const std::string &path, const std::vector<std::
|
||||
}
|
||||
for (auto resIter = hapResources_.begin(); resIter != hapResources_.end(); ) {
|
||||
if ((*resIter) == nullptr) {
|
||||
HILOG_ERROR("hapResource is nullptr");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "hapResource is nullptr");
|
||||
return false;
|
||||
}
|
||||
std::string hapPath = (*resIter)->GetIndexPath();
|
||||
@ -957,11 +957,11 @@ std::vector<std::shared_ptr<HapResource>> HapManager::GetHapResource()
|
||||
void HapManager::AddSystemResource(const std::shared_ptr<HapManager> &systemHapManager)
|
||||
{
|
||||
if (systemHapManager == nullptr) {
|
||||
HILOG_ERROR("add system resource failed, systemHapManager is nullptr");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "add system resource failed, systemHapManager is nullptr");
|
||||
return;
|
||||
}
|
||||
if (!systemHapManager->isSystem_) {
|
||||
HILOG_ERROR("add system resource failed, the added hapManager is not system");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "add system resource failed, the added hapManager is not system");
|
||||
return;
|
||||
}
|
||||
AutoMutex mutex(this->lock_);
|
||||
@ -989,7 +989,7 @@ uint32_t HapManager::GetResourceLimitKeys()
|
||||
for (size_t i = 0; i < hapResources_.size(); i++) {
|
||||
limitKeysValue |= hapResources_[i]->GetResourceLimitKeys();
|
||||
}
|
||||
HILOG_INFO("hap manager limit key is %{public}u", limitKeysValue);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "hap manager limit key is %{public}u", limitKeysValue);
|
||||
return limitKeysValue;
|
||||
}
|
||||
|
||||
@ -1055,13 +1055,13 @@ RState HapManager::GetResId(const std::string &resTypeName, uint32_t &resId)
|
||||
const std::string resType = std::get<0>(typeNameTuple);
|
||||
const std::string resName = std::get<1>(typeNameTuple);
|
||||
if (resType.empty() || resName.empty()) {
|
||||
HILOG_ERROR("invalid resTypeName = %{public}s", resTypeName.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "invalid resTypeName = %{public}s", resTypeName.c_str());
|
||||
return NOT_FOUND;
|
||||
}
|
||||
bool isSystem = IsPrefix("sys", resTypeName);
|
||||
bool isApp = IsPrefix("app", resTypeName);
|
||||
if (!isSystem && !isApp) {
|
||||
HILOG_ERROR("invalid resTypeName = %{public}s", resTypeName.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "invalid resTypeName = %{public}s", resTypeName.c_str());
|
||||
return NOT_FOUND;
|
||||
}
|
||||
for (auto iter = hapResources_.begin(); iter != hapResources_.end(); iter++) {
|
||||
@ -1087,7 +1087,8 @@ RState HapManager::GetResId(const std::string &resTypeName, uint32_t &resId)
|
||||
}
|
||||
resId = GetRealResId(resType, candidates);
|
||||
if (resId == 0) {
|
||||
HILOG_ERROR("GetResId name = %{public}s, resType = %{public}s", resName.c_str(), resType.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG,
|
||||
"GetResId name = %{public}s, resType = %{public}s", resName.c_str(), resType.c_str());
|
||||
return NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
@ -105,13 +105,13 @@ const std::shared_ptr<HapResource> HapResource::LoadFromIndex(const char *path,
|
||||
inFile.seekg(0, std::ios::end);
|
||||
int bufLen = inFile.tellg();
|
||||
if (bufLen <= 0) {
|
||||
HILOG_ERROR("file size is zero");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "file size is zero");
|
||||
inFile.close();
|
||||
return nullptr;
|
||||
}
|
||||
void *buf = malloc(bufLen);
|
||||
if (buf == nullptr) {
|
||||
HILOG_ERROR("Error allocating memory");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "Error allocating memory");
|
||||
inFile.close();
|
||||
return nullptr;
|
||||
}
|
||||
@ -119,18 +119,18 @@ const std::shared_ptr<HapResource> HapResource::LoadFromIndex(const char *path,
|
||||
inFile.read(static_cast<char *>(buf), bufLen);
|
||||
inFile.close();
|
||||
|
||||
HILOG_DEBUG("extract success, bufLen:%d", bufLen);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "extract success, bufLen:%d", bufLen);
|
||||
|
||||
std::shared_ptr<ResDesc> resDesc = std::make_shared<ResDesc>();
|
||||
if (resDesc == nullptr) {
|
||||
HILOG_ERROR("new ResDesc failed when LoadFromIndex");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new ResDesc failed when LoadFromIndex");
|
||||
free(buf);
|
||||
return nullptr;
|
||||
}
|
||||
int32_t out = HapParser::ParseResHex(static_cast<char *>(buf), bufLen, *resDesc, defaultConfig, selectedTypes);
|
||||
if (out != OK) {
|
||||
free(buf);
|
||||
HILOG_ERROR("ParseResHex failed! retcode:%d", out);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "ParseResHex failed! retcode:%d", out);
|
||||
return nullptr;
|
||||
}
|
||||
free(buf);
|
||||
@ -138,7 +138,7 @@ const std::shared_ptr<HapResource> HapResource::LoadFromIndex(const char *path,
|
||||
std::shared_ptr<HapResource> pResource = std::make_shared<HapResource>(std::string(path),
|
||||
0, resDesc, isSystem, isOverlay);
|
||||
if (pResource == nullptr) {
|
||||
HILOG_ERROR("new HapResource failed when LoadFromIndex");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new HapResource failed when LoadFromIndex");
|
||||
return nullptr;
|
||||
}
|
||||
if (!pResource->Init(defaultConfig)) {
|
||||
@ -175,7 +175,7 @@ bool GetIndexData(const char *path, std::unique_ptr<uint8_t[]> &tmpBuf, size_t &
|
||||
}
|
||||
bool ret = extractor->ExtractToBufByName(indexFilePath, tmpBuf, len);
|
||||
if (!ret) {
|
||||
HILOG_ERROR("failed to get buf data indexFilePath, %{public}s", indexFilePath.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get buf data indexFilePath, %{public}s", indexFilePath.c_str());
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@ -189,18 +189,18 @@ const std::shared_ptr<HapResource> HapResource::LoadFromHap(const char *path,
|
||||
size_t tmpLen = 0;
|
||||
bool ret = GetIndexData(path, tmpBuf, tmpLen);
|
||||
if (!ret) {
|
||||
HILOG_ERROR("read Index from file failed path, %{public}s", path);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "read Index from file failed path, %{public}s", path);
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<ResDesc> resDesc = std::make_shared<ResDesc>();
|
||||
if (resDesc == nullptr) {
|
||||
HILOG_ERROR("new ResDesc failed when LoadFromHap");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new ResDesc failed when LoadFromHap");
|
||||
return nullptr;
|
||||
}
|
||||
int32_t out = HapParser::ParseResHex(
|
||||
reinterpret_cast<char *>(tmpBuf.get()), tmpLen, *resDesc, defaultConfig, selectedTypes);
|
||||
if (out != OK) {
|
||||
HILOG_ERROR("ParseResHex failed! retcode:%d", out);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "ParseResHex failed! retcode:%d", out);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@ const std::unordered_map<std::string, std::shared_ptr<HapResource>> HapResource:
|
||||
do {
|
||||
const std::shared_ptr<HapResource> targetResource = Load(path.c_str(), defaultConfig, isSystem);
|
||||
if (targetResource == nullptr) {
|
||||
HILOG_ERROR("load target failed");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "load target failed");
|
||||
break;
|
||||
}
|
||||
result[path] = targetResource;
|
||||
@ -233,7 +233,7 @@ const std::unordered_map<std::string, std::shared_ptr<HapResource>> HapResource:
|
||||
// load overlay hap, the isOverlay flag set true.
|
||||
const std::shared_ptr<HapResource> overlayResource = Load(iter->c_str(), defaultConfig, isSystem, true);
|
||||
if (overlayResource == nullptr) {
|
||||
HILOG_ERROR("load overlay failed");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "load overlay failed");
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
@ -241,7 +241,7 @@ const std::unordered_map<std::string, std::shared_ptr<HapResource>> HapResource:
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
HILOG_ERROR("load overlay failed");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "load overlay failed");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ bool HapResource::Init(std::shared_ptr<ResConfigImpl> &defaultConfig)
|
||||
#endif
|
||||
auto index = indexPath_.rfind(separator);
|
||||
if (index == std::string::npos) {
|
||||
HILOG_ERROR("index path format error, %s", indexPath_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "index path format error, %s", indexPath_.c_str());
|
||||
return false;
|
||||
}
|
||||
#if defined(__IDE_PREVIEW__) || defined(__ARKUI_CROSS__)
|
||||
@ -317,7 +317,7 @@ bool HapResource::Init(std::shared_ptr<ResConfigImpl> &defaultConfig)
|
||||
}
|
||||
index = indexPath_.rfind(separator, index - 1);
|
||||
if (index == std::string::npos) {
|
||||
HILOG_ERROR("index path format error, %s", indexPath_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "index path format error, %s", indexPath_.c_str());
|
||||
return false;
|
||||
}
|
||||
resourcePath_ = indexPath_.substr(0, index + 1);
|
||||
@ -325,7 +325,7 @@ bool HapResource::Init(std::shared_ptr<ResConfigImpl> &defaultConfig)
|
||||
for (int i = 0; i < ResType::MAX_RES_TYPE; ++i) {
|
||||
auto mptr = new (std::nothrow) std::map<std::string, std::shared_ptr<IdValues>>();
|
||||
if (mptr == nullptr) {
|
||||
HILOG_ERROR("new std::map failed in HapResource::Init");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new std::map failed in HapResource::Init");
|
||||
return false;
|
||||
}
|
||||
idValuesNameMap_.push_back(mptr);
|
||||
@ -343,13 +343,13 @@ bool HapResource::InitMap(const std::shared_ptr<ResKey> &resKey, const std::pair
|
||||
if (iter == idValuesMap_.end()) {
|
||||
auto idValues = std::make_shared<HapResource::IdValues>();
|
||||
if (idValues == nullptr) {
|
||||
HILOG_ERROR("new IdValues failed in HapResource::InitIdList");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new IdValues failed in HapResource::InitIdList");
|
||||
return false;
|
||||
}
|
||||
auto limitPath = std::make_shared<HapResource::ValueUnderQualifierDir>(resKey,
|
||||
idParam->idItem_, resPath, isOverlay_, isSystem_);
|
||||
if (limitPath == nullptr) {
|
||||
HILOG_ERROR("new ValueUnderQualifierDir failed in HapResource::InitIdList");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new ValueUnderQualifierDir failed in HapResource::InitIdList");
|
||||
return false;
|
||||
}
|
||||
idValues->AddLimitPath(limitPath);
|
||||
@ -365,7 +365,7 @@ bool HapResource::InitMap(const std::shared_ptr<ResKey> &resKey, const std::pair
|
||||
auto limitPath = std::make_shared<HapResource::ValueUnderQualifierDir>(resKey,
|
||||
idParam->idItem_, resPath, isOverlay_, isSystem_);
|
||||
if (limitPath == nullptr) {
|
||||
HILOG_ERROR("new ValueUnderQualifierDir failed in HapResource::InitIdList");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new ValueUnderQualifierDir failed in HapResource::InitIdList");
|
||||
return false;
|
||||
}
|
||||
idValues->AddLimitPath(limitPath);
|
||||
@ -378,7 +378,7 @@ bool HapResource::InitMap(const std::shared_ptr<ResKey> &resKey, const std::pair
|
||||
bool HapResource::InitIdList(std::shared_ptr<ResConfigImpl> &defaultConfig)
|
||||
{
|
||||
if (resDesc_ == nullptr) {
|
||||
HILOG_ERROR("resDesc_ is null ! InitIdList failed");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "resDesc_ is null ! InitIdList failed");
|
||||
return false;
|
||||
}
|
||||
const auto resPath = std::make_pair(indexPath_, resourcePath_);
|
||||
@ -394,7 +394,7 @@ bool HapResource::InitIdList(std::shared_ptr<ResConfigImpl> &defaultConfig)
|
||||
const std::shared_ptr<HapResource::IdValues> HapResource::GetIdValues(const uint32_t id) const
|
||||
{
|
||||
if (idValuesMap_.empty()) {
|
||||
HILOG_ERROR("idValuesMap_ is empty");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "idValuesMap_ is empty");
|
||||
return nullptr;
|
||||
}
|
||||
uint32_t uid = id;
|
||||
@ -431,12 +431,12 @@ int HapResource::GetIdByName(const char *name, const ResType resType) const
|
||||
const std::shared_ptr<IdValues> ids = iter->second;
|
||||
|
||||
if (ids->GetLimitPathsConst().size() == 0) {
|
||||
HILOG_ERROR("limitPaths empty");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "limitPaths empty");
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
if (ids->GetLimitPathsConst()[0]->GetIdItem()->resType_ != resType) {
|
||||
HILOG_ERROR("ResType mismatch");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "ResType mismatch");
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
return ids->GetLimitPathsConst()[0]->GetIdItem()->id_;
|
||||
|
@ -17,18 +17,13 @@
|
||||
|
||||
#include <securec.h>
|
||||
#include "drawable_descriptor.h"
|
||||
#include "hilog/log_cpp.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "resource_manager_impl.h"
|
||||
#include "rstate.h"
|
||||
|
||||
using namespace OHOS::Global::Resource;
|
||||
using namespace OHOS::HiviewDFX;
|
||||
using namespace OHOS::Ace::Napi;
|
||||
|
||||
namespace {
|
||||
constexpr HiLogLabel LABEL = {LOG_CORE, 0xD001E00, "NativeResourceManager"};
|
||||
}
|
||||
|
||||
struct NativeResourceManager {
|
||||
std::shared_ptr<ResourceManager> resManager = nullptr;
|
||||
};
|
||||
@ -43,16 +38,17 @@ ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64(const NativeResource
|
||||
RState state = mgr->resManager->GetMediaBase64DataById(resId, tempResultValue, density);
|
||||
ResourceManager_ErrorCode errorCode = static_cast<ResourceManager_ErrorCode>(state);
|
||||
if (errorCode != ResourceManager_ErrorCode::SUCCESS) {
|
||||
HiLog::Error(LABEL, "failed get media base64 id = %{public}d, errorCode = %{public}d", resId, errorCode);
|
||||
RESMGR_HILOGE(RESMGR_NATIVE_TAG,
|
||||
"failed get media base64 id = %{public}d, errorCode = %{public}d", resId, errorCode);
|
||||
return errorCode;
|
||||
}
|
||||
*resultValue = (char*)malloc(tempResultValue.size() + 1);
|
||||
if (*resultValue == nullptr) {
|
||||
HiLog::Error(LABEL, "GetMediaBase64 malloc error");
|
||||
RESMGR_HILOGE(RESMGR_NATIVE_TAG, "GetMediaBase64 malloc error");
|
||||
return ResourceManager_ErrorCode::ERROR_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (strncpy_s(*resultValue, tempResultValue.size() + 1, tempResultValue.c_str(), tempResultValue.size()) != 0) {
|
||||
HiLog::Error(LABEL, "GetMediaBase64 strncpy_s error");
|
||||
RESMGR_HILOGE(RESMGR_NATIVE_TAG, "GetMediaBase64 strncpy_s error");
|
||||
free(*resultValue);
|
||||
*resultValue = nullptr;
|
||||
return ResourceManager_ErrorCode::ERROR_CODE_OUT_OF_MEMORY;
|
||||
@ -72,16 +68,17 @@ ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64ByName(const NativeRe
|
||||
RState state = mgr->resManager->GetMediaBase64DataByName(resName, tempResultValue, density);
|
||||
ResourceManager_ErrorCode errorCode = static_cast<ResourceManager_ErrorCode>(state);
|
||||
if (errorCode != ResourceManager_ErrorCode::SUCCESS) {
|
||||
HiLog::Error(LABEL, "failed get media base64 name = %{public}s, errorCode = %{public}d", resName, errorCode);
|
||||
RESMGR_HILOGE(RESMGR_NATIVE_TAG,
|
||||
"failed get media base64 name = %{public}s, errorCode = %{public}d", resName, errorCode);
|
||||
return errorCode;
|
||||
}
|
||||
*resultValue = (char*)malloc(tempResultValue.size() + 1);
|
||||
if (*resultValue == nullptr) {
|
||||
HiLog::Error(LABEL, "GetMediaBase64Byname malloc error");
|
||||
RESMGR_HILOGE(RESMGR_NATIVE_TAG, "GetMediaBase64Byname malloc error");
|
||||
return ResourceManager_ErrorCode::ERROR_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (strncpy_s(*resultValue, tempResultValue.size() + 1, tempResultValue.c_str(), tempResultValue.size()) != 0) {
|
||||
HiLog::Error(LABEL, "GetMediaBase64Byname strncpy_s error");
|
||||
RESMGR_HILOGE(RESMGR_NATIVE_TAG, "GetMediaBase64Byname strncpy_s error");
|
||||
free(*resultValue);
|
||||
*resultValue = nullptr;
|
||||
return ResourceManager_ErrorCode::ERROR_CODE_OUT_OF_MEMORY;
|
||||
@ -102,13 +99,14 @@ ResourceManager_ErrorCode OH_ResourceManager_GetMedia(const NativeResourceManage
|
||||
RState state = mgr->resManager->GetMediaDataById(resId, len, tempResultValue, density);
|
||||
ResourceManager_ErrorCode errorCode = static_cast<ResourceManager_ErrorCode>(state);
|
||||
if (errorCode != ResourceManager_ErrorCode::SUCCESS) {
|
||||
HiLog::Error(LABEL, "failed get media resource id = %{public}d, errorCode = %{public}d", resId, errorCode);
|
||||
RESMGR_HILOGE(RESMGR_NATIVE_TAG,
|
||||
"failed get media resource id = %{public}d, errorCode = %{public}d", resId, errorCode);
|
||||
return errorCode;
|
||||
}
|
||||
uint8_t *temPtr = tempResultValue.get();
|
||||
*resultValue = static_cast<uint8_t*>(malloc(len));
|
||||
if (*resultValue == nullptr) {
|
||||
HiLog::Error(LABEL, "GetMedia malloc error");
|
||||
RESMGR_HILOGE(RESMGR_NATIVE_TAG, "GetMedia malloc error");
|
||||
return ResourceManager_ErrorCode::ERROR_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
std::copy(temPtr, temPtr + len, *resultValue);
|
||||
@ -128,13 +126,14 @@ ResourceManager_ErrorCode OH_ResourceManager_GetMediaByName(const NativeResource
|
||||
RState state = mgr->resManager->GetMediaDataByName(resName, len, tempResultValue, density);
|
||||
ResourceManager_ErrorCode errorCode = static_cast<ResourceManager_ErrorCode>(state);
|
||||
if (errorCode != ResourceManager_ErrorCode::SUCCESS) {
|
||||
HiLog::Error(LABEL, "failed get media resource name = %{public}s, errorCode = %{public}d", resName, errorCode);
|
||||
RESMGR_HILOGE(RESMGR_NATIVE_TAG,
|
||||
"failed get media resource name = %{public}s, errorCode = %{public}d", resName, errorCode);
|
||||
return errorCode;
|
||||
}
|
||||
uint8_t *temPtr = tempResultValue.get();
|
||||
*resultValue = static_cast<uint8_t*>(malloc(len));
|
||||
if (*resultValue == nullptr) {
|
||||
HiLog::Error(LABEL, "GetMediaByName malloc error");
|
||||
RESMGR_HILOGE(RESMGR_NATIVE_TAG, "GetMediaByName malloc error");
|
||||
return ResourceManager_ErrorCode::ERROR_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
std::copy(temPtr, temPtr + len, *resultValue);
|
||||
@ -165,7 +164,7 @@ ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptor(const NativeR
|
||||
}
|
||||
auto descriptor = DrawableDescriptorFactory::Create(resId, mgr->resManager, state, drawableType, density);
|
||||
if (state != RState::SUCCESS) {
|
||||
HiLog::Error(LABEL, "Failed to Create drawableDescriptor");
|
||||
RESMGR_HILOGE(RESMGR_NATIVE_TAG, "Failed to Create drawableDescriptor");
|
||||
return static_cast<ResourceManager_ErrorCode>(state);
|
||||
}
|
||||
*drawableDescriptor = OH_ArkUI_CreateFromNapiDrawable(descriptor.get());
|
||||
@ -207,7 +206,7 @@ ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorByName(const N
|
||||
|
||||
auto descriptor = DrawableDescriptorFactory::Create(resName, mgr->resManager, state, drawableType, density);
|
||||
if (state != RState::SUCCESS) {
|
||||
HiLog::Error(LABEL, "Failed to Create drawableDescriptor");
|
||||
RESMGR_HILOGE(RESMGR_NATIVE_TAG, "Failed to Create drawableDescriptor");
|
||||
return static_cast<ResourceManager_ErrorCode>(state);
|
||||
}
|
||||
*drawableDescriptor = OH_ArkUI_CreateFromNapiDrawable(descriptor.get());
|
||||
|
@ -29,8 +29,7 @@
|
||||
#include "resource_manager.h"
|
||||
#include "resource_manager_addon.h"
|
||||
#include "resource_manager_impl.h"
|
||||
#include "hilog/log_c.h"
|
||||
#include "hilog/log_cpp.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
#ifdef __WINNT__
|
||||
#include <shlwapi.h>
|
||||
@ -38,11 +37,6 @@
|
||||
#endif
|
||||
|
||||
using namespace OHOS::Global::Resource;
|
||||
using namespace OHOS::HiviewDFX;
|
||||
|
||||
namespace {
|
||||
constexpr HiLogLabel LABEL = {LOG_CORE, 0xD001E00, "RawFile"};
|
||||
}
|
||||
|
||||
Lock g_rawDirLock;
|
||||
Lock g_rawFileLock;
|
||||
@ -101,13 +95,13 @@ NativeResourceManager *OH_ResourceManager_InitNativeResourceManager(napi_env env
|
||||
napi_valuetype valueType;
|
||||
napi_typeof(env, jsResMgr, &valueType);
|
||||
if (valueType != napi_object) {
|
||||
HiLog::Error(LABEL, "jsResMgr is not an object");
|
||||
RESMGR_HILOGE(RESMGR_RAWFILE_TAG, "jsResMgr is not an object");
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<ResourceManagerAddon> *addonPtr = nullptr;
|
||||
napi_status status = napi_unwrap(env, jsResMgr, reinterpret_cast<void **>(&addonPtr));
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get native resourcemanager");
|
||||
RESMGR_HILOGE(RESMGR_RAWFILE_TAG, "Failed to get native resourcemanager");
|
||||
return nullptr;
|
||||
}
|
||||
std::unique_ptr<NativeResourceManager> result = std::make_unique<NativeResourceManager>();
|
||||
@ -133,7 +127,7 @@ RawDir *LoadRawDirFromHap(const NativeResourceManager *mgr, const std::string di
|
||||
std::unique_ptr<RawDir> result = std::make_unique<RawDir>();
|
||||
RState state = mgr->resManager->GetRawFileList(dirName, result->fileNameCache.names);
|
||||
if (state != RState::SUCCESS) {
|
||||
HiLog::Debug(LABEL, "failed to get RawDir dirName, %{public}s", dirName.c_str());
|
||||
RESMGR_HILOGD(RESMGR_RAWFILE_TAG, "failed to get RawDir dirName, %{public}s", dirName.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
return result.release();
|
||||
@ -188,18 +182,18 @@ RawFile *LoadRawFileFromHap(const NativeResourceManager *mgr, const char *fileNa
|
||||
std::unique_ptr<uint8_t[]> tmpBuf;
|
||||
RState state = mgr->resManager->GetRawFileFromHap(fileName, len, tmpBuf);
|
||||
if (state != SUCCESS) {
|
||||
HiLog::Debug(LABEL, "failed to get %{public}s rawfile", fileName);
|
||||
RESMGR_HILOGD(RESMGR_RAWFILE_TAG, "failed to get %{public}s rawfile", fileName);
|
||||
return nullptr;
|
||||
}
|
||||
auto result = std::make_unique<RawFile>(fileName);
|
||||
result->buffer = tmpBuf.release();
|
||||
if (result->buffer == nullptr) {
|
||||
HiLog::Error(LABEL, "failed get file buffer");
|
||||
RESMGR_HILOGE(RESMGR_RAWFILE_TAG, "failed get file buffer");
|
||||
return nullptr;
|
||||
}
|
||||
int zipFd = open(hapPath.c_str(), O_RDONLY);
|
||||
if (zipFd < 0) {
|
||||
HiLog::Error(LABEL, "failed open file %{public}s", hapPath.c_str());
|
||||
RESMGR_HILOGE(RESMGR_RAWFILE_TAG, "failed open file %{public}s", hapPath.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
result->pf = fdopen(zipFd, "r");
|
||||
@ -277,7 +271,7 @@ int OH_ResourceManager_ReadRawFile(const RawFile *rawFile, void *buf, size_t len
|
||||
}
|
||||
int ret = memcpy_s(buf, length, rawFile->buffer + rawFile->actualOffset->offset, length);
|
||||
if (ret != 0) {
|
||||
HiLog::Error(LABEL, "failed to copy to buf");
|
||||
RESMGR_HILOGE(RESMGR_RAWFILE_TAG, "failed to copy to buf");
|
||||
return 0;
|
||||
}
|
||||
rawFile->actualOffset->offset += static_cast<int64_t>(length);
|
||||
@ -360,7 +354,7 @@ static bool GetRawFileDescriptorFromHap(const RawFile *rawFile, RawFileDescripto
|
||||
RState state = rawFile->resMgr->resManager->
|
||||
GetRawFdNdkFromHap(rawFile->filePath, resMgrDescriptor);
|
||||
if (state != SUCCESS) {
|
||||
HiLog::Error(LABEL, "GetRawFileDescriptorFromHap failed to get rawFile descriptor");
|
||||
RESMGR_HILOGE(RESMGR_RAWFILE_TAG, "GetRawFileDescriptorFromHap failed to get rawFile descriptor");
|
||||
return false;
|
||||
}
|
||||
descriptor.fd = resMgrDescriptor.fd;
|
||||
@ -380,11 +374,11 @@ bool OH_ResourceManager_GetRawFileDescriptor(const RawFile *rawFile, RawFileDesc
|
||||
char paths[PATH_MAX] = {0};
|
||||
#ifdef __WINNT__
|
||||
if (!PathCanonicalizeA(paths, rawFile->filePath.c_str())) {
|
||||
HiLog::Error(LABEL, "failed to PathCanonicalizeA the rawFile path");
|
||||
RESMGR_HILOGE(RESMGR_RAWFILE_TAG, "failed to PathCanonicalizeA the rawFile path");
|
||||
}
|
||||
#else
|
||||
if (realpath(rawFile->filePath.c_str(), paths) == nullptr) {
|
||||
HiLog::Error(LABEL, "failed to realpath the rawFile path");
|
||||
RESMGR_HILOGE(RESMGR_RAWFILE_TAG, "failed to realpath the rawFile path");
|
||||
}
|
||||
#endif
|
||||
int fd = open(paths, O_RDONLY);
|
||||
@ -447,7 +441,7 @@ RawFile64 *LoadRawFileFromHap64(const NativeResourceManager *mgr, const char *fi
|
||||
ResourceManager::RawFileDescriptor resMgrDescriptor;
|
||||
RState state = mgr->resManager->GetRawFdNdkFromHap(fileName, resMgrDescriptor);
|
||||
if (state != SUCCESS) {
|
||||
HiLog::Error(LABEL, "failed to get %{public}s rawfile descriptor", fileName);
|
||||
RESMGR_HILOGE(RESMGR_RAWFILE_TAG, "failed to get %{public}s rawfile descriptor", fileName);
|
||||
return nullptr;
|
||||
}
|
||||
auto result = std::make_unique<Raw>(fileName);
|
||||
@ -457,7 +451,7 @@ RawFile64 *LoadRawFileFromHap64(const NativeResourceManager *mgr, const char *fi
|
||||
result->start = resMgrDescriptor.offset;
|
||||
result->resMgr = mgr;
|
||||
if (result->pf == nullptr) {
|
||||
HiLog::Error(LABEL, "failed to open %{public}s rawfile descriptor", fileName);
|
||||
RESMGR_HILOGE(RESMGR_RAWFILE_TAG, "failed to open %{public}s rawfile descriptor", fileName);
|
||||
return nullptr;
|
||||
}
|
||||
std::fseek(result->pf, result->start, SEEK_SET);
|
||||
@ -502,7 +496,7 @@ int64_t OH_ResourceManager_ReadRawFile64(const RawFile64 *rawFile, void *buf, in
|
||||
}
|
||||
size_t ret = std::fread(buf, 1, length, rawFile->raw->pf);
|
||||
if (ret == 0) {
|
||||
HiLog::Error(LABEL, "failed to fread");
|
||||
RESMGR_HILOGE(RESMGR_RAWFILE_TAG, "failed to fread");
|
||||
return 0;
|
||||
}
|
||||
rawFile->raw->offset += length;
|
||||
@ -586,7 +580,7 @@ static bool GetRawFileDescriptorFromHap64(const RawFile64 *rawFile, RawFileDescr
|
||||
RState state = rawFile->raw->resMgr->resManager->
|
||||
GetRawFdNdkFromHap(rawFile->raw->filePath, resMgrDescriptor);
|
||||
if (state != SUCCESS) {
|
||||
HiLog::Error(LABEL, "GetRawFileDescriptorFromHap64 failed to get rawFile descriptor");
|
||||
RESMGR_HILOGE(RESMGR_RAWFILE_TAG, "GetRawFileDescriptorFromHap64 failed to get rawFile descriptor");
|
||||
return false;
|
||||
}
|
||||
descriptor->fd = resMgrDescriptor.fd;
|
||||
@ -606,11 +600,11 @@ bool OH_ResourceManager_GetRawFileDescriptor64(const RawFile64 *rawFile, RawFile
|
||||
char paths[PATH_MAX] = {0};
|
||||
#ifdef __WINNT__
|
||||
if (!PathCanonicalizeA(paths, rawFile->raw->filePath.c_str())) {
|
||||
HiLog::Error(LABEL, "failed to PathCanonicalizeA the rawFile path");
|
||||
RESMGR_HILOGE(RESMGR_RAWFILE_TAG, "failed to PathCanonicalizeA the rawFile path");
|
||||
}
|
||||
#else
|
||||
if (realpath(rawFile->raw->filePath.c_str(), paths) == nullptr) {
|
||||
HiLog::Error(LABEL, "failed to realpath the rawFile path");
|
||||
RESMGR_HILOGE(RESMGR_RAWFILE_TAG, "failed to realpath the rawFile path");
|
||||
}
|
||||
#endif
|
||||
int fd = open(paths, O_RDONLY);
|
||||
@ -640,7 +634,7 @@ bool OH_ResourceManager_IsRawDir(const NativeResourceManager *mgr, const char *p
|
||||
}
|
||||
RState state = mgr->resManager->IsRawDirFromHap(path, result);
|
||||
if (state != SUCCESS) {
|
||||
HiLog::Error(LABEL, "failed to determine whether the path is a directory");
|
||||
RESMGR_HILOGE(RESMGR_RAWFILE_TAG, "failed to determine whether the path is a directory");
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
|
@ -150,7 +150,7 @@ const std::string KeyParam::ConvertToStr() const
|
||||
char tmp2[5];
|
||||
errno_t eret = memcpy_s(tmp, sizeof(tmp), &value_, 4);
|
||||
if (eret != OK) {
|
||||
HILOG_ERROR("memcpy_s error : %d", eret);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "memcpy_s error : %d", eret);
|
||||
}
|
||||
int j = 0;
|
||||
// 4 means langauges/region/script key value max length
|
||||
@ -301,7 +301,7 @@ std::string ResId::ToString() const
|
||||
|
||||
ResKey::~ResKey()
|
||||
{
|
||||
HILOG_DEBUG("~ResKey()");
|
||||
RESMGR_HILOGD(RESMGR_TAG, "~ResKey()");
|
||||
keyParams_.clear();
|
||||
}
|
||||
|
||||
@ -321,7 +321,7 @@ ResDesc::ResDesc() : resHeader_(nullptr)
|
||||
|
||||
ResDesc::~ResDesc()
|
||||
{
|
||||
HILOG_DEBUG("~ResDesc()");
|
||||
RESMGR_HILOGD(RESMGR_TAG, "~ResDesc()");
|
||||
if (resHeader_ != nullptr) {
|
||||
delete (resHeader_);
|
||||
resHeader_ = nullptr;
|
||||
|
@ -35,7 +35,7 @@ ResourceManager *CreateResourceManager()
|
||||
{
|
||||
ResourceManagerImpl *impl = new (std::nothrow) ResourceManagerImpl;
|
||||
if (impl == nullptr) {
|
||||
HILOG_ERROR("new ResourceManagerImpl failed when CreateResourceManager");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new ResourceManagerImpl failed when CreateResourceManager");
|
||||
return nullptr;
|
||||
}
|
||||
if (!impl->Init()) {
|
||||
@ -55,12 +55,12 @@ std::shared_ptr<ResourceManager> CreateResourceManagerDef(
|
||||
ResConfig &resConfig, int32_t userId)
|
||||
{
|
||||
if (bundleName.empty()) {
|
||||
HILOG_ERROR("bundleName or hapPath is empty when CreateResourceManagerDef");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "bundleName or hapPath is empty when CreateResourceManagerDef");
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<ResourceManager> resourceManagerImpl(CreateResourceManager());
|
||||
if (resourceManagerImpl == nullptr) {
|
||||
HILOG_ERROR("CreateResourceManagerDef failed bundleName = %{public}s moduleName = %{public}s",
|
||||
RESMGR_HILOGE(RESMGR_TAG, "CreateResourceManagerDef failed bundleName = %{public}s moduleName = %{public}s",
|
||||
bundleName.c_str(), moduleName.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
@ -75,13 +75,13 @@ std::shared_ptr<ResourceManager> CreateResourceManagerDef(
|
||||
std::shared_ptr<ResourceManager> CreateResourceManagerExt(const std::string &bundleName, const int32_t appType)
|
||||
{
|
||||
if (bundleName.empty()) {
|
||||
HILOG_ERROR("bundleName is empty when CreateResourceManagerExt");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "bundleName is empty when CreateResourceManagerExt");
|
||||
return nullptr;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(resMgrExtLock);
|
||||
std::shared_ptr<ResourceManager> resMgrExt;
|
||||
if (!resMgrExtMgr->Init(resMgrExt, bundleName, appType) || resMgrExt == nullptr) {
|
||||
HILOG_ERROR("ResourceManagerExt init fail");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "ResourceManagerExt init fail");
|
||||
return nullptr;
|
||||
}
|
||||
return resMgrExt;
|
||||
|
@ -45,7 +45,7 @@ bool ResourceManagerExtMgr::Init(std::shared_ptr<ResourceManager> &resMgrExt, co
|
||||
std::string pluginPath = "system/lib64/libglobal_resmgr_broker.z.so";
|
||||
handle_ = dlopen(pluginPath.c_str(), RTLD_LAZY);
|
||||
if (handle_ == nullptr) {
|
||||
HILOG_ERROR("open so fail");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "open so fail");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -58,7 +58,7 @@ bool ResourceManagerExtMgr::Init(std::shared_ptr<ResourceManager> &resMgrExt, co
|
||||
IResMgrExt iResMgrExt = (IResMgrExt)dlsym(handle_, "CreateResMgrExt");
|
||||
int ret = (*iResMgrExt)(resMgrExt, bundleName, appType);
|
||||
if (ret) {
|
||||
HILOG_ERROR("CreateResMgrExt fail.");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "CreateResMgrExt fail.");
|
||||
return false;
|
||||
}
|
||||
resMgrExtMap_[bundleName] = resMgrExt;
|
||||
|
@ -67,12 +67,12 @@ bool ResourceManagerImpl::Init(bool isSystem)
|
||||
{
|
||||
auto resConfig = std::make_shared<ResConfigImpl>();
|
||||
if (resConfig == nullptr) {
|
||||
HILOG_ERROR("new ResConfigImpl failed when ResourceManagerImpl::Init");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new ResConfigImpl failed when ResourceManagerImpl::Init");
|
||||
return false;
|
||||
}
|
||||
hapManager_ = std::make_shared<HapManager>(resConfig, isSystem);
|
||||
if (hapManager_ == nullptr) {
|
||||
HILOG_ERROR("new HapManager failed when ResourceManagerImpl::Init");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new HapManager failed when ResourceManagerImpl::Init");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -81,7 +81,7 @@ bool ResourceManagerImpl::Init(bool isSystem)
|
||||
bool ResourceManagerImpl::Init(std::shared_ptr<HapManager> hapManager)
|
||||
{
|
||||
if (hapManager == nullptr) {
|
||||
HILOG_ERROR("ResourceManagerImpl::Init, hapManager is nullptr");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "ResourceManagerImpl::Init, hapManager is nullptr");
|
||||
return false;
|
||||
}
|
||||
this->hapManager_ = hapManager;
|
||||
@ -92,7 +92,7 @@ RState ResourceManagerImpl::GetStringById(uint32_t id, std::string &outValue)
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceById(id, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by string id error id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by string id error id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
RState state = GetString(idItem, outValue);
|
||||
@ -106,7 +106,7 @@ RState ResourceManagerImpl::GetStringByName(const char *name, std::string &outVa
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceByName(name, ResType::STRING, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by string name error name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by string name error name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
RState state = GetString(idItem, outValue);
|
||||
@ -169,7 +169,7 @@ RState ResourceManagerImpl::GetStringArrayById(uint32_t id, std::vector<std::str
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceById(id, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by string array id error id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by string array id error id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
RState state = GetStringArray(idItem, outValue);
|
||||
@ -184,7 +184,7 @@ RState ResourceManagerImpl::GetStringArrayByName(const char *name, std::vector<s
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceByName(
|
||||
name, ResType::STRINGARRAY, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by string array name error name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by string array name error name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
RState state = GetStringArray(idItem, outValue);
|
||||
@ -206,7 +206,8 @@ RState ResourceManagerImpl::GetStringArray(const std::shared_ptr<IdItem> idItem,
|
||||
std::string resolvedValue;
|
||||
RState rrRet = ResolveReference(idItem->values_[i], resolvedValue);
|
||||
if (rrRet != SUCCESS) {
|
||||
HILOG_DEBUG("GetStringArray ResolveReference failed, value:%{public}s", idItem->values_[i].c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG,
|
||||
"GetStringArray ResolveReference failed, value:%{public}s", idItem->values_[i].c_str());
|
||||
return rrRet;
|
||||
}
|
||||
outValue.push_back(resolvedValue);
|
||||
@ -228,7 +229,7 @@ RState ResourceManagerImpl::GetPatternById(uint32_t id, std::map<std::string, st
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceById(id, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by pattern id error id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by pattern id error id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
RState state = GetPattern(idItem, outValue);
|
||||
@ -242,7 +243,7 @@ RState ResourceManagerImpl::GetPatternByName(const char *name, std::map<std::str
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceByName(name, ResType::PATTERN, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by Pattern name error name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by Pattern name error name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
RState state = GetPattern(idItem, outValue);
|
||||
@ -257,7 +258,8 @@ RState ResourceManagerImpl::GetPattern(const std::shared_ptr<IdItem> idItem, std
|
||||
{
|
||||
//type invalid
|
||||
if (idItem->resType_ != ResType::PATTERN) {
|
||||
HILOG_ERROR("actual resType = %{public}d, expect resType = %{public}d", idItem->resType_, ResType::PATTERN);
|
||||
RESMGR_HILOGE(RESMGR_TAG,
|
||||
"actual resType = %{public}d, expect resType = %{public}d", idItem->resType_, ResType::PATTERN);
|
||||
return NOT_FOUND;
|
||||
}
|
||||
return ResolveParentReference(idItem, outValue);
|
||||
@ -282,7 +284,7 @@ RState ResourceManagerImpl::GetPluralStringByIdFormat(std::string &outValue, uin
|
||||
const std::shared_ptr<HapResource::ValueUnderQualifierDir> vuqd = hapManager_->FindQualifierValueById(id,
|
||||
isOverrideResMgr_);
|
||||
if (vuqd == nullptr) {
|
||||
HILOG_ERROR("find qualifier value by plural id error id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find qualifier value by plural id error id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
std::string temp;
|
||||
@ -307,7 +309,7 @@ RState ResourceManagerImpl::GetPluralStringByNameFormat(std::string &outValue, c
|
||||
const std::shared_ptr<HapResource::ValueUnderQualifierDir> vuqd =
|
||||
hapManager_->FindQualifierValueByName(name, ResType::PLURALS, isOverrideResMgr_);
|
||||
if (vuqd == nullptr) {
|
||||
HILOG_ERROR("find qualifier value by plural name error name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find qualifier value by plural name error name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
std::string temp;
|
||||
@ -350,7 +352,7 @@ RState ResourceManagerImpl::GetPluralString(const std::shared_ptr<HapResource::V
|
||||
std::string resolvedValue;
|
||||
RState rrRet = ResolveReference(value, resolvedValue);
|
||||
if (rrRet != SUCCESS) {
|
||||
HILOG_DEBUG("ResolveReference failed, value:%{public}s", value.c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "ResolveReference failed, value:%{public}s", value.c_str());
|
||||
return rrRet;
|
||||
}
|
||||
map[key] = resolvedValue;
|
||||
@ -391,24 +393,25 @@ RState ResourceManagerImpl::ResolveReference(const std::string value, std::strin
|
||||
|
||||
if (IdItem::IsArrayOfType(resType)) {
|
||||
// can't be array
|
||||
HILOG_DEBUG("ref %{public}s can't be array", refStr.c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "ref %{public}s can't be array", refStr.c_str());
|
||||
return ERROR;
|
||||
}
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceById(id, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("ref %s id not found", refStr.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "ref %s id not found", refStr.c_str());
|
||||
return ERROR;
|
||||
}
|
||||
// unless compile bug
|
||||
if (resType != idItem->resType_) {
|
||||
HILOG_ERROR("impossible. ref %s type mismatch, found type: %d", refStr.c_str(), idItem->resType_);
|
||||
RESMGR_HILOGE(RESMGR_TAG,
|
||||
"impossible. ref %s type mismatch, found type: %d", refStr.c_str(), idItem->resType_);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
refStr = idItem->value_;
|
||||
|
||||
if (++count > MAX_DEPTH_REF_SEARCH) {
|
||||
HILOG_ERROR("ref %s has re-ref too much", value.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "ref %s has re-ref too much", value.c_str());
|
||||
return ERROR_CODE_RES_REF_TOO_MUCH;
|
||||
}
|
||||
}
|
||||
@ -458,7 +461,7 @@ RState ResourceManagerImpl::ResolveParentReference(const std::shared_ptr<IdItem>
|
||||
}
|
||||
RState rrRet = ResolveReference(value, resolvedValue);
|
||||
if (rrRet != SUCCESS) {
|
||||
HILOG_DEBUG("ResolveReference failed, value:%{public}s", value.c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "ResolveReference failed, value:%{public}s", value.c_str());
|
||||
return ERROR;
|
||||
}
|
||||
outValue[key] = resolvedValue;
|
||||
@ -469,18 +472,19 @@ RState ResourceManagerImpl::ResolveParentReference(const std::shared_ptr<IdItem>
|
||||
ResType resType;
|
||||
bool isRef = IdItem::IsRef(currItem->values_[0], resType, id);
|
||||
if (!isRef) {
|
||||
HILOG_ERROR("something wrong, pls check HaveParent(). idItem: %{public}s", idItem->ToString().c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG,
|
||||
"something wrong, pls check HaveParent(). idItem: %{public}s", idItem->ToString().c_str());
|
||||
return ERROR;
|
||||
}
|
||||
currItem = hapManager_->FindResourceById(id, isOverrideResMgr_);
|
||||
if (currItem == nullptr) {
|
||||
HILOG_ERROR("ref %s id not found", idItem->values_[0].c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "ref %s id not found", idItem->values_[0].c_str());
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (++count > MAX_DEPTH_REF_SEARCH) {
|
||||
HILOG_ERROR(" %u has too many parents", idItem->id_);
|
||||
RESMGR_HILOGE(RESMGR_TAG, " %u has too many parents", idItem->id_);
|
||||
return ERROR;
|
||||
}
|
||||
} while (haveParent);
|
||||
@ -492,7 +496,7 @@ RState ResourceManagerImpl::GetBooleanById(uint32_t id, bool &outValue)
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceById(id, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by Boolean id error id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by Boolean id error id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
RState state = GetBoolean(idItem, outValue);
|
||||
@ -506,7 +510,7 @@ RState ResourceManagerImpl::GetBooleanByName(const char *name, bool &outValue)
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceByName(name, ResType::BOOLEAN, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by Boolean name error name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by Boolean name error name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
RState state = GetBoolean(idItem, outValue);
|
||||
@ -572,7 +576,7 @@ RState ResourceManagerImpl::GetFloatById(uint32_t id, float &outValue)
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceById(id, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by Float id error id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by Float id error id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -596,7 +600,7 @@ RState ResourceManagerImpl::GetFloatById(uint32_t id, float &outValue, std::stri
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceById(id, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by Float id error with unit id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by Float id error with unit id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -619,7 +623,7 @@ RState ResourceManagerImpl::GetFloatByName(const char *name, float &outValue)
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceByName(name, ResType::FLOAT, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by Float name error name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by Float name error name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -651,7 +655,7 @@ RState ResourceManagerImpl::RecalculateFloat(const std::string &unit, float &res
|
||||
GetResConfig(rc);
|
||||
float density = rc.GetScreenDensity();
|
||||
if (density == SCREEN_DENSITY_NOT_SET) {
|
||||
HILOG_DEBUG("RecalculateFloat srcDensity SCREEN_DENSITY_NOT_SET ");
|
||||
RESMGR_HILOGD(RESMGR_TAG, "RecalculateFloat srcDensity SCREEN_DENSITY_NOT_SET ");
|
||||
return SUCCESS;
|
||||
}
|
||||
if (unit == VIRTUAL_PIXEL) {
|
||||
@ -670,7 +674,7 @@ RState ResourceManagerImpl::ParseFloat(const std::string &strValue, float &resul
|
||||
std::regex reg("(\\+|-)?\\d+(\\.\\d+)? *(px|vp|fp)?");
|
||||
std::smatch floatMatch;
|
||||
if (!regex_search(strValue, floatMatch, reg)) {
|
||||
HILOG_DEBUG("not valid float value %{public}s", strValue.c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "not valid float value %{public}s", strValue.c_str());
|
||||
return ERROR;
|
||||
}
|
||||
std::string matchString(floatMatch.str());
|
||||
@ -700,7 +704,7 @@ RState ResourceManagerImpl::GetIntegerById(uint32_t id, int &outValue)
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceById(id, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by Integer id error id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by Integer id error id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
RState state = GetInteger(idItem, outValue);
|
||||
@ -714,7 +718,7 @@ RState ResourceManagerImpl::GetIntegerByName(const char *name, int &outValue)
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceByName(name, ResType::INTEGER, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by Integer name error name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by Integer name error name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
RState state = GetInteger(idItem, outValue);
|
||||
@ -754,25 +758,26 @@ RState ResourceManagerImpl::ProcessReference(const std::string value,
|
||||
|
||||
if (IdItem::IsArrayOfType(resType)) {
|
||||
// can't be array
|
||||
HILOG_DEBUG("ref %{public}s can't be array", refStr.c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "ref %{public}s can't be array", refStr.c_str());
|
||||
return ERROR;
|
||||
}
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceById(id, isOverrideResMgr_);
|
||||
idItems.emplace_back(idItem);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("ref %s id not found", refStr.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "ref %s id not found", refStr.c_str());
|
||||
return ERROR;
|
||||
}
|
||||
// unless compile bug
|
||||
if (resType != idItem->resType_) {
|
||||
HILOG_ERROR("impossible. ref %s type mismatch, found type: %d", refStr.c_str(), idItem->resType_);
|
||||
RESMGR_HILOGE(RESMGR_TAG,
|
||||
"impossible. ref %s type mismatch, found type: %d", refStr.c_str(), idItem->resType_);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
refStr = idItem->value_;
|
||||
|
||||
if (++count > MAX_DEPTH_REF_SEARCH) {
|
||||
HILOG_ERROR("ref %s has re-ref too much", value.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "ref %s has re-ref too much", value.c_str());
|
||||
return ERROR_CODE_RES_REF_TOO_MUCH;
|
||||
}
|
||||
}
|
||||
@ -798,7 +803,7 @@ RState ResourceManagerImpl::GetColorById(uint32_t id, uint32_t &outValue)
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceById(id, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by string id error id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by string id error id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -818,7 +823,7 @@ RState ResourceManagerImpl::GetColorByName(const char *name, uint32_t &outValue)
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceByName(name, ResType::COLOR, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by string id error name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by string id error name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -851,7 +856,7 @@ RState ResourceManagerImpl::GetSymbolById(uint32_t id, uint32_t &outValue)
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceById(id, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by symbol id error id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by symbol id error id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
RState state = GetSymbol(idItem, outValue);
|
||||
@ -865,7 +870,7 @@ RState ResourceManagerImpl::GetSymbolByName(const char *name, uint32_t &outValue
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceByName(name, ResType::SYMBOL, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by symbol name error name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by symbol name error name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
RState state = GetSymbol(idItem, outValue);
|
||||
@ -912,7 +917,7 @@ RState ResourceManagerImpl::GetIntArray(const std::shared_ptr<IdItem> idItem, st
|
||||
std::string resolvedValue;
|
||||
RState rrRet = ResolveReference(idItem->values_[i], resolvedValue);
|
||||
if (rrRet != SUCCESS) {
|
||||
HILOG_DEBUG("ResolveReference failed, value:%{public}s", idItem->values_[i].c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "ResolveReference failed, value:%{public}s", idItem->values_[i].c_str());
|
||||
return ERROR;
|
||||
}
|
||||
outValue.push_back(stoi(resolvedValue));
|
||||
@ -924,7 +929,7 @@ RState ResourceManagerImpl::GetThemeById(uint32_t id, std::map<std::string, std:
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceById(id, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by Theme id error id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by Theme id error id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
RState state = GetTheme(idItem, outValue);
|
||||
@ -938,7 +943,7 @@ RState ResourceManagerImpl::GetThemeByName(const char *name, std::map<std::strin
|
||||
{
|
||||
const std::shared_ptr<IdItem> idItem = hapManager_->FindResourceByName(name, ResType::THEME, isOverrideResMgr_);
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("find resource by Theme name error name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find resource by Theme name error name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
RState state = GetTheme(idItem, outValue);
|
||||
@ -952,7 +957,8 @@ RState ResourceManagerImpl::GetTheme(const std::shared_ptr<IdItem> idItem, std::
|
||||
{
|
||||
//type invalid
|
||||
if (idItem->resType_ != ResType::THEME) {
|
||||
HILOG_ERROR("actual resType = %{public}d, expect resType = %{public}d", idItem->resType_, ResType::THEME);
|
||||
RESMGR_HILOGE(RESMGR_TAG,
|
||||
"actual resType = %{public}d, expect resType = %{public}d", idItem->resType_, ResType::THEME);
|
||||
return NOT_FOUND;
|
||||
}
|
||||
return ResolveParentReference(idItem, outValue);
|
||||
@ -962,7 +968,7 @@ RState ResourceManagerImpl::GetProfileById(uint32_t id, std::string &outValue)
|
||||
{
|
||||
auto qd = hapManager_->FindQualifierValueById(id, isOverrideResMgr_);
|
||||
if (qd == nullptr) {
|
||||
HILOG_ERROR("GetProfileById find qualifier value by profile id error id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "GetProfileById find qualifier value by profile id error id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
RState state = hapManager_->GetFilePath(qd, ResType::PROF, outValue);
|
||||
@ -973,7 +979,8 @@ RState ResourceManagerImpl::GetProfileByName(const char *name, std::string &outV
|
||||
{
|
||||
auto qd = hapManager_->FindQualifierValueByName(name, ResType::PROF, isOverrideResMgr_);
|
||||
if (qd == nullptr) {
|
||||
HILOG_ERROR("GetProfileByName find qualifier value by profile name error name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG,
|
||||
"GetProfileByName find qualifier value by profile name error name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
RState state = hapManager_->GetFilePath(qd, ResType::PROF, outValue);
|
||||
@ -983,12 +990,12 @@ RState ResourceManagerImpl::GetProfileByName(const char *name, std::string &outV
|
||||
RState ResourceManagerImpl::GetMediaById(uint32_t id, std::string &outValue, uint32_t density)
|
||||
{
|
||||
if (!IsDensityValid(density)) {
|
||||
HILOG_ERROR("density invalid");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "density invalid");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
auto qd = hapManager_->FindQualifierValueById(id, isOverrideResMgr_, density);
|
||||
if (qd == nullptr) {
|
||||
HILOG_ERROR("GetMediaById find qualifier value by Media id error id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "GetMediaById find qualifier value by Media id error id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
RState state = hapManager_->GetFilePath(qd, ResType::MEDIA, outValue);
|
||||
@ -998,12 +1005,12 @@ RState ResourceManagerImpl::GetMediaById(uint32_t id, std::string &outValue, uin
|
||||
RState ResourceManagerImpl::GetMediaByName(const char *name, std::string &outValue, uint32_t density)
|
||||
{
|
||||
if (!IsDensityValid(density)) {
|
||||
HILOG_ERROR("density invalid");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "density invalid");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
auto qd = hapManager_->FindQualifierValueByName(name, ResType::MEDIA, isOverrideResMgr_, density);
|
||||
if (qd == nullptr) {
|
||||
HILOG_ERROR("GetMediaByName find qualifier value by Media name error name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "GetMediaByName find qualifier value by Media name error name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
RState state = hapManager_->GetFilePath(qd, ResType::MEDIA, outValue);
|
||||
@ -1032,7 +1039,7 @@ void ResourceManagerImpl::ProcessPsuedoTranslate(std::string &outValue)
|
||||
if (strcpy_s(src, len, outValue.c_str()) == EOK) {
|
||||
std::string resultMsg = psueManager_->Convert(src, outValue);
|
||||
if (resultMsg != "") {
|
||||
HILOG_ERROR("Psuedo translate failed, value:%s", src);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "Psuedo translate failed, value:%s", src);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1100,7 +1107,7 @@ RState ResourceManagerImpl::UpdateFakeLocaleFlag(ResConfig &resConfig)
|
||||
RState ResourceManagerImpl::UpdateResConfig(ResConfig &resConfig, bool isUpdateTheme)
|
||||
{
|
||||
if (isUpdateTheme) {
|
||||
HILOG_DEBUG("The theme enabled");
|
||||
RESMGR_HILOGD(RESMGR_TAG, "The theme enabled");
|
||||
ThemePackManager::GetThemePackManager()->LoadThemeRes(bundleInfo.first, bundleInfo.second, userId);
|
||||
}
|
||||
#if !defined(__WINNT__) && !defined(__IDE_PREVIEW__) && !defined(__ARKUI_CROSS__)
|
||||
@ -1169,12 +1176,12 @@ RState ResourceManagerImpl::GetMediaDataById(uint32_t id, size_t &len, std::uniq
|
||||
uint32_t density)
|
||||
{
|
||||
if (!IsDensityValid(density)) {
|
||||
HILOG_ERROR("density invalid");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "density invalid");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
auto qd = hapManager_->FindQualifierValueById(id, isOverrideResMgr_, density);
|
||||
if (qd == nullptr) {
|
||||
HILOG_ERROR("GetMediaDataById find qualifier value by media id error id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "GetMediaDataById find qualifier value by media id error id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -1192,13 +1199,14 @@ RState ResourceManagerImpl::GetMediaDataByName(const char *name, size_t &len, st
|
||||
uint32_t density)
|
||||
{
|
||||
if (!IsDensityValid(density)) {
|
||||
HILOG_ERROR("density invalid");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "density invalid");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
|
||||
auto qd = hapManager_->FindQualifierValueByName(name, ResType::MEDIA, isOverrideResMgr_, density);
|
||||
if (qd == nullptr) {
|
||||
HILOG_ERROR("GetMediaDataByName find qualifier value by media name error name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG,
|
||||
"GetMediaDataByName find qualifier value by media name error name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -1227,13 +1235,13 @@ RState ResourceManagerImpl::GetThemeMediaBase64(const std::shared_ptr<IdItem> id
|
||||
RState ResourceManagerImpl::GetMediaBase64DataById(uint32_t id, std::string &outValue, uint32_t density)
|
||||
{
|
||||
if (!IsDensityValid(density)) {
|
||||
HILOG_ERROR("density invalid");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "density invalid");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
|
||||
auto qd = hapManager_->FindQualifierValueById(id, isOverrideResMgr_, density);
|
||||
if (qd == nullptr) {
|
||||
HILOG_ERROR("GetMediaBase64DataById find qualifier value by media id error id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "GetMediaBase64DataById find qualifier value by media id error id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -1249,12 +1257,13 @@ RState ResourceManagerImpl::GetMediaBase64DataById(uint32_t id, std::string &out
|
||||
RState ResourceManagerImpl::GetMediaBase64DataByName(const char *name, std::string &outValue, uint32_t density)
|
||||
{
|
||||
if (!IsDensityValid(density)) {
|
||||
HILOG_ERROR("density invalid");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "density invalid");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
auto qd = hapManager_->FindQualifierValueByName(name, ResType::MEDIA, isOverrideResMgr_, density);
|
||||
if (qd == nullptr) {
|
||||
HILOG_ERROR("GetMediaBase64DataByName find qualifier value by media name error name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG,
|
||||
"GetMediaBase64DataByName find qualifier value by media name error name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -1271,7 +1280,7 @@ RState ResourceManagerImpl::GetProfileDataById(uint32_t id, size_t &len, std::un
|
||||
{
|
||||
auto qd = hapManager_->FindQualifierValueById(id, isOverrideResMgr_);
|
||||
if (qd == nullptr) {
|
||||
HILOG_ERROR("GetProfileDataById find qualifier value by profile id error id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "GetProfileDataById find qualifier value by profile id error id = %{public}d", id);
|
||||
return ERROR_CODE_RES_NOT_FOUND_BY_ID;
|
||||
}
|
||||
return hapManager_->GetProfileData(qd, len, outValue);
|
||||
@ -1281,7 +1290,8 @@ RState ResourceManagerImpl::GetProfileDataByName(const char *name, size_t &len,
|
||||
{
|
||||
auto qd = hapManager_->FindQualifierValueByName(name, ResType::PROF, isOverrideResMgr_);
|
||||
if (qd == nullptr) {
|
||||
HILOG_ERROR("GetProfileDataByName find qualifier value by profile name error name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG,
|
||||
"GetProfileDataByName find qualifier value by profile name error name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NOT_FOUND_BY_NAME;
|
||||
}
|
||||
return hapManager_->GetProfileData(qd, len, outValue);
|
||||
@ -1341,7 +1351,8 @@ RState ResourceManagerImpl::GetThemeIcon(const std::shared_ptr<IdItem> idItem, s
|
||||
std::string iconName = idItem->GetItemResName();
|
||||
std::string result = ThemePackManager::GetThemePackManager()->FindThemeIconResource(bundleInfo, iconName);
|
||||
if (result.empty()) {
|
||||
HILOG_DEBUG("GetThemeIcon FAILED bundlename = %{public}s, modulename = %{public}s, iconName = %{public}s",
|
||||
RESMGR_HILOGD(RESMGR_TAG,
|
||||
"GetThemeIcon FAILED bundlename = %{public}s, modulename = %{public}s, iconName = %{public}s",
|
||||
bundleInfo.first.c_str(), bundleInfo.second.c_str(), iconName.c_str());
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
@ -1366,17 +1377,17 @@ RState ResourceManagerImpl::GetDrawableInfoById(uint32_t id, std::string &type,
|
||||
std::unique_ptr<uint8_t[]> &outValue, uint32_t density)
|
||||
{
|
||||
if (!IsDensityValid(density)) {
|
||||
HILOG_ERROR("density invalid");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "density invalid");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
auto qd = hapManager_->FindQualifierValueById(id, isOverrideResMgr_, density);
|
||||
if (qd == nullptr) {
|
||||
HILOG_ERROR("find qualifier value error by drawable id id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find qualifier value error by drawable id id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
type = GetSuffix(qd);
|
||||
if (type.empty()) {
|
||||
HILOG_ERROR("failed to get resourceType");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get resourceType");
|
||||
return ERROR_CODE_RES_NOT_FOUND_BY_ID;
|
||||
}
|
||||
return hapManager_->GetMediaData(qd, len, outValue);
|
||||
@ -1386,17 +1397,17 @@ RState ResourceManagerImpl::GetDrawableInfoByName(const char *name, std::string
|
||||
std::unique_ptr<uint8_t[]> &outValue, uint32_t density)
|
||||
{
|
||||
if (!IsDensityValid(density)) {
|
||||
HILOG_ERROR("density invalid");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "density invalid");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
auto qd = hapManager_->FindQualifierValueByName(name, ResType::MEDIA, isOverrideResMgr_, density);
|
||||
if (qd == nullptr) {
|
||||
HILOG_ERROR("find qualifier value error by drawable name name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find qualifier value error by drawable name name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
type = GetSuffix(qd);
|
||||
if (type.empty()) {
|
||||
HILOG_ERROR("failed to get resourceType");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get resourceType");
|
||||
return ERROR_CODE_RES_NOT_FOUND_BY_NAME;
|
||||
}
|
||||
return hapManager_->GetMediaData(qd, len, outValue);
|
||||
@ -1407,17 +1418,17 @@ RState ResourceManagerImpl::GetDrawableInfoById(uint32_t id,
|
||||
std::unique_ptr<uint8_t[]> &outValue, uint32_t iconType, uint32_t density)
|
||||
{
|
||||
if (!IsDensityValid(density)) {
|
||||
HILOG_ERROR("density invalid");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "density invalid");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
auto qd = hapManager_->FindQualifierValueById(id, isOverrideResMgr_, density);
|
||||
if (qd == nullptr) {
|
||||
HILOG_ERROR("find qualifier value error by drawable id id = %{public}d", id);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find qualifier value error by drawable id id = %{public}d", id);
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
std::string type = GetSuffix(qd);
|
||||
if (type.empty()) {
|
||||
HILOG_ERROR("failed to get resourceType");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get resourceType");
|
||||
return ERROR_CODE_RES_NOT_FOUND_BY_ID;
|
||||
}
|
||||
size_t len = 0;
|
||||
@ -1439,17 +1450,17 @@ RState ResourceManagerImpl::GetDrawableInfoByName(const char *name,
|
||||
std::unique_ptr<uint8_t[]> &outValue, uint32_t iconType, uint32_t density)
|
||||
{
|
||||
if (!IsDensityValid(density)) {
|
||||
HILOG_ERROR("density invalid");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "density invalid");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
auto qd = hapManager_->FindQualifierValueByName(name, ResType::MEDIA, isOverrideResMgr_, density);
|
||||
if (qd == nullptr) {
|
||||
HILOG_ERROR("find qualifier value error by drawable name name = %{public}s", name);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "find qualifier value error by drawable name name = %{public}s", name);
|
||||
return ERROR_CODE_RES_NAME_NOT_FOUND;
|
||||
}
|
||||
std::string type = GetSuffix(qd);
|
||||
if (type.empty()) {
|
||||
HILOG_ERROR("failed to get resourceType");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get resourceType");
|
||||
return ERROR_CODE_RES_NOT_FOUND_BY_NAME;
|
||||
}
|
||||
size_t len = 0;
|
||||
@ -1499,7 +1510,7 @@ RState ResourceManagerImpl::GetStringFormatByName(const char *name, std::string
|
||||
uint32_t ResourceManagerImpl::GetResourceLimitKeys()
|
||||
{
|
||||
if (hapManager_ == nullptr) {
|
||||
HILOG_ERROR("resource manager get limit keys failed, hapManager_ is nullptr");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "resource manager get limit keys failed, hapManager_ is nullptr");
|
||||
return 0;
|
||||
}
|
||||
return hapManager_->GetResourceLimitKeys();
|
||||
@ -1525,7 +1536,7 @@ RState ResourceManagerImpl::GetThemeIconInfo(const std::string &iconName, size_t
|
||||
{
|
||||
std::string result = ThemePackManager::GetThemePackManager()->FindThemeIconResource(bundleInfo, iconName);
|
||||
if (result.empty()) {
|
||||
HILOG_DEBUG("GetThemeIconInfo FAILED bundlename = %{public}s,", result.c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "GetThemeIconInfo FAILED bundlename = %{public}s,", result.c_str());
|
||||
return ERROR_CODE_RES_ID_NOT_FOUND;
|
||||
}
|
||||
outValue = Utils::LoadResourceFile(result, len);
|
||||
@ -1569,7 +1580,7 @@ std::shared_ptr<ResourceManager> ResourceManagerImpl::GetOverrideResourceManager
|
||||
{
|
||||
ResourceManagerImpl *impl = new (std::nothrow) ResourceManagerImpl(true);
|
||||
if (impl == nullptr) {
|
||||
HILOG_ERROR("new ResourceManagerImpl failed when GetOverrideResourceManager");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new ResourceManagerImpl failed when GetOverrideResourceManager");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1580,7 +1591,7 @@ std::shared_ptr<ResourceManager> ResourceManagerImpl::GetOverrideResourceManager
|
||||
|
||||
std::shared_ptr<ResourceManager> overrideResMgr(impl);
|
||||
if (overrideResMgr == nullptr) {
|
||||
HILOG_ERROR("GetOverrideResourceManager failed bundleName = %{public}s, moduleName = %{public}s",
|
||||
RESMGR_HILOGE(RESMGR_TAG, "GetOverrideResourceManager failed bundleName = %{public}s, moduleName = %{public}s",
|
||||
this->bundleInfo.first.c_str(), this->bundleInfo.second.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
@ -1588,7 +1599,7 @@ std::shared_ptr<ResourceManager> ResourceManagerImpl::GetOverrideResourceManager
|
||||
overrideResMgr->bundleInfo.first = this->bundleInfo.first;
|
||||
overrideResMgr->bundleInfo.second = this->bundleInfo.second;
|
||||
if (overrideResConfig && overrideResMgr->UpdateOverrideResConfig(*overrideResConfig) != SUCCESS) {
|
||||
HILOG_ERROR("GetOverrideResourceManager UpdateOverrideResConfig failed bundleName = %{public}s, \
|
||||
RESMGR_HILOGE(RESMGR_TAG, "GetOverrideResourceManager UpdateOverrideResConfig failed bundleName = %{public}s, \
|
||||
moduleName = %{public}s", this->bundleInfo.first.c_str(), this->bundleInfo.second.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -61,12 +61,12 @@ ResourceManagerImpl *SystemResourceManager::GetSystemResourceManager()
|
||||
|
||||
ResourceManagerImpl *SystemResourceManager::GetSystemResourceManagerNoSandBox()
|
||||
{
|
||||
HILOG_INFO("GetSystemResourceManagerNoSandBox");
|
||||
RESMGR_HILOGI(RESMGR_TAG, "GetSystemResourceManagerNoSandBox");
|
||||
// appspawn can only add no sandbox system resource path, so all app that forked from appspawn have
|
||||
// one global resourceManager.
|
||||
bool isCreated = CreateSystemResourceManager(false);
|
||||
if (!isCreated) {
|
||||
HILOG_WARN("CreateSystemResourceManager failed when GetSystemResourceManagerNoSandBox");
|
||||
RESMGR_HILOGW(RESMGR_TAG, "CreateSystemResourceManager failed when GetSystemResourceManagerNoSandBox");
|
||||
return nullptr;
|
||||
}
|
||||
return resourceManager_;
|
||||
@ -81,7 +81,7 @@ bool SystemResourceManager::CreateSystemResourceManager(bool isSandbox)
|
||||
if (resourceManager_ == nullptr) {
|
||||
ResourceManagerImpl *impl = new (std::nothrow) ResourceManagerImpl;
|
||||
if (impl == nullptr) {
|
||||
HILOG_ERROR("new ResourceManagerImpl failed when CreateSystemResourceManager");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new ResourceManagerImpl failed when CreateSystemResourceManager");
|
||||
return false;
|
||||
}
|
||||
if (!impl->Init(true)) {
|
||||
|
@ -131,7 +131,7 @@ void ThemePackManager::LoadThemeSkinResource(const std::string &bundleName, cons
|
||||
for (const auto &dir : rootDirs) {
|
||||
auto pos = dir.rfind('/');
|
||||
if (pos == std::string::npos) {
|
||||
HILOG_ERROR("invalid dir = %{public}s in LoadThemeSkinResource", dir.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "invalid dir = %{public}s in LoadThemeSkinResource", dir.c_str());
|
||||
continue;
|
||||
}
|
||||
std::string tempBundleName = dir.substr(pos + 1);
|
||||
@ -234,7 +234,7 @@ const std::string ThemePackManager::GetThemeResource(const std::pair<std::string
|
||||
{
|
||||
auto themeQualifierValue = GetThemeQualifierValue(bundInfo, resType, resName, resConfig);
|
||||
if (themeQualifierValue == nullptr) {
|
||||
HILOG_DEBUG("themeQualifierValue == nullptr");
|
||||
RESMGR_HILOGD(RESMGR_TAG, "themeQualifierValue == nullptr");
|
||||
return std::string("");
|
||||
}
|
||||
return themeQualifierValue->GetResValue();
|
||||
@ -341,7 +341,7 @@ void ThemePackManager::LoadThemeIconsResource(const std::string &bundleName, con
|
||||
for (const auto &dir : rootDirs) {
|
||||
auto pos = dir.rfind('/');
|
||||
if (pos == std::string::npos) {
|
||||
HILOG_ERROR("invalid dir = %{public}s in LoadThemeIconsResource", dir.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "invalid dir = %{public}s in LoadThemeIconsResource", dir.c_str());
|
||||
continue;
|
||||
}
|
||||
auto pThemeResource = ThemeResource::LoadThemeIconResource(dir);
|
||||
|
@ -109,7 +109,7 @@ void ThemeResource::InitThemeRes(std::pair<std::string, std::string> bundleInfo,
|
||||
std::shared_ptr<ThemeConfig> themeConfig, const std::string &resTypeStr)
|
||||
{
|
||||
if (root == nullptr) {
|
||||
HILOG_WARN("The json file has not resType = %{public}s", resTypeStr.c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "The json file has not resType = %{public}s", resTypeStr.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -119,12 +119,12 @@ void ThemeResource::InitThemeRes(std::pair<std::string, std::string> bundleInfo,
|
||||
while (childValue != nullptr) {
|
||||
cJSON *name = cJSON_GetObjectItem(childValue, "name");
|
||||
if (name == nullptr || !cJSON_IsString(name)) {
|
||||
HILOG_WARN("The resource name is not exist in childValue");
|
||||
RESMGR_HILOGW(RESMGR_TAG, "The resource name is not exist in childValue");
|
||||
return;
|
||||
}
|
||||
cJSON *value = cJSON_GetObjectItem(childValue, "value");
|
||||
if (value == nullptr || !cJSON_IsString(value)) {
|
||||
HILOG_WARN("The resource value is not exist in childValue");
|
||||
RESMGR_HILOGW(RESMGR_TAG, "The resource value is not exist in childValue");
|
||||
return;
|
||||
}
|
||||
auto themeValue = std::make_shared<ThemeValue>();
|
||||
@ -145,7 +145,7 @@ void ThemeResource::ParseJson(const std::string &bundleName, const std::string &
|
||||
auto len = 0;
|
||||
FILE* pf = std::fopen(jsonPath.c_str(), "r");
|
||||
if (pf == nullptr) {
|
||||
HILOG_ERROR("fopen failed in ParseJson");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "fopen failed in ParseJson");
|
||||
return;
|
||||
}
|
||||
std::fseek(pf, 0, SEEK_END);
|
||||
@ -153,7 +153,7 @@ void ThemeResource::ParseJson(const std::string &bundleName, const std::string &
|
||||
std::fseek(pf, 0, SEEK_SET);
|
||||
char *jsonData = (char *)malloc(len + 1);
|
||||
if (jsonData == nullptr) {
|
||||
HILOG_ERROR("failed malloc in ParseJson");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed malloc in ParseJson");
|
||||
if (pf != nullptr) {
|
||||
fclose(pf);
|
||||
pf = nullptr;
|
||||
@ -187,7 +187,7 @@ void ThemeResource::ParseIcon(const std::string &bundleName, const std::string &
|
||||
auto pos1 = iconPath.rfind('.');
|
||||
auto pos2 = iconPath.rfind('/');
|
||||
if (pos1 == std::string::npos || pos2 == std::string::npos) {
|
||||
HILOG_ERROR("invalid iconPath = %{public}s in ParseIcon", iconPath.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "invalid iconPath = %{public}s in ParseIcon", iconPath.c_str());
|
||||
return;
|
||||
}
|
||||
if (pos1 < pos2 + 1) {
|
||||
@ -227,7 +227,7 @@ std::vector<std::string> GetFiles(const std::string &strCurrentDir)
|
||||
DIR *dir;
|
||||
struct dirent *pDir;
|
||||
if ((dir = opendir(strCurrentDir.c_str())) == nullptr) {
|
||||
HILOG_ERROR("opendir failed strCurrentDir = %{public}s", strCurrentDir.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "opendir failed strCurrentDir = %{public}s", strCurrentDir.c_str());
|
||||
return vFiles;
|
||||
}
|
||||
while ((pDir = readdir(dir)) != nullptr) {
|
||||
@ -256,13 +256,13 @@ std::tuple<std::string, std::string> GetBundleInfo(const std::string& rootDir, c
|
||||
size_t len = rootDir.size();
|
||||
auto pos = rootDir.rfind('/');
|
||||
if (pos == std::string::npos) {
|
||||
HILOG_ERROR("invalid rootDir = %{public}s in GetBundleInfo", rootDir.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "invalid rootDir = %{public}s in GetBundleInfo", rootDir.c_str());
|
||||
return std::tuple<std::string, std::string>("", "");
|
||||
}
|
||||
std::string bundleName = rootDir.substr(pos + 1);
|
||||
auto pos2 = path.find('/', len + 1);
|
||||
if (pos2 == std::string::npos) {
|
||||
HILOG_ERROR("invalid path = %{public}s in GetBundleInfo", path.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "invalid path = %{public}s in GetBundleInfo", path.c_str());
|
||||
return std::tuple<std::string, std::string>("", "");
|
||||
}
|
||||
if (pos2 < len + 1) {
|
||||
@ -276,7 +276,7 @@ std::tuple<std::string, std::string> GetBundleInfo(const std::string& rootDir, c
|
||||
const std::shared_ptr<ThemeResource> ThemeResource::LoadThemeResource(const std::string& rootDir)
|
||||
{
|
||||
if (rootDir.empty()) {
|
||||
HILOG_ERROR("Invalid rootDir in LoadThemeResource = %{public}s", rootDir.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "Invalid rootDir in LoadThemeResource = %{public}s", rootDir.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
auto themeResource = std::make_shared<ThemeResource>(rootDir);
|
||||
@ -285,7 +285,7 @@ const std::shared_ptr<ThemeResource> ThemeResource::LoadThemeResource(const std:
|
||||
auto bundleInfo = GetBundleInfo(rootDir, path);
|
||||
auto pos = path.rfind('.');
|
||||
if (pos == std::string::npos) {
|
||||
HILOG_ERROR("invalid resPath = %{public}s", path.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "invalid resPath = %{public}s", path.c_str());
|
||||
continue;
|
||||
}
|
||||
std::string tail = path.substr(pos + 1);
|
||||
@ -302,7 +302,7 @@ std::string ThemeResource::GetThemeResBundleName(const std::string &themePath)
|
||||
{
|
||||
auto pos = themePath.rfind('/');
|
||||
if (pos == std::string::npos) {
|
||||
HILOG_ERROR("invalid themePath = %{public}s", themePath.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "invalid themePath = %{public}s", themePath.c_str());
|
||||
return std::string("");
|
||||
}
|
||||
std::string bundleName = themePath.substr(pos + 1);
|
||||
@ -316,7 +316,7 @@ std::string GetIconsBundleName(const std::string& iconPath)
|
||||
}
|
||||
auto pos = iconPath.rfind('/');
|
||||
if (pos == std::string::npos) {
|
||||
HILOG_ERROR("invalid iconPath = %{public}s in GetIconsBundleName", iconPath.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "invalid iconPath = %{public}s in GetIconsBundleName", iconPath.c_str());
|
||||
return std::string("");
|
||||
}
|
||||
return iconPath.substr(pos + 1);
|
||||
@ -334,7 +334,7 @@ const std::shared_ptr<ThemeResource> ThemeResource::LoadThemeIconResource(const
|
||||
auto pos1 = path.rfind('.');
|
||||
auto pos2 = path.rfind('/');
|
||||
if (pos1 == std::string::npos || pos2 == std::string::npos || pos1 < pos2 + 1) {
|
||||
HILOG_ERROR("invalid path = %{public}s in LoadThemeIconResource", path.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "invalid path = %{public}s in LoadThemeIconResource", path.c_str());
|
||||
continue;
|
||||
}
|
||||
std::string iconName = path.substr(pos2 + 1, pos1 - pos2 - 1);
|
||||
|
@ -74,7 +74,7 @@ int32_t GetCurrentFileInfo(unzFile &uf, unz_file_info &fileInfo)
|
||||
char filenameInzip[256]; // for unzGetCurrentFileInfo
|
||||
int err = unzGetCurrentFileInfo(uf, &fileInfo, filenameInzip, sizeof(filenameInzip), nullptr, 0, nullptr, 0);
|
||||
if (err != UNZ_OK) {
|
||||
HILOG_ERROR("GetCurrentFileInfo failed");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "GetCurrentFileInfo failed");
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
return OK;
|
||||
@ -86,19 +86,19 @@ int32_t ReadCurrentFile(unzFile &uf, unz_file_info &fileInfo, std::unique_ptr<ui
|
||||
buffer = std::make_unique<uint8_t[]>(fileInfo.uncompressed_size);
|
||||
bufLen = fileInfo.uncompressed_size;
|
||||
if (buffer == nullptr) {
|
||||
HILOG_ERROR("Error allocating memory for read buffer");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "Error allocating memory for read buffer");
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
int err = unzOpenCurrentFilePassword(uf, nullptr);
|
||||
if (err != UNZ_OK) {
|
||||
HILOG_ERROR("Error %d in unzOpenCurrentFilePassword.", err);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "Error %d in unzOpenCurrentFilePassword.", err);
|
||||
return UNKNOWN_ERROR;
|
||||
} // file inside the zip is open
|
||||
|
||||
err = unzReadCurrentFile(uf, buffer.get(), bufLen);
|
||||
if (err < 0) {
|
||||
HILOG_ERROR("Error %d in unzReadCurrentFile", err);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "Error %d in unzReadCurrentFile", err);
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
@ -164,13 +164,13 @@ std::string ParseModuleNameFromHap(unzFile &uf)
|
||||
size_t tmpLen;
|
||||
ret = HapParser::ReadFileFromZip(uf, "config.json", tmpBuf, tmpLen);
|
||||
if (ret != OK) {
|
||||
HILOG_ERROR("read config.json error");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "read config.json error");
|
||||
return std::string();
|
||||
}
|
||||
// parse config.json
|
||||
std::string mName = GetModuleName(reinterpret_cast<char *>(tmpBuf.get()), tmpLen);
|
||||
if (mName.size() == 0) {
|
||||
HILOG_ERROR("parse moduleName from config.json error");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "parse moduleName from config.json error");
|
||||
return std::string();
|
||||
}
|
||||
return mName;
|
||||
@ -201,7 +201,7 @@ int32_t HapParser::ReadIndexFromFile(const char *zipFile, std::unique_ptr<uint8_
|
||||
{
|
||||
unzFile uf = unzOpen64(zipFile);
|
||||
if (uf == nullptr) {
|
||||
HILOG_ERROR("Error open %{public}s in ReadIndexFromFile %{public}d", zipFile, errno);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "Error open %{public}s in ReadIndexFromFile %{public}d", zipFile, errno);
|
||||
return UNKNOWN_ERROR;
|
||||
} // file is open
|
||||
if (IsStageMode(uf)) {
|
||||
@ -233,13 +233,13 @@ std::string HapParser::ParseModuleName(std::shared_ptr<AbilityBase::Extractor> &
|
||||
size_t len;
|
||||
bool ret = extractor->ExtractToBufByName("config.json", configBuf, len);
|
||||
if (!ret) {
|
||||
HILOG_ERROR("failed to get config data from ability");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get config data from ability");
|
||||
return std::string();
|
||||
}
|
||||
// parse config.json
|
||||
std::string mName = GetModuleName(reinterpret_cast<char *>(configBuf.get()), len);
|
||||
if (mName.size() == 0) {
|
||||
HILOG_ERROR("parse moduleName from config.json error");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "parse moduleName from config.json error");
|
||||
return std::string();
|
||||
}
|
||||
return mName;
|
||||
@ -284,17 +284,18 @@ RState HapParser::ReadRawFileFromHap(const std::string &hapPath, const std::stri
|
||||
bool isNewExtractor = false;
|
||||
auto extractor = AbilityBase::ExtractorUtil::GetExtractor(hapPath, isNewExtractor);
|
||||
if (extractor == nullptr) {
|
||||
HILOG_ERROR("failed to get extractor hapPath, %{public}s", hapPath.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get extractor hapPath, %{public}s", hapPath.c_str());
|
||||
return NOT_FOUND;
|
||||
}
|
||||
std::string rawfilePath = HapParser::GetRawFilePath(extractor, rawFileName);
|
||||
if (!extractor->HasEntry(rawfilePath)) {
|
||||
HILOG_DEBUG("the rawfile file %{public}s is not exist in %{public}s", rawfilePath.c_str(), hapPath.c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG,
|
||||
"the rawfile file %{public}s is not exist in %{public}s", rawfilePath.c_str(), hapPath.c_str());
|
||||
return ERROR_CODE_RES_PATH_INVALID;
|
||||
}
|
||||
bool ret = extractor->ExtractToBufByName(rawfilePath, outValue, len);
|
||||
if (!ret) {
|
||||
HILOG_ERROR("failed to get rawfile data rawfilePath, %{public}s, hapPath, %{public}s",
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get rawfile data rawfilePath, %{public}s, hapPath, %{public}s",
|
||||
rawfilePath.c_str(), hapPath.c_str());
|
||||
return NOT_FOUND;
|
||||
}
|
||||
@ -312,23 +313,24 @@ RState HapParser::ReadRawFileDescriptor(const char *hapPath, const std::string &
|
||||
bool isNewExtractor = false;
|
||||
auto extractor = AbilityBase::ExtractorUtil::GetExtractor(outPath, isNewExtractor);
|
||||
if (extractor == nullptr) {
|
||||
HILOG_ERROR("failed to get extractor in ReadRawFileDescriptor hapPath, %{public}s", outPath);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get extractor in ReadRawFileDescriptor hapPath, %{public}s", outPath);
|
||||
return NOT_FOUND;
|
||||
}
|
||||
std::string rawfilePath = HapParser::GetRawFilePath(extractor, rawFileName);
|
||||
if (!extractor->HasEntry(rawfilePath)) {
|
||||
HILOG_DEBUG("the rawfile file %{public}s is not exist in %{public}s", rawfilePath.c_str(), hapPath);
|
||||
RESMGR_HILOGD(RESMGR_TAG,
|
||||
"the rawfile file %{public}s is not exist in %{public}s", rawfilePath.c_str(), hapPath);
|
||||
return ERROR_CODE_RES_PATH_INVALID;
|
||||
}
|
||||
AbilityBase::FileInfo fileInfo;
|
||||
bool ret = extractor->GetFileInfo(rawfilePath, fileInfo);
|
||||
if (!ret) {
|
||||
HILOG_ERROR("failed to get rawFileDescriptor rawfilePath, %{public}s", rawfilePath.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get rawFileDescriptor rawfilePath, %{public}s", rawfilePath.c_str());
|
||||
return NOT_FOUND;
|
||||
}
|
||||
int zipFd = open(outPath, O_RDONLY);
|
||||
if (zipFd < 0) {
|
||||
HILOG_ERROR("failed open file %{public}s", outPath);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed open file %{public}s", outPath);
|
||||
return NOT_FOUND;
|
||||
}
|
||||
descriptor.offset = static_cast<long>(fileInfo.offset);
|
||||
@ -346,18 +348,20 @@ RState HapParser::GetRawFileList(const std::string &hapPath, const std::string &
|
||||
bool isNewExtractor = false;
|
||||
auto extractor = AbilityBase::ExtractorUtil::GetExtractor(hapPath, isNewExtractor);
|
||||
if (extractor == nullptr) {
|
||||
HILOG_ERROR("failed to get extractor from ability in GetRawFileList hapPath, %{public}s", hapPath.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG,
|
||||
"failed to get extractor from ability in GetRawFileList hapPath, %{public}s", hapPath.c_str());
|
||||
return NOT_FOUND;
|
||||
}
|
||||
std::set<std::string> fileSet;
|
||||
std::string rawfilePath = HapParser::GetRawFilePath(extractor, rawDirPath);
|
||||
if (!extractor->IsDirExist(rawfilePath)) {
|
||||
HILOG_DEBUG("the rawfile dir %{public}s is not exist in %{public}s", rawfilePath.c_str(), hapPath.c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG,
|
||||
"the rawfile dir %{public}s is not exist in %{public}s", rawfilePath.c_str(), hapPath.c_str());
|
||||
return ERROR_CODE_RES_PATH_INVALID;
|
||||
}
|
||||
bool ret = extractor->GetFileList(rawfilePath, fileSet);
|
||||
if (!ret) {
|
||||
HILOG_ERROR("failed to get fileSet from ability rawfilePath, %{public}s", rawfilePath.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get fileSet from ability rawfilePath, %{public}s", rawfilePath.c_str());
|
||||
return ERROR_CODE_RES_PATH_INVALID;
|
||||
}
|
||||
for (auto it = fileSet.begin(); it != fileSet.end(); it++) {
|
||||
@ -495,7 +499,7 @@ int32_t ParseId(const char *buffer, uint32_t &offset, std::shared_ptr<ResId> id,
|
||||
for (uint32_t i = 0; i < id->count_; ++i) {
|
||||
std::shared_ptr<IdParam> ip = std::make_shared<IdParam>();
|
||||
if (ip == nullptr) {
|
||||
HILOG_ERROR("new IdParam failed when ParseId");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new IdParam failed when ParseId");
|
||||
return SYS_ERROR;
|
||||
}
|
||||
errno_t eret = memcpy_s(ip.get(), sizeof(IdParam), buffer + offset, ResId::IDPARAM_HEADER_LEN);
|
||||
@ -505,7 +509,7 @@ int32_t ParseId(const char *buffer, uint32_t &offset, std::shared_ptr<ResId> id,
|
||||
offset += ResId::IDPARAM_HEADER_LEN;
|
||||
std::shared_ptr<IdItem> idItem = std::make_shared<IdItem>();
|
||||
if (idItem == nullptr) {
|
||||
HILOG_ERROR("new IdItem failed when ParseId");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new IdItem failed when ParseId");
|
||||
return SYS_ERROR;
|
||||
}
|
||||
uint32_t ipOffset = ip->offset_;
|
||||
@ -533,7 +537,7 @@ bool IsLocaleMatch(const std::shared_ptr<ResConfigImpl> defaultConfig,
|
||||
if (LocaleMatcher::Match(defaultConfig->GetResLocale(), config->GetResLocale())) {
|
||||
return true;
|
||||
}
|
||||
HILOG_DEBUG("mismatch, do not parse %s", HapParser::ToFolderPath(keyParams).c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "mismatch, do not parse %s", HapParser::ToFolderPath(keyParams).c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -552,7 +556,7 @@ int32_t ParseKey(const char *buffer, uint32_t &offset, std::shared_ptr<ResKey> k
|
||||
for (uint32_t i = 0; i < key->keyParamsCount_; ++i) {
|
||||
std::shared_ptr<KeyParam> kp = std::make_shared<KeyParam>();
|
||||
if (kp == nullptr) {
|
||||
HILOG_ERROR("new KeyParam failed when ParseKey");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new KeyParam failed when ParseKey");
|
||||
return SYS_ERROR;
|
||||
}
|
||||
errno_t eret = memcpy_s(kp.get(), sizeof(KeyParam), buffer + offset, ResKey::KEYPARAM_HEADER_LEN);
|
||||
@ -578,7 +582,7 @@ int32_t ParseKey(const char *buffer, uint32_t &offset, std::shared_ptr<ResKey> k
|
||||
uint32_t idOffset = key->offset_;
|
||||
std::shared_ptr<ResId> id = std::make_shared<ResId>();
|
||||
if (id == nullptr) {
|
||||
HILOG_ERROR("new ResId failed when ParseKey");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new ResId failed when ParseKey");
|
||||
return SYS_ERROR;
|
||||
}
|
||||
int32_t ret = ParseId(buffer, idOffset, id, selectedTypes);
|
||||
@ -595,7 +599,7 @@ int32_t HapParser::ParseResHex(const char *buffer, const size_t bufLen, ResDesc
|
||||
{
|
||||
ResHeader *resHeader = new (std::nothrow) ResHeader();
|
||||
if (resHeader == nullptr) {
|
||||
HILOG_ERROR("new ResHeader failed when ParseResHex");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new ResHeader failed when ParseResHex");
|
||||
return SYS_ERROR;
|
||||
}
|
||||
uint32_t offset = 0;
|
||||
@ -615,7 +619,7 @@ int32_t HapParser::ParseResHex(const char *buffer, const size_t bufLen, ResDesc
|
||||
for (uint32_t i = 0; i < resHeader->keyCount_; i++) {
|
||||
std::shared_ptr<ResKey> key = std::make_shared<ResKey>();
|
||||
if (key == nullptr) {
|
||||
HILOG_ERROR("new ResKey failed when ParseResHex");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new ResKey failed when ParseResHex");
|
||||
return SYS_ERROR;
|
||||
}
|
||||
bool match = true;
|
||||
@ -635,7 +639,7 @@ std::shared_ptr<ResConfigImpl> HapParser::CreateResConfigFromKeyParams(
|
||||
{
|
||||
auto resConfig = std::make_shared<ResConfigImpl>();
|
||||
if (resConfig == nullptr) {
|
||||
HILOG_ERROR("new ResConfigImpl failed when CreateResConfigFromKeyParams");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new ResConfigImpl failed when CreateResConfigFromKeyParams");
|
||||
return nullptr;
|
||||
}
|
||||
size_t len = keyParams.size();
|
||||
@ -681,12 +685,12 @@ std::shared_ptr<ResConfigImpl> HapParser::CreateResConfigFromKeyParams(
|
||||
std::shared_ptr<ResConfigImpl> HapParser::BuildResConfig(ResConfigKey *configKey)
|
||||
{
|
||||
if (configKey == nullptr) {
|
||||
HILOG_ERROR("configKey is null");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "configKey is null");
|
||||
return nullptr;
|
||||
}
|
||||
auto resConfig = std::make_shared<ResConfigImpl>();
|
||||
if (resConfig == nullptr) {
|
||||
HILOG_ERROR("new ResConfigImpl failed when BuildResConfig");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new ResConfigImpl failed when BuildResConfig");
|
||||
return nullptr;
|
||||
}
|
||||
resConfig->SetDeviceType(configKey->deviceType);
|
||||
@ -698,8 +702,8 @@ std::shared_ptr<ResConfigImpl> HapParser::BuildResConfig(ResConfigKey *configKey
|
||||
resConfig->SetScreenDensity((configKey->screenDensity) / Utils::DPI_BASE);
|
||||
RState r = resConfig->SetLocaleInfo(configKey->language, configKey->script, configKey->region);
|
||||
if (r != SUCCESS) {
|
||||
HILOG_ERROR("error set locale,lang %s,script %s,region %s", configKey->language, configKey->script,
|
||||
configKey->region);
|
||||
RESMGR_HILOGE(RESMGR_TAG,
|
||||
"error set locale,lang %s,script %s,region %s", configKey->language, configKey->script, configKey->region);
|
||||
}
|
||||
|
||||
return resConfig;
|
||||
@ -837,7 +841,7 @@ std::string HapParser::BuildFolderPath(Determiner *determiner)
|
||||
{
|
||||
std::string path;
|
||||
if (determiner == nullptr) {
|
||||
HILOG_ERROR("determiner is null");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "determiner is null");
|
||||
return path;
|
||||
}
|
||||
std::string connecter1("_");
|
||||
@ -870,13 +874,13 @@ RState HapParser::IsRawDirFromHap(const char *hapPath, const std::string &pathNa
|
||||
{
|
||||
#if !defined(__WINNT__) && !defined(__IDE_PREVIEW__) && !defined(__ARKUI_CROSS__)
|
||||
if (pathName.empty()) {
|
||||
HILOG_ERROR("the rawfile path is empty");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "the rawfile path is empty");
|
||||
return ERROR_CODE_RES_PATH_INVALID;
|
||||
}
|
||||
bool isNewExtractor = false;
|
||||
auto extractor = AbilityBase::ExtractorUtil::GetExtractor(hapPath, isNewExtractor);
|
||||
if (extractor == nullptr) {
|
||||
HILOG_ERROR("failed to get extractor hapPath, %{public}s", hapPath);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get extractor hapPath, %{public}s", hapPath);
|
||||
return NOT_FOUND;
|
||||
}
|
||||
std::string rawPath = HapParser::GetRawFilePath(extractor, pathName);
|
||||
@ -885,7 +889,7 @@ RState HapParser::IsRawDirFromHap(const char *hapPath, const std::string &pathNa
|
||||
} else if (extractor->IsDirExist(rawPath)) {
|
||||
outValue = true;
|
||||
} else {
|
||||
HILOG_ERROR("the rawfile file %{public}s is not exist in %{public}s", rawPath.c_str(), hapPath);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "the rawfile file %{public}s is not exist in %{public}s", rawPath.c_str(), hapPath);
|
||||
return ERROR_CODE_RES_PATH_INVALID;
|
||||
}
|
||||
#endif
|
||||
@ -898,7 +902,7 @@ RState HapParser::IsRawDirUnCompressed(const std::string &pathName, bool &outVal
|
||||
Utils::CanonicalizePath(pathName.c_str(), outPath, PATH_MAX);
|
||||
struct stat fileStat {};
|
||||
if (stat(outPath, &fileStat) != 0) {
|
||||
HILOG_ERROR("failed to get rawfile file info, %{public}s", outPath);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get rawfile file info, %{public}s", outPath);
|
||||
return ERROR_CODE_RES_PATH_INVALID;
|
||||
}
|
||||
if ((fileStat.st_mode & S_IFDIR)) {
|
||||
@ -906,7 +910,7 @@ RState HapParser::IsRawDirUnCompressed(const std::string &pathName, bool &outVal
|
||||
} else if ((fileStat.st_mode & S_IFREG)) {
|
||||
outValue = false;
|
||||
} else {
|
||||
HILOG_ERROR("the rawfile file %{public}s is not exist", outPath);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "the rawfile file %{public}s is not exist", outPath);
|
||||
return ERROR_CODE_RES_PATH_INVALID;
|
||||
}
|
||||
return SUCCESS;
|
||||
|
@ -76,7 +76,7 @@ bool LocalizeNumber(std::string &inputOutputNum, const ResConfigImpl &resConfig,
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
const ResLocale *resLocale = resConfig.GetResLocale();
|
||||
if (resLocale == nullptr) {
|
||||
HILOG_WARN("LocalizeNumber resLocale is null");
|
||||
RESMGR_HILOGW(RESMGR_TAG, "LocalizeNumber resLocale is null");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ bool LocalizeNumber(std::string &inputOutputNum, const ResConfigImpl &resConfig,
|
||||
if (language != nullptr && strlen(language) > 0) {
|
||||
localeInfo.assign(language);
|
||||
} else {
|
||||
HILOG_WARN("LocalizeNumber language is null");
|
||||
RESMGR_HILOGW(RESMGR_TAG, "LocalizeNumber language is null");
|
||||
return true;
|
||||
}
|
||||
std::string temp;
|
||||
@ -116,7 +116,7 @@ bool LocalizeNumber(std::string &inputOutputNum, const ResConfigImpl &resConfig,
|
||||
inputOutputNum.clear();
|
||||
numberFormat.formatDouble(num, status).toString(status).toUTF8String(inputOutputNum);
|
||||
if (status == U_ZERO_ERROR) {
|
||||
HILOG_ERROR("LocalizeNumber failed, status = %{public}d", status);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "LocalizeNumber failed, status = %{public}d", status);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -129,7 +129,7 @@ bool GetReplaceStr(const std::vector<std::tuple<ResourceManager::NapiValueType,
|
||||
const size_t ¶mIndex, const std::string &placeHolderType, const ResConfigImpl &config, std::string &replaceStr)
|
||||
{
|
||||
if (paramIndex >= jsParams.size()) {
|
||||
HILOG_ERROR("index of placeholder out of range");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "index of placeholder out of range");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ bool GetReplaceStr(const std::vector<std::tuple<ResourceManager::NapiValueType,
|
||||
// string type
|
||||
if (placeHolderType == "s") {
|
||||
if (paramType != ResourceManager::NapiValueType::NAPI_STRING) {
|
||||
HILOG_ERROR("the type of placeholder and param does not match");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "the type of placeholder and param does not match");
|
||||
return false;
|
||||
}
|
||||
replaceStr = paramValue;
|
||||
@ -148,7 +148,7 @@ bool GetReplaceStr(const std::vector<std::tuple<ResourceManager::NapiValueType,
|
||||
|
||||
// number type
|
||||
if (paramType != ResourceManager::NapiValueType::NAPI_NUMBER) {
|
||||
HILOG_ERROR("the type of placeholder and param does not match");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "the type of placeholder and param does not match");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ bool ReplacePlaceholderWithParams(std::string &inputOutputValue, const ResConfig
|
||||
if (placeholderIndex.length() != 0) {
|
||||
if (placeholderIndex.size() > SIZE_T_MAX_STR.size() ||
|
||||
(placeholderIndex.size() == SIZE_T_MAX_STR.size() && placeholderIndex > SIZE_T_MAX_STR)) {
|
||||
HILOG_ERROR("index of placeholder is too large");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "index of placeholder is too large");
|
||||
return false;
|
||||
}
|
||||
if (std::stoul(placeholderIndex) < 1) {
|
||||
|
@ -55,7 +55,7 @@ RState Utils::GetMediaBase64Data(const std::string& iconPath, std::string &base6
|
||||
size_t len = 0;
|
||||
auto tempData = Utils::LoadResourceFile(iconPath, len);
|
||||
if (tempData == nullptr) {
|
||||
HILOG_ERROR("get the tempData error");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "get the tempData error");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
auto pos = iconPath.find_last_of('.');
|
||||
@ -76,7 +76,7 @@ std::unique_ptr<uint8_t[]> Utils::LoadResourceFile(const std::string &path, size
|
||||
mediaStream.seekg(0, std::ios::end);
|
||||
int length = mediaStream.tellg();
|
||||
if (length == ERROR_RESULT) {
|
||||
HILOG_ERROR("failed to get the file length");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to get the file length");
|
||||
return nullptr;
|
||||
} else {
|
||||
len = static_cast<size_t>(length);
|
||||
@ -441,7 +441,7 @@ RState Utils::ConvertColorToUInt32(const char *s, uint32_t &outValue)
|
||||
bool Utils::endWithTail(const std::string& path, const std::string& tail)
|
||||
{
|
||||
if (path.size() < tail.size()) {
|
||||
HILOG_ERROR("the path is shorter than tail");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "the path is shorter than tail");
|
||||
return false;
|
||||
}
|
||||
return path.compare(path.size() - tail.size(), tail.size(), tail) == 0;
|
||||
@ -469,21 +469,21 @@ void Utils::CanonicalizePath(const char *path, char *outPath, size_t len)
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
#endif
|
||||
if (path == nullptr) {
|
||||
HILOG_ERROR("path is null");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "path is null");
|
||||
return;
|
||||
}
|
||||
if (strlen(path) >= len) {
|
||||
HILOG_ERROR("the length of path longer than len");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "the length of path longer than len");
|
||||
return;
|
||||
}
|
||||
#ifdef __WINNT__
|
||||
if (!PathCanonicalizeA(outPath, path)) {
|
||||
HILOG_ERROR("failed to canonicalize the path");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to canonicalize the path");
|
||||
return;
|
||||
}
|
||||
#else
|
||||
if (realpath(path, outPath) == nullptr) {
|
||||
HILOG_ERROR("failed to realpath the path, %{public}s, errno:%{public}d", path, errno);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "failed to realpath the path, %{public}s, errno:%{public}d", path, errno);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@ -500,13 +500,13 @@ RState Utils::GetFiles(const std::string &strCurrentDir, std::vector<std::string
|
||||
char outPath[PATH_MAX + 1] = {0};
|
||||
Utils::CanonicalizePath(strCurrentDir.c_str(), outPath, PATH_MAX);
|
||||
if (outPath[0] == '\0') {
|
||||
HILOG_ERROR("invalid path, %{public}s", strCurrentDir.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "invalid path, %{public}s", strCurrentDir.c_str());
|
||||
return ERROR_CODE_RES_PATH_INVALID;
|
||||
}
|
||||
DIR *dir;
|
||||
struct dirent *pDir;
|
||||
if ((dir = opendir(strCurrentDir.c_str())) == nullptr) {
|
||||
HILOG_ERROR("opendir failed strCurrentDir = %{public}s", strCurrentDir.c_str());
|
||||
RESMGR_HILOGE(RESMGR_TAG, "opendir failed strCurrentDir = %{public}s", strCurrentDir.c_str());
|
||||
return ERROR_CODE_RES_PATH_INVALID;
|
||||
}
|
||||
while ((pDir = readdir(dir)) != nullptr) {
|
||||
|
@ -53,13 +53,13 @@ void HapManagerTest::TearDownTestCase()
|
||||
void HapManagerTest::SetUp()
|
||||
{
|
||||
// step 3: input testcase setup step
|
||||
HILOG_DEBUG("HapManagerTest setup");
|
||||
RESMGR_HILOGD(RESMGR_TAG, "HapManagerTest setup");
|
||||
}
|
||||
|
||||
void HapManagerTest::TearDown()
|
||||
{
|
||||
// step 4: input testcase teardown step
|
||||
HILOG_DEBUG("HapManagerTest teardown");
|
||||
RESMGR_HILOGD(RESMGR_TAG, "HapManagerTest teardown");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -71,7 +71,7 @@ void TestGetIdValuesByName(const std::shared_ptr<HapResource> pResource)
|
||||
auto cost = CurrentTimeUsec() - start;
|
||||
// 3 compare with the size of LimitPaths
|
||||
EXPECT_EQ(static_cast<size_t>(3), idValues->GetLimitPathsConst().size());
|
||||
HILOG_DEBUG("GetIdValues by name cost: %ld us.", cost);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "GetIdValues by name cost: %ld us.", cost);
|
||||
PrintIdValues(idValues);
|
||||
{
|
||||
auto limitPath = idValues->GetLimitPathsConst()[0];
|
||||
@ -105,7 +105,7 @@ HWTEST_F(HapResourceTest, HapResourceFuncTest001, TestSize.Level0)
|
||||
std::shared_ptr<ResConfigImpl> rc = nullptr;
|
||||
auto pResource = HapResource::LoadFromIndex(FormatFullPath(g_resFilePath).c_str(), rc);
|
||||
auto cost = CurrentTimeUsec() - start;
|
||||
HILOG_DEBUG("load cost: %ld us.", cost);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "load cost: %ld us.", cost);
|
||||
|
||||
if (pResource == nullptr) {
|
||||
EXPECT_TRUE(false);
|
||||
@ -117,7 +117,7 @@ HWTEST_F(HapResourceTest, HapResourceFuncTest001, TestSize.Level0)
|
||||
auto idValues = pResource->GetIdValues(id);
|
||||
cost = CurrentTimeUsec() - start;
|
||||
EXPECT_EQ(static_cast<size_t>(3), idValues->GetLimitPathsConst().size());
|
||||
HILOG_DEBUG("GetIdValues by id cost: %ld us.", cost);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "GetIdValues by id cost: %ld us.", cost);
|
||||
PrintIdValues(idValues);
|
||||
{
|
||||
auto limitPath = idValues->GetLimitPathsConst()[0];
|
||||
@ -148,7 +148,7 @@ void GetIdValuesByNameFuncTest002(const std::shared_ptr<HapResource> pResource,
|
||||
auto idValues = pResource->GetIdValuesByName(name, ResType::STRING);
|
||||
auto cost = CurrentTimeUsec() - start;
|
||||
EXPECT_EQ(static_cast<size_t>(3), idValues->GetLimitPathsConst().size()); // 3 means the number of candidates
|
||||
HILOG_DEBUG("GetIdValues by name cost: %ld us.", cost);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "GetIdValues by name cost: %ld us.", cost);
|
||||
PrintIdValues(idValues);
|
||||
|
||||
{
|
||||
@ -181,7 +181,7 @@ HWTEST_F(HapResourceTest, HapResourceFuncTest002, TestSize.Level1)
|
||||
auto start = CurrentTimeUsec();
|
||||
auto pResource = HapResource::LoadFromIndex(path, rc);
|
||||
auto cost = CurrentTimeUsec() - start;
|
||||
HILOG_DEBUG("load cost: %ld us.", cost);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "load cost: %ld us.", cost);
|
||||
|
||||
if (pResource == nullptr) {
|
||||
EXPECT_TRUE(false);
|
||||
@ -193,7 +193,7 @@ HWTEST_F(HapResourceTest, HapResourceFuncTest002, TestSize.Level1)
|
||||
auto idValues = pResource->GetIdValues(id);
|
||||
cost = CurrentTimeUsec() - start;
|
||||
EXPECT_EQ(static_cast<size_t>(3), idValues->GetLimitPathsConst().size());
|
||||
HILOG_DEBUG("GetIdValues by id cost: %ld us.", cost);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "GetIdValues by id cost: %ld us.", cost);
|
||||
PrintIdValues(idValues);
|
||||
|
||||
{
|
||||
@ -224,7 +224,7 @@ HWTEST_F(HapResourceTest, HapResourceFuncTest003, TestSize.Level1)
|
||||
std::shared_ptr<ResConfigImpl> rc = nullptr;
|
||||
auto pResource = HapResource::LoadFromIndex(FormatFullPath(g_resFilePath).c_str(), rc);
|
||||
auto cost = CurrentTimeUsec() - start;
|
||||
HILOG_DEBUG("load cost: %ld us.", cost);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "load cost: %ld us.", cost);
|
||||
|
||||
if (pResource == nullptr) {
|
||||
EXPECT_TRUE(false);
|
||||
@ -265,19 +265,19 @@ ResDesc *LoadFromHap(const char *hapPath, const std::shared_ptr<ResConfigImpl> d
|
||||
size_t bufLen;
|
||||
int32_t out = HapParser::ReadIndexFromFile(hapPath, buf, bufLen);
|
||||
if (out != OK) {
|
||||
HILOG_ERROR("ReadIndexFromFile failed! retcode:%d", out);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "ReadIndexFromFile failed! retcode:%d", out);
|
||||
return nullptr;
|
||||
}
|
||||
HILOG_DEBUG("extract success, bufLen:%zu", bufLen);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "extract success, bufLen:%zu", bufLen);
|
||||
|
||||
ResDesc *resDesc = new ResDesc();
|
||||
out = HapParser::ParseResHex(reinterpret_cast<char *>(buf.get()), bufLen, *resDesc, defaultConfig);
|
||||
if (out != OK) {
|
||||
delete (resDesc);
|
||||
HILOG_ERROR("ParseResHex failed! retcode:%d", out);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "ParseResHex failed! retcode:%d", out);
|
||||
return nullptr;
|
||||
} else {
|
||||
HILOG_DEBUG("ParseResHex success:\n%s", resDesc->ToString().c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "ParseResHex success:\n%s", resDesc->ToString().c_str());
|
||||
}
|
||||
// construct hapresource
|
||||
return resDesc;
|
||||
|
@ -604,7 +604,7 @@ HWTEST_F(LocaleInfoTest, LocaleInfoPerformanceFuncTest001, TestSize.Level1)
|
||||
total += std::chrono::duration_cast<std::chrono::microseconds>(t2 - t1).count();
|
||||
}
|
||||
average = total / 1000.0;
|
||||
HILOG_DEBUG("avg cost FindAndSort: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost FindAndSort: %f us", average);
|
||||
EXPECT_LT(average, 500);
|
||||
};
|
||||
}
|
@ -49,13 +49,13 @@ void ResDescTest::TearDownTestCase(void)
|
||||
void ResDescTest::SetUp()
|
||||
{
|
||||
// step 3: input testcase setup step
|
||||
HILOG_DEBUG("ResDescTest setup");
|
||||
RESMGR_HILOGD(RESMGR_TAG, "ResDescTest setup");
|
||||
}
|
||||
|
||||
void ResDescTest::TearDown()
|
||||
{
|
||||
// step 4: input testcase teardown step
|
||||
HILOG_DEBUG("ResDescTest teardown");
|
||||
RESMGR_HILOGD(RESMGR_TAG, "ResDescTest teardown");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -98,7 +98,7 @@ void ResourceManagerPerformanceTest::SetUp(void)
|
||||
delete rc;
|
||||
bool ret = rm->AddResource(FormatFullPath(g_resFilePath).c_str());
|
||||
if (!ret) {
|
||||
HILOG_ERROR("AddResource failed. test would fail.");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "AddResource failed. test would fail.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,22 +118,22 @@ int ParseIndexCost(const std::string &pstr, char *buf, const size_t& bufLen)
|
||||
auto t1 = std::chrono::high_resolution_clock::now();
|
||||
auto resDesc = std::make_shared<ResDesc>();
|
||||
if (resDesc == nullptr) {
|
||||
HILOG_ERROR("new ResDesc failed when LoadFromIndex");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new ResDesc failed when LoadFromIndex");
|
||||
free(buf);
|
||||
return -1;
|
||||
}
|
||||
int32_t out = HapParser::ParseResHex((char *)buf, bufLen, *resDesc, nullptr);
|
||||
if (out != OK) {
|
||||
free(buf);
|
||||
HILOG_ERROR("ParseResHex failed! retcode:%d", out);
|
||||
RESMGR_HILOGE(RESMGR_TAG, "ParseResHex failed! retcode:%d", out);
|
||||
return -1;
|
||||
} else {
|
||||
HILOG_DEBUG("ParseResHex success:\n%s", resDesc->ToString().c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "ParseResHex success:\n%s", resDesc->ToString().c_str());
|
||||
}
|
||||
|
||||
auto pResource = new(std::nothrow) HapResource(pstr, 0, resDesc);
|
||||
if (pResource == nullptr) {
|
||||
HILOG_ERROR("new HapResource failed when LoadFromIndex");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "new HapResource failed when LoadFromIndex");
|
||||
free(buf);
|
||||
return -1;
|
||||
}
|
||||
@ -146,7 +146,7 @@ int ParseIndexCost(const std::string &pstr, char *buf, const size_t& bufLen)
|
||||
}
|
||||
double average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("parse index avg cost 001: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "parse index avg cost 001: %f us", average);
|
||||
EXPECT_LT(average, 2000); // 2000 means the cost of time
|
||||
return OK;
|
||||
}
|
||||
@ -166,13 +166,13 @@ int TestLoadFromIndex(const char *filePath)
|
||||
inFile.seekg(0, std::ios::end);
|
||||
size_t bufLen = inFile.tellg();
|
||||
if (bufLen <= 0) {
|
||||
HILOG_ERROR("file size is zero");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "file size is zero");
|
||||
inFile.close();
|
||||
return -1;
|
||||
}
|
||||
void *buf = malloc(bufLen);
|
||||
if (buf == nullptr) {
|
||||
HILOG_ERROR("Error allocating memory");
|
||||
RESMGR_HILOGE(RESMGR_TAG, "Error allocating memory");
|
||||
inFile.close();
|
||||
return -1;
|
||||
}
|
||||
@ -184,7 +184,7 @@ int TestLoadFromIndex(const char *filePath)
|
||||
auto readFilecost = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
|
||||
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("read index file cost 001: %lld us", readFilecost);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "read index file cost 001: %lld us", readFilecost);
|
||||
g_logLevel = LOG_INFO;
|
||||
if (ParseIndexCost(pstr, (char *)buf, bufLen) == -1) {
|
||||
return -1;
|
||||
@ -192,7 +192,7 @@ int TestLoadFromIndex(const char *filePath)
|
||||
free(buf);
|
||||
average = total / 1000.0; // 1000.0 means Divide by the total number to obtain the average value
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("parse index avg cost 001: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "parse index avg cost 001: %f us", average);
|
||||
EXPECT_LT(average, 2000); // 2000 means the cost of time
|
||||
return OK;
|
||||
}
|
||||
@ -240,7 +240,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest002,
|
||||
delete rc;
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 002: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 002: %f us", average);
|
||||
EXPECT_LT(average, 2000);
|
||||
};
|
||||
|
||||
@ -274,7 +274,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest003,
|
||||
delete rc;
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 003: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 003: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -311,7 +311,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest004,
|
||||
}
|
||||
average = total / (1000.0 * count);
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 004: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 004: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -341,7 +341,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest005,
|
||||
}
|
||||
average = total / (1000.0 * count);
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 005: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 005: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -371,7 +371,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest006,
|
||||
}
|
||||
average = total / (1000.0 * count);
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 006: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 006: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -408,7 +408,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest007,
|
||||
}
|
||||
average = total / (1000.0 * count);
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 007: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 007: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -438,7 +438,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest008,
|
||||
}
|
||||
average = total / (1000.0 * count);
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 008: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 008: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -467,7 +467,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest009,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 009: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 009: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -493,7 +493,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest010,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 010: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 010: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -529,7 +529,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest011,
|
||||
}
|
||||
average = total / (1000.0 * count);
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 011: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 011: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -559,7 +559,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest012,
|
||||
}
|
||||
average = total / (1000.0 * count);
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 012: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 012: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -592,7 +592,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest013,
|
||||
}
|
||||
average = total / (1000.0 * count);
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 013: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 013: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -622,7 +622,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest014,
|
||||
}
|
||||
average = total / (1000.0 * count);
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 014: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 014: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -655,7 +655,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest015,
|
||||
}
|
||||
average = total / (1000.0 * count);
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 015: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 015: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -685,7 +685,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest016,
|
||||
}
|
||||
average = total / (1000.0 * count);
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 016: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 016: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -714,7 +714,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest017,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 017: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 017: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -740,7 +740,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest018,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 018: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 018: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -769,7 +769,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest019,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 019: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 019: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -795,7 +795,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest020,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 020: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 020: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -824,7 +824,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest021,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 021: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 021: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -850,7 +850,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest022,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 022: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 022: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -879,7 +879,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest023,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 023: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 023: %f us", average);
|
||||
EXPECT_LT(average, 220);
|
||||
};
|
||||
|
||||
@ -905,7 +905,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest024,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 024: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 024: %f us", average);
|
||||
EXPECT_LT(average, 160);
|
||||
};
|
||||
|
||||
@ -934,7 +934,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest025,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 025: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 025: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -960,7 +960,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest026,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 026: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 026: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -989,7 +989,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest027,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 027: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 027: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -1015,7 +1015,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest028,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 028: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 028: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -1044,7 +1044,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest029,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 029: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 029: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -1070,7 +1070,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest030,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 030: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 030: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -1099,7 +1099,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest031,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 031: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 031: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
|
||||
@ -1125,7 +1125,7 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest032,
|
||||
}
|
||||
average = total / 1000.0;
|
||||
g_logLevel = LOG_DEBUG;
|
||||
HILOG_DEBUG("avg cost 032: %f us", average);
|
||||
RESMGR_HILOGD(RESMGR_TAG, "avg cost 032: %f us", average);
|
||||
EXPECT_LT(average, 100);
|
||||
};
|
||||
}
|
||||
|
@ -1779,7 +1779,7 @@ HWTEST_F(ResourceManagerTest, ResourceManagerResolveParentReferenceTest001, Test
|
||||
ASSERT_EQ(SUCCESS, ret);
|
||||
PrintMapString(outValue);
|
||||
|
||||
HILOG_DEBUG("=====");
|
||||
RESMGR_HILOGD(RESMGR_TAG, "=====");
|
||||
id = rmc->GetResId("child", ResType::PATTERN);
|
||||
idItem = ((ResourceManagerImpl *)rm)->hapManager_->FindResourceById(id);
|
||||
ASSERT_TRUE(idItem != nullptr);
|
||||
@ -1787,7 +1787,7 @@ HWTEST_F(ResourceManagerTest, ResourceManagerResolveParentReferenceTest001, Test
|
||||
ASSERT_EQ(SUCCESS, ret);
|
||||
PrintMapString(outValue);
|
||||
|
||||
HILOG_DEBUG("=====");
|
||||
RESMGR_HILOGD(RESMGR_TAG, "=====");
|
||||
id = rmc->GetResId("ccchild", ResType::PATTERN);
|
||||
idItem = ((ResourceManagerImpl *)rm)->hapManager_->FindResourceById(id);
|
||||
ASSERT_TRUE(idItem != nullptr);
|
||||
|
@ -69,7 +69,7 @@ void ResourceManagerTestCommon::TestStringByName(const char *name, const char *c
|
||||
std::string outValue;
|
||||
RState rState = rm->GetStringByName(name, outValue);
|
||||
ASSERT_EQ(SUCCESS, rState);
|
||||
HILOG_DEBUG("%s : %s", name, outValue.c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "%s : %s", name, outValue.c_str());
|
||||
ASSERT_EQ(std::string(cmp), outValue);
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ void ResourceManagerTestCommon::TestGetRawFilePathByName(const std::string &name
|
||||
{
|
||||
std::string outValue;
|
||||
rm->GetRawFilePathByName(name, outValue);
|
||||
HILOG_DEBUG("%s : %s", name.c_str(), outValue.c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "%s : %s", name.c_str(), outValue.c_str());
|
||||
ASSERT_EQ(cmp, outValue);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ void PrintIdValues(const std::shared_ptr<HapResource::IdValues> &idValues)
|
||||
}
|
||||
for (size_t i = 0; i < idValues->GetLimitPathsConst().size(); ++i) {
|
||||
auto limitPath = idValues->GetLimitPathsConst()[i];
|
||||
HILOG_DEBUG("%zu: folder is: %s, value: %s", i, limitPath->GetFolder().c_str(),
|
||||
RESMGR_HILOGD(RESMGR_TAG, "%zu: folder is: %s, value: %s", i, limitPath->GetFolder().c_str(),
|
||||
limitPath->GetIdItem()->ToString().c_str());
|
||||
}
|
||||
}
|
||||
@ -57,7 +57,7 @@ void PrintMapString(const std::map<std::string, std::string> &value)
|
||||
for (; iter != value.end(); ++iter) {
|
||||
std::string key = iter->first;
|
||||
std::string val = iter->second;
|
||||
HILOG_DEBUG("%s : %s", key.c_str(), val.c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "%s : %s", key.c_str(), val.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ void PrintVectorString(const std::vector<std::string> &value)
|
||||
{
|
||||
for (size_t i = 0; i < value.size(); ++i) {
|
||||
std::string val = value[i];
|
||||
HILOG_DEBUG("%zu : %s", i, val.c_str());
|
||||
RESMGR_HILOGD(RESMGR_TAG, "%zu : %s", i, val.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ void ThemeManagerTest::SetUp(void)
|
||||
|
||||
void ThemeManagerTest::TearDown(void)
|
||||
{
|
||||
HILOG_DEBUG("ThemeManagerTest teardown");
|
||||
RESMGR_HILOGD(RESMGR_TAG, "ThemeManagerTest teardown");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -32,6 +32,8 @@ ohos_shared_library("resmgr_napi_core") {
|
||||
"src/resource_manager_napi_utils.cpp",
|
||||
]
|
||||
|
||||
defines = [ "CONFIG_HILOG" ]
|
||||
|
||||
version_script = "libresmgr_napi_core.versionscript"
|
||||
|
||||
public_configs = [ ":resmgr_napi_core_public_config" ]
|
||||
@ -49,7 +51,7 @@ ohos_shared_library("resmgr_napi_core") {
|
||||
]
|
||||
|
||||
if (resource_management_support_icu) {
|
||||
defines = [ "SUPPORT_GRAPHICS" ]
|
||||
defines += [ "SUPPORT_GRAPHICS" ]
|
||||
}
|
||||
|
||||
subsystem_name = "global"
|
||||
|
@ -18,12 +18,10 @@
|
||||
#include "napi/native_node_api.h"
|
||||
#include "resource_manager.h"
|
||||
#include "resource_manager_addon.h"
|
||||
#include "hilog/log_cpp.h"
|
||||
#include "hilog_wrapper.h"
|
||||
namespace OHOS {
|
||||
namespace Global {
|
||||
namespace Resource {
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0xD001E00, "ResourceManagerJs" };
|
||||
using namespace OHOS::HiviewDFX;
|
||||
struct ResMgrDataContext {
|
||||
napi_async_work work_;
|
||||
|
||||
@ -73,9 +71,9 @@ struct ResMgrDataContext {
|
||||
success_ = false;
|
||||
errCode_ = errCode;
|
||||
if (withResId) {
|
||||
HiLog::Error(LABEL, "%{public}s id = %{public}d", msg.c_str(), resId_);
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "%{public}s id = %{public}d", msg.c_str(), resId_);
|
||||
} else {
|
||||
HiLog::Error(LABEL, "%{public}s name = %{public}s", msg.c_str(), resName_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "%{public}s name = %{public}s", msg.c_str(), resName_.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +84,7 @@ struct ResMgrDataContext {
|
||||
std::shared_ptr<ResourceManagerAddon> *addonPtr = nullptr;
|
||||
napi_status status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&addonPtr));
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to unwrap");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to unwrap");
|
||||
return nullptr;
|
||||
}
|
||||
return *addonPtr;
|
||||
|
@ -42,20 +42,20 @@ napi_value ResourceManagerAddon::CreateOverrideAddon(napi_env env, const std::sh
|
||||
napi_value ResourceManagerAddon::WrapResourceManager(napi_env env, std::shared_ptr<ResourceManagerAddon> &addon)
|
||||
{
|
||||
if (!Init(env)) {
|
||||
HiLog::Error(LABEL, "Failed to init resource manager addon");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to init resource manager addon");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value constructor = nullptr;
|
||||
napi_status status = napi_get_reference_value(env, g_constructor, &constructor);
|
||||
if (status != napi_ok || constructor == nullptr) {
|
||||
HiLog::Error(LABEL, "Failed to get reference value in Create, status = %{public}d", status);
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get reference value in Create, status = %{public}d", status);
|
||||
return nullptr;
|
||||
}
|
||||
napi_value result = nullptr;
|
||||
status = napi_new_instance(env, constructor, 0, nullptr, &result);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to new instance in Create, status = %{public}d", status);
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to new instance in Create, status = %{public}d", status);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ napi_value ResourceManagerAddon::WrapResourceManager(napi_env env, std::shared_p
|
||||
status = napi_wrap(env, result, reinterpret_cast<void *>(addonPtr.get()), ResourceManagerAddon::Destructor,
|
||||
nullptr, nullptr);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to wrape in Create");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to wrape in Create");
|
||||
return nullptr;
|
||||
}
|
||||
addonPtr.release();
|
||||
@ -93,20 +93,20 @@ ResourceManagerAddon::ResourceManagerAddon(
|
||||
const std::shared_ptr<AbilityRuntime::Context>& context, bool isSystem)
|
||||
: bundleName_(bundleName), resMgr_(resMgr), context_(context), isSystem_(isSystem)
|
||||
{
|
||||
HiLog::Debug(LABEL, "create ResourceManagerAddon %{public}s", bundleName_.c_str());
|
||||
RESMGR_HILOGD(RESMGR_JS_TAG, "create ResourceManagerAddon %{public}s", bundleName_.c_str());
|
||||
napiContext_ = std::make_shared<ResourceManagerNapiContext>();
|
||||
}
|
||||
|
||||
ResourceManagerAddon::ResourceManagerAddon(const std::shared_ptr<ResourceManager>& resMgr, bool isSystem)
|
||||
: resMgr_(resMgr), isSystem_(isSystem)
|
||||
{
|
||||
HiLog::Debug(LABEL, "create ResourceManagerAddon.");
|
||||
RESMGR_HILOGD(RESMGR_JS_TAG, "create ResourceManagerAddon.");
|
||||
napiContext_ = std::make_shared<ResourceManagerNapiContext>();
|
||||
}
|
||||
|
||||
ResourceManagerAddon::~ResourceManagerAddon()
|
||||
{
|
||||
HiLog::Debug(LABEL, "~ResourceManagerAddon %{public}s", bundleName_.c_str());
|
||||
RESMGR_HILOGD(RESMGR_JS_TAG, "~ResourceManagerAddon %{public}s", bundleName_.c_str());
|
||||
}
|
||||
|
||||
void ResourceManagerAddon::Destructor(napi_env env, void *nativeObject, void *hint)
|
||||
@ -188,13 +188,13 @@ bool ResourceManagerAddon::Init(napi_env env)
|
||||
napi_status status = napi_define_class(env, "ResourceManager", NAPI_AUTO_LENGTH, New, nullptr,
|
||||
sizeof(properties) / sizeof(napi_property_descriptor), properties, &constructor);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to define class at Init");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to define class at Init");
|
||||
return false;
|
||||
}
|
||||
|
||||
status = napi_create_reference(env, constructor, 1, &g_constructor);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to create reference at init");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to create reference at init");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -69,7 +69,7 @@ napi_value ResourceManagerNapiAsyncImpl::GetResource(napi_env env, napi_callback
|
||||
{
|
||||
auto functionIndex = asyncFuncMatch.find(functionName);
|
||||
if (functionIndex == asyncFuncMatch.end()) {
|
||||
HiLog::Info(LABEL, "Invalid functionName, %{public}s", functionName.c_str());
|
||||
RESMGR_HILOGI(RESMGR_JS_TAG, "Invalid functionName, %{public}s", functionName.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
return functionIndex->second(env, info);
|
||||
@ -108,12 +108,12 @@ void ResourceManagerNapiAsyncImpl::Complete(napi_env env, napi_status status, vo
|
||||
if (dataContext->deferred_) {
|
||||
if (dataContext->success_) {
|
||||
if (napi_resolve_deferred(env, dataContext->deferred_, result[1]) != napi_ok) {
|
||||
HiLog::Error(LABEL, "napi_resolve_deferred failed");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "napi_resolve_deferred failed");
|
||||
}
|
||||
} else {
|
||||
result[0] = GetCallbackErrorCode(env, dataContext->errCode_, dataContext->errMsg_.c_str());
|
||||
if (napi_reject_deferred(env, dataContext->deferred_, result[0]) != napi_ok) {
|
||||
HiLog::Error(LABEL, "napi_reject_deferred failed");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "napi_reject_deferred failed");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -121,18 +121,18 @@ void ResourceManagerNapiAsyncImpl::Complete(napi_env env, napi_status status, vo
|
||||
napi_value callback = nullptr;
|
||||
napi_status status = napi_get_reference_value(env, dataContext->callbackRef_, &callback);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "napi_get_reference_value failed status=%{public}d", status);
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "napi_get_reference_value failed status=%{public}d", status);
|
||||
break;
|
||||
}
|
||||
napi_value userRet = nullptr;
|
||||
status = napi_call_function(env, nullptr, callback, sizeof(result) / sizeof(napi_value), result, &userRet);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "napi_call_function failed status=%{public}d", status);
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "napi_call_function failed status=%{public}d", status);
|
||||
break;
|
||||
}
|
||||
status = napi_delete_reference(env, dataContext->callbackRef_);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "napi_call_function failed status=%{public}d", status);
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "napi_call_function failed status=%{public}d", status);
|
||||
break;
|
||||
}
|
||||
} while (false);
|
||||
@ -154,11 +154,11 @@ napi_value ResourceManagerNapiAsyncImpl::GetResult(napi_env env, std::unique_ptr
|
||||
napi_create_string_utf8(env, name.c_str(), NAPI_AUTO_LENGTH, &resource);
|
||||
if (napi_create_async_work(env, nullptr, resource, execute, ResourceManagerNapiAsyncImpl::Complete,
|
||||
static_cast<void*>(dataContext.get()), &dataContext->work_) != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to create async work for %{public}s", name.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to create async work for %{public}s", name.c_str());
|
||||
return result;
|
||||
}
|
||||
if (napi_queue_async_work_with_qos(env, dataContext->work_, napi_qos_user_initiated) != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to queue async work for %{public}s", name.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to queue async work for %{public}s", name.c_str());
|
||||
return result;
|
||||
}
|
||||
dataContext.release();
|
||||
@ -247,7 +247,7 @@ napi_value ResourceManagerNapiAsyncImpl::ProcessResourceParamV9(napi_env env, na
|
||||
auto resourcePtr = std::make_shared<ResourceManager::Resource>();
|
||||
int32_t retCode = ResourceManagerNapiUtils::GetResourceObject(env, resourcePtr, argv[0]);
|
||||
if (retCode != SUCCESS) {
|
||||
HiLog::Error(LABEL, "Failed to get native Resource object");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get native Resource object");
|
||||
ResourceManagerNapiUtils::NapiThrow(env, retCode);
|
||||
return nullptr;
|
||||
}
|
||||
@ -324,12 +324,12 @@ napi_value ResourceManagerNapiAsyncImpl::ProcessIdNameParam(napi_env env, napi_c
|
||||
std::shared_ptr<ResourceManager::Resource> resourcePtr = std::make_shared<ResourceManager::Resource>();
|
||||
int32_t retCode = ResourceManagerNapiUtils::GetResourceObject(env, resourcePtr, argv[0]);
|
||||
if (retCode != SUCCESS) {
|
||||
HiLog::Error(LABEL, "Failed to get native Resource object");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get native Resource object");
|
||||
return nullptr;
|
||||
}
|
||||
dataContext->resource_ = resourcePtr;
|
||||
} else if (i == 1 && valueType != napi_number) { // the second quantity param
|
||||
HiLog::Error(LABEL, "Parameter type is not napi_number");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Parameter type is not napi_number");
|
||||
ResourceManagerNapiUtils::NapiThrow(env, ERROR_CODE_INVALID_INPUT_PARAMETER);
|
||||
return nullptr;
|
||||
} else if (i == 1 && valueType == napi_number) {
|
||||
@ -354,7 +354,7 @@ napi_value ResourceManagerNapiAsyncImpl::ProcessNoParam(napi_env env, napi_callb
|
||||
std::shared_ptr<ResourceManagerAddon> *addonPtr = nullptr;
|
||||
napi_status status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&addonPtr));
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to unwrap ProcessNoParam");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to unwrap ProcessNoParam");
|
||||
return nullptr;
|
||||
}
|
||||
dataContext->addon_ = *addonPtr;
|
||||
@ -375,7 +375,7 @@ auto getStringFunc = [](napi_env env, void* data) {
|
||||
|
||||
bool ret = ResourceManagerNapiUtils::GetHapResourceManager(dataContext, resMgr, resId);
|
||||
if (!ret) {
|
||||
HiLog::Error(LABEL, "Failed to GetHapResourceManager in getStringFunc");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to GetHapResourceManager in getStringFunc");
|
||||
return;
|
||||
}
|
||||
RState state = resMgr->GetStringById(resId, dataContext->value_);
|
||||
@ -434,7 +434,7 @@ auto getStringArrayFunc = [](napi_env env, void* data) {
|
||||
if (dataContext->resId_ != 0 || dataContext->resource_ != nullptr) {
|
||||
bool ret = ResourceManagerNapiUtils::GetHapResourceManager(dataContext, resMgr, resId);
|
||||
if (!ret) {
|
||||
HiLog::Error(LABEL, "Failed to GetHapResourceManager in getStringArrayFunc");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to GetHapResourceManager in getStringArrayFunc");
|
||||
return;
|
||||
}
|
||||
state = resMgr->GetStringArrayById(resId, dataContext->arrayValue_);
|
||||
@ -486,7 +486,7 @@ auto getMediaFunc = [](napi_env env, void *data) {
|
||||
std::shared_ptr<ResourceManager> resMgr = nullptr;
|
||||
bool ret = ResourceManagerNapiUtils::GetHapResourceManager(dataContext, resMgr, resId);
|
||||
if (!ret) {
|
||||
HiLog::Error(LABEL, "Failed to GetHapResourceManager in getMediaFunc");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to GetHapResourceManager in getMediaFunc");
|
||||
return;
|
||||
}
|
||||
RState state = resMgr->GetMediaDataById(resId, dataContext->len_, dataContext->mediaData,
|
||||
@ -528,7 +528,7 @@ auto getMediaBase64Func = [](napi_env env, void *data) {
|
||||
std::shared_ptr<ResourceManager> resMgr = nullptr;
|
||||
bool ret = ResourceManagerNapiUtils::GetHapResourceManager(dataContext, resMgr, resId);
|
||||
if (!ret) {
|
||||
HiLog::Error(LABEL, "Failed to GetHapResourceManager in getMediaBase64Func");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to GetHapResourceManager in getMediaBase64Func");
|
||||
return;
|
||||
}
|
||||
state = resMgr->GetMediaBase64DataById(resId, dataContext->value_, dataContext->density_);
|
||||
@ -590,7 +590,7 @@ auto getPluralCapFunc = [](napi_env env, void *data) {
|
||||
std::shared_ptr<ResourceManager> resMgr = nullptr;
|
||||
bool ret = ResourceManagerNapiUtils::GetHapResourceManager(dataContext, resMgr, resId);
|
||||
if (!ret) {
|
||||
HiLog::Error(LABEL, "Failed to GetHapResourceManager in getPluralCapFunc");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to GetHapResourceManager in getPluralCapFunc");
|
||||
return;
|
||||
}
|
||||
state = resMgr->GetPluralStringByIdFormat(dataContext->value_,
|
||||
@ -771,7 +771,7 @@ auto getColorFunc = [](napi_env env, void* data) {
|
||||
int32_t resId = 0;
|
||||
|
||||
if (!ResourceManagerNapiUtils::GetHapResourceManager(dataContext, resMgr, resId)) {
|
||||
HiLog::Error(LABEL, "Failed to GetHapResourceManager in getColorFunc");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to GetHapResourceManager in getColorFunc");
|
||||
return;
|
||||
}
|
||||
RState state = resMgr->GetColorById(resId, dataContext->colorValue_);
|
||||
|
@ -77,7 +77,7 @@ napi_value ResourceManagerNapiSyncImpl::GetResource(napi_env env, napi_callback_
|
||||
{
|
||||
auto functionIndex = syncFuncMatch.find(functionName);
|
||||
if (functionIndex == syncFuncMatch.end()) {
|
||||
HiLog::Info(LABEL, "Invalid functionName, %{public}s", functionName.c_str());
|
||||
RESMGR_HILOGI(RESMGR_JS_TAG, "Invalid functionName, %{public}s", functionName.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
return functionIndex->second(env, info);
|
||||
@ -89,7 +89,7 @@ int32_t ResourceManagerNapiSyncImpl::InitPathAddon(napi_env env, napi_callback_i
|
||||
GET_PARAMS(env, info, PARAMS_NUM_TWO);
|
||||
dataContext->addon_ = ResMgrDataContext::GetResourceManagerAddon(env, info);
|
||||
if (dataContext->addon_ == nullptr) {
|
||||
HiLog::Error(LABEL, "Failed to get addon in InitPathAddon");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get addon in InitPathAddon");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
if (ResourceManagerNapiUtils::IsNapiString(env, info)) {
|
||||
@ -108,7 +108,8 @@ napi_value ResourceManagerNapiSyncImpl::GetRawFileListSync(napi_env env, napi_ca
|
||||
|
||||
int32_t ret = InitPathAddon(env, info, dataContext);
|
||||
if (ret != RState::SUCCESS) {
|
||||
HiLog::Error(LABEL, "Failed to init para in GetRawFileListSync by %{public}s", dataContext->path_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG,
|
||||
"Failed to init para in GetRawFileListSync by %{public}s", dataContext->path_.c_str());
|
||||
ResourceManagerNapiUtils::NapiThrow(env, ret);
|
||||
return nullptr;
|
||||
}
|
||||
@ -116,7 +117,7 @@ napi_value ResourceManagerNapiSyncImpl::GetRawFileListSync(napi_env env, napi_ca
|
||||
RState state = dataContext->addon_->GetResMgr()->GetRawFileList(dataContext->path_.c_str(),
|
||||
dataContext->arrayValue_);
|
||||
if (state != RState::SUCCESS || dataContext->arrayValue_.empty()) {
|
||||
HiLog::Error(LABEL, "Failed to get rawfile list by %{public}s", dataContext->path_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get rawfile list by %{public}s", dataContext->path_.c_str());
|
||||
ResourceManagerNapiUtils::NapiThrow(env, ERROR_CODE_RES_PATH_INVALID);
|
||||
return nullptr;
|
||||
}
|
||||
@ -132,7 +133,8 @@ napi_value ResourceManagerNapiSyncImpl::GetRawFileContentSync(napi_env env, napi
|
||||
|
||||
int32_t ret = InitPathAddon(env, info, dataContext);
|
||||
if (ret != RState::SUCCESS) {
|
||||
HiLog::Error(LABEL, "Failed to init para in GetRawFileContentSync by %{public}s", dataContext->path_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG,
|
||||
"Failed to init para in GetRawFileContentSync by %{public}s", dataContext->path_.c_str());
|
||||
ResourceManagerNapiUtils::NapiThrow(env, ret);
|
||||
return nullptr;
|
||||
}
|
||||
@ -140,7 +142,7 @@ napi_value ResourceManagerNapiSyncImpl::GetRawFileContentSync(napi_env env, napi
|
||||
RState state = dataContext->addon_->GetResMgr()->GetRawFileFromHap(dataContext->path_,
|
||||
dataContext->len_, dataContext->mediaData);
|
||||
if (state != SUCCESS) {
|
||||
HiLog::Error(LABEL, "Failed to get rawfile by %{public}s", dataContext->path_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get rawfile by %{public}s", dataContext->path_.c_str());
|
||||
ResourceManagerNapiUtils::NapiThrow(env, state);
|
||||
return nullptr;
|
||||
}
|
||||
@ -156,7 +158,7 @@ napi_value ResourceManagerNapiSyncImpl::GetRawFdSync(napi_env env, napi_callback
|
||||
|
||||
int32_t ret = InitPathAddon(env, info, dataContext);
|
||||
if (ret != RState::SUCCESS) {
|
||||
HiLog::Error(LABEL, "Failed to init para in GetRawFdSync by %{public}s", dataContext->path_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to init para in GetRawFdSync by %{public}s", dataContext->path_.c_str());
|
||||
ResourceManagerNapiUtils::NapiThrow(env, ret);
|
||||
return nullptr;
|
||||
}
|
||||
@ -164,7 +166,7 @@ napi_value ResourceManagerNapiSyncImpl::GetRawFdSync(napi_env env, napi_callback
|
||||
RState state = dataContext->addon_->GetResMgr()->GetRawFileDescriptorFromHap(dataContext->path_,
|
||||
dataContext->descriptor_);
|
||||
if (state != RState::SUCCESS) {
|
||||
HiLog::Error(LABEL, "Failed to get rawfd by %{public}s", dataContext->path_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get rawfd by %{public}s", dataContext->path_.c_str());
|
||||
ResourceManagerNapiUtils::NapiThrow(env, state);
|
||||
return nullptr;
|
||||
}
|
||||
@ -179,14 +181,14 @@ napi_value ResourceManagerNapiSyncImpl::CloseRawFdSync(napi_env env, napi_callba
|
||||
|
||||
int32_t ret = InitPathAddon(env, info, dataContext);
|
||||
if (ret != RState::SUCCESS) {
|
||||
HiLog::Error(LABEL, "Failed to init para in CloseRawFdSync by %{public}s", dataContext->path_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to init para in CloseRawFdSync by %{public}s", dataContext->path_.c_str());
|
||||
ResourceManagerNapiUtils::NapiThrow(env, ret);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RState state = dataContext->addon_->GetResMgr()->CloseRawFileDescriptor(dataContext->path_);
|
||||
if (state != RState::SUCCESS) {
|
||||
HiLog::Error(LABEL, "Failed to close rawfd by %{public}s", dataContext->path_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to close rawfd by %{public}s", dataContext->path_.c_str());
|
||||
ResourceManagerNapiUtils::NapiThrow(env, state);
|
||||
return nullptr;
|
||||
}
|
||||
@ -205,7 +207,7 @@ bool ResourceManagerNapiSyncImpl::InitParamsFromParamArray(napi_env env, napi_va
|
||||
if (valuetype == napi_number) {
|
||||
double param;
|
||||
if (napi_get_value_double(env, value, ¶m) != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get parameter value in InitParamsFromParamArray");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get parameter value in InitParamsFromParamArray");
|
||||
return false;
|
||||
}
|
||||
jsParams.push_back(std::make_tuple(ResourceManager::NapiValueType::NAPI_NUMBER, std::to_string(param)));
|
||||
@ -214,12 +216,12 @@ bool ResourceManagerNapiSyncImpl::InitParamsFromParamArray(napi_env env, napi_va
|
||||
if (valuetype == napi_string) {
|
||||
size_t len = 0;
|
||||
if (napi_get_value_string_utf8(env, value, nullptr, 0, &len) != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get parameter length in InitParamsFromParamArray");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get parameter length in InitParamsFromParamArray");
|
||||
return false;
|
||||
}
|
||||
std::vector<char> buf(len + 1);
|
||||
if (napi_get_value_string_utf8(env, value, buf.data(), len + 1, &len) != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get parameter value in InitParamsFromParamArray");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get parameter value in InitParamsFromParamArray");
|
||||
return false;
|
||||
}
|
||||
jsParams.push_back(std::make_tuple(ResourceManager::NapiValueType::NAPI_STRING, buf.data()));
|
||||
@ -254,7 +256,7 @@ int32_t ResourceManagerNapiSyncImpl::InitIdResourceAddon(napi_env env, napi_call
|
||||
GET_PARAMS(env, info, PARAMS_NUM_TWO);
|
||||
dataContext->addon_ = ResMgrDataContext::GetResourceManagerAddon(env, info);
|
||||
if (dataContext->addon_ == nullptr) {
|
||||
HiLog::Error(LABEL, "Failed to get addon in InitIdResourceAddon");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get addon in InitIdResourceAddon");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
if (ResourceManagerNapiUtils::IsNapiNumber(env, info)) {
|
||||
@ -277,12 +279,12 @@ int32_t ResourceManagerNapiSyncImpl::ProcessStrResource(napi_env env, napi_callb
|
||||
int32_t resId = 0;
|
||||
bool ret = ResourceManagerNapiUtils::GetHapResourceManager(dataContext.get(), resMgr, resId);
|
||||
if (!ret) {
|
||||
HiLog::Error(LABEL, "Failed to get resMgr in GetStringSync");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resMgr in GetStringSync");
|
||||
return ERROR_CODE_RES_NOT_FOUND_BY_ID;
|
||||
}
|
||||
|
||||
if (!InitNapiParameters(env, info, dataContext->jsParams_)) {
|
||||
HiLog::Error(LABEL, "GetStringSync formatting error");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "GetStringSync formatting error");
|
||||
return ERROR_CODE_RES_ID_FORMAT_ERROR;
|
||||
}
|
||||
|
||||
@ -325,7 +327,7 @@ int32_t ResourceManagerNapiSyncImpl::ProcessSymbolResource(napi_env env, napi_ca
|
||||
int32_t resId = 0;
|
||||
bool ret = ResourceManagerNapiUtils::GetHapResourceManager(dataContext.get(), resMgr, resId);
|
||||
if (!ret) {
|
||||
HiLog::Error(LABEL, "Failed to get resMgr in GetSymbol");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resMgr in GetSymbol");
|
||||
return ERROR_CODE_RES_NOT_FOUND_BY_ID;
|
||||
}
|
||||
|
||||
@ -367,7 +369,7 @@ int32_t ResourceManagerNapiSyncImpl::ProcessColorResource(napi_env env, napi_cal
|
||||
int32_t resId = 0;
|
||||
bool ret = ResourceManagerNapiUtils::GetHapResourceManager(dataContext.get(), resMgr, resId);
|
||||
if (!ret) {
|
||||
HiLog::Error(LABEL, "Failed to get resMgr in ProcessColorResource");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resMgr in ProcessColorResource");
|
||||
return ERROR_CODE_RES_NOT_FOUND_BY_ID;
|
||||
}
|
||||
|
||||
@ -410,7 +412,7 @@ int32_t ResourceManagerNapiSyncImpl::ProcessNumResource(napi_env env, napi_callb
|
||||
int32_t resId = 0;
|
||||
bool ret = ResourceManagerNapiUtils::GetHapResourceManager(dataContext.get(), resMgr, resId);
|
||||
if (!ret) {
|
||||
HiLog::Error(LABEL, "Failed to ResourceManagerNapiUtils::GetHapResourceManager in GetNumber");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to ResourceManagerNapiUtils::GetHapResourceManager in GetNumber");
|
||||
return ERROR_CODE_RES_NOT_FOUND_BY_ID;
|
||||
}
|
||||
|
||||
@ -452,7 +454,7 @@ int32_t ResourceManagerNapiSyncImpl::ProcessBoolResource(napi_env env, napi_call
|
||||
int32_t resId = 0;
|
||||
bool ret2 = ResourceManagerNapiUtils::GetHapResourceManager(dataContext.get(), resMgr, resId);
|
||||
if (!ret2) {
|
||||
HiLog::Error(LABEL, "Failed to get resMgr in GetBoolean");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resMgr in GetBoolean");
|
||||
return ERROR_CODE_RES_NOT_FOUND_BY_ID;
|
||||
}
|
||||
RState state = resMgr->GetBooleanById(resId, dataContext->bValue_);
|
||||
@ -493,7 +495,7 @@ int32_t ResourceManagerNapiSyncImpl::ProcesstMediaContentBase64Resource(napi_env
|
||||
int32_t resId = 0;
|
||||
bool ret2 = ResourceManagerNapiUtils::GetHapResourceManager(dataContext.get(), resMgr, resId);
|
||||
if (!ret2) {
|
||||
HiLog::Error(LABEL, "Failed to get resMgr in GetMediaContentBase64Sync");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resMgr in GetMediaContentBase64Sync");
|
||||
return ERROR_CODE_RES_NOT_FOUND_BY_ID;
|
||||
}
|
||||
RState state = resMgr->GetMediaBase64DataById(resId, dataContext->value_, dataContext->density_);
|
||||
@ -538,7 +540,7 @@ int32_t ResourceManagerNapiSyncImpl::ProcessMediaContentResource(napi_env env, n
|
||||
int32_t resId = 0;
|
||||
bool ret2 = ResourceManagerNapiUtils::GetHapResourceManager(dataContext.get(), resMgr, resId);
|
||||
if (!ret2) {
|
||||
HiLog::Error(LABEL, "Failed to get resMgr in GetMediaContentSync");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resMgr in GetMediaContentSync");
|
||||
return ERROR_CODE_RES_NOT_FOUND_BY_ID;
|
||||
}
|
||||
RState state = resMgr->GetMediaDataById(resId, dataContext->len_, dataContext->mediaData,
|
||||
@ -584,7 +586,7 @@ int32_t ResourceManagerNapiSyncImpl::ProcessPluralStringValueResource(napi_env e
|
||||
int32_t resId = 0;
|
||||
bool ret2 = ResourceManagerNapiUtils::GetHapResourceManager(dataContext.get(), resMgr, resId);
|
||||
if (!ret2) {
|
||||
HiLog::Error(LABEL, "Failed to get resMgr in GetPluralStringValueSync");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resMgr in GetPluralStringValueSync");
|
||||
return ERROR_CODE_RES_NOT_FOUND_BY_ID;
|
||||
}
|
||||
RState state = resMgr->GetPluralStringByIdFormat(dataContext->value_,
|
||||
@ -610,7 +612,7 @@ napi_value ResourceManagerNapiSyncImpl::GetPluralStringValueSync(napi_env env, n
|
||||
}
|
||||
|
||||
if (ResourceManagerNapiUtils::GetType(env, argv[ARRAY_SUBCRIPTOR_ONE]) != napi_number) {
|
||||
HiLog::Error(LABEL, "Parameter type is not napi_number in GetPluralStringValueSync");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Parameter type is not napi_number in GetPluralStringValueSync");
|
||||
ResourceManagerNapiUtils::NapiThrow(env, ERROR_CODE_INVALID_INPUT_PARAMETER);
|
||||
return nullptr;
|
||||
}
|
||||
@ -633,7 +635,7 @@ int32_t ResourceManagerNapiSyncImpl::ProcessStringArrayValueResource(napi_env en
|
||||
int32_t resId = 0;
|
||||
bool ret2 = ResourceManagerNapiUtils::GetHapResourceManager(dataContext.get(), resMgr, resId);
|
||||
if (!ret2) {
|
||||
HiLog::Error(LABEL, "Failed to get resMgr in GetStringArrayValueSync");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resMgr in GetStringArrayValueSync");
|
||||
return ERROR_CODE_RES_NOT_FOUND_BY_ID;
|
||||
}
|
||||
RState state = resMgr->GetStringArrayById(resId, dataContext->arrayValue_);
|
||||
@ -724,7 +726,7 @@ int32_t ResourceManagerNapiSyncImpl::InitNameAddon(napi_env env, napi_callback_i
|
||||
GET_PARAMS(env, info, PARAMS_NUM_TWO);
|
||||
dataContext->addon_ = ResMgrDataContext::GetResourceManagerAddon(env, info);
|
||||
if (dataContext->addon_ == nullptr) {
|
||||
HiLog::Error(LABEL, "Failed to get addon in InitNameAddon");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get addon in InitNameAddon");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
if (ResourceManagerNapiUtils::IsNapiString(env, info)) {
|
||||
@ -739,7 +741,7 @@ int32_t ResourceManagerNapiSyncImpl::ProcessStrResourceByName(napi_env env, napi
|
||||
std::unique_ptr<ResMgrDataContext> &dataContext)
|
||||
{
|
||||
if (!InitNapiParameters(env, info, dataContext->jsParams_)) {
|
||||
HiLog::Error(LABEL, "GetStringByNameSync formatting error");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "GetStringByNameSync formatting error");
|
||||
return ERROR_CODE_RES_NAME_FORMAT_ERROR;
|
||||
}
|
||||
|
||||
@ -965,7 +967,7 @@ std::shared_ptr<ResourceManager> GetNativeResoruceManager(napi_env env, napi_cal
|
||||
{
|
||||
auto addon = ResMgrDataContext::GetResourceManagerAddon(env, info);
|
||||
if (addon == nullptr) {
|
||||
HiLog::Error(LABEL, "Failed to get addon_ in GetNativeResoruceManager");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get addon_ in GetNativeResoruceManager");
|
||||
return nullptr;
|
||||
}
|
||||
return addon->GetResMgr();
|
||||
@ -982,7 +984,7 @@ napi_value ResourceManagerNapiSyncImpl::AddResource(napi_env env, napi_callback_
|
||||
dataContext->path_ = ResourceManagerNapiUtils::GetResNameOrPath(env, argc, argv);
|
||||
auto resMgr = GetNativeResoruceManager(env, info);
|
||||
if (!resMgr->AddAppOverlay(dataContext->path_)) {
|
||||
HiLog::Error(LABEL, "Failed to add overlay path = %{public}s", dataContext->path_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to add overlay path = %{public}s", dataContext->path_.c_str());
|
||||
ResourceManagerNapiUtils::NapiThrow(env, ERROR_CODE_OVERLAY_RES_PATH_INVALID);
|
||||
return nullptr;
|
||||
}
|
||||
@ -1000,7 +1002,7 @@ napi_value ResourceManagerNapiSyncImpl::RemoveResource(napi_env env, napi_callba
|
||||
dataContext->path_ = ResourceManagerNapiUtils::GetResNameOrPath(env, argc, argv);
|
||||
auto resMgr = GetNativeResoruceManager(env, info);
|
||||
if (!resMgr->RemoveAppOverlay(dataContext->path_)) {
|
||||
HiLog::Error(LABEL, "Failed to add overlay path = %{public}s", dataContext->path_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to add overlay path = %{public}s", dataContext->path_.c_str());
|
||||
ResourceManagerNapiUtils::NapiThrow(env, ERROR_CODE_OVERLAY_RES_PATH_INVALID);
|
||||
return nullptr;
|
||||
}
|
||||
@ -1035,7 +1037,7 @@ napi_value ResourceManagerNapiSyncImpl::GetPluralStringByNameSync(napi_env env,
|
||||
}
|
||||
|
||||
if (ResourceManagerNapiUtils::GetType(env, argv[ARRAY_SUBCRIPTOR_ONE]) != napi_number) {
|
||||
HiLog::Error(LABEL, "Parameter type is not napi_number in GetPluralStringByNameSync");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Parameter type is not napi_number in GetPluralStringByNameSync");
|
||||
ResourceManagerNapiUtils::NapiThrow(env, ERROR_CODE_INVALID_INPUT_PARAMETER);
|
||||
return nullptr;
|
||||
}
|
||||
@ -1210,7 +1212,7 @@ napi_value ResourceManagerNapiSyncImpl::IsRawDir(napi_env env, napi_callback_inf
|
||||
|
||||
int32_t ret = InitPathAddon(env, info, dataContext);
|
||||
if (ret != RState::SUCCESS) {
|
||||
HiLog::Error(LABEL, "Failed to init para in IsRawDir by %{public}s", dataContext->path_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to init para in IsRawDir by %{public}s", dataContext->path_.c_str());
|
||||
ResourceManagerNapiUtils::NapiThrow(env, ret);
|
||||
return nullptr;
|
||||
}
|
||||
@ -1218,7 +1220,8 @@ napi_value ResourceManagerNapiSyncImpl::IsRawDir(napi_env env, napi_callback_inf
|
||||
RState state = dataContext->addon_->GetResMgr()->IsRawDirFromHap(dataContext->path_,
|
||||
dataContext->bValue_);
|
||||
if (state != RState::SUCCESS) {
|
||||
HiLog::Error(LABEL, "Failed to determine the raw file is directory by %{public}s", dataContext->path_.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG,
|
||||
"Failed to determine the raw file is directory by %{public}s", dataContext->path_.c_str());
|
||||
ResourceManagerNapiUtils::NapiThrow(env, state);
|
||||
return nullptr;
|
||||
}
|
||||
@ -1240,7 +1243,7 @@ napi_value ResourceManagerNapiSyncImpl::GetOverrideResourceManager(napi_env env,
|
||||
dataContext->overrideResConfig_);
|
||||
if (overrideResMgr == nullptr) {
|
||||
dataContext->SetErrorMsg("GetOverrideResourceManager, overrideResMgr is null", false);
|
||||
HiLog::Error(LABEL, "GetOverrideResourceManager, overrideResMgr is null");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "GetOverrideResourceManager, overrideResMgr is null");
|
||||
ResourceManagerNapiUtils::NapiThrow(env, ERROR_CODE_INVALID_INPUT_PARAMETER);
|
||||
return nullptr;
|
||||
}
|
||||
@ -1254,11 +1257,11 @@ RState ResourceManagerNapiSyncImpl::getAddonAndConfig(napi_env env, napi_callbac
|
||||
GET_PARAMS(env, info, PARAMS_NUM_TWO);
|
||||
dataContext->addon_ = ResMgrDataContext::GetResourceManagerAddon(env, info);
|
||||
if (dataContext->addon_ == nullptr) {
|
||||
HiLog::Error(LABEL, "getAddonAndConfig failed to get addon");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "getAddonAndConfig failed to get addon");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
if (ResourceManagerNapiUtils::GetConfigObject(env, argv[ARRAY_SUBCRIPTOR_ZERO], dataContext) != SUCCESS) {
|
||||
HiLog::Error(LABEL, "getAddonAndConfig failed to get resConfig");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "getAddonAndConfig failed to get resConfig");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
return SUCCESS;
|
||||
@ -1269,7 +1272,7 @@ napi_value ResourceManagerNapiSyncImpl::GetOverrideConfiguration(napi_env env, n
|
||||
auto dataContext = std::make_unique<ResMgrDataContext>();
|
||||
dataContext->addon_ = ResMgrDataContext::GetResourceManagerAddon(env, info);
|
||||
if (dataContext->addon_ == nullptr) {
|
||||
HiLog::Error(LABEL, "GetOverrideConfiguration failed to get addon");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "GetOverrideConfiguration failed to get addon");
|
||||
return nullptr;
|
||||
}
|
||||
return ResourceManagerNapiUtils::CreateOverrideJsConfig(env, *dataContext);
|
||||
@ -1281,7 +1284,7 @@ napi_value ResourceManagerNapiSyncImpl::UpdateOverrideConfiguration(napi_env env
|
||||
int32_t state = getAddonAndConfig(env, info, dataContext);
|
||||
if (state != RState::SUCCESS) {
|
||||
dataContext->SetErrorMsg("Failed to get param in GetOverrideResourceManager", false);
|
||||
HiLog::Error(LABEL, "Failed to get param in GetOverrideResourceManager");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get param in GetOverrideResourceManager");
|
||||
ResourceManagerNapiUtils::NapiThrow(env, state);
|
||||
return nullptr;
|
||||
}
|
||||
@ -1290,7 +1293,7 @@ napi_value ResourceManagerNapiSyncImpl::UpdateOverrideConfiguration(napi_env env
|
||||
state = resMgr->UpdateOverrideResConfig(*dataContext->overrideResConfig_);
|
||||
if (state != RState::SUCCESS) {
|
||||
dataContext->SetErrorMsg("UpdateOverrideConfiguration failed due to invalid config", false);
|
||||
HiLog::Error(LABEL, "UpdateOverrideConfiguration failed due to invalid config");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "UpdateOverrideConfiguration failed due to invalid config");
|
||||
ResourceManagerNapiUtils::NapiThrow(env, ERROR_CODE_INVALID_INPUT_PARAMETER);
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -44,7 +44,7 @@ bool ResourceManagerNapiUtils::IsNapiString(napi_env env, napi_callback_info inf
|
||||
napi_valuetype valueType = napi_valuetype::napi_undefined;
|
||||
napi_typeof(env, argv[ARRAY_SUBCRIPTOR_ZERO], &valueType);
|
||||
if (valueType != napi_string) {
|
||||
HiLog::Warn(LABEL, "Parameter type is not napi_string");
|
||||
RESMGR_HILOGD(RESMGR_JS_TAG, "Parameter type is not napi_string");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -69,7 +69,7 @@ bool ResourceManagerNapiUtils::IsNapiObject(napi_env env, napi_callback_info inf
|
||||
napi_valuetype valueType = napi_valuetype::napi_undefined;
|
||||
napi_typeof(env, argv[ARRAY_SUBCRIPTOR_ZERO], &valueType);
|
||||
if (valueType != napi_object) {
|
||||
HiLog::Warn(LABEL, "Parameter type is not napi_object");
|
||||
RESMGR_HILOGI(RESMGR_JS_TAG, "Parameter type is not napi_object");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -91,19 +91,19 @@ std::string ResourceManagerNapiUtils::GetResNameOrPath(napi_env env, size_t argc
|
||||
napi_valuetype valuetype;
|
||||
napi_typeof(env, argv[ARRAY_SUBCRIPTOR_ZERO], &valuetype);
|
||||
if (valuetype != napi_string) {
|
||||
HiLog::Error(LABEL, "Invalid param, not string");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Invalid param, not string");
|
||||
return "";
|
||||
}
|
||||
size_t len = 0;
|
||||
napi_status status = napi_get_value_string_utf8(env, argv[ARRAY_SUBCRIPTOR_ZERO], nullptr, 0, &len);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get resName or rawfile path length");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resName or rawfile path length");
|
||||
return "";
|
||||
}
|
||||
std::vector<char> buf(len + 1);
|
||||
status = napi_get_value_string_utf8(env, argv[ARRAY_SUBCRIPTOR_ZERO], buf.data(), len + 1, &len);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get resName or raw file path");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resName or raw file path");
|
||||
return "";
|
||||
}
|
||||
return buf.data();
|
||||
@ -118,17 +118,17 @@ int ResourceManagerNapiUtils::GetResId(napi_env env, size_t argc, napi_value *ar
|
||||
napi_valuetype valuetype;
|
||||
napi_status status = napi_typeof(env, argv[ARRAY_SUBCRIPTOR_ZERO], &valuetype);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get value type");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get value type");
|
||||
return 0;
|
||||
}
|
||||
if (valuetype != napi_number) {
|
||||
HiLog::Error(LABEL, "Invalid param, not number");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Invalid param, not number");
|
||||
return 0;
|
||||
}
|
||||
int resId = 0;
|
||||
status = napi_get_value_int32(env, argv[ARRAY_SUBCRIPTOR_ZERO], &resId);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get id number");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get id number");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ napi_value ResourceManagerNapiUtils::CreateJsUint8Array(napi_env env, ResMgrData
|
||||
napi_value buffer;
|
||||
napi_status status = napi_create_external_arraybuffer(env, context.mediaData.get(), context.len_,
|
||||
[](napi_env env, void *data, void *hint) {
|
||||
HiLog::Debug(LABEL, "Media buffer finalized");
|
||||
RESMGR_HILOGD(RESMGR_JS_TAG, "Media buffer finalized");
|
||||
delete[] static_cast<char*>(data);
|
||||
}, nullptr, &buffer);
|
||||
if (status != napi_ok) {
|
||||
@ -309,23 +309,23 @@ bool ResourceManagerNapiUtils::GetResourceObjectName(napi_env env,
|
||||
napi_value name;
|
||||
napi_status status = napi_get_named_property(env, value, typeName.c_str(), &name);
|
||||
if (status != napi_ok || name == nullptr) {
|
||||
HiLog::Error(LABEL, "Failed to get resource name property");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resource name property");
|
||||
return false;
|
||||
}
|
||||
if (ResourceManagerNapiUtils::GetType(env, name) != napi_string) {
|
||||
HiLog::Error(LABEL, "Failed to get resource name string");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resource name string");
|
||||
return false;
|
||||
}
|
||||
size_t len = 0;
|
||||
status = napi_get_value_string_utf8(env, name, nullptr, 0, &len);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get resource len");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resource len");
|
||||
return false;
|
||||
}
|
||||
std::vector<char> buf(len + 1);
|
||||
status = napi_get_value_string_utf8(env, name, buf.data(), len + 1, &len);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get resource name value");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resource name value");
|
||||
return false;
|
||||
}
|
||||
if (type == 0) {
|
||||
@ -342,17 +342,17 @@ bool ResourceManagerNapiUtils::GetResourceObjectId(napi_env env,
|
||||
napi_value id;
|
||||
napi_status status = napi_get_named_property(env, value, "id", &id);
|
||||
if (status != napi_ok || id == nullptr) {
|
||||
HiLog::Error(LABEL, "Failed to get resource id property");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resource id property");
|
||||
return false;
|
||||
}
|
||||
if (ResourceManagerNapiUtils::GetType(env, id) != napi_number) {
|
||||
HiLog::Error(LABEL, "Failed to get resource id number");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resource id number");
|
||||
return false;
|
||||
}
|
||||
int32_t resId = 0;
|
||||
status = napi_get_value_int32(env, id, &resId);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get resource id value");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resource id value");
|
||||
return false;
|
||||
}
|
||||
resourcePtr->id = resId;
|
||||
@ -363,19 +363,19 @@ int32_t ResourceManagerNapiUtils::GetResourceObject(napi_env env,
|
||||
std::shared_ptr<ResourceManager::Resource> &resourcePtr, napi_value &value)
|
||||
{
|
||||
if (resourcePtr == nullptr) {
|
||||
HiLog::Error(LABEL, "resourcePtr == nullptr");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "resourcePtr == nullptr");
|
||||
return ERROR;
|
||||
}
|
||||
if (!GetResourceObjectName(env, resourcePtr, value, 0)) {
|
||||
HiLog::Error(LABEL, "Failed to get bundleName");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get bundleName");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
if (!GetResourceObjectName(env, resourcePtr, value, 1)) {
|
||||
HiLog::Error(LABEL, "Failed to get moduleName");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get moduleName");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
if (!GetResourceObjectId(env, resourcePtr, value)) {
|
||||
HiLog::Error(LABEL, "Failed to get id");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get id");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
|
||||
@ -407,12 +407,12 @@ bool ResourceManagerNapiUtils::GetHapResourceManager(const ResMgrDataContext* da
|
||||
}
|
||||
auto context = dataContext->addon_->GetContext();
|
||||
if (context == nullptr) {
|
||||
HiLog::Error(LABEL, "GetHapResourceManager context == nullptr");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "GetHapResourceManager context == nullptr");
|
||||
return false;
|
||||
}
|
||||
auto moduleContext = context->CreateModuleContext(resource->bundleName, resource->moduleName);
|
||||
if (moduleContext == nullptr) {
|
||||
HiLog::Error(LABEL, "GetHapResourceManager moduleContext == nullptr, bundleName = %{public}s," \
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "GetHapResourceManager moduleContext == nullptr, bundleName = %{public}s," \
|
||||
"moduleName = %{public}s", resource->bundleName.c_str(), resource->moduleName.c_str());
|
||||
return false;
|
||||
}
|
||||
@ -557,17 +557,17 @@ RState ResourceManagerNapiUtils::GetConfigObject(napi_env env,
|
||||
napi_valuetype valueType;
|
||||
napi_typeof(env, object, &valueType);
|
||||
if (valueType == napi_undefined || valueType == napi_null) {
|
||||
HiLog::Debug(LABEL, "GetConfigObject, no config");
|
||||
RESMGR_HILOGD(RESMGR_JS_TAG, "GetConfigObject, no config");
|
||||
return SUCCESS;
|
||||
}
|
||||
if (valueType != napi_object) {
|
||||
HiLog::Error(LABEL, "GetConfigObject, param not object");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "GetConfigObject, param not object");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
|
||||
ResConfig *config = CreateDefaultResConfig();
|
||||
if (config == nullptr) {
|
||||
HiLog::Error(LABEL, "GetConfigObject, new config failed");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "GetConfigObject, new config failed");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
dataContext->overrideResConfig_.reset(config);
|
||||
@ -590,25 +590,27 @@ bool ResourceManagerNapiUtils::GetEnumParamOfConfig(napi_env env,
|
||||
napi_value napi_val;
|
||||
napi_status status = napi_get_named_property(env, object, property.c_str(), &napi_val);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "GetEnumParamOfConfig failed to get property %{public}s", property.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "GetEnumParamOfConfig failed to get property %{public}s", property.c_str());
|
||||
return false;
|
||||
}
|
||||
if (napi_val == nullptr) {
|
||||
HiLog::Debug(LABEL, "GetEnumParamOfConfig property %{public}s not set", property.c_str());
|
||||
RESMGR_HILOGD(RESMGR_JS_TAG, "GetEnumParamOfConfig property %{public}s not set", property.c_str());
|
||||
continue;
|
||||
}
|
||||
if (ResourceManagerNapiUtils::GetType(env, napi_val) != napi_number) {
|
||||
HiLog::Error(LABEL, "GetEnumParamOfConfig type of property %{public}s is not number", property.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG,
|
||||
"GetEnumParamOfConfig type of property %{public}s is not number", property.c_str());
|
||||
return false;
|
||||
}
|
||||
int value;
|
||||
status = napi_get_value_int32(env, napi_val, &value);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "GetEnumParamOfConfig failed to get value of property %{public}s", property.c_str());
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG,
|
||||
"GetEnumParamOfConfig failed to get value of property %{public}s", property.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
HiLog::Debug(LABEL, "GetEnumParamOfConfig, %{public}s = %{public}d", property.c_str(), value);
|
||||
RESMGR_HILOGD(RESMGR_JS_TAG, "GetEnumParamOfConfig, %{public}s = %{public}d", property.c_str(), value);
|
||||
if (property == "direction") {
|
||||
configPtr->SetDirection(static_cast<Direction>(value));
|
||||
} else if (property == "deviceType") {
|
||||
@ -633,38 +635,38 @@ bool ResourceManagerNapiUtils::GetLocaleOfConfig(
|
||||
napi_value locale;
|
||||
napi_status status = napi_get_named_property(env, object, "locale", &locale);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "GetLocaleOfConfig failed to get property locale");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "GetLocaleOfConfig failed to get property locale");
|
||||
return false;
|
||||
}
|
||||
if (locale == nullptr) {
|
||||
HiLog::Debug(LABEL, "GetLocaleOfConfig property locale not set");
|
||||
RESMGR_HILOGD(RESMGR_JS_TAG, "GetLocaleOfConfig property locale not set");
|
||||
return true;
|
||||
}
|
||||
if (ResourceManagerNapiUtils::GetType(env, locale) != napi_string) {
|
||||
HiLog::Error(LABEL, "GetLocaleOfConfig type of property locale is not string");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "GetLocaleOfConfig type of property locale is not string");
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t len = 0;
|
||||
status = napi_get_value_string_utf8(env, locale, nullptr, 0, &len);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "GetLocaleOfConfig failed to get locale len");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "GetLocaleOfConfig failed to get locale len");
|
||||
return false;
|
||||
}
|
||||
if (len == 0) {
|
||||
HiLog::Debug(LABEL, "GetLocaleOfConfig locale not set or empty");
|
||||
RESMGR_HILOGD(RESMGR_JS_TAG, "GetLocaleOfConfig locale not set or empty");
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<char> buf(len + 1);
|
||||
status = napi_get_value_string_utf8(env, locale, buf.data(), len + 1, &len);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "GetLocaleOfConfig failed to get locale value");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "GetLocaleOfConfig failed to get locale value");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (configPtr->SetLocaleInfo(buf.data()) != SUCCESS) {
|
||||
HiLog::Error(LABEL, "GetLocaleOfConfig failed to SetLocaleInfo");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "GetLocaleOfConfig failed to SetLocaleInfo");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@ -675,7 +677,7 @@ napi_value ResourceManagerNapiUtils::CreateJsColor(napi_env env, ResMgrDataConte
|
||||
{
|
||||
napi_value jsColorValue;
|
||||
if (napi_create_uint32(env, context.colorValue_, &jsColorValue) != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get density");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get density");
|
||||
return nullptr;
|
||||
}
|
||||
return jsColorValue;
|
||||
@ -685,7 +687,7 @@ napi_value ResourceManagerNapiUtils::CreateJsSymbol(napi_env env, ResMgrDataCont
|
||||
{
|
||||
napi_value jsSymbolValue;
|
||||
if (napi_create_uint32(env, context.symbolValue_, &jsSymbolValue) != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get symbol");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get symbol");
|
||||
return nullptr;
|
||||
}
|
||||
return jsSymbolValue;
|
||||
@ -699,12 +701,12 @@ RState ResourceManagerNapiUtils::GetDataType(napi_env env, napi_value value, uin
|
||||
return SUCCESS;
|
||||
}
|
||||
if (valuetype != napi_number) {
|
||||
HiLog::Error(LABEL, "Invalid param, not number");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Invalid param, not number");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
|
||||
if (napi_get_value_uint32(env, value, &density) != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get density");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get density");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
return SUCCESS;
|
||||
@ -718,12 +720,12 @@ RState ResourceManagerNapiUtils::GetIncludeSystem(napi_env env, napi_value value
|
||||
return SUCCESS;
|
||||
}
|
||||
if (valuetype != napi_boolean) {
|
||||
HiLog::Error(LABEL, "Invalid param, not boolean");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Invalid param, not boolean");
|
||||
return ERROR_CODE_INVALID_INPUT_PARAMETER;
|
||||
}
|
||||
|
||||
if (napi_get_value_bool(env, value, &includeSystem) != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get includeSystem");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get includeSystem");
|
||||
return NOT_FOUND;
|
||||
}
|
||||
return SUCCESS;
|
||||
|
@ -26,6 +26,8 @@ ohos_shared_library("resourcemanager") {
|
||||
"src/resource_manager_napi.cpp",
|
||||
]
|
||||
|
||||
defines = [ "CONFIG_HILOG" ]
|
||||
|
||||
deps = [ "../innerkits/core:resmgr_napi_core" ]
|
||||
|
||||
external_deps = [
|
||||
@ -48,6 +50,8 @@ ohos_shared_library("sendableresourcemanager") {
|
||||
|
||||
sources = [ "src/sendable_resource_manager_napi.cpp" ]
|
||||
|
||||
defines = [ "CONFIG_HILOG" ]
|
||||
|
||||
external_deps = [
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
|
@ -65,14 +65,14 @@ Ability* GetGlobalAbility(napi_env env)
|
||||
napi_value global;
|
||||
napi_status status = napi_get_global(env, &global);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get global");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get global");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value abilityObj;
|
||||
status = napi_get_named_property(env, global, "ability", &abilityObj);
|
||||
if (status != napi_ok || abilityObj == nullptr) {
|
||||
HiLog::Warn(LABEL, "Failed to get ability property");
|
||||
RESMGR_HILOGI(RESMGR_JS_TAG, "Failed to get ability property");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ static napi_value getResult(napi_env env, std::unique_ptr<ResMgrDataContext> &as
|
||||
}
|
||||
|
||||
if (!InitAsyncContext(env, bundleName, GetGlobalAbility(env), abilityRuntimeContext, *asyncContext)) {
|
||||
HiLog::Error(LABEL, "init async context failed");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "init async context failed");
|
||||
ReportInitResourceManagerFail(bundleName, "failed to init async context");
|
||||
return nullptr;
|
||||
}
|
||||
@ -134,12 +134,12 @@ static napi_value getResult(napi_env env, std::unique_ptr<ResMgrDataContext> &as
|
||||
napi_status status = napi_create_async_work(env, nullptr, resource, ExecuteGetResMgr,
|
||||
ResourceManagerNapiAsyncImpl::Complete, static_cast<void*>(asyncContext.get()), &asyncContext->work_);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to create async work for getResourceManager %{public}d", status);
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to create async work for getResourceManager %{public}d", status);
|
||||
return result;
|
||||
}
|
||||
status = napi_queue_async_work_with_qos(env, asyncContext->work_, napi_qos_user_initiated);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to queue async work for getResourceManager %{public}d", status);
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to queue async work for getResourceManager %{public}d", status);
|
||||
return result;
|
||||
}
|
||||
asyncContext.release();
|
||||
@ -161,12 +161,12 @@ static napi_value GetResourceManager(napi_env env, napi_callback_info info)
|
||||
WeakContextPtr objContext;
|
||||
napi_status status = napi_unwrap(env, argv[0], reinterpret_cast<void **>(&objContext));
|
||||
if (status != napi_ok || objContext == nullptr) {
|
||||
HiLog::Error(LABEL, "Failed to get objContext");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get objContext");
|
||||
return nullptr;
|
||||
}
|
||||
auto context = objContext->lock();
|
||||
if (context == nullptr) {
|
||||
HiLog::Error(LABEL, "Failed to get context");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get context");
|
||||
return nullptr;
|
||||
}
|
||||
abilityRuntimeContext = context;
|
||||
@ -174,13 +174,13 @@ static napi_value GetResourceManager(napi_env env, napi_callback_info info)
|
||||
size_t len = 0;
|
||||
napi_status status = napi_get_value_string_utf8(env, argv[i], nullptr, 0, &len);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get bundle name length");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get bundle name length");
|
||||
return nullptr;
|
||||
}
|
||||
std::vector<char> buf(len + 1);
|
||||
status = napi_get_value_string_utf8(env, argv[i], buf.data(), len + 1, &len);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to get bundle name");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get bundle name");
|
||||
return nullptr;
|
||||
}
|
||||
bundleName = buf.data();
|
||||
@ -277,7 +277,7 @@ static napi_value ResMgrInit(napi_env env, napi_value exports)
|
||||
creatorProp);
|
||||
FinishTrace(HITRACE_TAG_GLOBAL_RESMGR);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Failed to set getResourceManager at init");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to set getResourceManager at init");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@ static napi_value ResMgrInit(napi_env env, napi_value exports)
|
||||
|
||||
status = napi_define_properties(env, exports, sizeof(static_prop) / sizeof(static_prop[0]), static_prop);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "failed to define properties for exports");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "failed to define properties for exports");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -13,20 +13,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "rstate.h"
|
||||
#include "hilog/log.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "native_engine.h"
|
||||
#include "../../../../frameworks/resmgr/include/hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Global {
|
||||
namespace Resource {
|
||||
using namespace OHOS::HiviewDFX;
|
||||
#undef LOG_DOMAIN
|
||||
#define LOG_DOMAIN 0xD001E00
|
||||
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "ResourceJs"
|
||||
#define GET_PARAMS(env, info, num) \
|
||||
size_t argc = num; \
|
||||
napi_value argv[num] = {nullptr}; \
|
||||
@ -40,7 +34,7 @@ static bool IsNapiObject(napi_env env, napi_callback_info info)
|
||||
napi_valuetype valueType = napi_valuetype::napi_undefined;
|
||||
napi_typeof(env, argv[0], &valueType);
|
||||
if (valueType != napi_object) {
|
||||
HILOG_WARN(LOG_CORE, "Parameter type is not napi_object");
|
||||
RESMGR_HILOGW(RESMGR_JS_TAG, "Parameter type is not napi_object");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -64,7 +58,7 @@ static void NapiThrow(napi_env env, int32_t errCode)
|
||||
static bool GetResourceProp(napi_env env, napi_callback_info info, std::vector<napi_value> &props)
|
||||
{
|
||||
if (!IsNapiObject(env, info)) {
|
||||
HILOG_ERROR(LOG_CORE, "Failed to get resource object");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resource object");
|
||||
return false;
|
||||
}
|
||||
GET_PARAMS(env, info, 1);
|
||||
@ -72,7 +66,7 @@ static bool GetResourceProp(napi_env env, napi_callback_info info, std::vector<n
|
||||
napi_valuetype bundleNameType = napi_undefined;
|
||||
if (napi_get_named_property(env, argv[0], "bundleName", &bundleName) != napi_ok ||
|
||||
napi_typeof(env, bundleName, &bundleNameType) != napi_ok || bundleNameType != napi_string) {
|
||||
HILOG_ERROR(LOG_CORE, "Failed to get resource bundleName property");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resource bundleName property");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -80,7 +74,7 @@ static bool GetResourceProp(napi_env env, napi_callback_info info, std::vector<n
|
||||
napi_valuetype moduleNameType = napi_undefined;
|
||||
if (napi_get_named_property(env, argv[0], "moduleName", &moduleName) != napi_ok ||
|
||||
napi_typeof(env, moduleName, &moduleNameType) != napi_ok || moduleNameType != napi_string) {
|
||||
HILOG_ERROR(LOG_CORE, "Failed to get resource moduleName property");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resource moduleName property");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -88,19 +82,19 @@ static bool GetResourceProp(napi_env env, napi_callback_info info, std::vector<n
|
||||
napi_valuetype idType = napi_undefined;
|
||||
if (napi_get_named_property(env, argv[0], "id", &id) != napi_ok ||
|
||||
napi_typeof(env, id, &idType) != napi_ok || idType != napi_number) {
|
||||
HILOG_ERROR(LOG_CORE, "Failed to get resource id property");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resource id property");
|
||||
return false;
|
||||
}
|
||||
|
||||
napi_value params = nullptr;
|
||||
if (napi_get_named_property(env, argv[0], "params", ¶ms) != napi_ok) {
|
||||
HILOG_ERROR(LOG_CORE, "Failed to get resource params property");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resource params property");
|
||||
return false;
|
||||
}
|
||||
|
||||
napi_value type = nullptr;
|
||||
if (napi_get_named_property(env, argv[0], "type", &type) != napi_ok) {
|
||||
HILOG_ERROR(LOG_CORE, "Failed to get resource type property");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resource type property");
|
||||
return false;
|
||||
}
|
||||
props.emplace_back(bundleName);
|
||||
@ -119,7 +113,7 @@ static bool GetParams(napi_env env, napi_value params, napi_value *newParams, bo
|
||||
napi_value length = nullptr;
|
||||
napi_valuetype paramsType = napi_undefined;
|
||||
if (napi_typeof(env, params, ¶msType) != napi_ok) {
|
||||
HILOG_ERROR(LOG_CORE, "Failed to get resource params property type");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get resource params property type");
|
||||
return false;
|
||||
}
|
||||
if (paramsType == napi_undefined) {
|
||||
@ -128,7 +122,7 @@ static bool GetParams(napi_env env, napi_value params, napi_value *newParams, bo
|
||||
if (napi_is_array(env, params, &isArray) != napi_ok || !isArray ||
|
||||
napi_get_named_property(env, params, "length", &length) != napi_ok ||
|
||||
napi_get_value_uint32(env, length, &len) != napi_ok) {
|
||||
HILOG_ERROR(LOG_CORE, "Resource params property params is error");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Resource params property params is error");
|
||||
return false;
|
||||
}
|
||||
if (isSendable) {
|
||||
@ -137,17 +131,17 @@ static bool GetParams(napi_env env, napi_value params, napi_value *newParams, bo
|
||||
status = napi_create_array_with_length(env, len, newParams);
|
||||
}
|
||||
if (status != napi_ok) {
|
||||
HILOG_ERROR(LOG_CORE, "Failed to create array, status = %{public}d", status);
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to create array, status = %{public}d", status);
|
||||
return false;
|
||||
}
|
||||
napi_value jsValue = nullptr;
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
if (napi_get_element(env, params, i, &jsValue) != napi_ok) {
|
||||
HILOG_ERROR(LOG_CORE, "Failed to get element");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to get element");
|
||||
return false;
|
||||
}
|
||||
if (napi_set_element(env, *(newParams), i, jsValue) != napi_ok) {
|
||||
HILOG_ERROR(LOG_CORE, "Failed to set element");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to set element");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -180,12 +174,12 @@ static napi_value InstanceResource(napi_env env, napi_callback_info info, bool i
|
||||
napi_value type = props[4]; // index 4
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
if (napi_typeof(env, type, &valueType) != napi_ok) {
|
||||
HILOG_ERROR(LOG_CORE, "Resource type property type is error");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Resource type property type is error");
|
||||
return nullptr;
|
||||
}
|
||||
if (valueType != napi_undefined) {
|
||||
if (valueType != napi_number) {
|
||||
HILOG_ERROR(LOG_CORE, "Resource type property type is not number");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Resource type property type is not number");
|
||||
return nullptr;
|
||||
}
|
||||
creatorProp[4] = DECLARE_NAPI_DEFAULT_PROPERTY("type", type); // index 4
|
||||
@ -201,7 +195,7 @@ static napi_value InstanceResource(napi_env env, napi_callback_info info, bool i
|
||||
creatorProp);
|
||||
}
|
||||
if (status != napi_ok) {
|
||||
HILOG_ERROR(LOG_CORE, "Failed to create object with properties, status = %{public}d", status);
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to create object with properties, status = %{public}d", status);
|
||||
return nullptr;
|
||||
}
|
||||
return result;
|
||||
@ -237,7 +231,7 @@ static napi_value SendableResourceManagerInit(napi_env env, napi_value exports)
|
||||
napi_status status = napi_define_properties(env, exports, sizeof(functionProp) / sizeof(functionProp[0]),
|
||||
functionProp);
|
||||
if (status != napi_ok) {
|
||||
HILOG_ERROR(LOG_CORE, "Failed to set function at init");
|
||||
RESMGR_HILOGE(RESMGR_JS_TAG, "Failed to set function at init");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user