From da8e4c39a95d817bcff763f9a70e6d9c0abb0518 Mon Sep 17 00:00:00 2001 From: zhoujunquan Date: Wed, 4 Aug 2021 09:19:16 +0000 Subject: [PATCH 01/31] update frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.cpp. restore performance test baseline --- .../unittest/lite/common/resource_manager_performance_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.cpp index 844420f..4eaf790 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.cpp @@ -184,7 +184,7 @@ int TestLoadFromIndex(const char *filePath) average = total / 1000.0; g_logLevel = LOG_DEBUG; HILOG_DEBUG("parse index avg cost 001: %f us", average); - EXPECT_LT(average, 2000); + EXPECT_LT(average, 4000); return OK; } -- Gitee From c9f54187def3991f4aa178560f6e7f614ddfee49 Mon Sep 17 00:00:00 2001 From: zhoujunquan Date: Fri, 13 Aug 2021 11:13:39 +0000 Subject: [PATCH 02/31] update frameworks/resmgr_lite/test/unittest/lite/common/test_common.cpp. https://gitee.com/openharmony/global_resmgr_lite/issues/I45FHQ?from=project-issue --- frameworks/resmgr_lite/test/unittest/lite/common/test_common.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/test_common.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/test_common.cpp index a8d261d..bfe10e7 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/test_common.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/test_common.cpp @@ -41,7 +41,6 @@ std::string FormatFullPath(const char *fileRelativePath) void PrintIdValues(const HapResource::IdValues *idValues) { - HILOG_DEBUG("idvalues size: %u", idValues->GetLimitPathsConst().size()); 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(), -- Gitee From 33d8ee321fd72a9aa8648ba82dce3799250a1adc Mon Sep 17 00:00:00 2001 From: huniuniu Date: Thu, 9 Sep 2021 17:55:45 +0800 Subject: [PATCH 03/31] fix codex issue, jiabing.hu@huawei.com Signed-off-by: huniuniu --- frameworks/resmgr_lite/src/hap_resource.cpp | 1 + frameworks/resmgr_lite/src/res_locale.cpp | 6 +++--- frameworks/resmgr_lite/src/utils/utils.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/frameworks/resmgr_lite/src/hap_resource.cpp b/frameworks/resmgr_lite/src/hap_resource.cpp index 741fc52..f25b157 100644 --- a/frameworks/resmgr_lite/src/hap_resource.cpp +++ b/frameworks/resmgr_lite/src/hap_resource.cpp @@ -111,6 +111,7 @@ const HapResource *HapResource::LoadFromIndex(const char *path, const ResConfigI ResDesc *resDesc = new (std::nothrow) ResDesc(); if (resDesc == nullptr) { HILOG_ERROR("new ResDesc failed when LoadFromIndex"); + free(buf); return nullptr; } int32_t out = HapParser::ParseResHex((char *)buf, bufLen, *resDesc, defaultConfig); diff --git a/frameworks/resmgr_lite/src/res_locale.cpp b/frameworks/resmgr_lite/src/res_locale.cpp index 6a061bc..a18abe6 100644 --- a/frameworks/resmgr_lite/src/res_locale.cpp +++ b/frameworks/resmgr_lite/src/res_locale.cpp @@ -340,9 +340,9 @@ bool ResLocale::UpdateDefault(const LocaleInfo &localeInfo, bool needNotify) ResLocale::~ResLocale() { - delete this->language_; - delete this->script_; - delete this->region_; + delete[] this->language_; + delete[] this->script_; + delete[] this->region_; } LocaleInfo *BuildFromString(const char *str, char sep, RState &rState) diff --git a/frameworks/resmgr_lite/src/utils/utils.cpp b/frameworks/resmgr_lite/src/utils/utils.cpp index fc5bf2f..a771bd8 100644 --- a/frameworks/resmgr_lite/src/utils/utils.cpp +++ b/frameworks/resmgr_lite/src/utils/utils.cpp @@ -160,7 +160,7 @@ uint32_t Utils::EncodeScript(const char *script) if (Utils::IsStrEmpty(script)) { return NULL_SCRIPT; } - return (script[0] << 24) | (script[1] << 16) | (script[2] << 8) | script[3]; + return ((uint8_t)script[0] << 24) | ((uint8_t)script[1] << 16) | ((uint8_t)script[2] << 8) | (uint8_t)script[3]; } /** @@ -189,9 +189,9 @@ uint16_t Utils::EncodeLanguageOrRegion(const char *str, char base) if (str[2] == 0 || str[2] == '-' || str[2] == '_') { return (str[0] << 8) | str[1]; } - uint8_t first = (str[0] - base) & 0x7f; - uint8_t second = (str[1] - base) & 0x7f; - uint8_t third = (str[2] - base) & 0x7f; + uint8_t first = ((uint8_t)(str[0] - base)) & 0x7f; + uint8_t second = ((uint8_t)(str[1] - base)) & 0x7f; + uint8_t third = ((uint8_t)(str[2] - base)) & 0x7f; return ((0x80 | (first << 2) | (second >> 3)) << 8) | ((second << 5) | third); }; -- Gitee From a17c70cf20b6ca61b380e412df93216739debc90 Mon Sep 17 00:00:00 2001 From: huniuniu Date: Thu, 9 Sep 2021 19:14:14 +0800 Subject: [PATCH 04/31] fix codex, jiabing.hu@huawei.com Signed-off-by: huniuniu --- frameworks/resmgr_lite/src/res_locale.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/frameworks/resmgr_lite/src/res_locale.cpp b/frameworks/resmgr_lite/src/res_locale.cpp index a18abe6..8abcb3f 100644 --- a/frameworks/resmgr_lite/src/res_locale.cpp +++ b/frameworks/resmgr_lite/src/res_locale.cpp @@ -340,9 +340,20 @@ bool ResLocale::UpdateDefault(const LocaleInfo &localeInfo, bool needNotify) ResLocale::~ResLocale() { - delete[] this->language_; - delete[] this->script_; - delete[] this->region_; + if (this->language_ != nullptr) { + delete[] this->language_; + this->language_ = nullptr; + } + + if (this->script_ != nullptr) { + delete[] this->script_; + this->script_ = nullptr; + } + + if (this->region_ != nullptr) { + delete[] this->region_; + this->region_ = nullptr + } } LocaleInfo *BuildFromString(const char *str, char sep, RState &rState) -- Gitee From d4b070bed555d4a62ac89d808c28270bff04bd9b Mon Sep 17 00:00:00 2001 From: huniuniu Date: Thu, 9 Sep 2021 19:38:45 +0800 Subject: [PATCH 05/31] fix codex, jiabing.hu@huawei.com Signed-off-by: huniuniu --- frameworks/resmgr_lite/src/res_locale.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/resmgr_lite/src/res_locale.cpp b/frameworks/resmgr_lite/src/res_locale.cpp index 8abcb3f..62ad69c 100644 --- a/frameworks/resmgr_lite/src/res_locale.cpp +++ b/frameworks/resmgr_lite/src/res_locale.cpp @@ -352,7 +352,7 @@ ResLocale::~ResLocale() if (this->region_ != nullptr) { delete[] this->region_; - this->region_ = nullptr + this->region_ = nullptr; } } -- Gitee From f073f40691bbd5b9ee62f78b671ce4e8c7a1aa8f Mon Sep 17 00:00:00 2001 From: huniuniu Date: Wed, 15 Sep 2021 09:59:05 +0000 Subject: [PATCH 06/31] update frameworks/resmgr_lite/src/utils/utils.cpp. --- frameworks/resmgr_lite/src/utils/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/resmgr_lite/src/utils/utils.cpp b/frameworks/resmgr_lite/src/utils/utils.cpp index a771bd8..f636f8d 100644 --- a/frameworks/resmgr_lite/src/utils/utils.cpp +++ b/frameworks/resmgr_lite/src/utils/utils.cpp @@ -187,7 +187,7 @@ uint32_t Utils::EncodeScript(const char *script) uint16_t Utils::EncodeLanguageOrRegion(const char *str, char base) { if (str[2] == 0 || str[2] == '-' || str[2] == '_') { - return (str[0] << 8) | str[1]; + return ((uint8_t)str[0] << 8) | ((uint8_t)str[1]); } uint8_t first = ((uint8_t)(str[0] - base)) & 0x7f; uint8_t second = ((uint8_t)(str[1] - base)) & 0x7f; -- Gitee From a84b7685cee13c2133e87f34f8ebf75364150f98 Mon Sep 17 00:00:00 2001 From: huniuniu Date: Tue, 28 Sep 2021 09:28:29 +0800 Subject: [PATCH 07/31] remove config limit. jiabing.hu@huawei.com Signed-off-by: huniuniu --- frameworks/resmgr_lite/src/global.c | 69 ++++++++++++++++------- frameworks/resmgr_lite/src/global_utils.c | 4 +- 2 files changed, 50 insertions(+), 23 deletions(-) diff --git a/frameworks/resmgr_lite/src/global.c b/frameworks/resmgr_lite/src/global.c index c132ff7..1d7c3f6 100644 --- a/frameworks/resmgr_lite/src/global.c +++ b/frameworks/resmgr_lite/src/global.c @@ -112,40 +112,31 @@ static void FreeValue(char **value) } } -int32_t GLOBAL_GetValueById(uint32_t id, const char *path, char **value) +static int32_t GLOBAL_GetValueByIdInternal(uint32_t id, const char *path, const char *locale, char **value) { - if (path == NULL || path[0] == '\0' || value == NULL) { - return MC_FAILURE; - } - - char tempLocale[MAX_LOCALE_LENGTH] = {'\0'}; - int32_t ret = strcpy_s(tempLocale, MAX_LOCALE_LENGTH, g_locale); - if (ret != EOK) { - return MC_FAILURE; - } - char realResourcePath[PATH_MAX] = {'\0'}; GlobalUtilsImpl *utilsImpl = GetGlobalUtilsImpl(); if (utilsImpl->CheckFilePath(path, realResourcePath, PATH_MAX) == MC_FAILURE) { return MC_FAILURE; } - uint32_t idHeaderOffset = utilsImpl->GetOffsetByLocale(realResourcePath, tempLocale, MAX_LOCALE_LENGTH); + uint32_t idHeaderOffset = utilsImpl->GetOffsetByLocale(realResourcePath, locale, MAX_LOCALE_LENGTH); IdHeader idHeader = {0, NULL}; int32_t file = open(realResourcePath, O_RDONLY, S_IRUSR | S_IRGRP | S_IROTH); if (file < 0) { return MC_FAILURE; } - ret = utilsImpl->GetIdHeaderByOffset(file, idHeaderOffset, &idHeader); + int32_t ret = utilsImpl->GetIdHeaderByOffset(file, idHeaderOffset, &idHeader); if (ret != MC_SUCCESS) { close(file); return ret; } + int32_t result = MC_FAILURE; IdItem idItem = {0, INVALID_RES_TYPE, 0, 0, NULL, 0, NULL}; for (uint32_t i = 0; i < idHeader.count; i++) { if (idHeader.idParams[i].id == id) { - int32_t ret = utilsImpl->GetIdItem(file, idHeader.idParams[i].offset, &idItem); + ret = utilsImpl->GetIdItem(file, idHeader.idParams[i].offset, &idItem); if (ret != MC_SUCCESS) { close(file); free(idHeader.idParams); @@ -159,18 +150,19 @@ int32_t GLOBAL_GetValueById(uint32_t id, const char *path, char **value) FreeValue(value); return MC_FAILURE; } + result = MC_SUCCESS; break; } } close(file); free(idHeader.idParams); FreeIdItem(&idItem); - return MC_SUCCESS; + return result; } -int32_t GLOBAL_GetValueByName(const char *name, const char *path, char **value) +int32_t GLOBAL_GetValueById(uint32_t id, const char *path, char **value) { - if (name == NULL || strlen(name) == 0 || path == NULL || strlen(path) == 0 || value == NULL) { + if (path == NULL || path[0] == '\0' || value == NULL) { return MC_FAILURE; } @@ -179,26 +171,39 @@ int32_t GLOBAL_GetValueByName(const char *name, const char *path, char **value) if (ret != EOK) { return MC_FAILURE; } + + char *locales[] = {tempLocale, ""}; + for (int i = 0; i < 2; i++) { + if (GLOBAL_GetValueByIdInternal(id, path, locales[i], value) == MC_SUCCESS) { + return MC_SUCCESS; + } + } + return MC_FAILURE; +} + +static int32_t GLOBAL_GetValueByNameInternal(const char *name, const char *path, const char *locale, char **value) +{ char realResourcePath[PATH_MAX] = {'\0'}; GlobalUtilsImpl *utilsImpl = GetGlobalUtilsImpl(); if (utilsImpl->CheckFilePath(path, realResourcePath, PATH_MAX) == MC_FAILURE) { return MC_FAILURE; } - uint32_t idHeaderOffset = utilsImpl->GetOffsetByLocale(realResourcePath, tempLocale, MAX_LOCALE_LENGTH); + uint32_t idHeaderOffset = utilsImpl->GetOffsetByLocale(realResourcePath, locale, MAX_LOCALE_LENGTH); IdHeader idHeader = {0, NULL}; int32_t file = open(realResourcePath, O_RDONLY, S_IRUSR | S_IRGRP | S_IROTH); if (file < 0) { return MC_FAILURE; } - ret = utilsImpl->GetIdHeaderByOffset(file, idHeaderOffset, &idHeader); + int32_t ret = utilsImpl->GetIdHeaderByOffset(file, idHeaderOffset, &idHeader); if (ret != MC_SUCCESS) { close(file); return ret; } + int32_t result = MC_FAILURE; IdItem idItem = {0, INVALID_RES_TYPE, 0, 0, NULL, 0, NULL}; for (uint32_t i = 0; i < idHeader.count; i++) { - int32_t ret = utilsImpl->GetIdItem(file, idHeader.idParams[i].offset, &idItem); + ret = utilsImpl->GetIdItem(file, idHeader.idParams[i].offset, &idItem); if (ret != MC_SUCCESS) { close(file); free(idHeader.idParams); @@ -216,11 +221,33 @@ int32_t GLOBAL_GetValueByName(const char *name, const char *path, char **value) FreeValue(value); return MC_FAILURE; } + result = MC_SUCCESS; break; } close(file); free(idHeader.idParams); FreeIdItem(&idItem); - return MC_SUCCESS; + return result; +} + +int32_t GLOBAL_GetValueByName(const char *name, const char *path, char **value) +{ + if (name == NULL || strlen(name) == 0 || path == NULL || strlen(path) == 0 || value == NULL) { + return MC_FAILURE; + } + + char tempLocale[MAX_LOCALE_LENGTH] = {'\0'}; + int32_t ret = strcpy_s(tempLocale, MAX_LOCALE_LENGTH, g_locale); + if (ret != EOK) { + return MC_FAILURE; + } + + char *locales[] = {tempLocale, ""}; + for (int i = 0; i < 2; i++) { + if (GLOBAL_GetValueByNameInternal(name, path, locales[i], value) == MC_SUCCESS) { + return MC_SUCCESS; + } + } + return MC_FAILURE; } diff --git a/frameworks/resmgr_lite/src/global_utils.c b/frameworks/resmgr_lite/src/global_utils.c index 64f54ec..ea0033d 100644 --- a/frameworks/resmgr_lite/src/global_utils.c +++ b/frameworks/resmgr_lite/src/global_utils.c @@ -28,7 +28,6 @@ #include #define MAX_ID_ITEM_NUM 0x7F -#define MAX_RES_CONFIG_NUM 0x10 #define MAX_ITEM_LENGTH 0xFF enum LocaleIndex { @@ -368,7 +367,7 @@ static uint32_t GetOffsetByLocale(const char *path, const char *locale, uint32_t return INVALID_OFFSET; } uint32_t resConfigNum = GetDefaultOffsetValue(file); - if (resConfigNum == 0 || resConfigNum > MAX_RES_CONFIG_NUM) { + if (resConfigNum == 0) { close(file); return INVALID_OFFSET; } @@ -487,6 +486,7 @@ static uint32_t GetIdHeaderOffsetByLocale(const char *locale, const Key *keys, u (void)Split(locale, "_", resConfig, &count); } else { resConfig[0] = (char *)locale; + count = 1; } return GetIdHeaderOffsetByCount(resConfig, keys, configNum, count); } -- Gitee From baca76a48df9b1ff12cc9544742b186021c558a0 Mon Sep 17 00:00:00 2001 From: huniuniu Date: Tue, 28 Sep 2021 10:16:23 +0800 Subject: [PATCH 08/31] change constant. jiabing.hu@huawei.com Signed-off-by: huniuniu --- frameworks/resmgr_lite/src/global.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frameworks/resmgr_lite/src/global.c b/frameworks/resmgr_lite/src/global.c index 1d7c3f6..8e76da7 100644 --- a/frameworks/resmgr_lite/src/global.c +++ b/frameworks/resmgr_lite/src/global.c @@ -173,7 +173,8 @@ int32_t GLOBAL_GetValueById(uint32_t id, const char *path, char **value) } char *locales[] = {tempLocale, ""}; - for (int i = 0; i < 2; i++) { + int count = sizeof(locales) / sizeof(const char *); + for (int i = 0; i < count; i++) { if (GLOBAL_GetValueByIdInternal(id, path, locales[i], value) == MC_SUCCESS) { return MC_SUCCESS; } @@ -244,7 +245,8 @@ int32_t GLOBAL_GetValueByName(const char *name, const char *path, char **value) } char *locales[] = {tempLocale, ""}; - for (int i = 0; i < 2; i++) { + int count = sizeof(locales) / sizeof(const char *); + for (int i = 0; i < count; i++) { if (GLOBAL_GetValueByNameInternal(name, path, locales[i], value) == MC_SUCCESS) { return MC_SUCCESS; } -- Gitee From cf8069d4edc24f4e69122d106f05d500801d7605 Mon Sep 17 00:00:00 2001 From: huniuniu Date: Tue, 28 Sep 2021 10:40:06 +0800 Subject: [PATCH 09/31] change constant. jiabing.hu@huawei.com Signed-off-by: huniuniu --- frameworks/resmgr_lite/src/global.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/frameworks/resmgr_lite/src/global.c b/frameworks/resmgr_lite/src/global.c index 8e76da7..4cb7d21 100644 --- a/frameworks/resmgr_lite/src/global.c +++ b/frameworks/resmgr_lite/src/global.c @@ -173,8 +173,7 @@ int32_t GLOBAL_GetValueById(uint32_t id, const char *path, char **value) } char *locales[] = {tempLocale, ""}; - int count = sizeof(locales) / sizeof(const char *); - for (int i = 0; i < count; i++) { + for (int i = 0; i < 2; i++) { // 2 current language and the default. if (GLOBAL_GetValueByIdInternal(id, path, locales[i], value) == MC_SUCCESS) { return MC_SUCCESS; } @@ -245,8 +244,7 @@ int32_t GLOBAL_GetValueByName(const char *name, const char *path, char **value) } char *locales[] = {tempLocale, ""}; - int count = sizeof(locales) / sizeof(const char *); - for (int i = 0; i < count; i++) { + for (int i = 0; i < 2; i++) { // 2 current language and the default. if (GLOBAL_GetValueByNameInternal(name, path, locales[i], value) == MC_SUCCESS) { return MC_SUCCESS; } -- Gitee From 1ad40d37a55678bb0c032899b0771f93577d6819 Mon Sep 17 00:00:00 2001 From: the-minions-of-cplu Date: Wed, 20 Oct 2021 20:04:09 +0800 Subject: [PATCH 10/31] add Global_IsRTL method Signed-off-by: the-minions-of-cplu --- frameworks/resmgr_lite/src/global.c | 34 +++++++++++++++++++++++++++ interfaces/innerkits/include/global.h | 1 + 2 files changed, 35 insertions(+) diff --git a/frameworks/resmgr_lite/src/global.c b/frameworks/resmgr_lite/src/global.c index c132ff7..5757dd6 100644 --- a/frameworks/resmgr_lite/src/global.c +++ b/frameworks/resmgr_lite/src/global.c @@ -35,6 +35,7 @@ #define MAX_LOCALE_LENGTH 13 #define UI_LOCALE_ELEMENT_NUM 2 +#define MAX_SCRIPT_LENGTH 5 static char g_locale[MAX_LOCALE_LENGTH] = {0}; void GLOBAL_ConfigLanguage(const char *appLanguage) @@ -72,6 +73,39 @@ int32_t GLOBAL_GetLanguage(char *language, uint8_t len) return (strncpy_s(language, len, localeArray[0], MAX_LANGUAGE_LENGTH - 1) != EOK) ? MC_FAILURE : MC_SUCCESS; } +int32_t GLOBAL_IsRTL(void) +{ + char *localeArray[LOCALE_ELEMENT_NUM] = { NULL }; + char tempLocale[MAX_LOCALE_LENGTH] = { '\0' }; + int32_t ret = strcpy_s(tempLocale, MAX_LOCALE_LENGTH, g_locale); + if (ret != EOK) { + return 0; + } + int32_t count = 0; + ret = GetGlobalUtilsImpl()->SplitLocale(tempLocale, localeArray, &count); + if (ret == MC_FAILURE || count != UI_LOCALE_ELEMENT_NUM) { + return 0; + } + char script[MAX_SCRIPT_LENGTH] = { 0 }; + if (strncpy_s(script, MAX_SCRIPT_LENGTH, localeArray[1], MAX_SCRIPT_LENGTH - 1) != EOK) { + return 0; + } + // if script is set and script != arab or script != hebr, return false; + if ((script != NULL) && (strlen(script) == MAX_SCRIPT_LENGTH - 1) && + (strcmp(script, "Arab") != 0) && (strcmp(script, "Hebr") != 0)) { + return 0; + } + char language[MAX_LANGUAGE_LENGTH] = { 0 }; + if (strncpy_s(language, MAX_LANGUAGE_LENGTH, localeArray[0], MAX_LANGUAGE_LENGTH - 1) != EOK) { + return 0; + } + if ((strcmp(language, "fa") == 0) || (strcmp(language, "ar") == 0) || (strcmp(language, "ur") == 0) || + (strcmp(language, "ug") == 0) || (strcmp(language, "he") == 0) || (strcmp(language, "iw") == 0)) { + return 1; + } + return 0; +} + int32_t GLOBAL_GetRegion(char *region, uint8_t len) { if (region == NULL || len == 0) { diff --git a/interfaces/innerkits/include/global.h b/interfaces/innerkits/include/global.h index 3a6f488..2eb2b50 100644 --- a/interfaces/innerkits/include/global.h +++ b/interfaces/innerkits/include/global.h @@ -38,6 +38,7 @@ int32_t GLOBAL_GetValueByName(const char *name, const char *path, char **value); void GLOBAL_ConfigLanguage(const char *appLanguage); int32_t GLOBAL_GetLanguage(char *language, uint8_t len); int32_t GLOBAL_GetRegion(char *region, uint8_t len); +int32_t GLOBAL_IsRTL(void); #ifdef __cplusplus #if __cplusplus -- Gitee From 4c35997678a6481eb4f9dcf65492c5aa85fb183c Mon Sep 17 00:00:00 2001 From: huniuniu Date: Tue, 26 Oct 2021 10:25:58 +0800 Subject: [PATCH 11/31] fix compile error. jiabing.hu@huawei.com Signed-off-by: huniuniu --- frameworks/resmgr_lite/src/global.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/resmgr_lite/src/global.c b/frameworks/resmgr_lite/src/global.c index 5f0211a..4b0e73f 100644 --- a/frameworks/resmgr_lite/src/global.c +++ b/frameworks/resmgr_lite/src/global.c @@ -91,7 +91,7 @@ int32_t GLOBAL_IsRTL(void) return 0; } // if script is set and script != arab or script != hebr, return false; - if ((script != NULL) && (strlen(script) == MAX_SCRIPT_LENGTH - 1) && + if ((strlen(script) == MAX_SCRIPT_LENGTH - 1) && (strcmp(script, "Arab") != 0) && (strcmp(script, "Hebr") != 0)) { return 0; } -- Gitee From 172e03bc7a46fa1c12360a2cfd127a6093650535 Mon Sep 17 00:00:00 2001 From: huniuniu Date: Thu, 28 Oct 2021 09:55:55 +0800 Subject: [PATCH 12/31] fix codex. jiabing.hu@huawei.com Signed-off-by: huniuniu --- frameworks/resmgr_lite/src/global_utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frameworks/resmgr_lite/src/global_utils.c b/frameworks/resmgr_lite/src/global_utils.c index ea0033d..f28e197 100644 --- a/frameworks/resmgr_lite/src/global_utils.c +++ b/frameworks/resmgr_lite/src/global_utils.c @@ -28,6 +28,7 @@ #include #define MAX_ID_ITEM_NUM 0x7F +#define MAX_RES_CONFIG_NUM 0xFFFF #define MAX_ITEM_LENGTH 0xFF enum LocaleIndex { @@ -367,7 +368,7 @@ static uint32_t GetOffsetByLocale(const char *path, const char *locale, uint32_t return INVALID_OFFSET; } uint32_t resConfigNum = GetDefaultOffsetValue(file); - if (resConfigNum == 0) { + if (resConfigNum == 0 || resConfigNum > MAX_RES_CONFIG_NUM) { close(file); return INVALID_OFFSET; } -- Gitee From 85ef396be77af0e6090a3569821456a53a5d9da8 Mon Sep 17 00:00:00 2001 From: SimonLi Date: Tue, 30 Nov 2021 05:28:34 +0800 Subject: [PATCH 13/31] =?UTF-8?q?build:=20=E6=96=B0=E5=A2=9ELiteOS-M?= =?UTF-8?q?=E7=9A=84=E7=BC=96=E8=AF=91=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SimonLi --- frameworks/resmgr_lite/BUILD.gn | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) mode change 100644 => 100755 frameworks/resmgr_lite/BUILD.gn diff --git a/frameworks/resmgr_lite/BUILD.gn b/frameworks/resmgr_lite/BUILD.gn old mode 100644 new mode 100755 index ce3ca97..ae1707c --- a/frameworks/resmgr_lite/BUILD.gn +++ b/frameworks/resmgr_lite/BUILD.gn @@ -80,16 +80,24 @@ config("global_resmgr_mingw_config") { } if (defined(ohos_lite)) { - shared_library("global_resmgr") { - sources = global_sources - configs += [ ":global_resmgr_config" ] - deps = [ "//third_party/bounds_checking_function:libsec_shared" ] - if (ohos_kernel_type == "liteos_a") { - public_deps = [ - "//base/global/i18n_lite/frameworks/i18n:global_i18n", - "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", - "//build/lite/config/component/zlib:zlib_shared", - ] + if (ohos_kernel_type == "liteos_m") { + static_library("global_resmgr") { + sources = global_sources + public_configs = [ ":global_resmgr_config" ] + deps = [ "//third_party/bounds_checking_function:libsec_static" ] + } + } else { + shared_library("global_resmgr") { + sources = global_sources + configs += [ ":global_resmgr_config" ] + deps = [ "//third_party/bounds_checking_function:libsec_shared" ] + if (ohos_kernel_type == "liteos_a") { + public_deps = [ + "//base/global/i18n_lite/frameworks/i18n:global_i18n", + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", + "//build/lite/config/component/zlib:zlib_shared", + ] + } } } -- Gitee From f4e76ee66c5d1c03fc1d95e99ed48742a7b390b7 Mon Sep 17 00:00:00 2001 From: VictoriaGuo Date: Thu, 23 Dec 2021 14:47:42 +0800 Subject: [PATCH 14/31] rename to pad Signed-off-by: VictoriaGuo --- frameworks/resmgr_lite/include/res_common.h | 4 ++-- frameworks/resmgr_lite/src/res_desc.cpp | 4 ++-- frameworks/resmgr_lite/src/utils/hap_parser.cpp | 4 ++-- .../test/unittest/lite/common/hap_parser_test.cpp | 2 +- .../test/unittest/lite/common/res_config_impl_test.cpp | 6 +++--- .../resmgr_lite/test/unittest/lite/common/res_desc_test.cpp | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/frameworks/resmgr_lite/include/res_common.h b/frameworks/resmgr_lite/include/res_common.h index f846876..5cebb9a 100644 --- a/frameworks/resmgr_lite/include/res_common.h +++ b/frameworks/resmgr_lite/include/res_common.h @@ -29,7 +29,7 @@ static const char *HORIZONTAL = "horizontal"; static const char *PHONE_STR = "phone"; static const char *TABLET_STR = "tablet"; static const char *CAR_STR = "car"; -static const char *PC_STR = "pc"; +static const char *PAD_STR = "pad"; static const char *TV_STR = "tv"; static const char *WEARABLE_STR = "wearable"; @@ -90,7 +90,7 @@ enum DeviceType { DEVICE_PHONE = 0, DEVICE_TABLET = 1, DEVICE_CAR = 2, - DEVICE_PC = 3, + DEVICE_PAD = 3, DEVICE_TV = 4, DEVICE_WEARABLE = 6, }; diff --git a/frameworks/resmgr_lite/src/res_desc.cpp b/frameworks/resmgr_lite/src/res_desc.cpp index 7ea5516..d143db0 100644 --- a/frameworks/resmgr_lite/src/res_desc.cpp +++ b/frameworks/resmgr_lite/src/res_desc.cpp @@ -67,8 +67,8 @@ std::string KeyParam::GetDeviceTypeStr() const case DeviceType::DEVICE_CAR: ret = std::string(CAR_STR); break; - case DeviceType::DEVICE_PC: - ret = std::string(PC_STR); + case DeviceType::DEVICE_PAD: + ret = std::string(PAD_STR); break; case DeviceType::DEVICE_TV: ret = std::string(TV_STR); diff --git a/frameworks/resmgr_lite/src/utils/hap_parser.cpp b/frameworks/resmgr_lite/src/utils/hap_parser.cpp index 02d49ae..07ee652 100644 --- a/frameworks/resmgr_lite/src/utils/hap_parser.cpp +++ b/frameworks/resmgr_lite/src/utils/hap_parser.cpp @@ -450,8 +450,8 @@ DeviceType HapParser::GetDeviceType(uint32_t value) DeviceType deviceType = DEVICE_NOT_SET; if (value == DEVICE_CAR) { deviceType = DEVICE_CAR; - } else if (value == DEVICE_PC) { - deviceType = DEVICE_PC; + } else if (value == DEVICE_PAD) { + deviceType = DEVICE_PAD; } else if (value == DEVICE_PHONE) { deviceType = DEVICE_PHONE; } else if (value == DEVICE_TABLET) { diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.cpp index 13decd6..1742629 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.cpp @@ -118,7 +118,7 @@ HWTEST_F(HapParserTest, HapParserFuncTest001, TestSize.Level1) HWTEST_F(HapParserTest, HapParserFuncTest002, TestSize.Level1) { ASSERT_EQ(DEVICE_CAR, HapParser::GetDeviceType(DEVICE_CAR)); - ASSERT_EQ(DEVICE_PC, HapParser::GetDeviceType(DEVICE_PC)); + ASSERT_EQ(DEVICE_PAD, HapParser::GetDeviceType(DEVICE_PAD)); ASSERT_EQ(DEVICE_PHONE, HapParser::GetDeviceType(DEVICE_PHONE)); ASSERT_EQ(DEVICE_TABLET, HapParser::GetDeviceType(DEVICE_TABLET)); ASSERT_EQ(DEVICE_TV, HapParser::GetDeviceType(DEVICE_TV)); diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.cpp index b58d3b8..18c2be0 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.cpp @@ -342,7 +342,7 @@ HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest020, TestSize.Level1) ResConfigImpl *other = CreateResConfigImpl("en", nullptr, nullptr); ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr); current->SetDeviceType(DeviceType::DEVICE_CAR); - other->SetDeviceType(DeviceType::DEVICE_PC); + other->SetDeviceType(DeviceType::DEVICE_PAD); EXPECT_FALSE(current->Match(other)); delete current; delete other; @@ -357,7 +357,7 @@ HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest021, TestSize.Level1) { ResConfigImpl *other = CreateResConfigImpl("en", nullptr, nullptr); ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr); - other->SetDeviceType(DeviceType::DEVICE_PC); + other->SetDeviceType(DeviceType::DEVICE_PAD); EXPECT_TRUE(current->Match(other)); delete current; delete other; @@ -372,7 +372,7 @@ HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest022, TestSize.Level1) { ResConfigImpl *other = CreateResConfigImpl("en", nullptr, nullptr); ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr); - current->SetDeviceType(DeviceType::DEVICE_PC); + current->SetDeviceType(DeviceType::DEVICE_PAD); EXPECT_TRUE(current->Match(other)); delete current; delete other; diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.cpp index 7b19f0b..fb44ca7 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.cpp @@ -141,7 +141,7 @@ HWTEST_F(ResDescTest, ResDescFuncTest002, TestSize.Level1) TestKeyParam(KeyType::DEVICETYPE, DeviceType::DEVICE_PHONE, PHONE_STR); TestKeyParam(KeyType::DEVICETYPE, DeviceType::DEVICE_TABLET, TABLET_STR); TestKeyParam(KeyType::DEVICETYPE, DeviceType::DEVICE_CAR, CAR_STR); - TestKeyParam(KeyType::DEVICETYPE, DeviceType::DEVICE_PC, PC_STR); + TestKeyParam(KeyType::DEVICETYPE, DeviceType::DEVICE_PAD, PAD_STR); TestKeyParam(KeyType::DEVICETYPE, DeviceType::DEVICE_TV, TV_STR); TestKeyParam(KeyType::DEVICETYPE, DeviceType::DEVICE_WEARABLE, WEARABLE_STR); TestKeyParam(KeyType::DEVICETYPE, DeviceType::DEVICE_NOT_SET, "not_device_type"); -- Gitee From 7ecdce3ec284f5cf3887f72e5bbde9731fbd8098 Mon Sep 17 00:00:00 2001 From: huangjie Date: Wed, 19 Jan 2022 17:34:30 +0800 Subject: [PATCH 15/31] =?UTF-8?q?resmgr=5Flite=E7=BC=96=E8=AF=91=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E5=8E=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjie --- frameworks/resmgr_lite/BUILD.gn | 2 -- 1 file changed, 2 deletions(-) diff --git a/frameworks/resmgr_lite/BUILD.gn b/frameworks/resmgr_lite/BUILD.gn index ae1707c..2cbf593 100755 --- a/frameworks/resmgr_lite/BUILD.gn +++ b/frameworks/resmgr_lite/BUILD.gn @@ -23,8 +23,6 @@ if (defined(ohos_lite) && ohos_kernel_type == "liteos_a") { "src/global.cpp", "src/hap_manager.cpp", "src/hap_resource.cpp", - "src/likely_subtags_key_data.cpp", - "src/likely_subtags_value_data.cpp", "src/locale_matcher.cpp", "src/lock.cpp", "src/res_config_impl.cpp", -- Gitee From d46650f267756b880a29ba655d32d9aec7bede8a Mon Sep 17 00:00:00 2001 From: wplan1 Date: Thu, 27 Jan 2022 20:16:44 +0800 Subject: [PATCH 16/31] add bundle.json Signed-off-by: wplan1 --- bundle.json | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 bundle.json diff --git a/bundle.json b/bundle.json new file mode 100644 index 0000000..6170a0b --- /dev/null +++ b/bundle.json @@ -0,0 +1,66 @@ +{ + "name": "@ohos/global_resmgr_lite", + "version": "", + "description": "Obtains resource information based on the device type and configuration", + "homePage": "https://gitee.com/openharmony", + "license": "Apache V2", + "repository": "https://gitee.com/openharmony/global_resmgr_lite", + "domain": "os", + "language": "", + "publishAs": "code-segment", + "private": false, + "scripts": {}, + "tags": [ + "base" + ], + "keywords": [ + "global", + "resmgr", + "lite" + ], + "envs": [], + "dirs": [], + "author": { + "name": "", + "email": "", + "url": "" + }, + "contributors": [ + { + "name": "", + "email": "", + "url": "" + } + ], + "segment": { + "destPath": "base/global/resmgr_lite" + }, + "component": { + "name": "resmgr_lite", + "subsystem": "global", + "syscap": [], + "features": [], + "adapted_system_type": [ + "small" + ], + "rom": "", + "ram": "", + "deps": { + "components": [ + "utils_base" + ], + "third_party": [ + "bounds_checking_function" + ] + }, + "build": { + "sub_component": [ + "//base/global/resmgr_lite/frameworks/resmgr_lite:global_resmgr" + ], + "inner_kits": [], + "test": [ + "//base/global/resmgr_lite/frameworks/resmgr_lite/test:unittest" + ] + } + } +} \ No newline at end of file -- Gitee From 989d95fe5f2bde30ec97eb13d5517d55db8e5df1 Mon Sep 17 00:00:00 2001 From: VictoriaGuo Date: Wed, 9 Feb 2022 14:20:25 +0800 Subject: [PATCH 17/31] fixed 244536f from https://gitee.com/victoriaguo/global_resmgr_lite/pulls/77 Modify test word Signed-off-by: VictoriaGuo --- .../lite/common/resource_manager_test.cpp | 2 +- test/resource/data/all.hap | Bin 27123 -> 19452 bytes .../data/all/assets/entry/resources.index | Bin 6414 -> 6410 bytes 3 files changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp index 7889673..c43bd22 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp @@ -995,7 +995,7 @@ HWTEST_F(ResourceManagerTest, ResourceManagerGetThemeByNameTest001, TestSize.Lev ASSERT_EQ(SUCCESS, state); PrintMapString(outValue); - state = rm->GetThemeByName("activity_theme", outValue); + state = rm->GetThemeByName("test_theme", outValue); ASSERT_EQ(SUCCESS, state); PrintMapString(outValue); } diff --git a/test/resource/data/all.hap b/test/resource/data/all.hap index 3faf9885d7e781c78e6682f427c639d99b0db1cd..e5244c5585ef4b9ab7132911e18706278a7f2a3d 100644 GIT binary patch literal 19452 zcmb7M1z1+w(x#-l8|m&wq`OO`k?w8@X{5WmK^mmHyFofcx>Fi{JYLTQ?g@W*Hp9oW zznOQ<%$hyxTkAze92f){0000SV9>{39yLb8s09!JKnxTB0P5kdIu_>oMg}y-HWud5 z3X;;^bnuM_B`<@8`6u#BzE>Ts@=6QAb;XT^(3O3bR1MN?|4(8c11V@z)pqy{B{YRz&bAOLJnhV%X9|Rgx9{h(W^iy zh8T6K<;ZS^`7g4Vi z52)^%lSKu*1Nx}7#f^{FN}(Mg!NUVWVaIiZU|W(GoqHpcJ8Wkd@+zLN6UhTZbv-<`a5 z7#$~C4Xl*^rrUl}r6l?tIlrjLi-9`IL8}ZuBJC^wqUX1)dwKEYJn0Fw{ za!6zcUeA8Xq2XQ$|DHiD03e~4`k>leWY^sAY2z>LsAO1zKmkee*eFri;g`Mp=y?bA zz02dnrUyi{sYFZ_iP%|)*zJiJ+0(3FvXCmkCThSEH70?adY%FTJjK`Z<;ZpF0oylV z008>m#P?8AY;3j6ZU6A0dSs)yDm}E%85vN*5g+^q0kIiK;N;@b1=X+`b?8@gp3tsW zxPA8TguQ6E#E9So7dx&lL#S`_Y_h*?)y$7-?QD)C$zJ@NvL!zp5hSHcCqlx1nt}=ScFxAYKu*TyFc=RRO zGgc$VC>pY=Ajl<4f{IrS1v(BUkh6S7_qE)2ZqDMWyt~naU!_fJX_&uRvHPu#xL9OM zl(+Hj2VbhpCrgH1X>uHBa%+TqfV)0D-LQOr=}2PZP?eCPA?-JQ*{9N+++S@YrJH)N z6hv+170$L^^fhs0c870DyF*ZeLqw91uqVz!G!F{`g1;1KXL~6`@XK5$B zowm~t6o1?PI|c59- z0z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XXTy4ZrR* zD7Fb6nlp-_HKU^8j{nbWkmRB5V4Gm0efwFnD`m}O^V7S~O>ot|ZLG<4C%1W>YvxSW zzVWNcs2INX-yALe^!{%X-P68dtI2f*e1D=jTz|N4+XN@=+o+nHZo^NSG>22;cT<~S zr+xcVlULhU%M#nYfzdz#`yo7M-!K#n&^x6z< znoP8vZTRr!FlnYY(qy9@C2edLo90a(O)kB(G^Ur-oX#|6Tn2av34TSV6J-)aqVYh7 GLivB*Mrxh_ diff --git a/test/resource/data/all/assets/entry/resources.index b/test/resource/data/all/assets/entry/resources.index index b06d9dcecc508f954d3352843118a6e35d452a22..9162b5ead5ae90415e9e5e4e382af8d0d25cab57 100644 GIT binary patch delta 486 zcmXZZ%`3wJ9LMp`kEJ&KHk-#%wwdRL*?!nC=3yA~R1RESh663xQI?aUNOBZMjvC2X zyU2f_9GsMLP|ou{IK4jKPv6t`dtx0~=5l&Bo5^hX!oiR=aOTdO`D}*c?!a4;`!OY- zWMrL^AMddd-!Xtrm(+wYY{oTg!9#4tCv3w{Y)4Op)PV`?#C7b#YwX5n4B|KTNI9dy zErlrJ7{)!c@CJMF75nf9`?1+0MQ|0Pc#H%1h=cfsLs-NZ1}ddtOyUUUFpdv6s+^1u z!Wcz;l{AhioWN5|;1^EfRJAmP`#6mSOrlXE&0qp&@d8u$i*vYIE6w8-E?^NCF;yom z*$B6Jzpd16f04vd)Nr0R3*Pext#G?AE@gh9Fx zF^Vwx4R#Neqa^mXGzr Date: Thu, 17 Feb 2022 11:29:37 +0800 Subject: [PATCH 18/31] 1323883142@qq.com Signed-off-by: w00617344 <1323883142@qq.com> --- frameworks/resmgr_lite/include/global_utils.h | 2 +- frameworks/resmgr_lite/include/hap_resource.h | 4 +- frameworks/resmgr_lite/include/res_desc.h | 2 +- .../resmgr_lite/include/resource_manager.h | 2 +- .../include/resource_manager_impl.h | 4 +- .../resmgr_lite/include/utils/date_utils.h | 1 - frameworks/resmgr_lite/src/lock.cpp | 1 - .../test/unittest/lite/common/global_test.cpp | 3 +- .../test/unittest/lite/common/global_test.h | 8 +- .../unittest/lite/common/hap_manager_test.cpp | 3 +- .../unittest/lite/common/hap_manager_test.h | 4 +- .../unittest/lite/common/hap_parser_test.cpp | 3 +- .../unittest/lite/common/hap_parser_test.h | 8 +- .../lite/common/hap_resource_test.cpp | 3 +- .../unittest/lite/common/hap_resource_test.h | 8 +- .../unittest/lite/common/locale_info_test.cpp | 5 +- .../unittest/lite/common/locale_info_test.h | 54 +++--- .../lite/common/res_config_impl_test.cpp | 3 +- .../lite/common/res_config_impl_test.h | 158 +++++++++--------- .../unittest/lite/common/res_config_test.cpp | 5 +- .../unittest/lite/common/res_config_test.h | 2 +- .../unittest/lite/common/res_desc_test.cpp | 3 +- .../test/unittest/lite/common/res_desc_test.h | 4 +- .../resource_manager_performance_test.cpp | 3 +- .../resource_manager_performance_test.h | 64 +++---- .../lite/common/resource_manager_test.cpp | 3 +- .../lite/common/resource_manager_test.h | 156 ++++++++--------- .../lite/common/string_utils_test.cpp | 3 +- .../unittest/lite/common/string_utils_test.h | 4 +- 29 files changed, 266 insertions(+), 257 deletions(-) diff --git a/frameworks/resmgr_lite/include/global_utils.h b/frameworks/resmgr_lite/include/global_utils.h index 6bd8c48..a2cedd4 100644 --- a/frameworks/resmgr_lite/include/global_utils.h +++ b/frameworks/resmgr_lite/include/global_utils.h @@ -114,7 +114,7 @@ typedef struct LocaleItem { GlobalUtilsImpl *GetGlobalUtilsImpl(void); -#define MC_FAILURE -1 +#define MC_FAILURE (-1) #define MC_SUCCESS 0 #ifdef __cplusplus diff --git a/frameworks/resmgr_lite/include/hap_resource.h b/frameworks/resmgr_lite/include/hap_resource.h index 007b899..0f5d6c9 100644 --- a/frameworks/resmgr_lite/include/hap_resource.h +++ b/frameworks/resmgr_lite/include/hap_resource.h @@ -15,12 +15,12 @@ #ifndef RESOURCE_MANAGER_HAPRESOURCE_H #define RESOURCE_MANAGER_HAPRESOURCE_H -#include "res_desc.h" -#include "res_config_impl.h" #include #include #include #include +#include "res_desc.h" +#include "res_config_impl.h" namespace OHOS { namespace Global { diff --git a/frameworks/resmgr_lite/include/res_desc.h b/frameworks/resmgr_lite/include/res_desc.h index 18cdb6f..15ac4aa 100644 --- a/frameworks/resmgr_lite/include/res_desc.h +++ b/frameworks/resmgr_lite/include/res_desc.h @@ -16,11 +16,11 @@ #ifndef OHOS_RESOURCE_MANAGER_RES_DESC_H #define OHOS_RESOURCE_MANAGER_RES_DESC_H -#include "res_common.h" #include #include #include #include +#include "res_common.h" namespace OHOS { namespace Global { diff --git a/frameworks/resmgr_lite/include/resource_manager.h b/frameworks/resmgr_lite/include/resource_manager.h index 560fc84..940cd9d 100644 --- a/frameworks/resmgr_lite/include/resource_manager.h +++ b/frameworks/resmgr_lite/include/resource_manager.h @@ -15,10 +15,10 @@ #ifndef OHOS_RESOURCE_MANAGER_RESOURCEMANAGER_H #define OHOS_RESOURCE_MANAGER_RESOURCEMANAGER_H -#include "res_config.h" #include #include #include +#include "res_config.h" namespace OHOS { namespace Global { diff --git a/frameworks/resmgr_lite/include/resource_manager_impl.h b/frameworks/resmgr_lite/include/resource_manager_impl.h index 6070a88..f402e8c 100644 --- a/frameworks/resmgr_lite/include/resource_manager_impl.h +++ b/frameworks/resmgr_lite/include/resource_manager_impl.h @@ -15,11 +15,11 @@ #ifndef OHOS_RESOURCE_MANAGER_RESOURCEMANAGERIMPL_H #define OHOS_RESOURCE_MANAGER_RESOURCEMANAGERIMPL_H -#include "hap_manager.h" -#include "resource_manager.h" #include #include #include +#include "hap_manager.h" +#include "resource_manager.h" namespace OHOS { namespace Global { diff --git a/frameworks/resmgr_lite/include/utils/date_utils.h b/frameworks/resmgr_lite/include/utils/date_utils.h index 88024ae..555f50e 100644 --- a/frameworks/resmgr_lite/include/utils/date_utils.h +++ b/frameworks/resmgr_lite/include/utils/date_utils.h @@ -18,7 +18,6 @@ #include #include - #include "common.h" namespace OHOS { diff --git a/frameworks/resmgr_lite/src/lock.cpp b/frameworks/resmgr_lite/src/lock.cpp index 293db12..2a9d305 100644 --- a/frameworks/resmgr_lite/src/lock.cpp +++ b/frameworks/resmgr_lite/src/lock.cpp @@ -13,7 +13,6 @@ * limitations under the License. */ #include "lock.h" -#include namespace OHOS { namespace Global { diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/global_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/global_test.cpp index 00e964b..c578f46 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/global_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/global_test.cpp @@ -27,7 +27,7 @@ using namespace OHOS::Global::Resource; using namespace testing::ext; - +namespace { class GlobalTest : public testing::Test { public: static void SetUpTestCase(void); @@ -174,3 +174,4 @@ HWTEST_F(GlobalTest, GlobalFuncTest004, TestSize.Level1) EXPECT_EQ(std::string("App Name"), values); free(values); } +} diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/global_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/global_test.h index beccf53..4bf724a 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/global_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/global_test.h @@ -16,9 +16,9 @@ #ifndef RESOURCE_MANAGER_GLOBAL_TEST_H #define RESOURCE_MANAGER_GLOBAL_TEST_H -int GlobalFuncTest001(); -int GlobalFuncTest002(); -int GlobalFuncTest003(); -int GlobalFuncTest004(); +int GlobalFuncTest001(void); +int GlobalFuncTest002(void); +int GlobalFuncTest003(void); +int GlobalFuncTest004(void); #endif diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.cpp index 67186bb..993bf0e 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.cpp @@ -26,7 +26,7 @@ using namespace OHOS::Global::Resource; using namespace testing::ext; - +namespace { class HapManagerTest : public testing::Test { public: static void SetUpTestCase(void); @@ -151,4 +151,5 @@ HWTEST_F(HapManagerTest, HapManagerFuncTest002, TestSize.Level1) delete (hapManager); delete (rc2); delete (rc); +} } \ No newline at end of file diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.h index 93b0537..c4082c2 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.h @@ -16,7 +16,7 @@ #ifndef RESOURCE_MANAGER_HAP_MANAGER_TEST_H #define RESOURCE_MANAGER_HAP_MANAGER_TEST_H -int HapManagerFuncTest001(); -int HapManagerFuncTest002(); +int HapManagerFuncTest001(void); +int HapManagerFuncTest002(void); #endif diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.cpp index 1742629..ad3dbe8 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.cpp @@ -26,7 +26,7 @@ using namespace OHOS::Global::Resource; using namespace testing::ext; - +namespace { class HapParserTest : public testing::Test { public: static void SetUpTestCase(void); @@ -180,4 +180,5 @@ HWTEST_F(HapParserTest, HapParserFuncTest004, TestSize.Level1) for (auto kp = keyParams.begin(); kp != keyParams.end(); kp++) { delete *kp; } +} } \ No newline at end of file diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.h index 7c5ef8d..a86ab36 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.h @@ -16,9 +16,9 @@ #ifndef RESOURCE_MANAGER_HAP_RESOURCE_TEST_H #define RESOURCE_MANAGER_HAP_RESOURCE_TEST_H -int HapParserFuncTest001(); -int HapParserFuncTest002(); -int HapParserFuncTest003(); -int HapParserFuncTest004(); +int HapParserFuncTest001(void); +int HapParserFuncTest002(void); +int HapParserFuncTest003(void); +int HapParserFuncTest004(void); #endif diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.cpp index 872646f..2b6278d 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.cpp @@ -29,7 +29,7 @@ using namespace OHOS::Global::Resource; using namespace testing::ext; - +namespace { class HapResourceTest : public testing::Test { public: static void SetUpTestCase(void); @@ -301,4 +301,5 @@ HWTEST_F(HapResourceTest, HapResourceFuncTest004, TestSize.Level1) // 3. hap file exists, config.json error: missing "moduleName" resDesc = LoadFromHap(FormatFullPath("err-config.json-2.hap").c_str(), nullptr); ASSERT_TRUE(resDesc == nullptr); +} } \ No newline at end of file diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.h index 7ea1b99..67a6922 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.h @@ -16,9 +16,9 @@ #ifndef RESOURCE_MANAGER_HAP_RESOURCE_TEST_H #define RESOURCE_MANAGER_HAP_RESOURCE_TEST_H -int HapResourceFuncTest001(); -int HapResourceFuncTest002(); -int HapResourceFuncTest003(); -int HapResourceFuncTest004(); +int HapResourceFuncTest001(void); +int HapResourceFuncTest002(void); +int HapResourceFuncTest003(void); +int HapResourceFuncTest004(void); #endif diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.cpp index eb0af69..6216b04 100755 --- a/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.cpp @@ -25,7 +25,7 @@ using namespace OHOS::Global::Resource; using namespace testing::ext; - +namespace { class LocaleInfoTest : public testing::Test { public: static void SetUpTestCase(void); @@ -606,4 +606,5 @@ HWTEST_F(LocaleInfoTest, LocaleInfoPerformanceFuncTest001, TestSize.Level1) average = total / 1000.0; HILOG_DEBUG("avg cost FindAndSort: %f us", average); EXPECT_LT(average, 500); -}; \ No newline at end of file +}; +} \ No newline at end of file diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.h index 6512ab3..9b46153 100755 --- a/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.h @@ -16,32 +16,32 @@ #ifndef RESOURCE_MANAGER_LOCALE_INFO_TEST_H #define RESOURCE_MANAGER_LOCALE_INFO_TEST_H -int LocaleInfoFindAndSortTest001(); -int LocaleInfoFindAndSortTest002(); -int LocaleInfoFindAndSortTest003(); -int LocaleInfoFindAndSortTest004(); -int LocaleInfoFindAndSortTest005(); -int LocaleInfoUpdateSysDefaultTest001(); -int LocaleInfoGetSysDefaultTest001(); -int LocaleInfoGetLanguageTest001(); -int LocaleInfoGetRegionTest001(); -int LocaleInfoGetScriptTest001(); -int LocaleInfoBuildFromPartsTest001(); -int LocaleInfoBuildFromPartsTest002(); -int LocaleInfoBuildFromPartsTest003(); -int LocaleInfoBuildFromPartsTest004(); -int LocaleInfoBuildFromPartsTest005(); -int LocaleInfoBuildFromPartsTest006(); -int LocaleInfoBuildFromStringTest001(); -int LocaleInfoBuildFromStringTest002(); -int LocaleInfoBuildFromStringTest003(); -int LocaleInfoBuildFromStringTest004(); -int LocaleInfoBuildFromStringTest005(); -int LocaleInfoBuildFromStringTest006(); -int LocaleInfoBuildFromStringTest007(); -int LocaleInfoBuildFromStringTest008(); -int LocaleInfoBuildFromStringTest009(); -int LocaleInfoBuildFromStringTest0010(); -int LocaleInfoPerformanceFuncTest001(); +int LocaleInfoFindAndSortTest001(void); +int LocaleInfoFindAndSortTest002(void); +int LocaleInfoFindAndSortTest003(void); +int LocaleInfoFindAndSortTest004(void); +int LocaleInfoFindAndSortTest005(void); +int LocaleInfoUpdateSysDefaultTest001(void); +int LocaleInfoGetSysDefaultTest001(void); +int LocaleInfoGetLanguageTest001(void); +int LocaleInfoGetRegionTest001(void); +int LocaleInfoGetScriptTest001(void); +int LocaleInfoBuildFromPartsTest001(void); +int LocaleInfoBuildFromPartsTest002(void); +int LocaleInfoBuildFromPartsTest003(void); +int LocaleInfoBuildFromPartsTest004(void); +int LocaleInfoBuildFromPartsTest005(void); +int LocaleInfoBuildFromPartsTest006(void); +int LocaleInfoBuildFromStringTest001(void); +int LocaleInfoBuildFromStringTest002(void); +int LocaleInfoBuildFromStringTest003(void); +int LocaleInfoBuildFromStringTest004(void); +int LocaleInfoBuildFromStringTest005(void); +int LocaleInfoBuildFromStringTest006(void); +int LocaleInfoBuildFromStringTest007(void); +int LocaleInfoBuildFromStringTest008(void); +int LocaleInfoBuildFromStringTest009(void); +int LocaleInfoBuildFromStringTest0010(void); +int LocaleInfoPerformanceFuncTest001(void); #endif // RESOURCE_MANAGER_LOCALE_INFO_TEST_H diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.cpp index 18c2be0..5a6dc4f 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.cpp @@ -23,7 +23,7 @@ using namespace OHOS::Global::Resource; using namespace testing::ext; - +namespace { class ResConfigImplTest : public testing::Test { public: static void SetUpTestCase(void); @@ -1392,4 +1392,5 @@ HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest050, TestSize.Level1) delete request; delete current; delete other; +} } \ No newline at end of file diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.h index 3a102ee..2c406ef 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.h @@ -16,84 +16,84 @@ #ifndef RESOURCE_MANAGER_RES_CONFIG_IMPL_TEST_H #define RESOURCE_MANAGER_RES_CONFIG_IMPL_TEST_H -int ResConfigImplMatchTest001(); -int ResConfigImplMatchTest002(); -int ResConfigImplMatchTest003(); -int ResConfigImplMatchTest004(); -int ResConfigImplMatchTest005(); -int ResConfigImplMatchTest006(); -int ResConfigImplMatchTest007(); -int ResConfigImplMatchTest008(); -int ResConfigImplMatchTest009(); -int ResConfigImplMatchTest010(); -int ResConfigImplMatchTest011(); -int ResConfigImplMatchTest012(); -int ResConfigImplMatchTest013(); -int ResConfigImplMatchTest014(); -int ResConfigImplMatchTest015(); -int ResConfigImplMatchTest016(); -int ResConfigImplMatchTest017(); -int ResConfigImplMatchTest018(); -int ResConfigImplMatchTest019(); -int ResConfigImplMatchTest020(); -int ResConfigImplMatchTest021(); -int ResConfigImplMatchTest022(); -int ResConfigImplMatchTest023(); -int ResConfigImplMatchTest024(); -int ResConfigImplMatchTest025(); -int ResConfigImplMatchTest026(); -int ResConfigImplMatchTest027(); -int ResConfigImplMatchTest028(); -int ResConfigImplMatchTest029(); -int ResConfigImplIsMoreSuitableTest001(); -int ResConfigImplIsMoreSuitableTest002(); -int ResConfigImplIsMoreSuitableTest003(); -int ResConfigImplIsMoreSuitableTest004(); -int ResConfigImplIsMoreSuitableTest005(); -int ResConfigImplIsMoreSuitableTest006(); -int ResConfigImplIsMoreSuitableTest007(); -int ResConfigImplIsMoreSuitableTest008(); -int ResConfigImplIsMoreSuitableTest009(); -int ResConfigImplIsMoreSuitableTest010(); -int ResConfigImplIsMoreSuitableTest011(); -int ResConfigImplIsMoreSuitableTest012(); -int ResConfigImplIsMoreSuitableTest013(); -int ResConfigImplIsMoreSuitableTest014(); -int ResConfigImplIsMoreSuitableTest015(); -int ResConfigImplIsMoreSuitableTest016(); -int ResConfigImplIsMoreSuitableTest017(); -int ResConfigImplIsMoreSuitableTest018(); -int ResConfigImplIsMoreSuitableTest019(); -int ResConfigImplIsMoreSuitableTest020(); -int ResConfigImplIsMoreSuitableTest021(); -int ResConfigImplIsMoreSuitableTest022(); -int ResConfigImplIsMoreSuitableTest023(); -int ResConfigImplIsMoreSuitableTest024(); -int ResConfigImplIsMoreSuitableTest025(); -int ResConfigImplIsMoreSuitableTest026(); -int ResConfigImplIsMoreSuitableTest027(); -int ResConfigImplIsMoreSuitableTest028(); -int ResConfigImplIsMoreSuitableTest029(); -int ResConfigImplIsMoreSuitableTest030(); -int ResConfigImplIsMoreSuitableTest031(); -int ResConfigImplIsMoreSuitableTest032(); -int ResConfigImplIsMoreSuitableTest033(); -int ResConfigImplIsMoreSuitableTest034(); -int ResConfigImplIsMoreSuitableTest035(); -int ResConfigImplIsMoreSuitableTest036(); -int ResConfigImplIsMoreSuitableTest037(); -int ResConfigImplIsMoreSuitableTest038(); -int ResConfigImplIsMoreSuitableTest039(); -int ResConfigImplIsMoreSuitableTest040(); -int ResConfigImplIsMoreSuitableTest041(); -int ResConfigImplIsMoreSuitableTest042(); -int ResConfigImplIsMoreSuitableTest043(); -int ResConfigImplIsMoreSuitableTest044(); -int ResConfigImplIsMoreSuitableTest045(); -int ResConfigImplIsMoreSuitableTest046(); -int ResConfigImplIsMoreSuitableTest047(); -int ResConfigImplIsMoreSuitableTest048(); -int ResConfigImplIsMoreSuitableTest049(); -int ResConfigImplIsMoreSuitableTest050(); +int ResConfigImplMatchTest001(void); +int ResConfigImplMatchTest002(void); +int ResConfigImplMatchTest003(void); +int ResConfigImplMatchTest004(void); +int ResConfigImplMatchTest005(void); +int ResConfigImplMatchTest006(void); +int ResConfigImplMatchTest007(void); +int ResConfigImplMatchTest008(void); +int ResConfigImplMatchTest009(void); +int ResConfigImplMatchTest010(void); +int ResConfigImplMatchTest011(void); +int ResConfigImplMatchTest012(void); +int ResConfigImplMatchTest013(void); +int ResConfigImplMatchTest014(void); +int ResConfigImplMatchTest015(void); +int ResConfigImplMatchTest016(void); +int ResConfigImplMatchTest017(void); +int ResConfigImplMatchTest018(void); +int ResConfigImplMatchTest019(void); +int ResConfigImplMatchTest020(void); +int ResConfigImplMatchTest021(void); +int ResConfigImplMatchTest022(void); +int ResConfigImplMatchTest023(void); +int ResConfigImplMatchTest024(void); +int ResConfigImplMatchTest025(void); +int ResConfigImplMatchTest026(void); +int ResConfigImplMatchTest027(void); +int ResConfigImplMatchTest028(void); +int ResConfigImplMatchTest029(void); +int ResConfigImplIsMoreSuitableTest001(void); +int ResConfigImplIsMoreSuitableTest002(void); +int ResConfigImplIsMoreSuitableTest003(void); +int ResConfigImplIsMoreSuitableTest004(void); +int ResConfigImplIsMoreSuitableTest005(void); +int ResConfigImplIsMoreSuitableTest006(void); +int ResConfigImplIsMoreSuitableTest007(void); +int ResConfigImplIsMoreSuitableTest008(void); +int ResConfigImplIsMoreSuitableTest009(void); +int ResConfigImplIsMoreSuitableTest010(void); +int ResConfigImplIsMoreSuitableTest011(void); +int ResConfigImplIsMoreSuitableTest012(void); +int ResConfigImplIsMoreSuitableTest013(void); +int ResConfigImplIsMoreSuitableTest014(void); +int ResConfigImplIsMoreSuitableTest015(void); +int ResConfigImplIsMoreSuitableTest016(void); +int ResConfigImplIsMoreSuitableTest017(void); +int ResConfigImplIsMoreSuitableTest018(void); +int ResConfigImplIsMoreSuitableTest019(void); +int ResConfigImplIsMoreSuitableTest020(void); +int ResConfigImplIsMoreSuitableTest021(void); +int ResConfigImplIsMoreSuitableTest022(void); +int ResConfigImplIsMoreSuitableTest023(void); +int ResConfigImplIsMoreSuitableTest024(void); +int ResConfigImplIsMoreSuitableTest025(void); +int ResConfigImplIsMoreSuitableTest026(void); +int ResConfigImplIsMoreSuitableTest027(void); +int ResConfigImplIsMoreSuitableTest028(void); +int ResConfigImplIsMoreSuitableTest029(void); +int ResConfigImplIsMoreSuitableTest030(void); +int ResConfigImplIsMoreSuitableTest031(void); +int ResConfigImplIsMoreSuitableTest032(void); +int ResConfigImplIsMoreSuitableTest033(void); +int ResConfigImplIsMoreSuitableTest034(void); +int ResConfigImplIsMoreSuitableTest035(void); +int ResConfigImplIsMoreSuitableTest036(void); +int ResConfigImplIsMoreSuitableTest037(void); +int ResConfigImplIsMoreSuitableTest038(void); +int ResConfigImplIsMoreSuitableTest039(void); +int ResConfigImplIsMoreSuitableTest040(void); +int ResConfigImplIsMoreSuitableTest041(void); +int ResConfigImplIsMoreSuitableTest042(void); +int ResConfigImplIsMoreSuitableTest043(void); +int ResConfigImplIsMoreSuitableTest044(void); +int ResConfigImplIsMoreSuitableTest045(void); +int ResConfigImplIsMoreSuitableTest046(void); +int ResConfigImplIsMoreSuitableTest047(void); +int ResConfigImplIsMoreSuitableTest048(void); +int ResConfigImplIsMoreSuitableTest049(void); +int ResConfigImplIsMoreSuitableTest050(void); #endif diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.cpp index 2682b32..97f21f8 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.cpp @@ -25,7 +25,7 @@ using namespace OHOS::Global::Resource; using namespace testing::ext; - +namespace { class ResConfigTest : public testing::Test { public: static void SetUpTestCase(void); @@ -74,4 +74,5 @@ HWTEST_F(ResConfigTest, ResConfigFuncTest001, TestSize.Level1) delete target; delete current; delete rc; -}; \ No newline at end of file +}; +} \ No newline at end of file diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.h index 2b689ed..d21ba14 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.h @@ -16,6 +16,6 @@ #ifndef RESOURCE_MANAGER_RES_CONFIG_TEST_H #define RESOURCE_MANAGER_RES_CONFIG_TEST_H -int ResConfigFuncTest001(); +int ResConfigFuncTest001(void); #endif diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.cpp index fb44ca7..6b58a44 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.cpp @@ -23,7 +23,7 @@ using namespace OHOS::Global::Resource; using namespace testing::ext; - +namespace { class ResDescTest : public testing::Test { public: static void SetUpTestCase(void); @@ -153,4 +153,5 @@ HWTEST_F(ResDescTest, ResDescFuncTest002, TestSize.Level1) TestKeyParam(KeyType::SCREEN_DENSITY, ScreenDensity::SCREEN_DENSITY_XXLDPI, RE_480_STR); TestKeyParam(KeyType::SCREEN_DENSITY, ScreenDensity::SCREEN_DENSITY_XXXLDPI, RE_640_STR); TestKeyParam(KeyType::SCREEN_DENSITY, ScreenDensity::SCREEN_DENSITY_NOT_SET, "not_screen_density"); +} } \ No newline at end of file diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.h index 416f348..6a3fee3 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.h @@ -16,7 +16,7 @@ #ifndef RESOURCE_MANAGER_RES_DESC_TEST_H #define RESOURCE_MANAGER_RES_DESC_TEST_H -int ResDescFuncTest001(); -int ResDescFuncTest002(); +int ResDescFuncTest001(void); +int ResDescFuncTest002(void); #endif diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.cpp index 4eaf790..d56394c 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.cpp @@ -35,7 +35,7 @@ using namespace OHOS::Global::Resource; using namespace testing::ext; using namespace std; - +namespace { class ResourceManagerPerformanceTest : public testing::Test { public: static void SetUpTestCase(void); @@ -1119,3 +1119,4 @@ HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest032, HILOG_DEBUG("avg cost 032: %f us", average); EXPECT_LT(average, 100); }; +} diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.h index 7269ed7..dd33795 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.h @@ -16,37 +16,37 @@ #ifndef RESOURCE_MANAGER_RESOURCE_MANANGER_PERF_TEST_H #define RESOURCE_MANAGER_RESOURCE_MANANGER_PERF_TEST_H -int ResourceManagerPerformanceFuncTest001(); -int ResourceManagerPerformanceFuncTest002(); -int ResourceManagerPerformanceFuncTest003(); -int ResourceManagerPerformanceFuncTest004(); -int ResourceManagerPerformanceFuncTest005(); -int ResourceManagerPerformanceFuncTest006(); -int ResourceManagerPerformanceFuncTest007(); -int ResourceManagerPerformanceFuncTest008(); -int ResourceManagerPerformanceFuncTest009(); -int ResourceManagerPerformanceFuncTest010(); -int ResourceManagerPerformanceFuncTest011(); -int ResourceManagerPerformanceFuncTest012(); -int ResourceManagerPerformanceFuncTest013(); -int ResourceManagerPerformanceFuncTest014(); -int ResourceManagerPerformanceFuncTest015(); -int ResourceManagerPerformanceFuncTest016(); -int ResourceManagerPerformanceFuncTest017(); -int ResourceManagerPerformanceFuncTest018(); -int ResourceManagerPerformanceFuncTest019(); -int ResourceManagerPerformanceFuncTest020(); -int ResourceManagerPerformanceFuncTest021(); -int ResourceManagerPerformanceFuncTest022(); -int ResourceManagerPerformanceFuncTest023(); -int ResourceManagerPerformanceFuncTest024(); -int ResourceManagerPerformanceFuncTest025(); -int ResourceManagerPerformanceFuncTest026(); -int ResourceManagerPerformanceFuncTest027(); -int ResourceManagerPerformanceFuncTest028(); -int ResourceManagerPerformanceFuncTest029(); -int ResourceManagerPerformanceFuncTest030(); -int ResourceManagerPerformanceFuncTest031(); -int ResourceManagerPerformanceFuncTest032(); +int ResourceManagerPerformanceFuncTest001(void); +int ResourceManagerPerformanceFuncTest002(void); +int ResourceManagerPerformanceFuncTest003(void); +int ResourceManagerPerformanceFuncTest004(void); +int ResourceManagerPerformanceFuncTest005(void); +int ResourceManagerPerformanceFuncTest006(void); +int ResourceManagerPerformanceFuncTest007(void); +int ResourceManagerPerformanceFuncTest008(void); +int ResourceManagerPerformanceFuncTest009(void); +int ResourceManagerPerformanceFuncTest010(void); +int ResourceManagerPerformanceFuncTest011(void); +int ResourceManagerPerformanceFuncTest012(void); +int ResourceManagerPerformanceFuncTest013(void); +int ResourceManagerPerformanceFuncTest014(void); +int ResourceManagerPerformanceFuncTest015(void); +int ResourceManagerPerformanceFuncTest016(void); +int ResourceManagerPerformanceFuncTest017(void); +int ResourceManagerPerformanceFuncTest018(void); +int ResourceManagerPerformanceFuncTest019(void); +int ResourceManagerPerformanceFuncTest020(void); +int ResourceManagerPerformanceFuncTest021(void); +int ResourceManagerPerformanceFuncTest022(void); +int ResourceManagerPerformanceFuncTest023(void); +int ResourceManagerPerformanceFuncTest024(void); +int ResourceManagerPerformanceFuncTest025(void); +int ResourceManagerPerformanceFuncTest026(void); +int ResourceManagerPerformanceFuncTest027(void); +int ResourceManagerPerformanceFuncTest028(void); +int ResourceManagerPerformanceFuncTest029(void); +int ResourceManagerPerformanceFuncTest030(void); +int ResourceManagerPerformanceFuncTest031(void); +int ResourceManagerPerformanceFuncTest032(void); #endif diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp index c43bd22..e68f9fb 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp @@ -29,7 +29,7 @@ using namespace OHOS::Global::Resource; using namespace testing::ext; - +namespace { static const int NON_EXIST_ID = 1111; static const char *g_nonExistName = "non_existent_name"; @@ -1701,3 +1701,4 @@ HWTEST_F(ResourceManagerTest, ResourceManagerSameNameTest001, TestSize.Level1) EXPECT_TRUE(state == SUCCESS); EXPECT_EQ(999, outValueI); } +} diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.h index c637d04..531d709 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.h @@ -16,83 +16,83 @@ #ifndef RESOURCE_MANAGER_RESOURCE_MANANGER_TEST_H #define RESOURCE_MANAGER_RESOURCE_MANANGER_TEST_H -int ResourceManagerAddResourceTest001(); -int ResourceManagerAddResourceTest002(); -int ResourceManagerAddResourceTest003(); -int ResourceManagerUpdateResConfigTest001(); -int ResourceManagerUpdateResConfigTest002(); -int ResourceManagerUpdateResConfigTest003(); -int ResourceManagerUpdateResConfigTest004(); -int ResourceManagerUpdateResConfigTest005(); -int ResourceManagerGetResConfigTest001(); -int ResourceManagerGetResConfigTest002(); -int ResourceManagerGetStringByIdTest001(); -int ResourceManagerGetStringByIdTest002(); -int ResourceManagerGetStringByIdTest003(); -int ResourceManagerGetStringByNameTest001(); -int ResourceManagerGetStringByNameTest002(); -int ResourceManagerGetStringByNameTest003(); -int ResourceManagerGetStringFormatByIdTest001(); -int ResourceManagerGetStringFormatByIdTest002(); -int ResourceManagerGetStringFormatByNameTest001(); -int ResourceManagerGetStringFormatByNameTest002(); -int ResourceManagerGetStringArrayByIdTest001(); -int ResourceManagerGetStringArrayByIdTest002(); -int ResourceManagerGetStringArrayByNameTest001(); -int ResourceManagerGetStringArrayByNameTest002(); -int ResourceManagerGetPatternByIdTest001(); -int ResourceManagerGetPatternByIdTest002(); -int ResourceManagerGetPatternByIdTest003(); -int ResourceManagerGetPatternByIdTest004(); -int ResourceManagerGetPatternByNameTest001(); -int ResourceManagerGetPatternByNameTest002(); -int ResourceManagerGetPatternByNameTest003(); -int ResourceManagerGetPatternByNameTest004(); -int ResourceManagerGetPluralStringByIdTest001(); -int ResourceManagerGetPluralStringByIdTest002(); -int ResourceManagerGetPluralStringByIdTest003(); -int ResourceManagerGetPluralStringByIdTest004(); -int ResourceManagerGetPluralStringByIdTest005(); -int ResourceManagerGetPluralStringByNameTest001(); -int ResourceManagerGetPluralStringByNameTest002(); -int ResourceManagerGetPluralStringByIdFormatTest001(); -int ResourceManagerGetPluralStringByIdFormatTest002(); -int ResourceManagerGetPluralStringByNameFormatTest001(); -int ResourceManagerGetPluralStringByNameFormatTest002(); -int ResourceManagerGetThemeByIdTest001(); -int ResourceManagerGetThemeByIdTest002(); -int ResourceManagerGetThemeByNameTest001(); -int ResourceManagerGetThemeByNameTest002(); -int ResourceManagerGetBooleanByIdTest001(); -int ResourceManagerGetBooleanByIdTest002(); -int ResourceManagerGetBooleanByNameTest001(); -int ResourceManagerGetBooleanByNameTest002(); -int ResourceManagerGetIntegerByIdTest001(); -int ResourceManagerGetIntegerByIdTest002(); -int ResourceManagerGetIntegerByNameTest001(); -int ResourceManagerGetIntegerByNameTest002(); -int ResourceManagerGetFloatByIdTest001(); -int ResourceManagerGetFloatByIdTest002(); -int ResourceManagerGetFloatByNameTest001(); -int ResourceManagerGetFloatByNameTest002(); -int ResourceManagerGetIntArrayByIdTest001(); -int ResourceManagerGetIntArrayByIdTest002(); -int ResourceManagerGetIntArrayByNameTest001(); -int ResourceManagerGetIntArrayByNameTest002(); -int ResourceManagerGetColorByIdTest001(); -int ResourceManagerGetColorByIdTest002(); -int ResourceManagerGetColorByNameTest001(); -int ResourceManagerGetColorByNameTest002(); -int ResourceManagerGetProfileByIdTest001(); -int ResourceManagerGetProfileByIdTest002(); -int ResourceManagerGetProfileByNameTest001(); -int ResourceManagerGetProfileByNameTest002(); -int ResourceManagerGetMediaByIdTest001(); -int ResourceManagerGetMediaByIdTest002(); -int ResourceManagerGetMediaByNameTest001(); -int ResourceManagerGetMediaByNameTest002(); -int ResourceManagerResolveReferenceTest001(); -int ResourceManagerResolveParentReferenceTest001(); -int ResourceManagerSameNameTest001(); +int ResourceManagerAddResourceTest001(void); +int ResourceManagerAddResourceTest002(void); +int ResourceManagerAddResourceTest003(void); +int ResourceManagerUpdateResConfigTest001(void); +int ResourceManagerUpdateResConfigTest002(void); +int ResourceManagerUpdateResConfigTest003(void); +int ResourceManagerUpdateResConfigTest004(void); +int ResourceManagerUpdateResConfigTest005(void); +int ResourceManagerGetResConfigTest001(void); +int ResourceManagerGetResConfigTest002(void); +int ResourceManagerGetStringByIdTest001(void); +int ResourceManagerGetStringByIdTest002(void); +int ResourceManagerGetStringByIdTest003(void); +int ResourceManagerGetStringByNameTest001(void); +int ResourceManagerGetStringByNameTest002(void); +int ResourceManagerGetStringByNameTest003(void); +int ResourceManagerGetStringFormatByIdTest001(void); +int ResourceManagerGetStringFormatByIdTest002(void); +int ResourceManagerGetStringFormatByNameTest001(void); +int ResourceManagerGetStringFormatByNameTest002(void); +int ResourceManagerGetStringArrayByIdTest001(void); +int ResourceManagerGetStringArrayByIdTest002(void); +int ResourceManagerGetStringArrayByNameTest001(void); +int ResourceManagerGetStringArrayByNameTest002(void); +int ResourceManagerGetPatternByIdTest001(void); +int ResourceManagerGetPatternByIdTest002(void); +int ResourceManagerGetPatternByIdTest003(void); +int ResourceManagerGetPatternByIdTest004(void); +int ResourceManagerGetPatternByNameTest001(void); +int ResourceManagerGetPatternByNameTest002(void); +int ResourceManagerGetPatternByNameTest003(void); +int ResourceManagerGetPatternByNameTest004(void); +int ResourceManagerGetPluralStringByIdTest001(void); +int ResourceManagerGetPluralStringByIdTest002(void); +int ResourceManagerGetPluralStringByIdTest003(void); +int ResourceManagerGetPluralStringByIdTest004(void); +int ResourceManagerGetPluralStringByIdTest005(void); +int ResourceManagerGetPluralStringByNameTest001(void); +int ResourceManagerGetPluralStringByNameTest002(void); +int ResourceManagerGetPluralStringByIdFormatTest001(void); +int ResourceManagerGetPluralStringByIdFormatTest002(void); +int ResourceManagerGetPluralStringByNameFormatTest001(void); +int ResourceManagerGetPluralStringByNameFormatTest002(void); +int ResourceManagerGetThemeByIdTest001(void); +int ResourceManagerGetThemeByIdTest002(void); +int ResourceManagerGetThemeByNameTest001(void); +int ResourceManagerGetThemeByNameTest002(void); +int ResourceManagerGetBooleanByIdTest001(void); +int ResourceManagerGetBooleanByIdTest002(void); +int ResourceManagerGetBooleanByNameTest001(void); +int ResourceManagerGetBooleanByNameTest002(void); +int ResourceManagerGetIntegerByIdTest001(void); +int ResourceManagerGetIntegerByIdTest002(void); +int ResourceManagerGetIntegerByNameTest001(void); +int ResourceManagerGetIntegerByNameTest002(void); +int ResourceManagerGetFloatByIdTest001(void); +int ResourceManagerGetFloatByIdTest002(void); +int ResourceManagerGetFloatByNameTest001(void); +int ResourceManagerGetFloatByNameTest002(void); +int ResourceManagerGetIntArrayByIdTest001(void); +int ResourceManagerGetIntArrayByIdTest002(void); +int ResourceManagerGetIntArrayByNameTest001(void); +int ResourceManagerGetIntArrayByNameTest002(void); +int ResourceManagerGetColorByIdTest001(void); +int ResourceManagerGetColorByIdTest002(void); +int ResourceManagerGetColorByNameTest001(void); +int ResourceManagerGetColorByNameTest002(void); +int ResourceManagerGetProfileByIdTest001(void); +int ResourceManagerGetProfileByIdTest002(void); +int ResourceManagerGetProfileByNameTest001(void); +int ResourceManagerGetProfileByNameTest002(void); +int ResourceManagerGetMediaByIdTest001(void); +int ResourceManagerGetMediaByIdTest002(void); +int ResourceManagerGetMediaByNameTest001(void); +int ResourceManagerGetMediaByNameTest002(void); +int ResourceManagerResolveReferenceTest001(void); +int ResourceManagerResolveParentReferenceTest001(void); +int ResourceManagerSameNameTest001(void); #endif diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp index 08cfbca..bdd0914 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp @@ -24,7 +24,7 @@ using namespace OHOS::Global::Resource; using namespace testing::ext; using namespace OHOS::I18N; - +namespace { class StringUtilsTest : public testing::Test { public: static void SetUpTestCase(void); @@ -103,4 +103,5 @@ HWTEST_F(StringUtilsTest, LockFuncTest001, TestSize.Level1) Lock lock = Lock(); TestThread(&num, threadNum, &lock); EXPECT_EQ(result, num); +} } \ No newline at end of file diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.h index f2ee919..c4fb50c 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.h @@ -16,7 +16,7 @@ #ifndef RESOURCE_MANAGER_STRING_UTILS_TEST_H #define RESOURCE_MANAGER_STRING_UTILS_TEST_H -int StringUtilsFuncTest001(); -int LockFuncTest001(); +int StringUtilsFuncTest001(void); +int LockFuncTest001(void); #endif -- Gitee From b61384d936addde2520a2f0a3224896b0ea6a090 Mon Sep 17 00:00:00 2001 From: w00617344 <1323883142@qq.com> Date: Sat, 19 Feb 2022 15:14:47 +0800 Subject: [PATCH 19/31] 1323883142@qq.com Signed-off-by: w00617344 <1323883142@qq.com> --- frameworks/resmgr_lite/include/res_common.h | 2 - .../resmgr_lite/include/utils/date_utils.h | 1 - frameworks/resmgr_lite/src/hap_manager.cpp | 44 ++++++------- frameworks/resmgr_lite/src/locale_matcher.cpp | 5 +- frameworks/resmgr_lite/src/res_desc.cpp | 8 ++- .../resmgr_lite/src/resource_manager_impl.cpp | 19 +++--- frameworks/resmgr_lite/src/utils/utils.cpp | 61 ++++++++----------- 7 files changed, 69 insertions(+), 71 deletions(-) diff --git a/frameworks/resmgr_lite/include/res_common.h b/frameworks/resmgr_lite/include/res_common.h index 5cebb9a..a3e93ff 100644 --- a/frameworks/resmgr_lite/include/res_common.h +++ b/frameworks/resmgr_lite/include/res_common.h @@ -16,8 +16,6 @@ #ifndef OHOS_RES_COMMON_H #define OHOS_RES_COMMON_H -#include - namespace OHOS { namespace Global { namespace Resource { diff --git a/frameworks/resmgr_lite/include/utils/date_utils.h b/frameworks/resmgr_lite/include/utils/date_utils.h index 555f50e..3937ca1 100644 --- a/frameworks/resmgr_lite/include/utils/date_utils.h +++ b/frameworks/resmgr_lite/include/utils/date_utils.h @@ -17,7 +17,6 @@ #define RESOURCE_MANAGER_DATEUTILS_H #include -#include #include "common.h" namespace OHOS { diff --git a/frameworks/resmgr_lite/src/hap_manager.cpp b/frameworks/resmgr_lite/src/hap_manager.cpp index b5f5e40..b387c0c 100644 --- a/frameworks/resmgr_lite/src/hap_manager.cpp +++ b/frameworks/resmgr_lite/src/hap_manager.cpp @@ -133,16 +133,17 @@ const HapResource::ValueUnderQualifierDir *HapManager::FindQualifierValueByName( for (i = 0; i < len; i++) { HapResource::ValueUnderQualifierDir *path = paths[i]; const ResConfigImpl *resConfig = path->GetResConfig(); - if (this->resConfig_->Match(resConfig)) { - if (bestResConfig == nullptr) { - bestIndex = i; - bestResConfig = resConfig; - } else if (bestResConfig->IsMoreSuitable(resConfig, currentResConfig)) { - continue; - } else { - bestResConfig = resConfig; - bestIndex = i; - } + if (!this->resConfig_->Match(resConfig)) { + continue; + } + if (bestResConfig == nullptr) { + bestIndex = i; + bestResConfig = resConfig; + continue; + } + if (!bestResConfig->IsMoreSuitable(resConfig, currentResConfig)) { + bestResConfig = resConfig; + bestIndex = i; } } return paths[bestIndex]; @@ -164,18 +165,17 @@ const HapResource::ValueUnderQualifierDir *HapManager::FindQualifierValueById(ui for (i = 0; i < len; i++) { HapResource::ValueUnderQualifierDir *path = paths[i]; const ResConfigImpl *resConfig = path->GetResConfig(); - if (this->resConfig_->Match(resConfig)) { - if (bestResConfig == nullptr) { - bestIndex = i; - bestResConfig = resConfig; - } else { - if (bestResConfig->IsMoreSuitable(resConfig, currentResConfig)) { - continue; - } else { - bestResConfig = resConfig; - bestIndex = i; - } - } + if (!this->resConfig_->Match(resConfig)) { + continue; + } + if (bestResConfig == nullptr) { + bestIndex = i; + bestResConfig = resConfig; + continue; + } + if (!bestResConfig->IsMoreSuitable(resConfig, currentResConfig)) { + bestResConfig = resConfig; + bestIndex = i; } } return paths[bestIndex]; diff --git a/frameworks/resmgr_lite/src/locale_matcher.cpp b/frameworks/resmgr_lite/src/locale_matcher.cpp index 7ccac93..b54f059 100644 --- a/frameworks/resmgr_lite/src/locale_matcher.cpp +++ b/frameworks/resmgr_lite/src/locale_matcher.cpp @@ -232,7 +232,7 @@ size_t ComputeTrackPathDistance(const uint64_t *requestPaths, } } } - return len * 2; + return len * 2; } int8_t CompareRegionWhenQaag(const ResLocale *current, @@ -269,6 +269,7 @@ bool CompareLanguage(const ResLocale *current, const ResLocale *other) Utils::EncodeLanguageByResLocale(current); uint16_t otherEncodedLanguage = Utils::EncodeLanguageByResLocale( other); + // 0-4 NEW/OLD language code means iw/he,tl/fil,ji/yi,jw/jv,in/id return ((currentEncodedLanguage == otherEncodedLanguage) || ((currentEncodedLanguage == NEW_LANGUAGES_CODES[0]) && (otherEncodedLanguage == OLD_LANGUAGES_CODES[0])) || @@ -687,9 +688,11 @@ bool LocaleMatcher::IsRegionTag(const char *str, int32_t len) if (len < 0) { len = strlen(str); } + // region is 2 letters if is alpha string if (len == 2 && Utils::IsAlphaString(str, len)) { return true; } + // region is 3 letters if is numeric string if (len == 3 && Utils::IsNumericString(str, len)) { return true; } diff --git a/frameworks/resmgr_lite/src/res_desc.cpp b/frameworks/resmgr_lite/src/res_desc.cpp index d143db0..81c7b1b 100644 --- a/frameworks/resmgr_lite/src/res_desc.cpp +++ b/frameworks/resmgr_lite/src/res_desc.cpp @@ -13,9 +13,6 @@ * limitations under the License. */ #include "res_desc.h" - -#include - #include "hilog_wrapper.h" #include "securec.h" #include "utils/common.h" @@ -91,7 +88,9 @@ const std::string KeyParam::ConvertToStr() const HILOG_ERROR("memcpy_s error : %d", eret); } int j = 0; + // 4 means langauages/region/script key value max length for (int i = 0; i < 4; ++i) { + // 3 means reverse temp value to temp2 if (tmp[3 - i]) { tmp2[j++] = tmp[3 - i]; } @@ -145,6 +144,8 @@ bool IdItem::HaveParent() const if (!(resType_ == THEME || resType_ == PATTERN)) { return false; } + // the values_ storage map(key, value) and parent ref + // if have parent, size would be odd number return (values_.size() % 2 == 1); } @@ -156,6 +157,7 @@ bool IdItem::IsRef(const std::string &value, ResType &resType, int &id) return false; } auto index = value.find(":"); + // there are atleast one letter between '$' and ':' if (index == std::string::npos || index < 2) { return false; } diff --git a/frameworks/resmgr_lite/src/resource_manager_impl.cpp b/frameworks/resmgr_lite/src/resource_manager_impl.cpp index b2c4665..65c5592 100644 --- a/frameworks/resmgr_lite/src/resource_manager_impl.cpp +++ b/frameworks/resmgr_lite/src/resource_manager_impl.cpp @@ -240,6 +240,7 @@ RState ResourceManagerImpl::GetPluralString(const HapResource::ValueUnderQualifi size_t startIdx = 0; size_t loop = idItem->values_.size() / 2; for (size_t i = 0; i < loop; ++i) { + // 2 means key and value appear in pairs std::string key(idItem->values_[startIdx + i * 2]); std::string value(idItem->values_[startIdx + i * 2 + 1]); auto iter = map.find(key); @@ -331,18 +332,20 @@ RState ResourceManagerImpl::ResolveParentReference(const IdItem *idItem, std::ma // this make sure child covers parent size_t loop = currItem->values_.size() / 2; for (size_t i = 0; i < loop; ++i) { + // 2 means key and value appear in pairs std::string key(currItem->values_[startIdx + i * 2]); std::string value(currItem->values_[startIdx + i * 2 + 1]); auto iter = outValue.find(key); - if (iter == outValue.end()) { - std::string resolvedValue; - RState rrRet = ResolveReference(value, resolvedValue); - if (rrRet != SUCCESS) { - HILOG_ERROR("ResolveReference failed, value:%s", value.c_str()); - return ERROR; - } - outValue[key] = resolvedValue; + if (iter != outValue.end()) { + continue; } + std::string resolvedValue; + RState rrRet = ResolveReference(value, resolvedValue); + if (rrRet != SUCCESS) { + HILOG_ERROR("ResolveReference failed, value:%s", value.c_str()); + return ERROR; + } + outValue[key] = resolvedValue; } if (haveParent) { // get parent diff --git a/frameworks/resmgr_lite/src/utils/utils.cpp b/frameworks/resmgr_lite/src/utils/utils.cpp index f636f8d..490eec9 100644 --- a/frameworks/resmgr_lite/src/utils/utils.cpp +++ b/frameworks/resmgr_lite/src/utils/utils.cpp @@ -197,40 +197,33 @@ uint16_t Utils::EncodeLanguageOrRegion(const char *str, char base) bool Utils::StrCompare(const char *left, const char *right, size_t len, bool isCaseSensitive) { - if (left == nullptr) { - if (right == nullptr) { + if (left == nullptr && right == nullptr) { + return true; + } + if (left == nullptr || right == nullptr) { + return false; + } + int rc; + unsigned char c1, c2; + while (len--) { + c1 = (unsigned char)*left; + c2 = (unsigned char)*right; + if (c1 == 0 && c2 == 0) { return true; - } else { + } + if (c1 == 0 || c2 == 0) { return false; } - } else if (right == nullptr) { - return false; - } else { - int rc; - unsigned char c1, c2; - while (len--) { - c1 = (unsigned char)*left; - c2 = (unsigned char)*right; - if (c1 == 0) { - if (c2 == 0) { - return true; - } - return false; - } else if (c2 == 0) { - return false; - } else { - if (isCaseSensitive) { - rc = (int)(c1) - (int)(c2); - } else { - rc = tolower(c1) - tolower(c2); - } - if (rc != 0) { - return false; - } - } - ++left; - ++right; + if (isCaseSensitive) { + rc = (int)(c1) - (int)(c2); + } else { + rc = tolower(c1) - tolower(c2); + } + if (rc != 0) { + return false; } + ++left; + ++right; } return true; } @@ -274,7 +267,7 @@ RState Utils::ConvertColorToUInt32(const char *s, uint32_t &outValue) RState parseState = SUCCESS; size_t len = strlen(s); if (*s == '#') { - if (len == 4) { + if (len == 4) { // 4 means #rgb color |= 0xFF000000; color |= ParseHex(s[1], parseState) << 20; color |= ParseHex(s[1], parseState) << 16; @@ -282,7 +275,7 @@ RState Utils::ConvertColorToUInt32(const char *s, uint32_t &outValue) color |= ParseHex(s[2], parseState) << 8; color |= ParseHex(s[3], parseState) << 4; color |= ParseHex(s[3], parseState); - } else if (len == 5) { + } else if (len == 5) { // 5 means #argb color |= ParseHex(s[1], parseState) << 28; color |= ParseHex(s[1], parseState) << 24; color |= ParseHex(s[2], parseState) << 20; @@ -291,7 +284,7 @@ RState Utils::ConvertColorToUInt32(const char *s, uint32_t &outValue) color |= ParseHex(s[3], parseState) << 8; color |= ParseHex(s[4], parseState) << 4; color |= ParseHex(s[4], parseState); - } else if (len == 7) { + } else if (len == 7) { // 7 means #rrggbb color |= 0xFF000000; color |= ParseHex(s[1], parseState) << 20; color |= ParseHex(s[2], parseState) << 16; @@ -299,7 +292,7 @@ RState Utils::ConvertColorToUInt32(const char *s, uint32_t &outValue) color |= ParseHex(s[4], parseState) << 8; color |= ParseHex(s[5], parseState) << 4; color |= ParseHex(s[6], parseState); - } else if (len == 9) { + } else if (len == 9) { // 9 means #aarrggbb color |= ParseHex(s[1], parseState) << 28; color |= ParseHex(s[2], parseState) << 24; color |= ParseHex(s[3], parseState) << 20; -- Gitee From 79d759d6b452819e1494adea1203d1b0b148c0c4 Mon Sep 17 00:00:00 2001 From: VictoriaGuo Date: Tue, 22 Feb 2022 18:55:35 +0800 Subject: [PATCH 20/31] Optimize code Signed-off-by: VictoriaGuo --- frameworks/resmgr_lite/src/hap_resource.cpp | 4 ++-- .../test/unittest/lite/common/resource_manager_test.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frameworks/resmgr_lite/src/hap_resource.cpp b/frameworks/resmgr_lite/src/hap_resource.cpp index f25b157..59e0cb9 100644 --- a/frameworks/resmgr_lite/src/hap_resource.cpp +++ b/frameworks/resmgr_lite/src/hap_resource.cpp @@ -70,7 +70,7 @@ HapResource::~HapResource() { delete (resDesc_); std::map::iterator iter; - for (iter = idValuesMap_.begin(); iter != idValuesMap_.end(); iter++) { + for (iter = idValuesMap_.begin(); iter != idValuesMap_.end(); ++iter) { IdValues *ptr = iter->second; delete (ptr); } @@ -90,7 +90,7 @@ const HapResource *HapResource::LoadFromIndex(const char *path, const ResConfigI return nullptr; } inFile.seekg(0, std::ios::end); - size_t bufLen = inFile.tellg(); + int bufLen = inFile.tellg(); if (bufLen <= 0) { HILOG_ERROR("file size is zero"); inFile.close(); diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp index e68f9fb..976b2c6 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp @@ -628,6 +628,7 @@ HWTEST_F(ResourceManagerTest, ResourceManagerGetPatternByIdTest001, TestSize.Lev RState state; id = GetResId("base", ResType::PATTERN); + ASSERT_TRUE(id > 0); state = rm->GetPatternById(id, outValue); ASSERT_EQ(SUCCESS, state); ASSERT_EQ(static_cast(3), outValue.size()); @@ -648,6 +649,7 @@ HWTEST_F(ResourceManagerTest, ResourceManagerGetPatternByIdTest002, TestSize.Lev RState state; id = GetResId("child", ResType::PATTERN); + ASSERT_TRUE(id > 0); state = rm->GetPatternById(id, outValue); ASSERT_EQ(SUCCESS, state); ASSERT_EQ(static_cast(4), outValue.size()); @@ -668,6 +670,7 @@ HWTEST_F(ResourceManagerTest, ResourceManagerGetPatternByIdTest003, TestSize.Lev RState state; id = GetResId("ccchild", ResType::PATTERN); + ASSERT_TRUE(id > 0); state = rm->GetPatternById(id, outValue); ASSERT_EQ(SUCCESS, state); ASSERT_EQ(static_cast(5), outValue.size()); @@ -1636,6 +1639,7 @@ HWTEST_F(ResourceManagerTest, ResourceManagerResolveParentReferenceTest001, Test RState ret; id = GetResId("base", ResType::PATTERN); + ASSERT_TRUE(id > 0); idItem = ((ResourceManagerImpl *)rm)->hapManager_->FindResourceById(id); ASSERT_TRUE(idItem != nullptr); ret = ((ResourceManagerImpl *)rm)->ResolveParentReference(idItem, outValue); @@ -1644,6 +1648,7 @@ HWTEST_F(ResourceManagerTest, ResourceManagerResolveParentReferenceTest001, Test HILOG_DEBUG("====="); id = GetResId("child", ResType::PATTERN); + ASSERT_TRUE(id > 0); idItem = ((ResourceManagerImpl *)rm)->hapManager_->FindResourceById(id); ASSERT_TRUE(idItem != nullptr); ret = ((ResourceManagerImpl *)rm)->ResolveParentReference(idItem, outValue); @@ -1652,6 +1657,7 @@ HWTEST_F(ResourceManagerTest, ResourceManagerResolveParentReferenceTest001, Test HILOG_DEBUG("====="); id = GetResId("ccchild", ResType::PATTERN); + ASSERT_TRUE(id > 0); idItem = ((ResourceManagerImpl *)rm)->hapManager_->FindResourceById(id); ASSERT_TRUE(idItem != nullptr); ret = ((ResourceManagerImpl *)rm)->ResolveParentReference(idItem, outValue); -- Gitee From b5b7f09a57b039ba8d22ef5ea31cc29628ad598a Mon Sep 17 00:00:00 2001 From: VictoriaGuo Date: Wed, 23 Feb 2022 16:29:34 +0800 Subject: [PATCH 21/31] Optimize code Signed-off-by: VictoriaGuo --- frameworks/resmgr_lite/src/hap_resource.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/resmgr_lite/src/hap_resource.cpp b/frameworks/resmgr_lite/src/hap_resource.cpp index 59e0cb9..0a39511 100644 --- a/frameworks/resmgr_lite/src/hap_resource.cpp +++ b/frameworks/resmgr_lite/src/hap_resource.cpp @@ -106,7 +106,7 @@ const HapResource *HapResource::LoadFromIndex(const char *path, const ResConfigI inFile.read((char *)buf, bufLen); inFile.close(); - HILOG_DEBUG("extract success, bufLen:%zu", bufLen); + HILOG_DEBUG("extract success, bufLen:%d", bufLen); ResDesc *resDesc = new (std::nothrow) ResDesc(); if (resDesc == nullptr) { -- Gitee From bff55caf62512df653d2a140255625bcf43554b6 Mon Sep 17 00:00:00 2001 From: VictoriaGuo Date: Fri, 4 Mar 2022 13:54:12 +0800 Subject: [PATCH 22/31] Optimize lock code Signed-off-by: VictoriaGuo --- frameworks/resmgr_lite/include/lock.h | 2 ++ frameworks/resmgr_lite/src/res_locale.cpp | 4 ++-- .../test/unittest/lite/common/string_utils_test.cpp | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/frameworks/resmgr_lite/include/lock.h b/frameworks/resmgr_lite/include/lock.h index d200f07..a1414d0 100644 --- a/frameworks/resmgr_lite/include/lock.h +++ b/frameworks/resmgr_lite/include/lock.h @@ -31,6 +31,8 @@ public: private: std::mutex* mtx_; + + Lock(const Lock &src) = delete; }; } // namespace Resource } // namespace Global diff --git a/frameworks/resmgr_lite/src/res_locale.cpp b/frameworks/resmgr_lite/src/res_locale.cpp index 62ad69c..5831993 100644 --- a/frameworks/resmgr_lite/src/res_locale.cpp +++ b/frameworks/resmgr_lite/src/res_locale.cpp @@ -32,7 +32,7 @@ namespace OHOS { namespace Global { namespace Resource { LocaleInfo *ResLocale::defaultLocale_ = nullptr; -Lock ResLocale::lock_ = Lock(); +Lock ResLocale::lock_; ResLocale::ResLocale() : language_(nullptr), region_(nullptr), script_(nullptr) { @@ -426,7 +426,7 @@ void FindAndSort(std::string localeStr, std::vector &candidateLocal ResLocale *currentLocale = ResLocale::BuildFromString(localeStr.c_str(), DASH_SEP, state); LocaleMatcher::Normalize(currentLocale); std::vector::const_iterator iter; - for (iter = candidateLocale.cbegin(); iter != candidateLocale.cend(); iter++) { + for (iter = candidateLocale.cbegin(); iter != candidateLocale.cend(); ++iter) { ResLocale *resLocale = ResLocale::BuildFromString(iter->c_str(), DASH_SEP, state); if (state == SUCCESS) { LocaleMatcher::Normalize(resLocale); diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp index bdd0914..d59cdcd 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp @@ -100,7 +100,7 @@ HWTEST_F(StringUtilsTest, LockFuncTest001, TestSize.Level1) int num = 0; int threadNum = 3; int result = num + threadNum; - Lock lock = Lock(); + Lock lock; TestThread(&num, threadNum, &lock); EXPECT_EQ(result, num); } -- Gitee From d38e1f8bc9b653740bc75e57355fb6330e20ec55 Mon Sep 17 00:00:00 2001 From: huangke11 Date: Wed, 9 Mar 2022 22:16:33 +0800 Subject: [PATCH 23/31] delete cust_lite Signed-off-by: huangke11 --- README.md | 4 +--- README_zh.md | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 456e3aa..4766482 100644 --- a/README.md +++ b/README.md @@ -52,9 +52,7 @@ if (values != NULL) { [Globalization subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/globalization.md) -global\_resmgr\_lite +**global\_resmgr\_lite** [global\_i18n\_lite](https://gitee.com/openharmony/global_i18n_lite/blob/master/README.md) -[global\_cust\_lite](https://gitee.com/openharmony/global_cust_lite/blob/master/README.md) - diff --git a/README_zh.md b/README_zh.md index dd18841..d7e6a80 100644 --- a/README_zh.md +++ b/README_zh.md @@ -52,9 +52,7 @@ if (values != NULL) { [全球化子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E5%85%A8%E7%90%83%E5%8C%96%E5%AD%90%E7%B3%BB%E7%BB%9F.md) -global\_resmgr\_lite +**global\_resmgr\_lite** [global\_i18n\_lite](https://gitee.com/openharmony/global_i18n_lite/blob/master/README_zh.md) -[global\_cust\_lite](https://gitee.com/openharmony/global_cust_lite/blob/master/README_zh.md) - -- Gitee From 4b64c229dc668a0d78a36e57f5df29611f4cec81 Mon Sep 17 00:00:00 2001 From: VictoriaGuo Date: Sat, 12 Mar 2022 21:48:20 +0800 Subject: [PATCH 24/31] Optimize code Signed-off-by: VictoriaGuo --- OAT.xml | 0 frameworks/resmgr_lite/BUILD.gn | 0 frameworks/resmgr_lite/include/rstate.h | 1 + frameworks/resmgr_lite/src/res_locale.cpp | 6 ++++++ .../test/unittest/lite/common/locale_info_test.cpp | 0 .../test/unittest/lite/common/locale_info_test.h | 0 test/resource/data/err-config.json-1.hap | Bin test/resource/data/err-config.json-2.hap | Bin 8 files changed, 7 insertions(+) mode change 100755 => 100644 OAT.xml mode change 100755 => 100644 frameworks/resmgr_lite/BUILD.gn mode change 100755 => 100644 frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.cpp mode change 100755 => 100644 frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.h mode change 100755 => 100644 test/resource/data/err-config.json-1.hap mode change 100755 => 100644 test/resource/data/err-config.json-2.hap diff --git a/OAT.xml b/OAT.xml old mode 100755 new mode 100644 diff --git a/frameworks/resmgr_lite/BUILD.gn b/frameworks/resmgr_lite/BUILD.gn old mode 100755 new mode 100644 diff --git a/frameworks/resmgr_lite/include/rstate.h b/frameworks/resmgr_lite/include/rstate.h index 310a3c8..f9a3213 100644 --- a/frameworks/resmgr_lite/include/rstate.h +++ b/frameworks/resmgr_lite/include/rstate.h @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #ifndef OHOS_RESOURCE_MANAGER_RSTATE_H #define OHOS_RESOURCE_MANAGER_RSTATE_H diff --git a/frameworks/resmgr_lite/src/res_locale.cpp b/frameworks/resmgr_lite/src/res_locale.cpp index 5831993..8313791 100644 --- a/frameworks/resmgr_lite/src/res_locale.cpp +++ b/frameworks/resmgr_lite/src/res_locale.cpp @@ -128,12 +128,18 @@ RState ResLocale::Init(const char *language, size_t languageLen, const char *scr RState ResLocale::CopyFromLocaleInfo(const LocaleInfo *other) { + if (other == nullptr) { + return ERROR; + } return this->Init(other->GetLanguage(), Utils::StrLen(other->GetLanguage()), other->GetScript(), Utils::StrLen(other->GetScript()), other->GetRegion(), Utils::StrLen(other->GetRegion())); } RState ResLocale::Copy(const ResLocale *other) { + if (other == nullptr) { + return ERROR; + } return this->Init(other->GetLanguage(), Utils::StrLen(other->GetLanguage()), other->GetScript(), Utils::StrLen(other->GetScript()), other->GetRegion(), Utils::StrLen(other->GetRegion())); } diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.cpp old mode 100755 new mode 100644 diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.h old mode 100755 new mode 100644 diff --git a/test/resource/data/err-config.json-1.hap b/test/resource/data/err-config.json-1.hap old mode 100755 new mode 100644 diff --git a/test/resource/data/err-config.json-2.hap b/test/resource/data/err-config.json-2.hap old mode 100755 new mode 100644 -- Gitee From 9f350e7f222adc4389fa2a3155714b5c1793d3b8 Mon Sep 17 00:00:00 2001 From: VictoriaGuo Date: Mon, 14 Mar 2022 16:29:42 +0800 Subject: [PATCH 25/31] Optimize code Signed-off-by: VictoriaGuo --- frameworks/resmgr_lite/src/global_utils.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frameworks/resmgr_lite/src/global_utils.c b/frameworks/resmgr_lite/src/global_utils.c index f28e197..ecd778d 100644 --- a/frameworks/resmgr_lite/src/global_utils.c +++ b/frameworks/resmgr_lite/src/global_utils.c @@ -76,14 +76,15 @@ static int32_t Split(const char *src, const char *separator, char **dest, int32_ if (src == NULL || src[0] == '\0' || separator == NULL || separator[0] == '\0' || dest == NULL || num == NULL) { return MC_FAILURE; } - next = strtok((char *)src, separator); + char *temp = NULL; + next = strtok_r((char *)src, separator, &temp); while (next != NULL) { if (count >= LOCALE_ELEMENT_NUM) { return MC_FAILURE; } *dest++ = next; ++count; - next = strtok(NULL, separator); + next = strtok_r(NULL, separator, &temp); } *num = count; return MC_SUCCESS; -- Gitee From 587d0c269e776a989b70ceace10e762eb91113a1 Mon Sep 17 00:00:00 2001 From: ws Date: Mon, 21 Mar 2022 15:50:57 +0800 Subject: [PATCH 26/31] wangsen69@huawei.com Signed-off-by: ws --- frameworks/resmgr_lite/include/auto_mutex.h | 6 +++--- frameworks/resmgr_lite/include/hap_manager.h | 4 ++-- frameworks/resmgr_lite/include/hap_parser.h | 3 ++- frameworks/resmgr_lite/src/global.cpp | 9 ++++++--- frameworks/resmgr_lite/src/hap_manager.cpp | 10 +++++----- frameworks/resmgr_lite/src/hap_resource.cpp | 6 +++--- frameworks/resmgr_lite/src/res_config_impl.cpp | 7 +++++-- .../resmgr_lite/src/resource_manager_impl.cpp | 7 +++++-- frameworks/resmgr_lite/src/utils/hap_parser.cpp | 8 ++++---- frameworks/resmgr_lite/src/utils/utils.cpp | 14 +++++++++++++- .../test/unittest/lite/common/global_test.cpp | 2 +- .../test/unittest/lite/common/global_test.h | 2 +- .../test/unittest/lite/common/hap_manager_test.cpp | 2 +- .../test/unittest/lite/common/hap_manager_test.h | 2 +- .../test/unittest/lite/common/hap_parser_test.cpp | 2 +- .../test/unittest/lite/common/hap_parser_test.h | 2 +- .../unittest/lite/common/hap_resource_test.cpp | 2 +- .../test/unittest/lite/common/hap_resource_test.h | 2 +- .../test/unittest/lite/common/locale_info_test.cpp | 2 +- .../test/unittest/lite/common/locale_info_test.h | 2 +- .../unittest/lite/common/res_config_impl_test.cpp | 2 +- .../unittest/lite/common/res_config_impl_test.h | 2 +- .../test/unittest/lite/common/res_config_test.cpp | 2 +- .../test/unittest/lite/common/res_config_test.h | 2 +- .../test/unittest/lite/common/res_desc_test.cpp | 2 +- .../test/unittest/lite/common/res_desc_test.h | 2 +- .../common/resource_manager_performance_test.cpp | 2 +- .../common/resource_manager_performance_test.h | 2 +- .../unittest/lite/common/resource_manager_test.cpp | 2 +- .../unittest/lite/common/resource_manager_test.h | 2 +- .../unittest/lite/common/string_utils_test.cpp | 2 +- .../test/unittest/lite/common/string_utils_test.h | 2 +- .../test/unittest/lite/common/test_common.cpp | 2 +- .../test/unittest/lite/common/test_common.h | 2 +- 34 files changed, 72 insertions(+), 50 deletions(-) diff --git a/frameworks/resmgr_lite/include/auto_mutex.h b/frameworks/resmgr_lite/include/auto_mutex.h index 58e1026..756eec0 100644 --- a/frameworks/resmgr_lite/include/auto_mutex.h +++ b/frameworks/resmgr_lite/include/auto_mutex.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -22,10 +22,10 @@ namespace Global { namespace Resource { class AutoMutex { public: - inline AutoMutex(Lock &lock) : lock_(lock) + explicit inline AutoMutex(Lock &lock) : lock_(lock) { lock_.lock(); } - inline AutoMutex(Lock *lock) : lock_(*lock) + explicit inline AutoMutex(Lock *lock) : lock_(*lock) { lock_.lock(); } inline ~AutoMutex() diff --git a/frameworks/resmgr_lite/include/hap_manager.h b/frameworks/resmgr_lite/include/hap_manager.h index 8c2485c..6b9cc2e 100644 --- a/frameworks/resmgr_lite/include/hap_manager.h +++ b/frameworks/resmgr_lite/include/hap_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -29,7 +29,7 @@ namespace Global { namespace Resource { class HapManager { public: - HapManager(ResConfigImpl *resConfig); + explicit HapManager(ResConfigImpl *resConfig); ~HapManager(); diff --git a/frameworks/resmgr_lite/include/hap_parser.h b/frameworks/resmgr_lite/include/hap_parser.h index 85dd13d..fdd5ac9 100644 --- a/frameworks/resmgr_lite/include/hap_parser.h +++ b/frameworks/resmgr_lite/include/hap_parser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -61,6 +61,7 @@ public: static ScreenDensity GetScreenDensity(uint32_t value); static DeviceType GetDeviceType(uint32_t value); + private: static const char *RES_FILE_NAME; }; diff --git a/frameworks/resmgr_lite/src/global.cpp b/frameworks/resmgr_lite/src/global.cpp index db0dc1a..a66a833 100644 --- a/frameworks/resmgr_lite/src/global.cpp +++ b/frameworks/resmgr_lite/src/global.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -119,20 +119,23 @@ int32_t GLOBAL_GetRegion(char *region, uint8_t len) int32_t GetValue(const IdItem *idItem, char **value) { + if (idItem == nullptr) { + return SYS_ERROR; + } if (idItem->isArray_) { std::string ret("["); for (size_t i = 0; i < idItem->values_.size(); ++i) { ret.append(FormatString("'%s',", idItem->values_[i].c_str())); } ret.append("]"); - *value = (char *)malloc(ret.size() + 1); + *value = static_cast(malloc(ret.size() + 1)); if (*value == nullptr || strcpy_s(*value, ret.size() + 1, ret.c_str()) != EOK) { FreeValue(value); return SYS_ERROR; } (*value)[ret.size()] = '\0'; } else { - *value = (char *)malloc(idItem->valueLen_ + 1); + *value = static_cast(malloc(idItem->valueLen_ + 1)); if (*value == nullptr || strcpy_s(*value, idItem->valueLen_ + 1, idItem->value_.c_str()) != EOK) { FreeValue(value); return SYS_ERROR; diff --git a/frameworks/resmgr_lite/src/hap_manager.cpp b/frameworks/resmgr_lite/src/hap_manager.cpp index b387c0c..218d5e7 100644 --- a/frameworks/resmgr_lite/src/hap_manager.cpp +++ b/frameworks/resmgr_lite/src/hap_manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -260,7 +260,7 @@ bool HapManager::AddResourcePath(const char *path) if (pResource == nullptr) { return false; } - this->hapResources_.push_back((HapResource *)pResource); + this->hapResources_.push_back(const_cast(pResource)); this->loadedHapPaths_.push_back(sPath); return true; } @@ -274,12 +274,12 @@ RState HapManager::ReloadAll() for (size_t i = 0; i < hapResources_.size(); ++i) { const HapResource *pResource = HapResource::LoadFromIndex(hapResources_[i]->GetIndexPath().c_str(), resConfig_); if (pResource == nullptr) { - for (size_t i = 0; i < newResources.size(); ++i) { - delete (newResources[i]); + for (size_t j = 0; j < newResources.size(); ++j) { + delete (newResources[j]); } return HAP_INIT_FAILED; } - newResources.push_back((HapResource *)pResource); + newResources.push_back(const_cast(pResource)); } for (size_t i = 0; i < hapResources_.size(); ++i) { delete (hapResources_[i]); diff --git a/frameworks/resmgr_lite/src/hap_resource.cpp b/frameworks/resmgr_lite/src/hap_resource.cpp index 0a39511..c40d093 100644 --- a/frameworks/resmgr_lite/src/hap_resource.cpp +++ b/frameworks/resmgr_lite/src/hap_resource.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -103,7 +103,7 @@ const HapResource *HapResource::LoadFromIndex(const char *path, const ResConfigI return nullptr; } inFile.seekg(0, std::ios::beg); - inFile.read((char *)buf, bufLen); + inFile.read(static_cast(buf), bufLen); inFile.close(); HILOG_DEBUG("extract success, bufLen:%d", bufLen); @@ -114,7 +114,7 @@ const HapResource *HapResource::LoadFromIndex(const char *path, const ResConfigI free(buf); return nullptr; } - int32_t out = HapParser::ParseResHex((char *)buf, bufLen, *resDesc, defaultConfig); + int32_t out = HapParser::ParseResHex(static_cast(buf), bufLen, *resDesc, defaultConfig); if (out != OK) { delete (resDesc); free(buf); diff --git a/frameworks/resmgr_lite/src/res_config_impl.cpp b/frameworks/resmgr_lite/src/res_config_impl.cpp index 5fb6068..950cfd7 100644 --- a/frameworks/resmgr_lite/src/res_config_impl.cpp +++ b/frameworks/resmgr_lite/src/res_config_impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -181,6 +181,9 @@ bool ResConfigImpl::Copy(ResConfig &other) bool ResConfigImpl::Match(const ResConfigImpl *other) const { + if (other == nullptr) { + return false; + } if (LocaleMatcher::Match(this->resLocale_, other->GetResLocale()) == false) { return false; } @@ -209,7 +212,7 @@ bool ResConfigImpl::Match(const ResConfigImpl *other) const bool ResConfigImpl::IsMoreSuitable(const ResConfigImpl *other, const ResConfigImpl *request) const { - if (request != nullptr) { + if (request != nullptr && other != nullptr) { int8_t result = LocaleMatcher::IsMoreSuitable(this->GetResLocale(), other->GetResLocale(), request->GetResLocale()); diff --git a/frameworks/resmgr_lite/src/resource_manager_impl.cpp b/frameworks/resmgr_lite/src/resource_manager_impl.cpp index 65c5592..c3956e0 100644 --- a/frameworks/resmgr_lite/src/resource_manager_impl.cpp +++ b/frameworks/resmgr_lite/src/resource_manager_impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -227,7 +227,7 @@ RState ResourceManagerImpl::GetPluralStringByNameFormat(std::string &outValue, c RState ResourceManagerImpl::GetPluralString(const HapResource::ValueUnderQualifierDir *vuqd, int quantity, std::string &outValue) { -// not found or type invalid + // not found or type invalid if (vuqd == nullptr) { return NOT_FOUND; } @@ -575,6 +575,9 @@ RState ResourceManagerImpl::GetRawFile(const HapResource::ValueUnderQualifierDir std::string &outValue) { // not found or type invalid + if (vuqd == nullptr) { + return NOT_FOUND; + } const IdItem *idItem = vuqd->GetIdItem(); if (idItem == nullptr || idItem->resType_ != resType) { return NOT_FOUND; diff --git a/frameworks/resmgr_lite/src/utils/hap_parser.cpp b/frameworks/resmgr_lite/src/utils/hap_parser.cpp index 07ee652..61fa19d 100644 --- a/frameworks/resmgr_lite/src/utils/hap_parser.cpp +++ b/frameworks/resmgr_lite/src/utils/hap_parser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -69,7 +69,7 @@ int32_t HapParser::ReadFileFromZip(const char *zipFile, const char *fileName, vo return UNKNOWN_ERROR; } // obtained the necessary details about file inside zip - *buffer = (void *)malloc(fileInfo.uncompressed_size); // setup buffer + *buffer = static_cast(malloc(fileInfo.uncompressed_size)); // setup buffer bufLen = fileInfo.uncompressed_size; if ((*buffer) == nullptr) { unzClose(uf); @@ -137,7 +137,7 @@ int32_t HapParser::ReadIndexFromFile(const char *zipFile, void **buffer, } // parse config.json - std::string mName = GetModuleName((char *)tmpBuf); + std::string mName = GetModuleName(static_cast(tmpBuf)); if (mName.size() == 0) { errInfo = "parse moduleName from config.json error"; free(tmpBuf); @@ -167,7 +167,7 @@ int32_t ParseString(const char *buffer, uint32_t &offset, std::string &id, bool return SYS_ERROR; } offset += 2; - std::string tmp = std::string((char *)buffer + offset, includeTemi ? (strLen - 1) : strLen); + std::string tmp = std::string(const_cast(buffer) + offset, includeTemi ? (strLen - 1) : strLen); offset += includeTemi ? strLen : (strLen + 1); id = tmp; return OK; diff --git a/frameworks/resmgr_lite/src/utils/utils.cpp b/frameworks/resmgr_lite/src/utils/utils.cpp index 490eec9..d98dcc5 100644 --- a/frameworks/resmgr_lite/src/utils/utils.cpp +++ b/frameworks/resmgr_lite/src/utils/utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -25,6 +25,9 @@ namespace Global { namespace Resource { bool Utils::IsAlphaString(const char *s, int32_t len) { + if (s == nullptr) { + return false; + } int32_t i; for (i = 0; i < len; i++) { char c = *(s + i); @@ -37,6 +40,9 @@ bool Utils::IsAlphaString(const char *s, int32_t len) bool Utils::IsNumericString(const char *s, int32_t len) { + if (s == nullptr) { + return false; + } int32_t i; for (i = 0; i < len; i++) { char c = *(s + i); @@ -60,6 +66,9 @@ bool Utils::IsNumericString(const char *s, int32_t len) */ void Utils::DecodeScript(uint32_t encodeScript, char *outValue) { + if (outValue == nullptr) { + return; + } outValue[0] = (encodeScript & 0xFF000000) >> 24; outValue[1] = (encodeScript & 0x00FF0000) >> 16; outValue[2] = (encodeScript & 0x0000FF00) >> 8; @@ -263,6 +272,9 @@ static uint32_t ParseHex(char c, RState &state) */ RState Utils::ConvertColorToUInt32(const char *s, uint32_t &outValue) { + if (s == nullptr) { + return INVALID_FORMAT; + } uint32_t color = 0; RState parseState = SUCCESS; size_t len = strlen(s); diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/global_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/global_test.cpp index c578f46..f70df48 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/global_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/global_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/global_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/global_test.h index 4bf724a..e7bd482 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/global_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/global_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.cpp index 993bf0e..1df22dd 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.h index c4082c2..3da4fc4 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/hap_manager_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.cpp index ad3dbe8..6374fd7 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.h index a86ab36..f2945d7 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/hap_parser_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.cpp index 2b6278d..b27767c 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.h index 67a6922..1e037ed 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/hap_resource_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.cpp index 6216b04..4cc3763 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.h index 9b46153..65d7fd7 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/locale_info_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.cpp index 5a6dc4f..6f022d4 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.h index 2c406ef..2eb6e00 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_impl_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.cpp index 97f21f8..a839f4d 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.h index d21ba14..7e23721 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.cpp index 6b58a44..d6aa129 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.h index 6a3fee3..a36486b 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/res_desc_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.cpp index d56394c..07b614e 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.h index dd33795..af3f4dc 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_performance_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp index 976b2c6..838ce67 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.h index 531d709..ee8e4ed 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/resource_manager_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp index d59cdcd..8ff7e18 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.h b/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.h index c4fb50c..8a268e6 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/test_common.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/test_common.cpp index bfe10e7..1a11c6c 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/test_common.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/test_common.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/test_common.h b/frameworks/resmgr_lite/test/unittest/lite/common/test_common.h index 53dd723..ee596b6 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/test_common.h +++ b/frameworks/resmgr_lite/test/unittest/lite/common/test_common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at -- Gitee From e12a432e4b6fcf558c042764f7dcdefcb04bef1f Mon Sep 17 00:00:00 2001 From: huangjie Date: Thu, 24 Mar 2022 14:34:18 +0800 Subject: [PATCH 27/31] =?UTF-8?q?L1=E7=BC=96=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjie --- frameworks/resmgr_lite/include/hap_manager.h | 47 +++++ frameworks/resmgr_lite/include/hap_parser.h | 28 +++ frameworks/resmgr_lite/include/hap_resource.h | 28 ++- .../resmgr_lite/include/locale_matcher.h | 36 ++++ .../resmgr_lite/include/res_config_impl.h | 49 ++++- frameworks/resmgr_lite/include/res_desc.h | 5 + frameworks/resmgr_lite/include/res_locale.h | 25 +++ .../include/resource_manager_impl.h | 186 ++++++++++++++++++ frameworks/resmgr_lite/src/locale_matcher.cpp | 6 +- .../resmgr_lite/src/res_config_impl.cpp | 2 +- frameworks/resmgr_lite/src/res_locale.cpp | 2 +- .../resmgr_lite/src/resource_manager_impl.cpp | 4 +- .../unittest/lite/common/res_config_test.cpp | 2 +- 13 files changed, 410 insertions(+), 10 deletions(-) diff --git a/frameworks/resmgr_lite/include/hap_manager.h b/frameworks/resmgr_lite/include/hap_manager.h index 6b9cc2e..721b6c6 100644 --- a/frameworks/resmgr_lite/include/hap_manager.h +++ b/frameworks/resmgr_lite/include/hap_manager.h @@ -29,24 +29,71 @@ namespace Global { namespace Resource { class HapManager { public: + /** + * The constructor of HapManager + */ explicit HapManager(ResConfigImpl *resConfig); + /** + * The destructor of HapManager + */ ~HapManager(); + /** + * Update the resConfig + * @param resConfig the resource config + * @return the resConfig after update + */ RState UpdateResConfig(ResConfig &resConfig); + /** + * Get the resConfig + * @param resConfig the resource config + */ void GetResConfig(ResConfig &resConfig); + /** + * Add resource path to hap paths + * @param path the resource path + * @return true if add resource path success, else false + */ bool AddResource(const char *path); + /** + * Find resource by resource id + * @param id the resource id + * @return the resources corresponding resource id + */ const IdItem *FindResourceById(uint32_t id); + /** + * Find resource by resource name + * @param name the resource name + * @param resType the resource type + * @return the resources corresponding resource name + */ const IdItem *FindResourceByName(const char *name, const ResType resType); + /** + * Find best resource path by resource id + * @param id the resource id + * @return the best resource path + */ const HapResource::ValueUnderQualifierDir *FindQualifierValueById(uint32_t id); + /** + * Find best resource path by resource name + * @param name the resource name + * @param resType the resource type + * @return the best resource path + */ const HapResource::ValueUnderQualifierDir *FindQualifierValueByName(const char *name, const ResType resType); + /** + * Get the language pluralRule corresponding to quantity + * @param quantity the language quantity + * @return the language pluralRule corresponding to quantity + */ std::string GetPluralRulesAndSelect(int quantity); private: diff --git a/frameworks/resmgr_lite/include/hap_parser.h b/frameworks/resmgr_lite/include/hap_parser.h index fdd5ac9..ec7f31e 100644 --- a/frameworks/resmgr_lite/include/hap_parser.h +++ b/frameworks/resmgr_lite/include/hap_parser.h @@ -51,15 +51,43 @@ public: static int32_t ReadIndexFromFile(const char *zipFile, void **buffer, size_t &bufLen, std::string &errInfo); + /** + * Parse resource hex to resDesc + * @param buffer the resource bytes + * @param bufLen length in bytes + * @param resDesc index file in hap + * @param defaultConfig the default config + * @return OK if the resource hex parse success, else SYS_ERROR + */ static int32_t ParseResHex(const char *buffer, const size_t bufLen, ResDesc &resDesc, const ResConfigImpl *defaultConfig = nullptr); + /** + * Create resource config from KeyParams + * @param keyParams the keyParams contain type and value + * @return the resource config corresponding the keyParams + */ static ResConfigImpl *CreateResConfigFromKeyParams(const std::vector &keyParams); + /** + * To resource folder path + * @param keyParams the keyParams contain type and value + * @return the resources folder path + */ static std::string ToFolderPath(const std::vector &keyParams); + /** + * Get screen density + * @param value the type of screen density + * @return the screen density corresponding the value + */ static ScreenDensity GetScreenDensity(uint32_t value); + /** + * Get device type + * @param value the type of device + * @return the device type corresponding the value + */ static DeviceType GetDeviceType(uint32_t value); private: diff --git a/frameworks/resmgr_lite/include/hap_resource.h b/frameworks/resmgr_lite/include/hap_resource.h index 0f5d6c9..1334210 100644 --- a/frameworks/resmgr_lite/include/hap_resource.h +++ b/frameworks/resmgr_lite/include/hap_resource.h @@ -43,20 +43,29 @@ public: */ static const HapResource *LoadFromIndex(const char *path, const ResConfigImpl *defaultConfig, bool system = false); + /** + * The destructor of HapResource + */ ~HapResource(); + /** + * Get the resource.index file path + */ inline const std::string GetIndexPath() const { return indexPath_; } + /** + * Get the resource path + */ inline const std::string GetResourcePath() const { return resourcePath_; } /** - * describe limitpath and value under the path + * Describe limitpath and value under the path */ class ValueUnderQualifierDir { public: @@ -133,10 +142,27 @@ public: std::vector limitPaths_; }; + /** + * Get the resource value by resource id + * @param id the resource id + * @return the rsource value corresponding id + */ const IdValues *GetIdValues(const uint32_t id) const; + /** + * Get the resource value by resource name + * @param name the resource name + * @param resType the resource type + * @return the rsource value corresponding resource name + */ const IdValues *GetIdValuesByName(const std::string name, const ResType resType) const; + /** + * Get the resource id by resource name + * @param name the resource name + * @param resType the resource type + * @return the resource id corresponding resource name + */ int GetIdByName(const char *name, const ResType resType) const; size_t IdSize() const diff --git a/frameworks/resmgr_lite/include/locale_matcher.h b/frameworks/resmgr_lite/include/locale_matcher.h index 4e92c92..e997b98 100644 --- a/frameworks/resmgr_lite/include/locale_matcher.h +++ b/frameworks/resmgr_lite/include/locale_matcher.h @@ -25,16 +25,52 @@ public: const ResLocale *other, const ResLocale *request); + /** + * Whether the current ResLocale same to the other ResLocale + * @param current the current ResLocale + * @param other the other ResLocale + * @return true if the current ResLocale same to the other ResLocale, else false + */ static bool Match(const ResLocale *current, const ResLocale *other); + /** + * Whether the string is the language tag + * @param str the tag string + * @param len the tag length + * @return true if the str is language tag, else false + */ static bool IsLanguageTag(const char *str, int32_t len); + /** + * Whether the string is the script tag + * @param str the tag string + * @param len the tag length + * @return true if the str is script tag, else false + */ static bool IsScriptTag(const char *str, int32_t len); + /** + * Whether the string is the Region tag + * @param str the tag string + * @param len the tag length + * @return true if the str is Region tag, else false + */ static bool IsRegionTag(const char *str, int32_t len); + /** + * Get the resLocale script + * @param resLocale the resLocale infomation + * @return true if get the resLocale script, else false + */ static bool Normalize(ResLocale *resLocale); + /** + * Whether the current resLocale more specific than target resLocale + * @param current the current resLocale + * @param target the target resLocale + * @return 0 means current resLocale same to target resLocale, + * 1 means current resLocale more specific than target resLocale, else -1 + */ static int8_t IsMoreSpecificThan(const ResLocale *current, const ResLocale *target); public: diff --git a/frameworks/resmgr_lite/include/res_config_impl.h b/frameworks/resmgr_lite/include/res_config_impl.h index c8ca03c..49639f7 100644 --- a/frameworks/resmgr_lite/include/res_config_impl.h +++ b/frameworks/resmgr_lite/include/res_config_impl.h @@ -29,16 +29,46 @@ class ResConfigImpl : public ResConfig { public: ResConfigImpl(); + /** + * Whether the this resConfig more match request resConfig + * @param other the other resConfig + * @param request the request resConfig + * @return true if this resConfig more match request resConfig than other resConfig, else false + */ bool IsMoreSuitable(const ResConfigImpl *other, const ResConfigImpl *request) const; + /** + * Set locale information + * @param language the locale language + * @param script the locale script + * @param region the locale region + * @return SUCCESS if set locale information success, else false + */ RState SetLocaleInfo(const char *language, const char *script, const char *region); - + + /** + * Set locale information + * @param localeInfo the localeInfo + * @return SUCCESS if set locale information success, else false + */ RState SetLocaleInfo(LocaleInfo &localeInfo); + /** + * Set resConfig device type + * @param deviceType the device type + */ void SetDeviceType(DeviceType deviceType); + /** + * Set resConfig direction + * @param direction the resConfig direction + */ void SetDirection(Direction direction); + /** + * Set resConfig screenDensity + * @param screenDensity the resConfig screenDensity + */ void SetScreenDensity(ScreenDensity screenDensity); const LocaleInfo *GetLocaleInfo() const; @@ -51,12 +81,29 @@ public: DeviceType GetDeviceType() const; + /** + * Whether this resConfig match other resConfig + * @param other the other resConfig + * @return true if this resConfig match other resConfig, else false + */ bool Match(const ResConfigImpl *other) const; + /** + * Copy this resConfig match other resConfig + * @param other the other resConfig + * @return true if copy other resConfig to this resConfig success, else false + */ bool Copy(ResConfig &other); + /** + * Complete the local script + */ void CompleteScript(); + /** + * Whether the script completed + * @return true if copy other resConfig to this resConfig success, else false + */ bool IsCompletedScript() const; virtual ~ResConfigImpl(); diff --git a/frameworks/resmgr_lite/include/res_desc.h b/frameworks/resmgr_lite/include/res_desc.h index 15ac4aa..f335659 100644 --- a/frameworks/resmgr_lite/include/res_desc.h +++ b/frameworks/resmgr_lite/include/res_desc.h @@ -48,6 +48,11 @@ class IdItem { public: static const uint32_t HEADER_LEN = 12; + /** + * Whether the resType is array or not + * @param type the resType + * @return true if the resType is array, else false + */ static bool IsArrayOfType(ResType type) { if (type == ResType::STRINGARRAY || type == ResType::INTARRAY || type == ResType::THEME || diff --git a/frameworks/resmgr_lite/include/res_locale.h b/frameworks/resmgr_lite/include/res_locale.h index 832eb7c..0851727 100644 --- a/frameworks/resmgr_lite/include/res_locale.h +++ b/frameworks/resmgr_lite/include/res_locale.h @@ -45,16 +45,41 @@ public: ResLocale(); + /** + * Copy from other LocaleInfo to this + * @param other the other LocaleInfo copy to this localeInfo + * @return SUCCESS if copy other LocaleInfo success, else ERROR + */ RState CopyFromLocaleInfo(const LocaleInfo *other); + /** + * Copy from other ResLocale to this + * @param other the other ResLocale copy to this ResLocale + * @return SUCCESS if copy other ResLocale success, else ERROR + */ RState Copy(const ResLocale *other); static const LocaleInfo *GetDefault(); static bool UpdateDefault(const LocaleInfo &localeInfo, bool needNotify); + /** + * Build resLocal from string + * @param bcp47String the target string + * @param sep the parse string position + * @param rState the parse status + * @return the resLocal after parse bcp47String + */ static ResLocale *BuildFromString(const char *bcp47String, char sep, RState &rState); + /** + * Build resLocal from parts + * @param language the resLocal language + * @param script the resLocal script + * @param region the resLocal region + * @param rState the Build status + * @return the resLocal after Build resLocal from parts if success, else return nullptr + */ static ResLocale *BuildFromParts(const char *language, const char *script, const char *region, RState &rState); ~ResLocale(); diff --git a/frameworks/resmgr_lite/include/resource_manager_impl.h b/frameworks/resmgr_lite/include/resource_manager_impl.h index f402e8c..d39f8c4 100644 --- a/frameworks/resmgr_lite/include/resource_manager_impl.h +++ b/frameworks/resmgr_lite/include/resource_manager_impl.h @@ -32,66 +32,252 @@ public: bool Init(); + /** + * Add resource path to hap paths + * @param path the resource path + * @return true if add resource path success, else false + */ virtual bool AddResource(const char *path); + /** + * Update the resConfig + * @param resConfig the resource config + * @return the resConfig after update + */ virtual RState UpdateResConfig(ResConfig &resConfig); + /** + * Get the resConfig + * @param resConfig the resource config + */ virtual void GetResConfig(ResConfig &resConfig); + /** + * Get string resource by Id + * @param id the resource Id + * @param outValue the string resource write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetStringById(uint32_t id, std::string &outValue); + /** + * Get string by resource name + * @param name the resource name + * @param outValue the resource write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetStringByName(const char *name, std::string &outValue); + /** + * Get formatstring by resource id + * @param id the resource id + * @param outValue the resource write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetStringFormatById(std::string &outValue, uint32_t id, ...); + /** + * Get formatstring by resource name + * @param name the resource name + * @param outValue the resource write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetStringFormatByName(std::string &outValue, const char *name, ...); + /** + * Get the ResType is STRINGARRAY resource by resource id + * @param id the resource id + * @param outValue the resource write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetStringArrayById(uint32_t id, std::vector &outValue); + /** + * Get the ResType is STRINGARRAY resource by resource name + * @param name the resource name + * @param outValue the resource write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetStringArrayByName(const char *name, std::vector &outValue); + /** + * Get the ResType is PATTERN resource by resource id + * @param id the resource id + * @param outValue the resource write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetPatternById(uint32_t id, std::map &outValue); + /** + * Get the ResType is PATTERN resource by resource name + * @param name the resource name + * @param outValue the resource write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetPatternByName(const char *name, std::map &outValue); + /** + * Get the plural string by resource id + * @param id the resource id + * @param quantity the language quantity + * @param outValue the resource write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetPluralStringById(uint32_t id, int quantity, std::string &outValue); + /** + * Get the plural string by resource name + * @param name the resource name + * @param quantity the language quantity + * @param outValue the resource write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetPluralStringByName(const char *name, int quantity, std::string &outValue); + /** + * Get the plural format string by resource id + * @param outValue the resource write to + * @param id the resource id + * @param quantity the language quantity + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetPluralStringByIdFormat(std::string &outValue, uint32_t id, int quantity, ...); + /** + * Get the plural format string by resource name + * @param outValue the resource write to + * @param id the resource id + * @param quantity the language quantity + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetPluralStringByNameFormat(std::string &outValue, const char *name, int quantity, ...); + /** + * Get the ResType is THEME resource by resource id + * @param id the resource id + * @param outValue the resource write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetThemeById(uint32_t id, std::map &outValue); + /** + * Get the ResType is THEME resource by resource name + * @param name the resource name + * @param outValue the resource write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetThemeByName(const char *name, std::map &outValue); + /** + * Get the ResType is BOOLEAN resource by resource id + * @param id the resource id + * @param outValue the obtain boolean value write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetBooleanById(uint32_t id, bool &outValue); + /** + * Get the ResType is BOOLEAN resource by resource name + * @param name the resource name + * @param outValue the obtain boolean value write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetBooleanByName(const char *name, bool &outValue); + /** + * Get the ResType is INTEGER resource by resource id + * @param id the resource id + * @param outValue the obtain Integer value write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetIntegerById(uint32_t id, int &outValue); + /** + * Get the ResType is INTEGER resource by resource name + * @param name the resource name + * @param outValue the obtain Integer value write to + * @return SUCCESS if resource path exist, else NOT_FOUND + */ virtual RState GetIntegerByName(const char *name, int &outValue); + /** + * Get the ResType is FLOAT resource by resource id + * @param id the resource id + * @param outValue the obtain float value write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetFloatById(uint32_t id, float &outValue); + /** + * Get the ResType is FLOAT resource by resource name + * @param name the resource name + * @param outValue the obtain float value write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetFloatByName(const char *name, float &outValue); + /** + * Get the ResType is INTARRAY resource by resource id + * @param id the resource id + * @param outValue the obtain resource value convert to vector write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetIntArrayById(uint32_t id, std::vector &outValue); + /** + * Get the ResType is INTARRAY resource by resource name + * @param name the resource name + * @param outValue the obtain resource value convert to vector write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetIntArrayByName(const char *name, std::vector &outValue); + /** + * Get the ResType is COLOR resource by resource id + * @param id the resource id + * @param outValue the obtain resource value convert to uint32_t write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetColorById(uint32_t id, uint32_t &outValue); + /** + * Get the ResType is COLOR resource by resource name + * @param name the resource name + * @param outValue the obtain resource value convert to uint32_t write to + * @return SUCCESS if resource exist, else NOT_FOUND + */ virtual RState GetColorByName(const char *name, uint32_t &outValue); + /** + * Get the ResType is PROF resource by resource id + * @param id the resource id + * @param outValue the obtain resource path write to + * @return SUCCESS if resource path exist, else NOT_FOUND + */ virtual RState GetProfileById(uint32_t id, std::string &outValue); + /** + * Get the ResType is PROF resource by resource name + * @param name the resource name + * @param outValue the obtain resource path write to + * @return SUCCESS if resource path exist, else NOT_FOUND + */ virtual RState GetProfileByName(const char *name, std::string &outValue); + /** + * Get the ResType is MEDIA resource by resource id + * @param id the resource id + * @param outValue the obtain resource path write to + * @return SUCCESS if resource path exist, else NOT_FOUND + */ virtual RState GetMediaById(uint32_t id, std::string &outValue); + /** + * Get the ResType is PROF resource by resource name + * @param name the resource name + * @param outValue the obtain resource path write to + * @return SUCCESS if resource path exist, else NOT_FOUND + */ virtual RState GetMediaByName(const char *name, std::string &outValue); private: diff --git a/frameworks/resmgr_lite/src/locale_matcher.cpp b/frameworks/resmgr_lite/src/locale_matcher.cpp index b54f059..2d197df 100644 --- a/frameworks/resmgr_lite/src/locale_matcher.cpp +++ b/frameworks/resmgr_lite/src/locale_matcher.cpp @@ -525,7 +525,7 @@ bool LocaleMatcher::Normalize(ResLocale *localeInfo) } uint32_t encodedScript = FindDefaultScriptEncode(localeInfo->GetLanguage(), localeInfo->GetRegion()); - if (encodedScript == NULL_SCRIPT) { + if (encodedScript == LocaleMatcher::NULL_SCRIPT) { return true; } char *tempScript = new(std::nothrow) char[SCRIPT_ARRAY_LEN]; @@ -609,10 +609,10 @@ int8_t LocaleMatcher::IsMoreSuitable(const ResLocale *current, return 0; } bool isLangEqual = CompareLanguage(current, other); - if (isLangEqual == false) { + if (!isLangEqual) { // current or other language is null, not null language is better bool result = CompareRegionWhenLangIsNotEqual(current, other, request); - return (result == true) ? 1 : -1; + return result ? 1 : -1; } uint16_t currentEncodedRegion = Utils::EncodeRegionByResLocale(current); diff --git a/frameworks/resmgr_lite/src/res_config_impl.cpp b/frameworks/resmgr_lite/src/res_config_impl.cpp index 950cfd7..a758bec 100644 --- a/frameworks/resmgr_lite/src/res_config_impl.cpp +++ b/frameworks/resmgr_lite/src/res_config_impl.cpp @@ -184,7 +184,7 @@ bool ResConfigImpl::Match(const ResConfigImpl *other) const if (other == nullptr) { return false; } - if (LocaleMatcher::Match(this->resLocale_, other->GetResLocale()) == false) { + if (!(LocaleMatcher::Match(this->resLocale_, other->GetResLocale()))) { return false; } if (this->direction_ != DIRECTION_NOT_SET && diff --git a/frameworks/resmgr_lite/src/res_locale.cpp b/frameworks/resmgr_lite/src/res_locale.cpp index 8313791..45e99a5 100644 --- a/frameworks/resmgr_lite/src/res_locale.cpp +++ b/frameworks/resmgr_lite/src/res_locale.cpp @@ -385,7 +385,7 @@ LocaleInfo *BuildFromParts(const char *language, const char *script, const char rState = INVALID_BCP47_LANGUAGE_SUBTAG; return nullptr; } - if (LocaleMatcher::IsLanguageTag(language, len) == false) { + if (!(LocaleMatcher::IsLanguageTag(language, len))) { rState = INVALID_BCP47_LANGUAGE_SUBTAG; return nullptr; } diff --git a/frameworks/resmgr_lite/src/resource_manager_impl.cpp b/frameworks/resmgr_lite/src/resource_manager_impl.cpp index c3956e0..ec0be78 100644 --- a/frameworks/resmgr_lite/src/resource_manager_impl.cpp +++ b/frameworks/resmgr_lite/src/resource_manager_impl.cpp @@ -451,7 +451,7 @@ RState ResourceManagerImpl::GetInteger(const IdItem *idItem, int &outValue) std::string temp; RState state = ResolveReference(idItem->value_, temp); if (state == SUCCESS) { - outValue = atoi(temp.c_str()); + outValue = stoi(temp); return SUCCESS; } return state; @@ -509,7 +509,7 @@ RState ResourceManagerImpl::GetIntArray(const IdItem *idItem, std::vector & HILOG_ERROR("ResolveReference failed, value:%s", idItem->values_[i].c_str()); return ERROR; } - outValue.push_back(atoi(resolvedValue.c_str())); + outValue.push_back(stoi(resolvedValue)); } return SUCCESS; } diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.cpp index a839f4d..0e25998 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/res_config_test.cpp @@ -70,7 +70,7 @@ HWTEST_F(ResConfigTest, ResConfigFuncTest001, TestSize.Level1) ResConfigImpl *target = new ResConfigImpl; target->SetLocaleInfo("zh", nullptr, "CN"); EXPECT_TRUE(rc->Match(current)); - EXPECT_TRUE(rc->Match(target) == false); + EXPECT_TRUE(!(rc->Match(target))); delete target; delete current; delete rc; -- Gitee From 52e0545916d756d558cc2d7ce8baea49216ed1cb Mon Sep 17 00:00:00 2001 From: huangjie Date: Fri, 25 Mar 2022 18:01:53 +0800 Subject: [PATCH 28/31] =?UTF-8?q?L1=E7=BC=96=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjie --- frameworks/resmgr_lite/include/hap_manager.h | 10 ++-- frameworks/resmgr_lite/include/hap_parser.h | 6 +-- frameworks/resmgr_lite/include/hap_resource.h | 6 +-- .../resmgr_lite/include/res_config_impl.h | 8 +-- .../include/resource_manager_impl.h | 52 +++++++++---------- 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/frameworks/resmgr_lite/include/hap_manager.h b/frameworks/resmgr_lite/include/hap_manager.h index 721b6c6..1c3da3e 100644 --- a/frameworks/resmgr_lite/include/hap_manager.h +++ b/frameworks/resmgr_lite/include/hap_manager.h @@ -42,7 +42,7 @@ public: /** * Update the resConfig * @param resConfig the resource config - * @return the resConfig after update + * @return SUCCESS if the resConfig updated success, else HAP_INIT_FAILED */ RState UpdateResConfig(ResConfig &resConfig); @@ -62,7 +62,7 @@ public: /** * Find resource by resource id * @param id the resource id - * @return the resources corresponding resource id + * @return the resources related to resource id */ const IdItem *FindResourceById(uint32_t id); @@ -70,7 +70,7 @@ public: * Find resource by resource name * @param name the resource name * @param resType the resource type - * @return the resources corresponding resource name + * @return the resources related to resource name */ const IdItem *FindResourceByName(const char *name, const ResType resType); @@ -90,9 +90,9 @@ public: const HapResource::ValueUnderQualifierDir *FindQualifierValueByName(const char *name, const ResType resType); /** - * Get the language pluralRule corresponding to quantity + * Get the language pluralRule related to quantity * @param quantity the language quantity - * @return the language pluralRule corresponding to quantity + * @return the language pluralRule related to quantity */ std::string GetPluralRulesAndSelect(int quantity); diff --git a/frameworks/resmgr_lite/include/hap_parser.h b/frameworks/resmgr_lite/include/hap_parser.h index ec7f31e..900149f 100644 --- a/frameworks/resmgr_lite/include/hap_parser.h +++ b/frameworks/resmgr_lite/include/hap_parser.h @@ -65,7 +65,7 @@ public: /** * Create resource config from KeyParams * @param keyParams the keyParams contain type and value - * @return the resource config corresponding the keyParams + * @return the resource config related to the keyParams */ static ResConfigImpl *CreateResConfigFromKeyParams(const std::vector &keyParams); @@ -79,14 +79,14 @@ public: /** * Get screen density * @param value the type of screen density - * @return the screen density corresponding the value + * @return the screen density related to the value */ static ScreenDensity GetScreenDensity(uint32_t value); /** * Get device type * @param value the type of device - * @return the device type corresponding the value + * @return the device type related to the value */ static DeviceType GetDeviceType(uint32_t value); diff --git a/frameworks/resmgr_lite/include/hap_resource.h b/frameworks/resmgr_lite/include/hap_resource.h index 1334210..59397a1 100644 --- a/frameworks/resmgr_lite/include/hap_resource.h +++ b/frameworks/resmgr_lite/include/hap_resource.h @@ -145,7 +145,7 @@ public: /** * Get the resource value by resource id * @param id the resource id - * @return the rsource value corresponding id + * @return the resource value related to id */ const IdValues *GetIdValues(const uint32_t id) const; @@ -153,7 +153,7 @@ public: * Get the resource value by resource name * @param name the resource name * @param resType the resource type - * @return the rsource value corresponding resource name + * @return the resource value related to resource name */ const IdValues *GetIdValuesByName(const std::string name, const ResType resType) const; @@ -161,7 +161,7 @@ public: * Get the resource id by resource name * @param name the resource name * @param resType the resource type - * @return the resource id corresponding resource name + * @return the resource id related to resource name */ int GetIdByName(const char *name, const ResType resType) const; diff --git a/frameworks/resmgr_lite/include/res_config_impl.h b/frameworks/resmgr_lite/include/res_config_impl.h index 49639f7..7cf6671 100644 --- a/frameworks/resmgr_lite/include/res_config_impl.h +++ b/frameworks/resmgr_lite/include/res_config_impl.h @@ -30,7 +30,7 @@ public: ResConfigImpl(); /** - * Whether the this resConfig more match request resConfig + * Whether this resConfig more match request resConfig * @param other the other resConfig * @param request the request resConfig * @return true if this resConfig more match request resConfig than other resConfig, else false @@ -89,7 +89,7 @@ public: bool Match(const ResConfigImpl *other) const; /** - * Copy this resConfig match other resConfig + * Copy other resConfig to this resConfig * @param other the other resConfig * @return true if copy other resConfig to this resConfig success, else false */ @@ -101,8 +101,8 @@ public: void CompleteScript(); /** - * Whether the script completed - * @return true if copy other resConfig to this resConfig success, else false + * Whether this resLocal script completed + * @return true if resLocal script completed, else false */ bool IsCompletedScript() const; diff --git a/frameworks/resmgr_lite/include/resource_manager_impl.h b/frameworks/resmgr_lite/include/resource_manager_impl.h index d39f8c4..3fba09b 100644 --- a/frameworks/resmgr_lite/include/resource_manager_impl.h +++ b/frameworks/resmgr_lite/include/resource_manager_impl.h @@ -53,8 +53,8 @@ public: virtual void GetResConfig(ResConfig &resConfig); /** - * Get string resource by Id - * @param id the resource Id + * Get string resource by id + * @param id the resource id * @param outValue the string resource write to * @return SUCCESS if resource exist, else NOT_FOUND */ @@ -85,7 +85,7 @@ public: virtual RState GetStringFormatByName(std::string &outValue, const char *name, ...); /** - * Get the ResType is STRINGARRAY resource by resource id + * Get the STRINGARRAY resource by resource id * @param id the resource id * @param outValue the resource write to * @return SUCCESS if resource exist, else NOT_FOUND @@ -93,7 +93,7 @@ public: virtual RState GetStringArrayById(uint32_t id, std::vector &outValue); /** - * Get the ResType is STRINGARRAY resource by resource name + * Get the STRINGARRAY resource by resource name * @param name the resource name * @param outValue the resource write to * @return SUCCESS if resource exist, else NOT_FOUND @@ -101,7 +101,7 @@ public: virtual RState GetStringArrayByName(const char *name, std::vector &outValue); /** - * Get the ResType is PATTERN resource by resource id + * Get the PATTERN resource by resource id * @param id the resource id * @param outValue the resource write to * @return SUCCESS if resource exist, else NOT_FOUND @@ -109,7 +109,7 @@ public: virtual RState GetPatternById(uint32_t id, std::map &outValue); /** - * Get the ResType is PATTERN resource by resource name + * Get the PATTERN resource by resource name * @param name the resource name * @param outValue the resource write to * @return SUCCESS if resource exist, else NOT_FOUND @@ -153,7 +153,7 @@ public: virtual RState GetPluralStringByNameFormat(std::string &outValue, const char *name, int quantity, ...); /** - * Get the ResType is THEME resource by resource id + * Get the THEME resource by resource id * @param id the resource id * @param outValue the resource write to * @return SUCCESS if resource exist, else NOT_FOUND @@ -161,7 +161,7 @@ public: virtual RState GetThemeById(uint32_t id, std::map &outValue); /** - * Get the ResType is THEME resource by resource name + * Get the THEME resource by resource name * @param name the resource name * @param outValue the resource write to * @return SUCCESS if resource exist, else NOT_FOUND @@ -169,7 +169,7 @@ public: virtual RState GetThemeByName(const char *name, std::map &outValue); /** - * Get the ResType is BOOLEAN resource by resource id + * Get the BOOLEAN resource by resource id * @param id the resource id * @param outValue the obtain boolean value write to * @return SUCCESS if resource exist, else NOT_FOUND @@ -177,7 +177,7 @@ public: virtual RState GetBooleanById(uint32_t id, bool &outValue); /** - * Get the ResType is BOOLEAN resource by resource name + * Get the BOOLEAN resource by resource name * @param name the resource name * @param outValue the obtain boolean value write to * @return SUCCESS if resource exist, else NOT_FOUND @@ -185,7 +185,7 @@ public: virtual RState GetBooleanByName(const char *name, bool &outValue); /** - * Get the ResType is INTEGER resource by resource id + * Get the INTEGER resource by resource id * @param id the resource id * @param outValue the obtain Integer value write to * @return SUCCESS if resource exist, else NOT_FOUND @@ -193,7 +193,7 @@ public: virtual RState GetIntegerById(uint32_t id, int &outValue); /** - * Get the ResType is INTEGER resource by resource name + * Get the INTEGER resource by resource name * @param name the resource name * @param outValue the obtain Integer value write to * @return SUCCESS if resource path exist, else NOT_FOUND @@ -201,7 +201,7 @@ public: virtual RState GetIntegerByName(const char *name, int &outValue); /** - * Get the ResType is FLOAT resource by resource id + * Get the FLOAT resource by resource id * @param id the resource id * @param outValue the obtain float value write to * @return SUCCESS if resource exist, else NOT_FOUND @@ -209,7 +209,7 @@ public: virtual RState GetFloatById(uint32_t id, float &outValue); /** - * Get the ResType is FLOAT resource by resource name + * Get the FLOAT resource by resource name * @param name the resource name * @param outValue the obtain float value write to * @return SUCCESS if resource exist, else NOT_FOUND @@ -217,7 +217,7 @@ public: virtual RState GetFloatByName(const char *name, float &outValue); /** - * Get the ResType is INTARRAY resource by resource id + * Get the INTARRAY resource by resource id * @param id the resource id * @param outValue the obtain resource value convert to vector write to * @return SUCCESS if resource exist, else NOT_FOUND @@ -225,7 +225,7 @@ public: virtual RState GetIntArrayById(uint32_t id, std::vector &outValue); /** - * Get the ResType is INTARRAY resource by resource name + * Get the NTARRAY resource by resource name * @param name the resource name * @param outValue the obtain resource value convert to vector write to * @return SUCCESS if resource exist, else NOT_FOUND @@ -233,7 +233,7 @@ public: virtual RState GetIntArrayByName(const char *name, std::vector &outValue); /** - * Get the ResType is COLOR resource by resource id + * Get the COLOR resource by resource id * @param id the resource id * @param outValue the obtain resource value convert to uint32_t write to * @return SUCCESS if resource exist, else NOT_FOUND @@ -241,7 +241,7 @@ public: virtual RState GetColorById(uint32_t id, uint32_t &outValue); /** - * Get the ResType is COLOR resource by resource name + * Get the COLOR resource by resource name * @param name the resource name * @param outValue the obtain resource value convert to uint32_t write to * @return SUCCESS if resource exist, else NOT_FOUND @@ -249,34 +249,34 @@ public: virtual RState GetColorByName(const char *name, uint32_t &outValue); /** - * Get the ResType is PROF resource by resource id + * Get the PROF resource by resource id * @param id the resource id * @param outValue the obtain resource path write to - * @return SUCCESS if resource path exist, else NOT_FOUND + * @return SUCCESS if resource exist, else NOT_FOUND */ virtual RState GetProfileById(uint32_t id, std::string &outValue); /** - * Get the ResType is PROF resource by resource name + * Get the PROF resource by resource name * @param name the resource name * @param outValue the obtain resource path write to - * @return SUCCESS if resource path exist, else NOT_FOUND + * @return SUCCESS if resource exist, else NOT_FOUND */ virtual RState GetProfileByName(const char *name, std::string &outValue); /** - * Get the ResType is MEDIA resource by resource id + * Get the MEDIA resource by resource id * @param id the resource id * @param outValue the obtain resource path write to - * @return SUCCESS if resource path exist, else NOT_FOUND + * @return SUCCESS if resource exist, else NOT_FOUND */ virtual RState GetMediaById(uint32_t id, std::string &outValue); /** - * Get the ResType is PROF resource by resource name + * Get the MEDIA resource by resource name * @param name the resource name * @param outValue the obtain resource path write to - * @return SUCCESS if resource path exist, else NOT_FOUND + * @return SUCCESS if resource exist, else NOT_FOUND */ virtual RState GetMediaByName(const char *name, std::string &outValue); -- Gitee From 67ea27bfa34c81d3e11f6bc2e8e22ce773bfe794 Mon Sep 17 00:00:00 2001 From: huangjie Date: Thu, 5 May 2022 22:09:37 +0800 Subject: [PATCH 29/31] =?UTF-8?q?=E8=B5=84=E6=BA=90resource=5Fmanagement?= =?UTF-8?q?=5Flite=E9=83=A8=E4=BB=B6=E5=90=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjie --- README.md | 16 ++++++++-------- README_zh.md | 16 ++++++++-------- bundle.json | 12 ++++++------ frameworks/resmgr_lite/BUILD.gn | 6 +++--- frameworks/resmgr_lite/CMakeLists.txt | 6 +++--- frameworks/resmgr_lite/test/BUILD.gn | 6 +++--- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 4766482..f9f3003 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,14 @@ The directory structure for the resource management module is as follows: ``` /base/global/ -├── resmgr_lite # Code repository for the resource management module -│ ├── frameworks # Core code of the resource management module -│ │ ├── resmgr_lite # Core code for resource parsing -│ │ │ ├── include # Header files of the resource management module -│ │ │ ├── src # Implementation code of the resource management module -│ │ │ └── test # Test code -│ ├── interfaces # APIs of the resource management module -│ │ └── innerkits # APIs of the resource management module for internal subsystems +├── resource_management_lite # Code repository for the resource management module +│ ├── frameworks # Core code of the resource management module +│ │ ├── resource_management_lite # Core code for resource parsing +│ │ │ ├── include # Header files of the resource management module +│ │ │ ├── src # Implementation code of the resource management module +│ │ │ └── test # Test code +│ ├── interfaces # APIs of the resource management module +│ │ └── innerkits # APIs of the resource management module for internal subsystems ``` ## Usage diff --git a/README_zh.md b/README_zh.md index d7e6a80..c6412a1 100644 --- a/README_zh.md +++ b/README_zh.md @@ -16,14 +16,14 @@ ``` /base/global/ -├── resmgr_lite # 资源管理代码仓 -│ ├── frameworks # 资源管理核心代码 -│ │ ├── resmgr_lite # 资源解析核心代码 -│ │ │ ├── include # 资源管理头文件 -│ │ │ ├── src # 资源管理实现代码 -│ │ │ └── test # 资源管理测试代码 -│ ├── interfaces # 资源管理接口 -│ │ └── innerkits # 资源管理对子系统间接口 +├── resource_management_lite # 资源管理代码仓 +│ ├── frameworks # 资源管理核心代码 +│ │ ├── resource_management_lite # 资源解析核心代码 +│ │ │ ├── include # 资源管理头文件 +│ │ │ ├── src # 资源管理实现代码 +│ │ │ └── test # 资源管理测试代码 +│ ├── interfaces # 资源管理接口 +│ │ └── innerkits # 资源管理对子系统间接口 ``` ## 说明 diff --git a/bundle.json b/bundle.json index 6170a0b..9150456 100644 --- a/bundle.json +++ b/bundle.json @@ -1,10 +1,10 @@ { - "name": "@ohos/global_resmgr_lite", + "name": "@ohos/global_resource_management_lite", "version": "", "description": "Obtains resource information based on the device type and configuration", "homePage": "https://gitee.com/openharmony", "license": "Apache V2", - "repository": "https://gitee.com/openharmony/global_resmgr_lite", + "repository": "https://gitee.com/openharmony/global_resource_management_lite", "domain": "os", "language": "", "publishAs": "code-segment", @@ -33,10 +33,10 @@ } ], "segment": { - "destPath": "base/global/resmgr_lite" + "destPath": "base/global/resource_management_lite" }, "component": { - "name": "resmgr_lite", + "name": "resource_management_lite", "subsystem": "global", "syscap": [], "features": [], @@ -55,11 +55,11 @@ }, "build": { "sub_component": [ - "//base/global/resmgr_lite/frameworks/resmgr_lite:global_resmgr" + "//base/global/resource_management_lite/frameworks/resmgr_lite:global_resmgr" ], "inner_kits": [], "test": [ - "//base/global/resmgr_lite/frameworks/resmgr_lite/test:unittest" + "//base/global/resource_management_lite/frameworks/resmgr_lite/test:unittest" ] } } diff --git a/frameworks/resmgr_lite/BUILD.gn b/frameworks/resmgr_lite/BUILD.gn index 2cbf593..cb6ce28 100644 --- a/frameworks/resmgr_lite/BUILD.gn +++ b/frameworks/resmgr_lite/BUILD.gn @@ -43,7 +43,7 @@ if (defined(ohos_lite) && ohos_kernel_type == "liteos_a") { config("global_resmgr_config") { include_dirs = [ "include", - "//base/global/resmgr_lite/interfaces/innerkits/include", + "//base/global/resource_management_lite/interfaces/innerkits/include", "//utils/native/lite/include", "//third_party/bounds_checking_function/include", ] @@ -60,8 +60,8 @@ config("global_resmgr_config") { config("global_public_config") { include_dirs = [ - "//base/global/resmgr_lite/frameworks/resmgr_lite/include", - "//base/global/resmgr_lite/interfaces/innerkits/include", + "//base/global/resource_management_lite/frameworks/resmgr_lite/include", + "//base/global/resource_management_lite/interfaces/innerkits/include", ] } diff --git a/frameworks/resmgr_lite/CMakeLists.txt b/frameworks/resmgr_lite/CMakeLists.txt index d561265..6dc229c 100644 --- a/frameworks/resmgr_lite/CMakeLists.txt +++ b/frameworks/resmgr_lite/CMakeLists.txt @@ -13,9 +13,9 @@ cmake_minimum_required(VERSION 3.16.5) -set(GlobalSrc "${PROJECT_SOURCE_DIR}/base/global/resmgr_lite/frameworks/resmgr_lite/src") -set(GlobalInc "${PROJECT_SOURCE_DIR}/base/global/resmgr_lite/frameworks/resmgr_lite/include") -set(GlobalKitInc "${PROJECT_SOURCE_DIR}/base/global/resmgr_lite/interfaces/innerkits/include") +set(GlobalSrc "${PROJECT_SOURCE_DIR}/base/global/resource_management_lite/frameworks/resmgr_lite/src") +set(GlobalInc "${PROJECT_SOURCE_DIR}/base/global/resource_management_lite/frameworks/resmgr_lite/include") +set(GlobalKitInc "${PROJECT_SOURCE_DIR}/base/global/resource_management_lite/interfaces/innerkits/include") include_directories(${PROJECT_SOURCE_DIR}/third_party/bounds_checking_function/include) diff --git a/frameworks/resmgr_lite/test/BUILD.gn b/frameworks/resmgr_lite/test/BUILD.gn index 3c66b4d..1f266ef 100644 --- a/frameworks/resmgr_lite/test/BUILD.gn +++ b/frameworks/resmgr_lite/test/BUILD.gn @@ -35,12 +35,12 @@ if (ohos_kernel_type == "liteos_a") { include_dirs = [ "unittest/lite/common", - "//base/global/resmgr_lite/frameworks/resmgr_lite/include", - "//base/global/resmgr_lite/interfaces/innerkits/include", + "//base/global/resource_management_lite/frameworks/resmgr_lite/include", + "//base/global/resource_management_lite/interfaces/innerkits/include", "//base/global/i18n_lite/interfaces/kits/i18n/include/", ] - deps = [ "//base/global/resmgr_lite/frameworks/resmgr_lite:global_resmgr" ] + deps = [ "//base/global/resource_management_lite/frameworks/resmgr_lite:global_resmgr" ] output_dir = "$root_out_dir/test/unittest/global" } -- Gitee From 7e4a5aced95e5ca34123e20a85d384cc46f87c50 Mon Sep 17 00:00:00 2001 From: huangjie Date: Sat, 7 May 2022 17:28:51 +0800 Subject: [PATCH 30/31] =?UTF-8?q?=E5=B0=86innerkits=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BAinner=5Fapi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjie --- README.md | 2 +- README_zh.md | 2 +- frameworks/resmgr_lite/BUILD.gn | 4 ++-- frameworks/resmgr_lite/CMakeLists.txt | 2 +- frameworks/resmgr_lite/test/BUILD.gn | 2 +- interfaces/{innerkits => inner_api}/include/global.h | 0 6 files changed, 6 insertions(+), 6 deletions(-) rename interfaces/{innerkits => inner_api}/include/global.h (100%) diff --git a/README.md b/README.md index f9f3003..afc70f5 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The directory structure for the resource management module is as follows: │ │ │ ├── src # Implementation code of the resource management module │ │ │ └── test # Test code │ ├── interfaces # APIs of the resource management module -│ │ └── innerkits # APIs of the resource management module for internal subsystems +│ │ └── inner_api # APIs of the resource management module for internal subsystems ``` ## Usage diff --git a/README_zh.md b/README_zh.md index c6412a1..2f24208 100644 --- a/README_zh.md +++ b/README_zh.md @@ -23,7 +23,7 @@ │ │ │ ├── src # 资源管理实现代码 │ │ │ └── test # 资源管理测试代码 │ ├── interfaces # 资源管理接口 -│ │ └── innerkits # 资源管理对子系统间接口 +│ │ └── inner_api # 资源管理对子系统间接口 ``` ## 说明 diff --git a/frameworks/resmgr_lite/BUILD.gn b/frameworks/resmgr_lite/BUILD.gn index cb6ce28..9b0dcf2 100644 --- a/frameworks/resmgr_lite/BUILD.gn +++ b/frameworks/resmgr_lite/BUILD.gn @@ -43,7 +43,7 @@ if (defined(ohos_lite) && ohos_kernel_type == "liteos_a") { config("global_resmgr_config") { include_dirs = [ "include", - "//base/global/resource_management_lite/interfaces/innerkits/include", + "//base/global/resource_management_lite/interfaces/inner_api/include", "//utils/native/lite/include", "//third_party/bounds_checking_function/include", ] @@ -61,7 +61,7 @@ config("global_resmgr_config") { config("global_public_config") { include_dirs = [ "//base/global/resource_management_lite/frameworks/resmgr_lite/include", - "//base/global/resource_management_lite/interfaces/innerkits/include", + "//base/global/resource_management_lite/interfaces/inner_api/include", ] } diff --git a/frameworks/resmgr_lite/CMakeLists.txt b/frameworks/resmgr_lite/CMakeLists.txt index 6dc229c..276159a 100644 --- a/frameworks/resmgr_lite/CMakeLists.txt +++ b/frameworks/resmgr_lite/CMakeLists.txt @@ -15,7 +15,7 @@ cmake_minimum_required(VERSION 3.16.5) set(GlobalSrc "${PROJECT_SOURCE_DIR}/base/global/resource_management_lite/frameworks/resmgr_lite/src") set(GlobalInc "${PROJECT_SOURCE_DIR}/base/global/resource_management_lite/frameworks/resmgr_lite/include") -set(GlobalKitInc "${PROJECT_SOURCE_DIR}/base/global/resource_management_lite/interfaces/innerkits/include") +set(GlobalKitInc "${PROJECT_SOURCE_DIR}/base/global/resource_management_lite/interfaces/inner_api/include") include_directories(${PROJECT_SOURCE_DIR}/third_party/bounds_checking_function/include) diff --git a/frameworks/resmgr_lite/test/BUILD.gn b/frameworks/resmgr_lite/test/BUILD.gn index 1f266ef..9eadf9f 100644 --- a/frameworks/resmgr_lite/test/BUILD.gn +++ b/frameworks/resmgr_lite/test/BUILD.gn @@ -36,7 +36,7 @@ if (ohos_kernel_type == "liteos_a") { include_dirs = [ "unittest/lite/common", "//base/global/resource_management_lite/frameworks/resmgr_lite/include", - "//base/global/resource_management_lite/interfaces/innerkits/include", + "//base/global/resource_management_lite/interfaces/inner_api/include", "//base/global/i18n_lite/interfaces/kits/i18n/include/", ] diff --git a/interfaces/innerkits/include/global.h b/interfaces/inner_api/include/global.h similarity index 100% rename from interfaces/innerkits/include/global.h rename to interfaces/inner_api/include/global.h -- Gitee From 1f92313d7b40d9f7188ae4f7fdd413eb0898162e Mon Sep 17 00:00:00 2001 From: jacklee0906 Date: Tue, 24 May 2022 11:45:03 +0800 Subject: [PATCH 31/31] add log for maintenance Signed-off-by: jacklee0906 --- frameworks/resmgr_lite/src/global.c | 9 +++++++ frameworks/resmgr_lite/src/global_utils.c | 33 +++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/frameworks/resmgr_lite/src/global.c b/frameworks/resmgr_lite/src/global.c index 4b0e73f..cf86ef0 100644 --- a/frameworks/resmgr_lite/src/global.c +++ b/frameworks/resmgr_lite/src/global.c @@ -24,6 +24,7 @@ #include #include "global_utils.h" +#include "hilog_wrapper.h" /* * locale format as below, use '-' or '_' to link, e.g. en_Latn_US @@ -151,6 +152,7 @@ static int32_t GLOBAL_GetValueByIdInternal(uint32_t id, const char *path, const char realResourcePath[PATH_MAX] = {'\0'}; GlobalUtilsImpl *utilsImpl = GetGlobalUtilsImpl(); if (utilsImpl->CheckFilePath(path, realResourcePath, PATH_MAX) == MC_FAILURE) { + HILOG_ERROR("GLOBAL_GetValueByIdInternal failed to check file %s", path); return MC_FAILURE; } @@ -158,10 +160,12 @@ static int32_t GLOBAL_GetValueByIdInternal(uint32_t id, const char *path, const IdHeader idHeader = {0, NULL}; int32_t file = open(realResourcePath, O_RDONLY, S_IRUSR | S_IRGRP | S_IROTH); if (file < 0) { + HILOG_ERROR("GLOBAL_GetValueByIdInternal failed to open file %s", realResourcePath); return MC_FAILURE; } int32_t ret = utilsImpl->GetIdHeaderByOffset(file, idHeaderOffset, &idHeader); if (ret != MC_SUCCESS) { + HILOG_ERROR("GLOBAL_GetValueByIdInternal failed to git id header by offset %u", idHeaderOffset); close(file); return ret; } @@ -172,12 +176,14 @@ static int32_t GLOBAL_GetValueByIdInternal(uint32_t id, const char *path, const if (idHeader.idParams[i].id == id) { ret = utilsImpl->GetIdItem(file, idHeader.idParams[i].offset, &idItem); if (ret != MC_SUCCESS) { + HILOG_ERROR("GLOBAL_GetValueByIdInternal failed to get id item. ret: %d", ret); close(file); free(idHeader.idParams); return ret; } *value = (char *)malloc(idItem.valueLen); if (*value == NULL || strcpy_s(*value, idItem.valueLen, idItem.value) != EOK) { + HILOG_ERROR("GLOBAL_GetValueByIdInternal failed to copy id item value %s", idItem.value); close(file); free(idHeader.idParams); FreeIdItem(&idItem); @@ -197,12 +203,14 @@ static int32_t GLOBAL_GetValueByIdInternal(uint32_t id, const char *path, const int32_t GLOBAL_GetValueById(uint32_t id, const char *path, char **value) { if (path == NULL || path[0] == '\0' || value == NULL) { + HILOG_ERROR("GLOBAL_GetValueById input params invalid"); return MC_FAILURE; } char tempLocale[MAX_LOCALE_LENGTH] = {'\0'}; int32_t ret = strcpy_s(tempLocale, MAX_LOCALE_LENGTH, g_locale); if (ret != EOK) { + HILOG_ERROR("GLOBAL_GetValueById failed to copy g_locale %s", g_locale); return MC_FAILURE; } @@ -212,6 +220,7 @@ int32_t GLOBAL_GetValueById(uint32_t id, const char *path, char **value) return MC_SUCCESS; } } + HILOG_ERROR("GLOBAL_GetValueById failed to get value by id internal, id:%u, path:%s, tempLocale:%s", id, path, tempLocale); return MC_FAILURE; } diff --git a/frameworks/resmgr_lite/src/global_utils.c b/frameworks/resmgr_lite/src/global_utils.c index ecd778d..f052d9a 100644 --- a/frameworks/resmgr_lite/src/global_utils.c +++ b/frameworks/resmgr_lite/src/global_utils.c @@ -27,6 +27,8 @@ #include #include +#include "hilog_wrapper.h" + #define MAX_ID_ITEM_NUM 0x7F #define MAX_RES_CONFIG_NUM 0xFFFF #define MAX_ITEM_LENGTH 0xFF @@ -258,6 +260,7 @@ static uint32_t FindOffsetByAllParam(char **resConfig, const Key *keys, uint32_t static uint32_t GetIdHeaderOffsetByCount(char **resConfig, const Key *keys, uint32_t configNum, int32_t count) { if (resConfig == NULL || keys == NULL) { + HILOG_ERROR("GetIdHeaderOffsetByCount resConfig or keys is null"); return INVALID_OFFSET; } uint32_t offset = INVALID_OFFSET; @@ -294,12 +297,14 @@ static void FreeKeyParams(Key *keys, int32_t count) static int32_t GetKeyParams(int32_t file, Key *keys, uint32_t resConfigNum) { if (file < 0 || keys == NULL) { + HILOG_ERROR("GetKeyParams file negative or keys is null"); return MC_FAILURE; } g_defaultIdHeaderOffset = INVALID_OFFSET; for (uint32_t i = 0; i < resConfigNum; ++i) { int seekRet = lseek(file, INDEX_DEFAULT_OFFSET, SEEK_CUR); // skip the "KEYS" header if (seekRet < 0) { + HILOG_ERROR("GetKeyParams file %d seek failed, seekRet: %d", file, seekRet); FreeKeyParams(keys, i); return MC_FAILURE; } @@ -310,11 +315,13 @@ static int32_t GetKeyParams(int32_t file, Key *keys, uint32_t resConfigNum) continue; } if (keys[i].keysCount > KEY_TYPE_MAX) { + HILOG_ERROR("GetKeyParams keysCount %u invalid, i: %u", keys[i].keysCount, i); FreeKeyParams(keys, i); return MC_FAILURE; } keys[i].keyParams = (KeyParam *)malloc(sizeof(KeyParam) * keys[i].keysCount); if (keys[i].keyParams == NULL) { + HILOG_ERROR("GetKeyParams keyParams is null, i: %u", i); FreeKeyParams(keys, i); return MC_FAILURE; } @@ -329,21 +336,25 @@ static int32_t GetKeyParams(int32_t file, Key *keys, uint32_t resConfigNum) static int32_t CheckFilePath(const char *path, char *realResourcePath, int32_t length) { if (length > PATH_MAX || length < 0) { + HILOG_ERROR("CheckFilePath length %d invalid", length); return MC_FAILURE; } #if (defined(_WIN32) || defined(_WIN64)) if (!PathCanonicalizeA((char*)path, realResourcePath)) { + HILOG_ERROR("CheckFilePath path %s canonicalize failed", path); return MC_FAILURE; } return MC_SUCCESS; #elif defined(I18N_PRODUCT) int ret = strcpy_s(realResourcePath, PATH_MAX, path); if (ret != 0) { + HILOG_ERROR("CheckFilePath path %s copy failed", path); return MC_FAILURE; } return MC_SUCCESS; #else if (realpath(path, realResourcePath) == NULL) { + HILOG_ERROR("CheckFilePath path %s realpath failed, realResourcePath %s", path, realResourcePath); return MC_FAILURE; } return MC_SUCCESS; @@ -353,40 +364,48 @@ static int32_t CheckFilePath(const char *path, char *realResourcePath, int32_t l static uint32_t GetOffsetByLocale(const char *path, const char *locale, uint32_t length) { if (path == NULL || strlen(path) == 0 || locale == NULL || length == 0) { + HILOG_ERROR("GetOffsetByLocale input params invalid"); return INVALID_OFFSET; } char realResourcePath[PATH_MAX] = {0}; if (CheckFilePath(path, realResourcePath, PATH_MAX) == MC_FAILURE) { + HILOG_ERROR("GetOffsetByLocale check file path %s failed", path); return INVALID_OFFSET; } int32_t file = open(realResourcePath, O_RDONLY, S_IRUSR | S_IRGRP | S_IROTH); if (file < 0) { + HILOG_ERROR("GetOffsetByLocale open file %s failed", realResourcePath); return INVALID_OFFSET; } int seekRet = lseek(file, RES_CONFIG_NUM_OFFSET, SEEK_SET); // goto resConfigNum index, now is fixed at 132 if (seekRet < 0) { + HILOG_ERROR("GetOffsetByLocale file %s seek failed, seekRet: %d", realResourcePath, seekRet); close(file); return INVALID_OFFSET; } uint32_t resConfigNum = GetDefaultOffsetValue(file); if (resConfigNum == 0 || resConfigNum > MAX_RES_CONFIG_NUM) { + HILOG_ERROR("GetOffsetByLocale file %s get default offset value failed, resConfigNum: %u", realResourcePath, resConfigNum); close(file); return INVALID_OFFSET; } int size = sizeof(Key) * resConfigNum; Key *keys = (Key *)malloc(size); if (keys == NULL) { + HILOG_ERROR("GetOffsetByLocale keys is null, resConfigNum: %u", resConfigNum); close(file); return INVALID_OFFSET; } (void)memset_s(keys, size, 0, size); int32_t ret = GetKeyParams(file, keys, resConfigNum); if (ret != MC_SUCCESS) { + HILOG_ERROR("GetOffsetByLocale get key params failed, ret: %d", ret); close(file); free(keys); return INVALID_OFFSET; } close(file); + HILOG_INFO("GetOffsetByLocale locale: %s, resConfigNum: %d", locale, resConfigNum); uint32_t offset = GetIdHeaderOffsetByLocale(locale, keys, resConfigNum); if (offset == INVALID_OFFSET) { offset = g_defaultIdHeaderOffset; @@ -399,11 +418,13 @@ static uint32_t GetOffsetByLocale(const char *path, const char *locale, uint32_t static uint32_t GetDefaultOffsetValue(int32_t file) { if (file < 0) { + HILOG_ERROR("GetDefaultOffsetValue file %d negative", file); return 0; } uint8_t cache[INDEX_DEFAULT_OFFSET] = {0}; int32_t ret = read(file, cache, INDEX_DEFAULT_OFFSET); if (ret != INDEX_DEFAULT_OFFSET) { + HILOG_ERROR("GetDefaultOffsetValue file %d read failed, ret: %d", file, ret); return 0; } return ConvertUint8ArrayToUint32(cache, INDEX_DEFAULT_OFFSET); @@ -425,12 +446,14 @@ static uint32_t GetKeyValue(int32_t file) static int32_t GetIdItem(int32_t file, uint32_t offset, IdItem *idItem) { if (offset == INVALID_OFFSET || file == -1 || idItem == NULL) { + HILOG_ERROR("GetIdItem input params invalid"); return MC_FAILURE; } uint8_t defaultCache[INDEX_DEFAULT_OFFSET] = {0}; uint8_t lengthCache[VALUE_LENGTH_OFFSET] = {0}; int seekRet = lseek(file, offset, SEEK_SET); if (seekRet < 0) { + HILOG_ERROR("GetIdItem file %d seek failed, seekRet: %d", file, seekRet); return MC_FAILURE; } (void)read(file, defaultCache, INDEX_DEFAULT_OFFSET); @@ -445,19 +468,23 @@ static int32_t GetIdItem(int32_t file, uint32_t offset, IdItem *idItem) (void)read(file, lengthCache, VALUE_LENGTH_OFFSET); idItem->valueLen = (uint16_t)ConvertUint8ArrayToUint32(lengthCache, VALUE_LENGTH_OFFSET); if (idItem->valueLen == 0 || idItem->valueLen > MAX_ITEM_LENGTH) { + HILOG_ERROR("GetIdItem idItem valueLen %u invalid", idItem->valueLen); return MC_FAILURE; } idItem->value = (char *)malloc(idItem->valueLen); if (idItem->value == NULL) { + HILOG_ERROR("GetIdItem idItem value is null"); return MC_FAILURE; } + HILOG_INFO("GetIdItem file: %d, idItem->value: %s, idItem->valueLen: %u", file, idItem->value, idItem->valueLen); (void)memset_s(idItem->value, idItem->valueLen, 0, idItem->valueLen); (void)read(file, idItem->value, idItem->valueLen); (void)read(file, lengthCache, VALUE_LENGTH_OFFSET); idItem->nameLen = (uint16_t)ConvertUint8ArrayToUint32(lengthCache, VALUE_LENGTH_OFFSET); if (idItem->nameLen == 0 || idItem->nameLen > MAX_ITEM_LENGTH) { + HILOG_ERROR("GetIdItem idItem nameLen %u invalid", idItem->nameLen); free(idItem->value); idItem->value = NULL; return MC_FAILURE; @@ -465,10 +492,12 @@ static int32_t GetIdItem(int32_t file, uint32_t offset, IdItem *idItem) idItem->name = (char *)malloc(idItem->nameLen); if (idItem->name == NULL) { + HILOG_ERROR("GetIdItem idItem name is null"); free(idItem->value); idItem->value = NULL; return MC_FAILURE; } + HILOG_INFO("GetIdItem file: %d, idItem->name: %s, idItem->nameLen: %u", file, idItem->name, idItem->nameLen); (void)memset_s(idItem->name, idItem->nameLen, 0, idItem->nameLen); (void)read(file, idItem->name, idItem->nameLen); @@ -496,18 +525,22 @@ static uint32_t GetIdHeaderOffsetByLocale(const char *locale, const Key *keys, u static int32_t GetIdHeaderByOffset(int32_t file, uint32_t offset, IdHeader *idHeader) { if (file == -1 || offset == INVALID_OFFSET || idHeader == NULL) { + HILOG_ERROR("GetIdHeaderByOffset input params invalid"); return MC_FAILURE; } (void)lseek(file, (int32_t)offset + INDEX_DEFAULT_OFFSET, SEEK_SET); // skip the "IDSS" header idHeader->count = GetDefaultOffsetValue(file); if (idHeader->count == 0 || idHeader->count > MAX_ID_ITEM_NUM) { + HILOG_ERROR("GetIdHeaderByOffset idHeader count %u invalid", idHeader->count); return MC_FAILURE; } idHeader->idParams = (IdParam *)malloc(sizeof(IdParam) * idHeader->count); if (idHeader->idParams == NULL) { + HILOG_ERROR("GetIdHeaderByOffset idHeader idParams is null, idHeader->count: %u", idHeader->count); return MC_FAILURE; } + HILOG_INFO("GetIdHeaderByOffset file: %d, idHeader->count: %u", file, idHeader->count); for (uint32_t i = 0; i < idHeader->count; i++) { idHeader->idParams[i].id = GetDefaultOffsetValue(file); idHeader->idParams[i].offset = GetDefaultOffsetValue(file); -- Gitee