From: SnickerSun Date: Mon, 29 Apr 2024 07:17:29 +0000 (+0800) Subject: 修复恢复出厂设置后 ConfigModel.json不会再次生成问题 X-Git-Tag: release_V1.2.70_20241020_135402~1025^2~48^2 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=2461e2850bb5d2155ff5365cc3fd67ab05a2b71b;p=mirrors%2FFD230.git 修复恢复出厂设置后 ConfigModel.json不会再次生成问题 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp index 19035b2db..30ea2e204 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp @@ -123,13 +123,22 @@ namespace OHOS reset_item_to_default(item); } } - return true; } else { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Open JSON filePath fail!:%s", filePath.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Open JSON filePath fail!:%s , create a new Json Configfile!", filePath.c_str()); + cjson_json = cJSON_CreateObject(); + for (int i = 0; i< ConfigItem::CONFIGMODEL_ITEM_MAX;i++) + { + ConfigItem item = (ConfigItem)i; + cJSON *obj=get_item(item); + if (obj == NULL) //没有变量则用默认值初始化 + { + reset_item_to_default(item); + } + } } - return false; + return true; } /*1.读取字符串*/