• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "form_info.h"
17 
18 #include <errno.h>
19 #include <fcntl.h>
20 #include <string.h>
21 #include <unistd.h>
22 
23 #include "app_log_wrapper.h"
24 #include "bundle_constants.h"
25 #include "json_serializer.h"
26 #include "json_util.h"
27 #include "nlohmann/json.hpp"
28 #include "parcel_macro.h"
29 #include "string_ex.h"
30 
31 namespace OHOS {
32 namespace AppExecFwk {
33 namespace {
34 const std::string JSON_KEY_COLOR_MODE = "colorMode";
35 const std::string JSON_KEY_PACKAGE = "package";
36 const std::string JSON_KEY_SUPPORT_DIMENSIONS = "supportDimensions";
37 const std::string JSON_KEY_DEFAULT_DIMENSION = "defaultDimension";
38 const std::string JSON_KEY_UPDATE_ENABLED = "updateEnabled";
39 const std::string JSON_KEY_SCHEDULED_UPDATE_TIME = "scheduledUpdateTime";
40 const std::string JSON_KEY_UPDATE_DURATION = "updateDuration";
41 const std::string JSON_KEY_DEEP_LINK = "deepLink";
42 const std::string JSON_KEY_JS_COMPONENT_NAME = "jsComponentName";
43 const std::string JSON_KEY_VALUE = "value";
44 const std::string JSON_KEY_NAME = "name";
45 const std::string JSON_KEY_ORIGINAL_BUNDLE_NAME = "originalBundleName";
46 const std::string JSON_KEY_CUSTOMIZE_DATA = "customizeData";
47 const std::string JSON_KEY_DESCRIPTION = "description";
48 const std::string JSON_KEY_DESCRIPTION_ID = "descriptionId";
49 const std::string JSON_KEY_TYPE = "type";
50 const std::string JSON_KEY_UI_SYNTAX = "uiSyntax";
51 const std::string JSON_KEY_LANDSCAPE_LAYOUTS = "landscapeLayouts";
52 const std::string JSON_KEY_FORMCONFIG_ABILITY = "formConfigAbility";
53 const std::string JSON_KEY_FORM_VISIBLE_NOTIFY = "formVisibleNotify";
54 const std::string JSON_KEY_RELATED_BUNDLE_NAME = "relatedBundleName";
55 const std::string JSON_KEY_DEFAULT_FLAG = "defaultFlag";
56 const std::string JSON_KEY_PORTRAIT_LAYOUTS = "portraitLayouts";
57 const std::string JSON_KEY_SRC = "src";
58 const std::string JSON_KEY_WINDOW = "window";
59 const std::string JSON_KEY_DESIGN_WIDTH = "designWidth";
60 const std::string JSON_KEY_AUTO_DESIGN_WIDTH = "autoDesignWidth";
61 const std::string JSON_KEY_IS_STATIC = "isStatic";
62 const std::string JSON_KEY_DATA_PROXY_ENABLED = "dataProxyEnabled";
63 const std::string JSON_KEY_IS_DYNAMIC = "isDynamic";
64 }  // namespace
65 
FormInfo(const ExtensionAbilityInfo & abilityInfo,const ExtensionFormInfo & formInfo)66 FormInfo::FormInfo(const ExtensionAbilityInfo &abilityInfo, const ExtensionFormInfo &formInfo)
67 {
68     package = abilityInfo.bundleName + abilityInfo.moduleName;
69     bundleName = abilityInfo.bundleName;
70     originalBundleName = abilityInfo.bundleName;
71     relatedBundleName = abilityInfo.bundleName;
72     moduleName = abilityInfo.moduleName;
73     abilityName = abilityInfo.name;
74     name = formInfo.name;
75     description = formInfo.description;
76     jsComponentName = "";
77     deepLink = "";
78     formConfigAbility = formInfo.formConfigAbility;
79     scheduledUpdateTime = formInfo.scheduledUpdateTime;
80     src = formInfo.src;
81     window.designWidth = formInfo.window.designWidth;
82     window.autoDesignWidth = formInfo.window.autoDesignWidth;
83     std::size_t pos = formInfo.description.find(":");
84     if (pos != std::string::npos) {
85         descriptionId = atoi(formInfo.description.substr(pos + 1, formInfo.description.length() - pos - 1).c_str());
86     }
87     updateDuration = formInfo.updateDuration;
88     defaultDimension = formInfo.defaultDimension;
89     defaultFlag = formInfo.isDefault;
90     formVisibleNotify = formInfo.formVisibleNotify;
91     updateEnabled = formInfo.updateEnabled;
92     type = formInfo.type;
93     uiSyntax = formInfo.uiSyntax;
94     colorMode = formInfo.colorMode;
95     for (const auto &dimension : formInfo.supportDimensions) {
96         supportDimensions.push_back(dimension);
97     }
98     for (const auto &metadata : formInfo.metadata) {
99         customizeDatas.push_back(metadata);
100     }
101     dataProxyEnabled = formInfo.dataProxyEnabled;
102     isDynamic = formInfo.isDynamic;
103 }
104 
ReadCustomizeData(Parcel & parcel)105 bool FormInfo::ReadCustomizeData(Parcel &parcel)
106 {
107     int32_t customizeDataSize = 0;
108     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, customizeDataSize);
109     CONTAINER_SECURITY_VERIFY(parcel, customizeDataSize, &customizeDatas);
110     for (auto i = 0; i < customizeDataSize; ++i) {
111         FormCustomizeData customizeData;
112         std::string customizeName = Str16ToStr8(parcel.ReadString16());
113         std::string customizeValue = Str16ToStr8(parcel.ReadString16());
114         customizeData.name = customizeName;
115         customizeData.value = customizeValue;
116         customizeDatas.emplace_back(customizeData);
117     }
118     return true;
119 }
120 
ReadFromParcel(Parcel & parcel)121 bool FormInfo::ReadFromParcel(Parcel &parcel)
122 {
123     name = Str16ToStr8(parcel.ReadString16());
124     package = Str16ToStr8(parcel.ReadString16());
125     bundleName = Str16ToStr8(parcel.ReadString16());
126     moduleName = Str16ToStr8(parcel.ReadString16());
127     abilityName = Str16ToStr8(parcel.ReadString16());
128     description = Str16ToStr8(parcel.ReadString16());
129     formConfigAbility = Str16ToStr8(parcel.ReadString16());
130     scheduledUpdateTime = Str16ToStr8(parcel.ReadString16());
131     jsComponentName = Str16ToStr8(parcel.ReadString16());
132     relatedBundleName = Str16ToStr8(parcel.ReadString16());
133     originalBundleName = Str16ToStr8(parcel.ReadString16());
134     deepLink = Str16ToStr8(parcel.ReadString16());
135     src = Str16ToStr8(parcel.ReadString16());
136     updateEnabled = parcel.ReadBool();
137     defaultFlag = parcel.ReadBool();
138     formVisibleNotify = parcel.ReadBool();
139     isStatic = parcel.ReadBool();
140     defaultDimension = parcel.ReadInt32();
141     descriptionId = parcel.ReadInt32();
142     updateDuration = parcel.ReadInt32();
143 
144     int32_t typeData;
145     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, typeData);
146     type = static_cast<FormType>(typeData);
147 
148     int32_t uiSyntaxData;
149     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, uiSyntaxData);
150     uiSyntax = static_cast<FormType>(uiSyntaxData);
151 
152     int32_t colorModeData;
153     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, colorModeData);
154     colorMode = static_cast<FormsColorMode>(colorModeData);
155 
156     int32_t supportDimensionSize;
157     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, supportDimensionSize);
158     CONTAINER_SECURITY_VERIFY(parcel, supportDimensionSize, &supportDimensions);
159     for (int32_t i = 0; i < supportDimensionSize; i++) {
160         supportDimensions.emplace_back(parcel.ReadInt32());
161     }
162 
163     int32_t landscapeLayoutsSize;
164     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, landscapeLayoutsSize);
165     CONTAINER_SECURITY_VERIFY(parcel, landscapeLayoutsSize, &landscapeLayouts);
166     for (auto i = 0; i < landscapeLayoutsSize; i++) {
167         landscapeLayouts.emplace_back(Str16ToStr8(parcel.ReadString16()));
168     }
169 
170     int32_t portraitLayoutsSize;
171     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, portraitLayoutsSize);
172     CONTAINER_SECURITY_VERIFY(parcel, portraitLayoutsSize, &portraitLayouts);
173     for (auto i = 0; i < portraitLayoutsSize; i++) {
174         portraitLayouts.emplace_back(Str16ToStr8(parcel.ReadString16()));
175     }
176 
177     if (!ReadCustomizeData(parcel)) {
178         return false;
179     }
180 
181     window.designWidth = parcel.ReadInt32();
182     window.autoDesignWidth = parcel.ReadBool();
183     dataProxyEnabled = parcel.ReadBool();
184     isDynamic = parcel.ReadBool();
185     return true;
186 }
187 
Unmarshalling(Parcel & parcel)188 FormInfo *FormInfo::Unmarshalling(Parcel &parcel)
189 {
190     std::unique_ptr<FormInfo> info = std::make_unique<FormInfo>();
191     if (!info->ReadFromParcel(parcel)) {
192         APP_LOGW("read from parcel failed");
193         info = nullptr;
194     }
195     return info.release();
196 }
197 
Marshalling(Parcel & parcel) const198 bool FormInfo::Marshalling(Parcel &parcel) const
199 {
200     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(name));
201     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(package));
202     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName));
203     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleName));
204     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(abilityName));
205     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(description));
206     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(formConfigAbility));
207     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(scheduledUpdateTime));
208     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(jsComponentName));
209     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(relatedBundleName));
210     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(originalBundleName));
211     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(deepLink));
212     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(src));
213     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, updateEnabled);
214     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, defaultFlag);
215     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, formVisibleNotify);
216     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isStatic);
217     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, defaultDimension);
218     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, descriptionId);
219     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, updateDuration);
220     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(type));
221     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(uiSyntax));
222     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(colorMode));
223 
224     const auto supportDimensionSize = static_cast<int32_t>(supportDimensions.size());
225     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, supportDimensionSize);
226     for (auto i = 0; i < supportDimensionSize; i++) {
227         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, supportDimensions[i]);
228     }
229 
230     const auto landscapeLayoutsSize = static_cast<int32_t>(landscapeLayouts.size());
231     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, landscapeLayoutsSize);
232     for (auto i = 0; i < landscapeLayoutsSize; i++) {
233         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(landscapeLayouts[i]));
234     }
235 
236     const auto portraitLayoutsSize = static_cast<int32_t>(portraitLayouts.size());
237     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, portraitLayoutsSize);
238     for (auto i = 0; i < portraitLayoutsSize; i++) {
239         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(portraitLayouts[i]));
240     }
241 
242     const auto customizeDataSize = static_cast<int32_t>(customizeDatas.size());
243     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, customizeDataSize);
244     for (auto i = 0; i < customizeDataSize; i++) {
245         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(customizeDatas[i].name));
246         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(customizeDatas[i].value));
247     }
248 
249     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, window.designWidth);
250     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, window.autoDesignWidth);
251     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, dataProxyEnabled);
252     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isDynamic);
253     return true;
254 }
255 
IsValid() const256 bool FormInfo::IsValid() const
257 {
258     if (!window.autoDesignWidth && window.designWidth <= 0) {
259         APP_LOGW("Invalid FormInfo, window.designWidth <= 0.");
260         return false;
261     }
262     return true;
263 }
264 
to_json(nlohmann::json & jsonObject,const FormCustomizeData & customizeDatas)265 void to_json(nlohmann::json &jsonObject, const FormCustomizeData &customizeDatas)
266 {
267     jsonObject = nlohmann::json{
268         {JSON_KEY_NAME, customizeDatas.name},
269         {JSON_KEY_VALUE, customizeDatas.value}
270     };
271 }
272 
to_json(nlohmann::json & jsonObject,const FormWindow & formWindow)273 void to_json(nlohmann::json &jsonObject, const FormWindow &formWindow)
274 {
275     jsonObject[JSON_KEY_DESIGN_WIDTH] = formWindow.designWidth;
276     jsonObject[JSON_KEY_AUTO_DESIGN_WIDTH] = formWindow.autoDesignWidth;
277 }
278 
to_json(nlohmann::json & jsonObject,const FormInfo & formInfo)279 void to_json(nlohmann::json &jsonObject, const FormInfo &formInfo)
280 {
281     jsonObject = nlohmann::json{
282         {JSON_KEY_NAME, formInfo.name},
283         {JSON_KEY_PACKAGE, formInfo.package},
284         {Constants::BUNDLE_NAME, formInfo.bundleName},
285         {Constants::MODULE_NAME, formInfo.moduleName},
286         {Constants::ABILITY_NAME, formInfo.abilityName},
287         {JSON_KEY_DESCRIPTION, formInfo.description},
288         {JSON_KEY_RELATED_BUNDLE_NAME, formInfo.relatedBundleName},
289         {JSON_KEY_JS_COMPONENT_NAME, formInfo.jsComponentName},
290         {JSON_KEY_DEEP_LINK, formInfo.deepLink},
291         {JSON_KEY_SRC, formInfo.src},
292         {JSON_KEY_FORMCONFIG_ABILITY, formInfo.formConfigAbility},
293         {JSON_KEY_SCHEDULED_UPDATE_TIME, formInfo.scheduledUpdateTime},
294         {JSON_KEY_ORIGINAL_BUNDLE_NAME, formInfo.originalBundleName},
295         {JSON_KEY_DESCRIPTION_ID, formInfo.descriptionId},
296         {JSON_KEY_UPDATE_DURATION, formInfo.updateDuration},
297         {JSON_KEY_DEFAULT_DIMENSION, formInfo.defaultDimension},
298         {JSON_KEY_DEFAULT_FLAG, formInfo.defaultFlag},
299         {JSON_KEY_FORM_VISIBLE_NOTIFY, formInfo.formVisibleNotify},
300         {JSON_KEY_UPDATE_ENABLED, formInfo.updateEnabled},
301         {JSON_KEY_IS_STATIC, formInfo.isStatic},
302         {JSON_KEY_TYPE, formInfo.type},
303         {JSON_KEY_UI_SYNTAX, formInfo.uiSyntax},
304         {JSON_KEY_COLOR_MODE, formInfo.colorMode},
305         {JSON_KEY_SUPPORT_DIMENSIONS, formInfo.supportDimensions},
306         {JSON_KEY_CUSTOMIZE_DATA, formInfo.customizeDatas},
307         {JSON_KEY_LANDSCAPE_LAYOUTS, formInfo.landscapeLayouts},
308         {JSON_KEY_PORTRAIT_LAYOUTS, formInfo.portraitLayouts},
309         {JSON_KEY_WINDOW, formInfo.window},
310         {JSON_KEY_DATA_PROXY_ENABLED, formInfo.dataProxyEnabled},
311         {JSON_KEY_IS_DYNAMIC, formInfo.isDynamic}
312         };
313 }
314 
from_json(const nlohmann::json & jsonObject,FormCustomizeData & customizeDatas)315 void from_json(const nlohmann::json &jsonObject, FormCustomizeData &customizeDatas)
316 {
317     const auto &jsonObjectEnd = jsonObject.end();
318     int32_t parseResult = ERR_OK;
319     GetValueIfFindKey<std::string>(jsonObject,
320         jsonObjectEnd,
321         JSON_KEY_NAME,
322         customizeDatas.name,
323         JsonType::STRING,
324         false,
325         parseResult,
326         ArrayType::NOT_ARRAY);
327     GetValueIfFindKey<std::string>(jsonObject,
328         jsonObjectEnd,
329         JSON_KEY_VALUE,
330         customizeDatas.value,
331         JsonType::STRING,
332         false,
333         parseResult,
334         ArrayType::NOT_ARRAY);
335     if (parseResult != ERR_OK) {
336         APP_LOGE("read module customizeDatas from jsonObject error, error code : %{public}d", parseResult);
337     }
338 }
339 
from_json(const nlohmann::json & jsonObject,FormWindow & formWindow)340 void from_json(const nlohmann::json &jsonObject, FormWindow &formWindow)
341 {
342     const auto &jsonObjectEnd = jsonObject.end();
343     int32_t parseResult = ERR_OK;
344     GetValueIfFindKey<int32_t>(jsonObject,
345         jsonObjectEnd,
346         JSON_KEY_DESIGN_WIDTH,
347         formWindow.designWidth,
348         JsonType::NUMBER,
349         false,
350         parseResult,
351         ArrayType::NOT_ARRAY);
352     GetValueIfFindKey<bool>(jsonObject,
353         jsonObjectEnd,
354         JSON_KEY_AUTO_DESIGN_WIDTH,
355         formWindow.autoDesignWidth,
356         JsonType::BOOLEAN,
357         false,
358         parseResult,
359         ArrayType::NOT_ARRAY);
360     if (parseResult != ERR_OK) {
361         APP_LOGE("read module formWindow from jsonObject error, error code : %{public}d", parseResult);
362     }
363 }
364 
from_json(const nlohmann::json & jsonObject,FormInfo & formInfo)365 void from_json(const nlohmann::json &jsonObject, FormInfo &formInfo)
366 {
367     int32_t parseResult = ERR_OK;
368     const auto &jsonObjectEnd = jsonObject.end();
369     GetValueIfFindKey<std::string>(jsonObject,
370         jsonObjectEnd,
371         Constants::BUNDLE_NAME,
372         formInfo.bundleName,
373         JsonType::STRING,
374         false,
375         parseResult,
376         ArrayType::NOT_ARRAY);
377     GetValueIfFindKey<std::string>(jsonObject,
378         jsonObjectEnd,
379         JSON_KEY_PACKAGE,
380         formInfo.package,
381         JsonType::STRING,
382         false,
383         parseResult,
384         ArrayType::NOT_ARRAY);
385     GetValueIfFindKey<std::string>(jsonObject,
386         jsonObjectEnd,
387         Constants::MODULE_NAME,
388         formInfo.moduleName,
389         JsonType::STRING,
390         false,
391         parseResult,
392         ArrayType::NOT_ARRAY);
393     GetValueIfFindKey<std::string>(jsonObject,
394         jsonObjectEnd,
395         Constants::ABILITY_NAME,
396         formInfo.abilityName,
397         JsonType::STRING,
398         false,
399         parseResult,
400         ArrayType::NOT_ARRAY);
401     GetValueIfFindKey<std::string>(jsonObject,
402         jsonObjectEnd,
403         JSON_KEY_NAME,
404         formInfo.name,
405         JsonType::STRING,
406         false,
407         parseResult,
408         ArrayType::NOT_ARRAY);
409     GetValueIfFindKey<std::string>(jsonObject,
410         jsonObjectEnd,
411         JSON_KEY_DESCRIPTION,
412         formInfo.description,
413         JsonType::STRING,
414         false,
415         parseResult,
416         ArrayType::NOT_ARRAY);
417     GetValueIfFindKey<std::string>(jsonObject,
418         jsonObjectEnd,
419         JSON_KEY_RELATED_BUNDLE_NAME,
420         formInfo.relatedBundleName,
421         JsonType::STRING,
422         false,
423         parseResult,
424         ArrayType::NOT_ARRAY);
425     GetValueIfFindKey<std::string>(jsonObject,
426         jsonObjectEnd,
427         JSON_KEY_JS_COMPONENT_NAME,
428         formInfo.jsComponentName,
429         JsonType::STRING,
430         false,
431         parseResult,
432         ArrayType::NOT_ARRAY);
433     GetValueIfFindKey<std::string>(jsonObject,
434         jsonObjectEnd,
435         JSON_KEY_DEEP_LINK,
436         formInfo.deepLink,
437         JsonType::STRING,
438         false,
439         parseResult,
440         ArrayType::NOT_ARRAY);
441     GetValueIfFindKey<std::string>(jsonObject,
442         jsonObjectEnd,
443         JSON_KEY_FORMCONFIG_ABILITY,
444         formInfo.formConfigAbility,
445         JsonType::STRING,
446         false,
447         parseResult,
448         ArrayType::NOT_ARRAY);
449     GetValueIfFindKey<std::string>(jsonObject,
450         jsonObjectEnd,
451         JSON_KEY_SCHEDULED_UPDATE_TIME,
452         formInfo.scheduledUpdateTime,
453         JsonType::STRING,
454         false,
455         parseResult,
456         ArrayType::NOT_ARRAY);
457     GetValueIfFindKey<std::string>(jsonObject,
458         jsonObjectEnd,
459         JSON_KEY_SRC,
460         formInfo.src,
461         JsonType::STRING,
462         false,
463         parseResult,
464         ArrayType::NOT_ARRAY);
465     GetValueIfFindKey<std::string>(jsonObject,
466         jsonObjectEnd,
467         JSON_KEY_ORIGINAL_BUNDLE_NAME,
468         formInfo.originalBundleName,
469         JsonType::STRING,
470         false,
471         parseResult,
472         ArrayType::NOT_ARRAY);
473     GetValueIfFindKey<int32_t>(jsonObject,
474         jsonObjectEnd,
475         JSON_KEY_DESCRIPTION_ID,
476         formInfo.descriptionId,
477         JsonType::NUMBER,
478         false,
479         parseResult,
480         ArrayType::NOT_ARRAY);
481     GetValueIfFindKey<int32_t>(jsonObject,
482         jsonObjectEnd,
483         JSON_KEY_UPDATE_DURATION,
484         formInfo.updateDuration,
485         JsonType::NUMBER,
486         false,
487         parseResult,
488         ArrayType::NOT_ARRAY);
489     GetValueIfFindKey<int32_t>(jsonObject,
490         jsonObjectEnd,
491         JSON_KEY_DEFAULT_DIMENSION,
492         formInfo.defaultDimension,
493         JsonType::NUMBER,
494         false,
495         parseResult,
496         ArrayType::NOT_ARRAY);
497     GetValueIfFindKey<bool>(jsonObject,
498         jsonObjectEnd,
499         JSON_KEY_DEFAULT_FLAG,
500         formInfo.defaultFlag,
501         JsonType::BOOLEAN,
502         false,
503         parseResult,
504         ArrayType::NOT_ARRAY);
505     GetValueIfFindKey<bool>(jsonObject,
506         jsonObjectEnd,
507         JSON_KEY_FORM_VISIBLE_NOTIFY,
508         formInfo.formVisibleNotify,
509         JsonType::BOOLEAN,
510         false,
511         parseResult,
512         ArrayType::NOT_ARRAY);
513     GetValueIfFindKey<bool>(jsonObject,
514         jsonObjectEnd,
515         JSON_KEY_UPDATE_ENABLED,
516         formInfo.updateEnabled,
517         JsonType::BOOLEAN,
518         false,
519         parseResult,
520         ArrayType::NOT_ARRAY);
521     GetValueIfFindKey<bool>(jsonObject,
522         jsonObjectEnd,
523         JSON_KEY_IS_STATIC,
524         formInfo.isStatic,
525         JsonType::BOOLEAN,
526         false,
527         parseResult,
528         ArrayType::NOT_ARRAY);
529     GetValueIfFindKey<FormType>(jsonObject,
530         jsonObjectEnd,
531         JSON_KEY_TYPE,
532         formInfo.type,
533         JsonType::NUMBER,
534         false,
535         parseResult,
536         ArrayType::NOT_ARRAY);
537     GetValueIfFindKey<FormsColorMode>(jsonObject,
538         jsonObjectEnd,
539         JSON_KEY_COLOR_MODE,
540         formInfo.colorMode,
541         JsonType::NUMBER,
542         false,
543         parseResult,
544         ArrayType::NOT_ARRAY);
545     GetValueIfFindKey<std::vector<int32_t>>(jsonObject,
546         jsonObjectEnd,
547         JSON_KEY_SUPPORT_DIMENSIONS,
548         formInfo.supportDimensions,
549         JsonType::ARRAY,
550         false,
551         parseResult,
552         ArrayType::NUMBER);
553     GetValueIfFindKey<std::vector<FormCustomizeData>>(jsonObject,
554         jsonObjectEnd,
555         JSON_KEY_CUSTOMIZE_DATA,
556         formInfo.customizeDatas,
557         JsonType::ARRAY,
558         false,
559         parseResult,
560         ArrayType::OBJECT);
561     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
562         jsonObjectEnd,
563         JSON_KEY_LANDSCAPE_LAYOUTS,
564         formInfo.landscapeLayouts,
565         JsonType::ARRAY,
566         false,
567         parseResult,
568         ArrayType::STRING);
569     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
570         jsonObjectEnd,
571         JSON_KEY_PORTRAIT_LAYOUTS,
572         formInfo.portraitLayouts,
573         JsonType::ARRAY,
574         false,
575         parseResult,
576         ArrayType::STRING);
577     GetValueIfFindKey<FormWindow>(jsonObject,
578         jsonObjectEnd,
579         JSON_KEY_WINDOW,
580         formInfo.window,
581         JsonType::OBJECT,
582         false,
583         parseResult,
584         ArrayType::NOT_ARRAY);
585     GetValueIfFindKey<FormType>(jsonObject,
586         jsonObjectEnd,
587         JSON_KEY_UI_SYNTAX,
588         formInfo.uiSyntax,
589         JsonType::NUMBER,
590         false,
591         parseResult,
592         ArrayType::NOT_ARRAY);
593     GetValueIfFindKey<bool>(jsonObject,
594         jsonObjectEnd,
595         JSON_KEY_DATA_PROXY_ENABLED,
596         formInfo.dataProxyEnabled,
597         JsonType::BOOLEAN,
598         false,
599         parseResult,
600         ArrayType::NOT_ARRAY);
601     GetValueIfFindKey<bool>(jsonObject,
602         jsonObjectEnd,
603         JSON_KEY_IS_DYNAMIC,
604         formInfo.isDynamic,
605         JsonType::BOOLEAN,
606         false,
607         parseResult,
608         ArrayType::NOT_ARRAY);
609     if (parseResult != ERR_OK) {
610         APP_LOGE("read module formInfo from jsonObject error, error code : %{public}d", parseResult);
611     }
612 }
613 }  // namespace AppExecFwk
614 }  // namespace OHOS
615