diff --git a/OAT.xml b/OAT.xml
old mode 100755
new mode 100644
diff --git a/README.md b/README.md
index 456e3aa939d39d823b941f69edbde0621d99c8c9..afc70f5970eae80b52bf8f6a624f13a674690444 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
+│ │ └── inner_api # APIs of the resource management module for internal subsystems
```
## Usage
@@ -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 dd1884153a76fe0d48fedec355e8f9f5fa92f8e1..2f242080a2d551f45fdc874b3d471a7e587146c4 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 # 资源管理接口
+│ │ └── inner_api # 资源管理对子系统间接口
```
## 说明
@@ -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)
-
diff --git a/bundle.json b/bundle.json
new file mode 100644
index 0000000000000000000000000000000000000000..9150456a76db1ec765946ce2bc8df228e6cb2226
--- /dev/null
+++ b/bundle.json
@@ -0,0 +1,66 @@
+{
+ "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_resource_management_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/resource_management_lite"
+ },
+ "component": {
+ "name": "resource_management_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/resource_management_lite/frameworks/resmgr_lite:global_resmgr"
+ ],
+ "inner_kits": [],
+ "test": [
+ "//base/global/resource_management_lite/frameworks/resmgr_lite/test:unittest"
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/frameworks/resmgr_lite/BUILD.gn b/frameworks/resmgr_lite/BUILD.gn
index ce3ca97e97e60a4336ac3dbd9d33a011ea7365ea..9b0dcf263ff5f597addfe4eece8c949f1e35467f 100644
--- 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",
@@ -45,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/inner_api/include",
"//utils/native/lite/include",
"//third_party/bounds_checking_function/include",
]
@@ -62,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/inner_api/include",
]
}
@@ -80,16 +78,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",
+ ]
+ }
}
}
diff --git a/frameworks/resmgr_lite/CMakeLists.txt b/frameworks/resmgr_lite/CMakeLists.txt
index d561265cf69dc2ea5e4b506b533e65a0f4257d5d..276159a5286115a397bdfaf88b04c141a7bcbeaa 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/inner_api/include")
include_directories(${PROJECT_SOURCE_DIR}/third_party/bounds_checking_function/include)
diff --git a/frameworks/resmgr_lite/include/auto_mutex.h b/frameworks/resmgr_lite/include/auto_mutex.h
index 58e1026678770566f2d40dc61917ea3d378f0965..756eec091c24578a132d32678daaa51e5f02a5c6 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/global_utils.h b/frameworks/resmgr_lite/include/global_utils.h
index 6bd8c486161f855f8bcd2bf1fea6724248ffb0e7..a2cedd46d7811f4125abd8da09e697add8ffa003 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_manager.h b/frameworks/resmgr_lite/include/hap_manager.h
index 8c2485c10387a21df91123813ffb3faf4fdcc29f..1c3da3e98872388105b65ce9cdd4d4ae4a5c14a6 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,24 +29,71 @@ namespace Global {
namespace Resource {
class HapManager {
public:
- HapManager(ResConfigImpl *resConfig);
-
+ /**
+ * The constructor of HapManager
+ */
+ explicit HapManager(ResConfigImpl *resConfig);
+
+ /**
+ * The destructor of HapManager
+ */
~HapManager();
+ /**
+ * Update the resConfig
+ * @param resConfig the resource config
+ * @return SUCCESS if the resConfig updated success, else HAP_INIT_FAILED
+ */
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 related to 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 related to 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 related to quantity
+ * @param quantity the language quantity
+ * @return the language pluralRule related 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 85dd13d7835506aaf1c3c3c890d551aa53e0fbf8..900149fd1ee6c5a51581de5c7a1f01ccba9a47ec 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
@@ -51,16 +51,45 @@ 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 related to 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 related to the value
+ */
static ScreenDensity GetScreenDensity(uint32_t value);
+ /**
+ * Get device type
+ * @param value the type of device
+ * @return the device type related to the value
+ */
static DeviceType GetDeviceType(uint32_t value);
+
private:
static const char *RES_FILE_NAME;
};
diff --git a/frameworks/resmgr_lite/include/hap_resource.h b/frameworks/resmgr_lite/include/hap_resource.h
index 007b8990d5bbabf5ce1095dfd9ba21b30aa9fc48..59397a1b08122283edc6d84974f5d552a9a0a15c 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