修复恢复出厂设置后 ConfigModel.json不会再次生成问题 110/target/2 112/2 112/head 113/target/1
authorSnickerSun <snickersun@163.com>
Mon, 29 Apr 2024 07:17:29 +0000 (15:17 +0800)
committerSnickerSun <snickersun@163.com>
Mon, 29 Apr 2024 07:17:29 +0000 (15:17 +0800)
code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp

index 19035b2..30ea2e2 100644 (file)
@@ -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.读取字符串*/