diff --git a/brightness_manager/BUILD.gn b/brightness_manager/BUILD.gn index 145b20e10207e384bda85a9fac7765590c0209a7..a94c6940043ab650cc98300e0755d6c1074439d2 100644 --- a/brightness_manager/BUILD.gn +++ b/brightness_manager/BUILD.gn @@ -54,6 +54,7 @@ ohos_static_library("brightness_manager") { external_deps = [ "ability_base:zuri", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "data_share:datashare_consumer", "eventhandler:libeventhandler", @@ -63,7 +64,6 @@ ohos_static_library("brightness_manager") { "hilog:libhilog", "image_framework:image_native", "ipc:ipc_core", - "jsoncpp:jsoncpp", "power_manager:power_ffrt", "power_manager:power_setting", "power_manager:power_sysparam", diff --git a/brightness_manager/include/config_parser_base.h b/brightness_manager/include/config_parser_base.h index 3b094ffa810a3aaff8a496b69fa034662cfac9c6..79000898e10aedc00870b8e27429f5c08933930f 100644 --- a/brightness_manager/include/config_parser_base.h +++ b/brightness_manager/include/config_parser_base.h @@ -16,13 +16,14 @@ #ifndef CONFIG_PARSER_BASE_H #define CONFIG_PARSER_BASE_H -#include #include #include #include -#include "calculation_config_parser.h" +#include + #include "brightness_config_parser.h" +#include "calculation_config_parser.h" namespace OHOS { namespace DisplayPowerMgr { @@ -37,10 +38,10 @@ public: void Initialize(); const std::string LoadConfigPath(int displayId, const std::string& configName) const; - const Json::Value LoadConfigRoot(int displayId, const std::string& configName) const; - void ParsePointXy(const Json::Value& root, const std::string& name, std::vector& data) const; + const cJSON* LoadConfigRoot(int displayId, const std::string& configName) const; + void ParsePointXy(const cJSON* root, const std::string& name, std::vector& data) const; const std::string PointXyToString(const std::string& name, const std::vector& data) const; - void ParseScreenData(const Json::Value& root, const std::string& name, std::unordered_map& data, + void ParseScreenData(const cJSON* root, const std::string& name, std::unordered_map& data, const std::string paramName) const; const std::string ScreenDataToString(const std::string& name, const std::unordered_map& data, const std::string paramName) const; diff --git a/brightness_manager/include/lux_filter_config_parser.h b/brightness_manager/include/lux_filter_config_parser.h index f01f1a09a1d8f758363a14ef586be223bcd16baa..3a2556b3190f88b6237530c7d6aff6748b5227a8 100644 --- a/brightness_manager/include/lux_filter_config_parser.h +++ b/brightness_manager/include/lux_filter_config_parser.h @@ -18,6 +18,7 @@ #include #include +#include namespace OHOS { namespace DisplayPowerMgr { @@ -39,6 +40,8 @@ public: LuxFilterConfigParser(LuxFilterConfigParser&&) = delete; LuxFilterConfigParser& operator=(LuxFilterConfigParser&&) = delete; + static void LuxFilterParseConfigParams( + cJSON* item, std::unordered_map& data); static bool ParseConfig( int displayId, std::unordered_map& data); static void PrintConfig( diff --git a/brightness_manager/include/lux_threshold_config_parser.h b/brightness_manager/include/lux_threshold_config_parser.h index d8f16d462ce2c3bf386892d738dd3d8cf788a293..9da71461c29be64d950e9fc177447cff932144b6 100644 --- a/brightness_manager/include/lux_threshold_config_parser.h +++ b/brightness_manager/include/lux_threshold_config_parser.h @@ -20,6 +20,7 @@ #include #include +#include #include "calculation_config_parser.h" namespace OHOS { @@ -47,6 +48,7 @@ public: LuxThresholdConfigParser(LuxThresholdConfigParser&&) = delete; LuxThresholdConfigParser& operator=(LuxThresholdConfigParser&&) = delete; + static void LuxThresholdParseConfigParams(cJSON* item, LuxThresholdConfig::Data& data); static bool ParseConfig(int displayId, LuxThresholdConfig::Data& data); static void PrintConfig(int displayId, const LuxThresholdConfig::Data& data); }; diff --git a/brightness_manager/src/brightness_config_parser.cpp b/brightness_manager/src/brightness_config_parser.cpp index b9ab5232f0d6a9a0b037bc8f4e8ee9d6fb51a9ab..c5dcb293af66628a5622ffac6206c43af78eac5c 100644 --- a/brightness_manager/src/brightness_config_parser.cpp +++ b/brightness_manager/src/brightness_config_parser.cpp @@ -16,7 +16,7 @@ #include "brightness_config_parser.h" #include -#include +#include #include "config_parser_base.h" #include "display_log.h" @@ -32,12 +32,21 @@ using namespace OHOS::DisplayPowerMgr; bool BrightnessConfigParser::ParseConfig(BrightnessConfig::Data& data) { DISPLAY_HILOGI(FEAT_BRIGHTNESS, "parse BrightnessConfigParser start!"); - const Json::Value root = ConfigParserBase::Get().LoadConfigRoot(0, CONFIG_NAME); - if (root.isNull()) { + const cJSON* root = ConfigParserBase::Get().LoadConfigRoot(0, CONFIG_NAME); + if (!root) { + DISPLAY_HILOGI(FEAT_BRIGHTNESS, "parse BrightnessConfigParser error!"); return false; } + if (!cJSON_IsObject(root)) { + DISPLAY_HILOGI(FEAT_BRIGHTNESS, "root is not an object!"); + cJSON_Delete(const_cast(root)); + return false; + } + ConfigParserBase::Get().ParseScreenData(root, "displayModeData", data.displayModeMap, "displayMode"); ConfigParserBase::Get().ParseScreenData(root, "foldStatus", data.foldStatusModeMap, "foldStatus"); + + cJSON_Delete(const_cast(root)); DISPLAY_HILOGI(FEAT_BRIGHTNESS, "parse BrightnessConfigParser over!"); return true; } diff --git a/brightness_manager/src/calculation_config_parser.cpp b/brightness_manager/src/calculation_config_parser.cpp index 960c3b427d0e26dd0ef2c4269f24d78228ac5290..f42214662d76c6af7efffcc9f135242582610157 100644 --- a/brightness_manager/src/calculation_config_parser.cpp +++ b/brightness_manager/src/calculation_config_parser.cpp @@ -16,7 +16,7 @@ #include "calculation_config_parser.h" #include -#include +#include #include "config_parser_base.h" #include "display_log.h" @@ -32,16 +32,27 @@ using namespace OHOS::DisplayPowerMgr; bool CalculationConfigParser::ParseConfig(int displayId, CalculationConfig::Data& data) { DISPLAY_HILOGI(FEAT_BRIGHTNESS, "[%{public}d] parse CalculationConfig start!", displayId); - const Json::Value root = ConfigParserBase::Get().LoadConfigRoot(displayId, CONFIG_NAME); - if (root.isNull()) { + const cJSON* root = ConfigParserBase::Get().LoadConfigRoot(displayId, CONFIG_NAME); + if (!root) { + DISPLAY_HILOGI(FEAT_BRIGHTNESS, "[%{public}d] parse CalculationConfig error!", displayId); return false; } - if (root["defaultBrightness"].isNumeric()) { - data.defaultBrightness = root["defaultBrightness"].asFloat(); + if (!cJSON_IsObject(root)) { + DISPLAY_HILOGI(FEAT_BRIGHTNESS, "root is not an object!"); + cJSON_Delete(const_cast(root)); + return false; + } + + const cJSON* defaultBrightnessNode = cJSON_GetObjectItemCaseSensitive(root, "defaultBrightness"); + if (defaultBrightnessNode && cJSON_IsNumber(defaultBrightnessNode)) { + data.defaultBrightness = static_cast(defaultBrightnessNode->valuedouble); } else { DISPLAY_HILOGW(FEAT_BRIGHTNESS, "[%{public}d] parse defaultBrightness error!", displayId); } + ConfigParserBase::Get().ParsePointXy(root, "defaultPoints", data.defaultPoints); + + cJSON_Delete(const_cast(root)); DISPLAY_HILOGI(FEAT_BRIGHTNESS, "[%{public}d] parse CalculationConfig over!", displayId); return true; } diff --git a/brightness_manager/src/config_parser_base.cpp b/brightness_manager/src/config_parser_base.cpp index 2c738e9a56c07d848e2b6ff58202cefc9d7dc67b..decc9ede3aefe0d12babf6966b294ae75c2906eb 100644 --- a/brightness_manager/src/config_parser_base.cpp +++ b/brightness_manager/src/config_parser_base.cpp @@ -26,6 +26,8 @@ namespace DisplayPowerMgr { namespace { constexpr int DISPLAY_ID_MAX = 5; constexpr uint16_t POINT_XY_SIZE = 2; +constexpr int POINT_X_INDEX = 0; +constexpr int POINT_Y_INDEX = 1; const std::string CONFIG_PATH_FOR_ROOT = "/sys_prod/etc/display/"; const std::string CONFIG_PATH_TYP = ".json"; const std::string CONFIG_PATHS[DISPLAY_ID_MAX] = { @@ -124,54 +126,64 @@ const std::string ConfigParserBase::LoadConfigPath(int displayId, const std::str return configPath; } -const Json::Value ConfigParserBase::LoadConfigRoot(int displayId, const std::string& configName) const +const cJSON* ConfigParserBase::LoadConfigRoot(int displayId, const std::string& configName) const { DISPLAY_HILOGI(FEAT_BRIGHTNESS, "[%{public}d] LoadConfigRoot [%{public}s]!", displayId, configName.c_str()); const std::string configPath = LoadConfigPath(displayId, configName); std::ifstream fileStream(configPath, std::ios::in | std::ios::binary); if (!fileStream) { DISPLAY_HILOGE(FEAT_BRIGHTNESS, "Open file %{public}s failure.", configName.c_str()); - return Json::Value(); - } - Json::Reader reader; - Json::Value root; - if (reader.parse(fileStream, root)) { - fileStream.close(); - return root; + return nullptr; } + + std::string fileContent((std::istreambuf_iterator(fileStream)), std::istreambuf_iterator()); fileStream.close(); - return Json::Value(); + cJSON* root = cJSON_Parse(fileContent.c_str()); + if (!root) { + DISPLAY_HILOGE(FEAT_BRIGHTNESS, "Parse file %{public}s failure.", configName.c_str()); + return nullptr; + } + return root; } void ConfigParserBase::ParsePointXy( - const Json::Value& root, const std::string& name, std::vector& data) const + const cJSON* root, const std::string& name, std::vector& data) const { data.clear(); - if (!root[name.c_str()].isArray()) { - DISPLAY_HILOGW(FEAT_BRIGHTNESS, "root <%{public}s> is not found!", name.c_str()); + const cJSON* array = cJSON_GetObjectItemCaseSensitive(root, name.c_str()); + if (!array || !cJSON_IsArray(array)) { + DISPLAY_HILOGW(FEAT_BRIGHTNESS, "root <%{public}s> is not found or is not an array!", name.c_str()); return; } - Json::Value array = root[name.c_str()]; - for (auto value : array) { - if (!value.isArray()) { - DISPLAY_HILOGW(FEAT_BRIGHTNESS, "array <%{public}s> is not found!", name.c_str()); + + cJSON* item = nullptr; + cJSON_ArrayForEach(item, array) { + if (!cJSON_IsArray(item)) { + DISPLAY_HILOGW(FEAT_BRIGHTNESS, "array <%{public}s> element is not an array!", name.c_str()); return; } + PointXy pointXy{}; - if (static_cast(value.size()) != POINT_XY_SIZE) { + uint32_t arraySize = (uint32_t)cJSON_GetArraySize(item); + if (arraySize != POINT_XY_SIZE) { DISPLAY_HILOGW(FEAT_BRIGHTNESS, "array <%{public}s> size!=%{public}d!", name.c_str(), POINT_XY_SIZE); return; } - if (value[0].isNumeric()) { - pointXy.x = value[0].asFloat(); + + const cJSON* xNode = cJSON_GetArrayItem(item, POINT_X_INDEX); + if (xNode && cJSON_IsNumber(xNode)) { + pointXy.x = static_cast(xNode->valuedouble); } else { DISPLAY_HILOGW(FEAT_BRIGHTNESS, "parse [%{public}s] error!", name.c_str()); } - if (value[1].isNumeric()) { - pointXy.y = value[1].asFloat(); + + const cJSON* yNode = cJSON_GetArrayItem(item, POINT_Y_INDEX); + if (yNode && cJSON_IsNumber(yNode)) { + pointXy.y = static_cast(yNode->valuedouble); } else { DISPLAY_HILOGW(FEAT_BRIGHTNESS, "parse [%{public}s] error!", name.c_str()); } + data.emplace_back(pointXy); } } @@ -188,27 +200,38 @@ const std::string ConfigParserBase::PointXyToString( } -void ConfigParserBase::ParseScreenData(const Json::Value& root, const std::string& name, +void ConfigParserBase::ParseScreenData(const cJSON* root, const std::string& name, std::unordered_map& data, const std::string paramName) const { data.clear(); - if (!root[name.c_str()].isArray()) { - DISPLAY_HILOGW(FEAT_BRIGHTNESS, "root <%{public}s> is not found!", name.c_str()); + const cJSON* array = cJSON_GetObjectItemCaseSensitive(root, name.c_str()); + if (!array || !cJSON_IsArray(array)) { + DISPLAY_HILOGW(FEAT_BRIGHTNESS, "root <%{public}s> is not found or is not an array!", name.c_str()); return; } - Json::Value array = root[name.c_str()]; - for (auto value : array) { + + cJSON* item = nullptr; + cJSON_ArrayForEach(item, array) { + if (!cJSON_IsObject(item)) { + continue; + } ScreenData screenData{}; int displayMode = 0; - if (value[paramName].isNumeric()) { - displayMode = value[paramName].asInt(); + const cJSON* displayModeNode = cJSON_GetObjectItemCaseSensitive(item, paramName.c_str()); + if (displayModeNode && cJSON_IsNumber(displayModeNode)) { + displayMode = displayModeNode->valueint; } - if (value["displayId"].isNumeric()) { - screenData.displayId = value["displayId"].asInt(); + + const cJSON* displayIdNode = cJSON_GetObjectItemCaseSensitive(item, "displayId"); + if (displayIdNode && cJSON_IsNumber(displayIdNode)) { + screenData.displayId = displayIdNode->valueint; } - if (value["sensorId"].isNumeric()) { - screenData.sensorId = value["sensorId"].asInt(); + + const cJSON* sensorIdNode = cJSON_GetObjectItemCaseSensitive(item, "sensorId"); + if (sensorIdNode && cJSON_IsNumber(sensorIdNode)) { + screenData.sensorId = sensorIdNode->valueint; } + data[displayMode] = screenData; } } diff --git a/brightness_manager/src/lux_filter_config_parser.cpp b/brightness_manager/src/lux_filter_config_parser.cpp index ce39e970321fd42d6f7ce1f58c60b76c4b5e3168..522e3aa69b88a3f0688f457359f1a13b5e94d147 100644 --- a/brightness_manager/src/lux_filter_config_parser.cpp +++ b/brightness_manager/src/lux_filter_config_parser.cpp @@ -16,7 +16,6 @@ #include "lux_filter_config_parser.h" #include -#include #include "config_parser_base.h" #include "display_log.h" @@ -34,44 +33,66 @@ void SetDefault(std::unordered_map& data) using namespace OHOS::DisplayPowerMgr; +void LuxFilterConfigParser::LuxFilterParseConfigParams( + cJSON* item, std::unordered_map& data) +{ + LuxFilterConfig::Data config{}; + std::string name; + const cJSON* filterNameNode = cJSON_GetObjectItemCaseSensitive(item, "filterName"); + if (filterNameNode && cJSON_IsString(filterNameNode) && filterNameNode->valuestring && + strlen(filterNameNode->valuestring) > 0) { + name = filterNameNode->valuestring; + } else { + DISPLAY_HILOGW(FEAT_BRIGHTNESS, "<%{public}s> filterName is not found!", CONFIG_NAME.c_str()); + return; + } + const cJSON* filterNoFilterNumNode = cJSON_GetObjectItemCaseSensitive(item, "filterNoFilterNum"); + if (filterNoFilterNumNode && cJSON_IsNumber(filterNoFilterNumNode)) { + config.filterNoFilterNum = filterNoFilterNumNode->valueint; + } + const cJSON* filterNumNode = cJSON_GetObjectItemCaseSensitive(item, "filterNum"); + if (filterNumNode && cJSON_IsNumber(filterNumNode)) { + config.filterNum = filterNumNode->valueint; + } + const cJSON* filterMaxFuncLuxNumNode = cJSON_GetObjectItemCaseSensitive(item, "filterMaxFuncLuxNum"); + if (filterMaxFuncLuxNumNode && cJSON_IsNumber(filterMaxFuncLuxNumNode)) { + config.filterMaxFuncLuxNum = filterMaxFuncLuxNumNode->valueint; + } + const cJSON* filterAlphaNode = cJSON_GetObjectItemCaseSensitive(item, "filterAlpha"); + if (filterAlphaNode && cJSON_IsNumber(filterAlphaNode)) { + config.filterAlpha = static_cast(filterAlphaNode->valuedouble); + } + const cJSON* filterLuxThNode = cJSON_GetObjectItemCaseSensitive(item, "filterLuxTh"); + if (filterLuxThNode && cJSON_IsNumber(filterLuxThNode)) { + config.filterLuxTh = filterLuxThNode->valueint; + } + data.insert(std::make_pair(name, config)); + DISPLAY_HILOGI(FEAT_BRIGHTNESS, "<%{public}s> is insert!", name.c_str()); +} + bool LuxFilterConfigParser::ParseConfig( int displayId, std::unordered_map& data) { DISPLAY_HILOGI(FEAT_BRIGHTNESS, "[%{public}d] parse LuxFilterConfig start!", displayId); - const Json::Value root = ConfigParserBase::Get().LoadConfigRoot(displayId, CONFIG_NAME); - if (root.isNull()) { + const cJSON* root = ConfigParserBase::Get().LoadConfigRoot(displayId, CONFIG_NAME); + if (!root) { SetDefault(data); return false; } - if (!root.isArray()) { + if (!cJSON_IsArray(root)) { DISPLAY_HILOGW(FEAT_BRIGHTNESS, "root <%{public}s> is not Array!", CONFIG_NAME.c_str()); + cJSON_Delete(const_cast(root)); return false; } - for (auto value : root) { - LuxFilterConfig::Data config{}; - if (!value["filterName"].isString() || value["filterName"].asString().empty()) { - DISPLAY_HILOGW(FEAT_BRIGHTNESS, "<%{public}s> filterName is not find!", CONFIG_NAME.c_str()); + + cJSON* item = nullptr; + cJSON_ArrayForEach(item, root) { + if (!cJSON_IsObject(item)) { continue; } - std::string name = value["filterName"].asString(); - if (value["filterNoFilterNum"].isInt()) { - config.filterNoFilterNum = value["filterNoFilterNum"].asInt(); - } - if (value["filterNum"].isInt()) { - config.filterNum = value["filterNum"].asInt(); - } - if (value["filterMaxFuncLuxNum"].isInt()) { - config.filterMaxFuncLuxNum = value["filterMaxFuncLuxNum"].asInt(); - } - if (value["filterAlpha"].isNumeric()) { - config.filterAlpha = value["filterAlpha"].asFloat(); - } - if (value["filterLuxTh"].isInt()) { - config.filterLuxTh = value["filterLuxTh"].asInt(); - } - data.insert(std::make_pair(name, config)); - DISPLAY_HILOGI(FEAT_BRIGHTNESS, "<%{public}s> is insert!", name.c_str()); + LuxFilterParseConfigParams(item, data); } + cJSON_Delete(const_cast(root)); DISPLAY_HILOGI(FEAT_BRIGHTNESS, "[%{public}d] parse LuxFilterConfig over!", displayId); return true; } diff --git a/brightness_manager/src/lux_threshold_config_parser.cpp b/brightness_manager/src/lux_threshold_config_parser.cpp index fb9afc355bafef25fd5ec0ff1acdb2bf26f589ce..3eb32645e8529a3f3adf1a118dd7f858ce99b798 100644 --- a/brightness_manager/src/lux_threshold_config_parser.cpp +++ b/brightness_manager/src/lux_threshold_config_parser.cpp @@ -15,7 +15,6 @@ #include "lux_threshold_config_parser.h" -#include #include #include "config_parser_base.h" @@ -67,43 +66,76 @@ void SetDefault(LuxThresholdConfig::Data& data) using namespace OHOS::DisplayPowerMgr; +void LuxThresholdConfigParser::LuxThresholdParseConfigParams(cJSON* item, LuxThresholdConfig::Data& data) +{ + LuxThresholdConfig::Mode config{}; + std::string name; + + const cJSON* modeNameNode = cJSON_GetObjectItemCaseSensitive(item, "modeName"); + if (modeNameNode && cJSON_IsString(modeNameNode) && modeNameNode->valuestring && + strlen(modeNameNode->valuestring) > 0) { + name = modeNameNode->valuestring; + } else { + DISPLAY_HILOGW(FEAT_BRIGHTNESS, "<%{public}s> modeName is not found!", CONFIG_NAME.c_str()); + return; + } + + const cJSON* brightenDebounceTimeNode = cJSON_GetObjectItemCaseSensitive(item, "brightenDebounceTime"); + if (brightenDebounceTimeNode && cJSON_IsNumber(brightenDebounceTimeNode)) { + config.brightenDebounceTime = brightenDebounceTimeNode->valueint; + } + + const cJSON* darkenDebounceTimeNode = cJSON_GetObjectItemCaseSensitive(item, "darkenDebounceTime"); + if (darkenDebounceTimeNode && cJSON_IsNumber(darkenDebounceTimeNode)) { + config.darkenDebounceTime = darkenDebounceTimeNode->valueint; + } + + ConfigParserBase::Get().ParsePointXy(item, "brightenPoints", config.brightenPoints); + ConfigParserBase::Get().ParsePointXy(item, "darkenPoints", config.darkenPoints); + + data.modeArray.insert(std::make_pair(name, config)); + DISPLAY_HILOGI(FEAT_BRIGHTNESS, "<%{public}s> is insert!", name.c_str()); +} + bool LuxThresholdConfigParser::ParseConfig(int displayId, LuxThresholdConfig::Data& data) { DISPLAY_HILOGI(FEAT_BRIGHTNESS, "[%{public}d] parse LuxThresholdConfigParser start!", displayId); - const Json::Value root = ConfigParserBase::Get().LoadConfigRoot(displayId, CONFIG_NAME); - if (root.isNull()) { + const cJSON* root = ConfigParserBase::Get().LoadConfigRoot(displayId, CONFIG_NAME); + if (!root) { SetDefault(data); return false; } - if (root["isLevelEnable"].isBool()) { - data.isLevelEnable = root["isLevelEnable"].asBool(); + if (!cJSON_IsObject(root)) { + DISPLAY_HILOGI(FEAT_BRIGHTNESS, "root is not an object!"); + cJSON_Delete(const_cast(root)); + return false; + } + const cJSON* isLevelEnableNode = cJSON_GetObjectItemCaseSensitive(root, "isLevelEnable"); + if (isLevelEnableNode && cJSON_IsBool(isLevelEnableNode)) { + data.isLevelEnable = cJSON_IsTrue(isLevelEnableNode); } + ConfigParserBase::Get().ParsePointXy( root, "brightenPointsForLevel", data.brightenPointsForLevel); ConfigParserBase::Get().ParsePointXy( root, "darkenPointsForLevel", data.darkenPointsForLevel); - if (!root["thresholdMode"].isArray()) { + + const cJSON* thresholdModeArray = cJSON_GetObjectItemCaseSensitive(root, "thresholdMode"); + if (!thresholdModeArray || !cJSON_IsArray(thresholdModeArray)) { DISPLAY_HILOGW(FEAT_BRIGHTNESS, "root <%{public}s> is not Array!", CONFIG_NAME.c_str()); + cJSON_Delete(const_cast(root)); return false; } - for (auto value : root["thresholdMode"]) { - LuxThresholdConfig::Mode config{}; - if (!value["modeName"].isString() || value["modeName"].asString().empty()) { - DISPLAY_HILOGW(FEAT_BRIGHTNESS, "<%{public}s> modeName is not find!", CONFIG_NAME.c_str()); + + cJSON* item = nullptr; + cJSON_ArrayForEach(item, thresholdModeArray) { + if (!cJSON_IsObject(item)) { continue; } - std::string name = value["modeName"].asString(); - if (value["brightenDebounceTime"].isInt()) { - config.brightenDebounceTime = value["brightenDebounceTime"].asInt(); - } - if (value["darkenDebounceTime"].isInt()) { - config.darkenDebounceTime = value["darkenDebounceTime"].asInt(); - } - ConfigParserBase::Get().ParsePointXy(value, "brightenPoints", config.brightenPoints); - ConfigParserBase::Get().ParsePointXy(value, "darkenPoints", config.darkenPoints); - data.modeArray.insert(std::make_pair(name, config)); - DISPLAY_HILOGI(FEAT_BRIGHTNESS, "<%{public}s> is insert!", name.c_str()); + LuxThresholdParseConfigParams(item, data); } + + cJSON_Delete(const_cast(root)); DISPLAY_HILOGI(FEAT_BRIGHTNESS, "[%{public}d] parse LuxThresholdConfigParser over!", displayId); return true; } diff --git a/brightness_manager/test/unittest/BUILD.gn b/brightness_manager/test/unittest/BUILD.gn index 9fd92c620d1c8ceb7b9a178c9abfb2a4ce2e486d..7d862667bde2b5f4b0f7ed81ee18fe0bfb2d3ca9 100644 --- a/brightness_manager/test/unittest/BUILD.gn +++ b/brightness_manager/test/unittest/BUILD.gn @@ -42,6 +42,7 @@ set_defaults("ohos_unittest") { "ability_base:want", "ability_base:zuri", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_consumer", diff --git a/bundle.json b/bundle.json index 3b15b89a3c913cb29bfd9097ec284eb03f78f5c5..898a2cd39609b1004223e8660659afc0bd7dae5f 100644 --- a/bundle.json +++ b/bundle.json @@ -30,6 +30,7 @@ "components": [ "ability_base", "ability_runtime", + "cJSON", "c_utils", "data_share", "ets_runtime", @@ -42,7 +43,6 @@ "hilog", "ipc", "image_framework", - "jsoncpp", "napi", "power_manager", "safwk", diff --git a/state_manager/service/BUILD.gn b/state_manager/service/BUILD.gn index 85ad61e142c389add817b7f1cec35d8a814e7c2c..820ad3f896b7e3d2d6b1a8b34b2f5c6f28e9796e 100644 --- a/state_manager/service/BUILD.gn +++ b/state_manager/service/BUILD.gn @@ -64,6 +64,7 @@ ohos_shared_library("displaymgrservice") { external_deps += [ "ability_base:zuri", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "data_share:datashare_consumer", "eventhandler:libeventhandler", diff --git a/state_manager/test/fuzztest/adjustbrightness_fuzzer/BUILD.gn b/state_manager/test/fuzztest/adjustbrightness_fuzzer/BUILD.gn index 561d7842b6fab126abf2e05dee90dd9c192d4348..1cda6ac14546af12bd3b7248cbfd471294ce3b8a 100644 --- a/state_manager/test/fuzztest/adjustbrightness_fuzzer/BUILD.gn +++ b/state_manager/test/fuzztest/adjustbrightness_fuzzer/BUILD.gn @@ -65,6 +65,7 @@ ohos_fuzztest("AdjustBrightnessFuzzTest") { "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_common", diff --git a/state_manager/test/fuzztest/autoadjustbrightness_fuzzer/BUILD.gn b/state_manager/test/fuzztest/autoadjustbrightness_fuzzer/BUILD.gn index 87ee95998fb4dcdf9a1286d08684b1bd6a276d91..4b90ef2feaae1d999f2e9c36c9416c0a86ac8cd6 100644 --- a/state_manager/test/fuzztest/autoadjustbrightness_fuzzer/BUILD.gn +++ b/state_manager/test/fuzztest/autoadjustbrightness_fuzzer/BUILD.gn @@ -65,6 +65,7 @@ ohos_fuzztest("AutoAdjustBrightnessFuzzTest") { "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_common", diff --git a/state_manager/test/fuzztest/boostbrightness_fuzzer/BUILD.gn b/state_manager/test/fuzztest/boostbrightness_fuzzer/BUILD.gn index ac54ba24cb4cf0cea258a00fea26b296e92bb719..120abe7f482376648412aaea9d5131d9eded6638 100644 --- a/state_manager/test/fuzztest/boostbrightness_fuzzer/BUILD.gn +++ b/state_manager/test/fuzztest/boostbrightness_fuzzer/BUILD.gn @@ -65,6 +65,7 @@ ohos_fuzztest("BoostBrightnessFuzzTest") { "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_common", diff --git a/state_manager/test/fuzztest/discountbrightness_fuzzer/BUILD.gn b/state_manager/test/fuzztest/discountbrightness_fuzzer/BUILD.gn index da49b44271283d0aed6a2b764983a3e59afbb650..cca9a4da6ebab5531cfca8f80bfc924c45361786 100644 --- a/state_manager/test/fuzztest/discountbrightness_fuzzer/BUILD.gn +++ b/state_manager/test/fuzztest/discountbrightness_fuzzer/BUILD.gn @@ -65,6 +65,7 @@ ohos_fuzztest("DiscountBrightnessFuzzTest") { "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_common", diff --git a/state_manager/test/fuzztest/displaycoverage_fuzzer/BUILD.gn b/state_manager/test/fuzztest/displaycoverage_fuzzer/BUILD.gn index c53f84b33d2f4457fc3611713921f6fe875c4e2d..500ea03de0a6c6e9256b7551173a834e5920bd6f 100644 --- a/state_manager/test/fuzztest/displaycoverage_fuzzer/BUILD.gn +++ b/state_manager/test/fuzztest/displaycoverage_fuzzer/BUILD.gn @@ -65,6 +65,7 @@ ohos_fuzztest("DisplayCoverageFuzzTest") { "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_common", diff --git a/state_manager/test/fuzztest/displaystate_fuzzer/BUILD.gn b/state_manager/test/fuzztest/displaystate_fuzzer/BUILD.gn index d5fd071b6e57a41ae77902df20215fdcb95fe8b3..8212a6219afe4c50cf1655952cfc2b92c57bd0c7 100644 --- a/state_manager/test/fuzztest/displaystate_fuzzer/BUILD.gn +++ b/state_manager/test/fuzztest/displaystate_fuzzer/BUILD.gn @@ -64,6 +64,7 @@ ohos_fuzztest("DisplayStateFuzzTest") { "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_common", diff --git a/state_manager/test/fuzztest/getbrightness_fuzzer/BUILD.gn b/state_manager/test/fuzztest/getbrightness_fuzzer/BUILD.gn index c2c3babef69eb697b501bf33a46f6cf5945b4b96..fd0651f1a774a991cc967deacc4bdab1c9a43b93 100644 --- a/state_manager/test/fuzztest/getbrightness_fuzzer/BUILD.gn +++ b/state_manager/test/fuzztest/getbrightness_fuzzer/BUILD.gn @@ -65,6 +65,7 @@ ohos_fuzztest("GetBrightnessFuzzTest") { "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_common", diff --git a/state_manager/test/fuzztest/getdisplayid_fuzzer/BUILD.gn b/state_manager/test/fuzztest/getdisplayid_fuzzer/BUILD.gn index b189fb1984e80bfbe0036a5573b1a2cf04ba1779..cf16e1c8dbfaf74525936d2a7f82e77b468192ca 100644 --- a/state_manager/test/fuzztest/getdisplayid_fuzzer/BUILD.gn +++ b/state_manager/test/fuzztest/getdisplayid_fuzzer/BUILD.gn @@ -64,6 +64,7 @@ ohos_fuzztest("GetDisplayIdFuzzTest") { "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_common", diff --git a/state_manager/test/fuzztest/overridebrightness_fuzzer/BUILD.gn b/state_manager/test/fuzztest/overridebrightness_fuzzer/BUILD.gn index b0bd5e24cb72e2c49106a0bff6c5233d2fedd016..df2a682cffdf73bdc7092376bee752a3cfd6c7f4 100644 --- a/state_manager/test/fuzztest/overridebrightness_fuzzer/BUILD.gn +++ b/state_manager/test/fuzztest/overridebrightness_fuzzer/BUILD.gn @@ -65,6 +65,7 @@ ohos_fuzztest("OverrideBrightnessFuzzTest") { "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_common", diff --git a/state_manager/test/fuzztest/overridedisplayoffdelay_fuzzer/BUILD.gn b/state_manager/test/fuzztest/overridedisplayoffdelay_fuzzer/BUILD.gn index 787a70499738aa8873ecd5c6f500503df9f51ff7..b06925b72a8d298abebe0be2208e8cbe01673613 100644 --- a/state_manager/test/fuzztest/overridedisplayoffdelay_fuzzer/BUILD.gn +++ b/state_manager/test/fuzztest/overridedisplayoffdelay_fuzzer/BUILD.gn @@ -65,6 +65,7 @@ ohos_fuzztest("OverrideDisplayOffDelayFuzzTest") { "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_common", diff --git a/state_manager/test/fuzztest/registercallback_fuzzer/BUILD.gn b/state_manager/test/fuzztest/registercallback_fuzzer/BUILD.gn index 6095b5f14cbe116ca8074352b8d7d5ef19803129..9a7158f0a56f22e4a7da4de19b6bdba4a4b8a246 100644 --- a/state_manager/test/fuzztest/registercallback_fuzzer/BUILD.gn +++ b/state_manager/test/fuzztest/registercallback_fuzzer/BUILD.gn @@ -65,6 +65,7 @@ ohos_fuzztest("RegisterCallbackFuzzTest") { "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_common", diff --git a/state_manager/test/fuzztest/setbrightness_fuzzer/BUILD.gn b/state_manager/test/fuzztest/setbrightness_fuzzer/BUILD.gn index 0bbcd31690df9d00bb435a1a0a533a6677ed6918..88feb5374671c9655c9a7420d917adc45ee6d085 100644 --- a/state_manager/test/fuzztest/setbrightness_fuzzer/BUILD.gn +++ b/state_manager/test/fuzztest/setbrightness_fuzzer/BUILD.gn @@ -65,6 +65,7 @@ ohos_fuzztest("SetBrightnessFuzzTest") { "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_common", diff --git a/state_manager/test/fuzztest/setcoordinated_fuzzer/BUILD.gn b/state_manager/test/fuzztest/setcoordinated_fuzzer/BUILD.gn index c05780051090a5bb0804f04b09cd7ff3f0bb4bed..723ff1604d5c8f569cd2fee96a8089f45cf13e22 100644 --- a/state_manager/test/fuzztest/setcoordinated_fuzzer/BUILD.gn +++ b/state_manager/test/fuzztest/setcoordinated_fuzzer/BUILD.gn @@ -65,6 +65,7 @@ ohos_fuzztest("SetCoordinatedFuzzTest") { "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_common", diff --git a/state_manager/test/fuzztest/setlightbrightnessthreshold_fuzzer/BUILD.gn b/state_manager/test/fuzztest/setlightbrightnessthreshold_fuzzer/BUILD.gn index e9801ca2914a9ecd9ae82b8f41f7f84c0da8d78f..7954b4a3ced38323ea3c4633df7d6fdf9c65e3ce 100644 --- a/state_manager/test/fuzztest/setlightbrightnessthreshold_fuzzer/BUILD.gn +++ b/state_manager/test/fuzztest/setlightbrightnessthreshold_fuzzer/BUILD.gn @@ -65,6 +65,7 @@ ohos_fuzztest("SetLightBrightnessThresholdFuzzTest") { "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_common", diff --git a/state_manager/test/fuzztest/setmaxbrightness_fuzzer/BUILD.gn b/state_manager/test/fuzztest/setmaxbrightness_fuzzer/BUILD.gn index e14681c9187aaa052f026f8734873ae979b77419..0b8370e525a614fca4a2fb5fee701e7361f91abc 100644 --- a/state_manager/test/fuzztest/setmaxbrightness_fuzzer/BUILD.gn +++ b/state_manager/test/fuzztest/setmaxbrightness_fuzzer/BUILD.gn @@ -65,6 +65,7 @@ ohos_fuzztest("SetMaxBrightnessFuzzTest") { "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "common_event_service:cesfwk_innerkits", "data_share:datashare_common", diff --git a/state_manager/test/unittest/BUILD.gn b/state_manager/test/unittest/BUILD.gn index d9f1af7cdfa64b0c2d89eb3d190098c7570547b9..0f6654207eb340f966e2247ce7bec193dc7be8de 100644 --- a/state_manager/test/unittest/BUILD.gn +++ b/state_manager/test/unittest/BUILD.gn @@ -68,6 +68,7 @@ ohos_unittest("unittest_display_mgr_service") { "ability_base:want", "ability_base:zuri", "ability_runtime:ability_manager", + "cJSON:cjson", "c_utils:utils", "data_share:datashare_consumer", "hilog:libhilog",