1 /*
2  * Copyright (c) 2023-2024 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 "hap_module_info.h"
17 
18 #include "bundle_constants.h"
19 #include "hilog_tag_wrapper.h"
20 #include "json_util.h"
21 #include "nlohmann/json.hpp"
22 #include "string_ex.h"
23 
24 namespace OHOS {
25 namespace AppExecFwk {
26 namespace {
27 const std::string HAP_MODULE_INFO_NAME = "name";
28 const std::string HAP_MODULE_INFO_PACKAGE = "package";
29 const std::string HAP_MODULE_INFO_DESCRIPTION = "description";
30 const std::string HAP_MODULE_INFO_DESCRIPTION_ID = "descriptionId";
31 const std::string HAP_MODULE_INFO_ICON_PATH = "iconPath";
32 const std::string HAP_MODULE_INFO_ICON_ID = "iconId";
33 const std::string HAP_MODULE_INFO_LABEL = "label";
34 const std::string HAP_MODULE_INFO_LABEL_ID = "labelId";
35 const std::string HAP_MODULE_INFO_BACKGROUND_IMG = "backgroundImg";
36 const std::string HAP_MODULE_INFO_MAIN_ABILITY = "mainAbility";
37 const std::string HAP_MODULE_INFO_SRC_PATH = "srcPath";
38 const std::string HAP_MODULE_INFO_HASH_VALUE = "hashValue";
39 const std::string HAP_MODULE_INFO_SUPPORTED_MODES = "supportedModes";
40 const std::string HAP_MODULE_INFO_REQ_CAPABILITIES = "reqCapabilities";
41 const std::string HAP_MODULE_INFO_DEVICE_TYPES = "deviceTypes";
42 const std::string HAP_MODULE_INFO_ABILITY_INFOS = "abilityInfos";
43 const std::string HAP_MODULE_INFO_COLOR_MODE = "colorMode";
44 const std::string HAP_MODULE_INFO_MAIN_ELEMENTNAME = "mainElementName";
45 const std::string HAP_MODULE_INFO_PAGES = "pages";
46 const std::string HAP_MODULE_INFO_PROCESS = "process";
47 const std::string HAP_MODULE_INFO_RESOURCE_PATH = "resourcePath";
48 const std::string HAP_MODULE_INFO_SRC_ENTRANCE = "srcEntrance";
49 const std::string HAP_MODULE_INFO_UI_SYNTAX = "uiSyntax";
50 const std::string HAP_MODULE_INFO_VIRTUAL_MACHINE = "virtualMachine";
51 const std::string HAP_MODULE_INFO_DELIVERY_WITH_INSTALL = "deliveryWithInstall";
52 const std::string HAP_MODULE_INFO_INSTALLATION_FREE = "installationFree";
53 const std::string HAP_MODULE_INFO_IS_MODULE_JSON = "isModuleJson";
54 const std::string HAP_MODULE_INFO_IS_STAGE_BASED_MODEL = "isStageBasedModel";
55 const std::string HAP_MODULE_INFO_IS_REMOVABLE = "isRemovable";
56 const std::string HAP_MODULE_INFO_MODULE_TYPE = "moduleType";
57 const std::string HAP_MODULE_INFO_EXTENSION_INFOS = "extensionInfos";
58 const std::string HAP_MODULE_INFO_META_DATA = "metadata";
59 const std::string HAP_MODULE_INFO_DEPENDENCIES = "dependencies";
60 const std::string HAP_MODULE_INFO_UPGRADE_FLAG = "upgradeFlag";
61 const std::string HAP_MODULE_INFO_HAP_PATH = "hapPath";
62 const std::string HAP_MODULE_INFO_COMPILE_MODE = "compileMode";
63 const std::string HAP_MODULE_INFO_IS_LIB_ISOLATED = "isLibIsolated";
64 const std::string HAP_MODULE_INFO_NATIVE_LIBRARY_PATH = "nativeLibraryPath";
65 const std::string HAP_MODULE_INFO_CPU_ABI = "cpuAbi";
66 const std::string HAP_MODULE_INFO_MODULE_SOURCE_DIR = "moduleSourceDir";
67 const std::string HAP_MODULE_INFO_ATOMIC_SERVICE_MODULE_TYPE = "atomicServiceModuleType";
68 const std::string HAP_MODULE_INFO_PRELOADS = "preloads";
69 const std::string PRELOAD_ITEM_MODULE_NAME = "moduleName";
70 const std::string HAP_MODULE_INFO_VERSION_CODE = "versionCode";
71 const std::string HAP_MODULE_INFO_PROXY_DATAS = "proxyDatas";
72 const std::string PROXY_DATA_URI = "uri";
73 const std::string PROXY_DATA_REQUIRED_READ_PERMISSION = "requiredReadPermission";
74 const std::string PROXY_DATA_REQUIRED_WRITE_PERMISSION = "requiredWritePermission";
75 const std::string PROXY_DATA_METADATA = "metadata";
76 const std::string HAP_MODULE_INFO_BUILD_HASH = "buildHash";
77 const std::string HAP_MODULE_INFO_ISOLATION_MODE = "isolationMode";
78 const std::string HAP_MODULE_INFO_AOT_COMPILE_STATUS = "aotCompileStatus";
79 const std::string HAP_MODULE_INFO_COMPRESS_NATIVE_LIBS = "compressNativeLibs";
80 const std::string HAP_MODULE_INFO_NATIVE_LIBRARY_FILE_NAMES = "nativeLibraryFileNames";
81 }
to_json(nlohmann::json & jsonObject,const PreloadItem & preloadItem)82 void to_json(nlohmann::json &jsonObject, const PreloadItem &preloadItem)
83 {
84     jsonObject = nlohmann::json {
85         {PRELOAD_ITEM_MODULE_NAME, preloadItem.moduleName}
86     };
87 }
88 
from_json(const nlohmann::json & jsonObject,PreloadItem & preloadItem)89 void from_json(const nlohmann::json &jsonObject, PreloadItem &preloadItem)
90 {
91     const auto &jsonObjectEnd = jsonObject.end();
92     int32_t parseResult = ERR_OK;
93     GetValueIfFindKey<std::string>(jsonObject,
94         jsonObjectEnd,
95         PRELOAD_ITEM_MODULE_NAME,
96         preloadItem.moduleName,
97         JsonType::STRING,
98         false,
99         parseResult,
100         ArrayType::NOT_ARRAY);
101     if (parseResult != ERR_OK) {
102         TAG_LOGE(AAFwkTag::ABILITY_SIM, "read PreloadItem error:%{public}d", parseResult);
103     }
104 }
105 
to_json(nlohmann::json & jsonObject,const ProxyData & proxyData)106 void to_json(nlohmann::json &jsonObject, const ProxyData &proxyData)
107 {
108     jsonObject = nlohmann::json {
109         {PROXY_DATA_URI, proxyData.uri},
110         {PROXY_DATA_REQUIRED_READ_PERMISSION, proxyData.requiredReadPermission},
111         {PROXY_DATA_REQUIRED_WRITE_PERMISSION, proxyData.requiredWritePermission},
112         {PROXY_DATA_METADATA, proxyData.metadata}
113     };
114 }
115 
from_json(const nlohmann::json & jsonObject,ProxyData & proxyData)116 void from_json(const nlohmann::json &jsonObject, ProxyData &proxyData)
117 {
118     const auto &jsonObjectEnd = jsonObject.end();
119     int32_t parseResult = ERR_OK;
120     GetValueIfFindKey<std::string>(jsonObject,
121         jsonObjectEnd,
122         PROXY_DATA_URI,
123         proxyData.uri,
124         JsonType::STRING,
125         false,
126         parseResult,
127         ArrayType::NOT_ARRAY);
128     GetValueIfFindKey<std::string>(jsonObject,
129         jsonObjectEnd,
130         PROXY_DATA_REQUIRED_READ_PERMISSION,
131         proxyData.requiredReadPermission,
132         JsonType::STRING,
133         false,
134         parseResult,
135         ArrayType::NOT_ARRAY);
136     GetValueIfFindKey<std::string>(jsonObject,
137         jsonObjectEnd,
138         PROXY_DATA_REQUIRED_WRITE_PERMISSION,
139         proxyData.requiredWritePermission,
140         JsonType::STRING,
141         false,
142         parseResult,
143         ArrayType::NOT_ARRAY);
144     GetValueIfFindKey<Metadata>(jsonObject,
145         jsonObjectEnd,
146         PROXY_DATA_METADATA,
147         proxyData.metadata,
148         JsonType::OBJECT,
149         false,
150         parseResult,
151         ArrayType::NOT_ARRAY);
152     if (parseResult != ERR_OK) {
153         TAG_LOGE(AAFwkTag::ABILITY_SIM, "read ProxyData from database error:%{public}d", parseResult);
154     }
155 }
156 
to_json(nlohmann::json & jsonObject,const HapModuleInfo & hapModuleInfo)157 void to_json(nlohmann::json &jsonObject, const HapModuleInfo &hapModuleInfo)
158 {
159     jsonObject = nlohmann::json {
160         {HAP_MODULE_INFO_NAME, hapModuleInfo.name}, {HAP_MODULE_INFO_PACKAGE, hapModuleInfo.package},
161         {Constants::MODULE_NAME, hapModuleInfo.moduleName}, {HAP_MODULE_INFO_DESCRIPTION, hapModuleInfo.description},
162         {HAP_MODULE_INFO_DESCRIPTION_ID, hapModuleInfo.descriptionId},
163         {HAP_MODULE_INFO_ICON_PATH, hapModuleInfo.iconPath}, {HAP_MODULE_INFO_ICON_ID, hapModuleInfo.iconId},
164         {HAP_MODULE_INFO_LABEL, hapModuleInfo.label}, {HAP_MODULE_INFO_LABEL_ID, hapModuleInfo.labelId},
165         {HAP_MODULE_INFO_BACKGROUND_IMG, hapModuleInfo.backgroundImg},
166         {HAP_MODULE_INFO_MAIN_ABILITY, hapModuleInfo.mainAbility},
167         {HAP_MODULE_INFO_SRC_PATH, hapModuleInfo.srcPath}, {HAP_MODULE_INFO_HASH_VALUE, hapModuleInfo.hashValue},
168         {HAP_MODULE_INFO_HAP_PATH, hapModuleInfo.hapPath},
169         {HAP_MODULE_INFO_SUPPORTED_MODES, hapModuleInfo.supportedModes},
170         {HAP_MODULE_INFO_REQ_CAPABILITIES, hapModuleInfo.reqCapabilities},
171         {HAP_MODULE_INFO_DEVICE_TYPES, hapModuleInfo.deviceTypes},
172         {HAP_MODULE_INFO_ABILITY_INFOS, hapModuleInfo.abilityInfos},
173         {HAP_MODULE_INFO_COLOR_MODE, hapModuleInfo.colorMode}, {Constants::BUNDLE_NAME, hapModuleInfo.bundleName},
174         {HAP_MODULE_INFO_MAIN_ELEMENTNAME, hapModuleInfo.mainElementName}, {HAP_MODULE_INFO_PAGES, hapModuleInfo.pages},
175         {HAP_MODULE_INFO_PROCESS, hapModuleInfo.process}, {HAP_MODULE_INFO_RESOURCE_PATH, hapModuleInfo.resourcePath},
176         {HAP_MODULE_INFO_SRC_ENTRANCE, hapModuleInfo.srcEntrance}, {HAP_MODULE_INFO_UI_SYNTAX, hapModuleInfo.uiSyntax},
177         {HAP_MODULE_INFO_VIRTUAL_MACHINE, hapModuleInfo.virtualMachine},
178         {HAP_MODULE_INFO_DELIVERY_WITH_INSTALL, hapModuleInfo.deliveryWithInstall},
179         {HAP_MODULE_INFO_INSTALLATION_FREE, hapModuleInfo.installationFree},
180         {HAP_MODULE_INFO_IS_MODULE_JSON, hapModuleInfo.isModuleJson},
181         {HAP_MODULE_INFO_IS_STAGE_BASED_MODEL, hapModuleInfo.isStageBasedModel},
182         {HAP_MODULE_INFO_IS_REMOVABLE, hapModuleInfo.isRemovable},
183         {HAP_MODULE_INFO_UPGRADE_FLAG, hapModuleInfo.upgradeFlag},
184         {HAP_MODULE_INFO_MODULE_TYPE, hapModuleInfo.moduleType},
185         {HAP_MODULE_INFO_EXTENSION_INFOS, hapModuleInfo.extensionInfos},
186         {HAP_MODULE_INFO_META_DATA, hapModuleInfo.metadata},
187         {HAP_MODULE_INFO_DEPENDENCIES, hapModuleInfo.dependencies},
188         {HAP_MODULE_INFO_COMPILE_MODE, hapModuleInfo.compileMode},
189         {HAP_MODULE_INFO_IS_LIB_ISOLATED, hapModuleInfo.isLibIsolated},
190         {HAP_MODULE_INFO_NATIVE_LIBRARY_PATH, hapModuleInfo.nativeLibraryPath},
191         {HAP_MODULE_INFO_CPU_ABI, hapModuleInfo.cpuAbi},
192         {HAP_MODULE_INFO_MODULE_SOURCE_DIR, hapModuleInfo.moduleSourceDir},
193         {HAP_MODULE_INFO_ATOMIC_SERVICE_MODULE_TYPE, hapModuleInfo.atomicServiceModuleType},
194         {HAP_MODULE_INFO_PRELOADS, hapModuleInfo.preloads},
195         {HAP_MODULE_INFO_PROXY_DATAS, hapModuleInfo.proxyDatas},
196         {HAP_MODULE_INFO_BUILD_HASH, hapModuleInfo.buildHash},
197         {HAP_MODULE_INFO_ISOLATION_MODE, hapModuleInfo.isolationMode},
198         {HAP_MODULE_INFO_AOT_COMPILE_STATUS, hapModuleInfo.aotCompileStatus},
199         {HAP_MODULE_INFO_COMPRESS_NATIVE_LIBS, hapModuleInfo.compressNativeLibs},
200         {HAP_MODULE_INFO_NATIVE_LIBRARY_FILE_NAMES, hapModuleInfo.nativeLibraryFileNames}
201     };
202 }
203 
from_json(const nlohmann::json & jsonObject,HapModuleInfo & hapModuleInfo)204 void from_json(const nlohmann::json &jsonObject, HapModuleInfo &hapModuleInfo)
205 {
206     const auto &jsonObjectEnd = jsonObject.end();
207     int32_t parseResult = ERR_OK;
208     GetValueIfFindKey<std::string>(jsonObject,
209         jsonObjectEnd,
210         HAP_MODULE_INFO_NAME,
211         hapModuleInfo.name,
212         JsonType::STRING,
213         false,
214         parseResult,
215         ArrayType::NOT_ARRAY);
216     GetValueIfFindKey<std::string>(jsonObject,
217         jsonObjectEnd,
218         HAP_MODULE_INFO_PACKAGE,
219         hapModuleInfo.package,
220         JsonType::STRING,
221         false,
222         parseResult,
223         ArrayType::NOT_ARRAY);
224     GetValueIfFindKey<std::string>(jsonObject,
225         jsonObjectEnd,
226         Constants::MODULE_NAME,
227         hapModuleInfo.moduleName,
228         JsonType::STRING,
229         false,
230         parseResult,
231         ArrayType::NOT_ARRAY);
232     GetValueIfFindKey<std::string>(jsonObject,
233         jsonObjectEnd,
234         HAP_MODULE_INFO_DESCRIPTION,
235         hapModuleInfo.description,
236         JsonType::STRING,
237         false,
238         parseResult,
239         ArrayType::NOT_ARRAY);
240     GetValueIfFindKey<int>(jsonObject,
241         jsonObjectEnd,
242         HAP_MODULE_INFO_DESCRIPTION_ID,
243         hapModuleInfo.descriptionId,
244         JsonType::NUMBER,
245         false,
246         parseResult,
247         ArrayType::NOT_ARRAY);
248     GetValueIfFindKey<std::string>(jsonObject,
249         jsonObjectEnd,
250         HAP_MODULE_INFO_ICON_PATH,
251         hapModuleInfo.iconPath,
252         JsonType::STRING,
253         false,
254         parseResult,
255         ArrayType::NOT_ARRAY);
256     GetValueIfFindKey<int>(jsonObject,
257         jsonObjectEnd,
258         HAP_MODULE_INFO_ICON_ID,
259         hapModuleInfo.iconId,
260         JsonType::NUMBER,
261         false,
262         parseResult,
263         ArrayType::NOT_ARRAY);
264     GetValueIfFindKey<std::string>(jsonObject,
265         jsonObjectEnd,
266         HAP_MODULE_INFO_LABEL,
267         hapModuleInfo.label,
268         JsonType::STRING,
269         false,
270         parseResult,
271         ArrayType::NOT_ARRAY);
272     GetValueIfFindKey<int>(jsonObject,
273         jsonObjectEnd,
274         HAP_MODULE_INFO_LABEL_ID,
275         hapModuleInfo.labelId,
276         JsonType::NUMBER,
277         false,
278         parseResult,
279         ArrayType::NOT_ARRAY);
280     GetValueIfFindKey<std::string>(jsonObject,
281         jsonObjectEnd,
282         HAP_MODULE_INFO_BACKGROUND_IMG,
283         hapModuleInfo.backgroundImg,
284         JsonType::STRING,
285         false,
286         parseResult,
287         ArrayType::NOT_ARRAY);
288     GetValueIfFindKey<std::string>(jsonObject,
289         jsonObjectEnd,
290         HAP_MODULE_INFO_MAIN_ABILITY,
291         hapModuleInfo.mainAbility,
292         JsonType::STRING,
293         false,
294         parseResult,
295         ArrayType::NOT_ARRAY);
296     GetValueIfFindKey<std::string>(jsonObject,
297         jsonObjectEnd,
298         HAP_MODULE_INFO_SRC_PATH,
299         hapModuleInfo.srcPath,
300         JsonType::STRING,
301         false,
302         parseResult,
303         ArrayType::NOT_ARRAY);
304     GetValueIfFindKey<std::string>(jsonObject,
305         jsonObjectEnd,
306         HAP_MODULE_INFO_HASH_VALUE,
307         hapModuleInfo.hashValue,
308         JsonType::STRING,
309         false,
310         parseResult,
311         ArrayType::NOT_ARRAY);
312     GetValueIfFindKey<std::string>(jsonObject,
313         jsonObjectEnd,
314         HAP_MODULE_INFO_HAP_PATH,
315         hapModuleInfo.hapPath,
316         JsonType::STRING,
317         false,
318         parseResult,
319         ArrayType::NOT_ARRAY);
320     GetValueIfFindKey<int>(jsonObject,
321         jsonObjectEnd,
322         HAP_MODULE_INFO_SUPPORTED_MODES,
323         hapModuleInfo.supportedModes,
324         JsonType::NUMBER,
325         false,
326         parseResult,
327         ArrayType::NOT_ARRAY);
328     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
329         jsonObjectEnd,
330         HAP_MODULE_INFO_REQ_CAPABILITIES,
331         hapModuleInfo.reqCapabilities,
332         JsonType::ARRAY,
333         false,
334         parseResult,
335         ArrayType::STRING);
336     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
337         jsonObjectEnd,
338         HAP_MODULE_INFO_DEVICE_TYPES,
339         hapModuleInfo.deviceTypes,
340         JsonType::ARRAY,
341         false,
342         parseResult,
343         ArrayType::STRING);
344     GetValueIfFindKey<std::vector<AbilityInfo>>(jsonObject,
345         jsonObjectEnd,
346         HAP_MODULE_INFO_ABILITY_INFOS,
347         hapModuleInfo.abilityInfos,
348         JsonType::ARRAY,
349         false,
350         parseResult,
351         ArrayType::OBJECT);
352     GetValueIfFindKey<ModuleColorMode>(jsonObject,
353         jsonObjectEnd,
354         HAP_MODULE_INFO_COLOR_MODE,
355         hapModuleInfo.colorMode,
356         JsonType::NUMBER,
357         false,
358         parseResult,
359         ArrayType::NOT_ARRAY);
360     GetValueIfFindKey<std::string>(jsonObject,
361         jsonObjectEnd,
362         Constants::BUNDLE_NAME,
363         hapModuleInfo.bundleName,
364         JsonType::STRING,
365         false,
366         parseResult,
367         ArrayType::NOT_ARRAY);
368     GetValueIfFindKey<std::string>(jsonObject,
369         jsonObjectEnd,
370         HAP_MODULE_INFO_MAIN_ELEMENTNAME,
371         hapModuleInfo.mainElementName,
372         JsonType::STRING,
373         false,
374         parseResult,
375         ArrayType::NOT_ARRAY);
376     GetValueIfFindKey<std::string>(jsonObject,
377         jsonObjectEnd,
378         HAP_MODULE_INFO_PAGES,
379         hapModuleInfo.pages,
380         JsonType::STRING,
381         false,
382         parseResult,
383         ArrayType::NOT_ARRAY);
384     GetValueIfFindKey<std::string>(jsonObject,
385         jsonObjectEnd,
386         HAP_MODULE_INFO_PROCESS,
387         hapModuleInfo.process,
388         JsonType::STRING,
389         false,
390         parseResult,
391         ArrayType::NOT_ARRAY);
392     GetValueIfFindKey<std::string>(jsonObject,
393         jsonObjectEnd,
394         HAP_MODULE_INFO_RESOURCE_PATH,
395         hapModuleInfo.resourcePath,
396         JsonType::STRING,
397         false,
398         parseResult,
399         ArrayType::NOT_ARRAY);
400     GetValueIfFindKey<std::string>(jsonObject,
401         jsonObjectEnd,
402         HAP_MODULE_INFO_SRC_ENTRANCE,
403         hapModuleInfo.srcEntrance,
404         JsonType::STRING,
405         false,
406         parseResult,
407         ArrayType::NOT_ARRAY);
408     GetValueIfFindKey<std::string>(jsonObject,
409         jsonObjectEnd,
410         HAP_MODULE_INFO_UI_SYNTAX,
411         hapModuleInfo.uiSyntax,
412         JsonType::STRING,
413         false,
414         parseResult,
415         ArrayType::NOT_ARRAY);
416     GetValueIfFindKey<std::string>(jsonObject,
417         jsonObjectEnd,
418         HAP_MODULE_INFO_VIRTUAL_MACHINE,
419         hapModuleInfo.virtualMachine,
420         JsonType::STRING,
421         false,
422         parseResult,
423         ArrayType::NOT_ARRAY);
424     GetValueIfFindKey<bool>(jsonObject,
425         jsonObjectEnd,
426         HAP_MODULE_INFO_DELIVERY_WITH_INSTALL,
427         hapModuleInfo.deliveryWithInstall,
428         JsonType::BOOLEAN,
429         false,
430         parseResult,
431         ArrayType::NOT_ARRAY);
432     GetValueIfFindKey<bool>(jsonObject,
433         jsonObjectEnd,
434         HAP_MODULE_INFO_INSTALLATION_FREE,
435         hapModuleInfo.installationFree,
436         JsonType::BOOLEAN,
437         false,
438         parseResult,
439         ArrayType::NOT_ARRAY);
440     GetValueIfFindKey<bool>(jsonObject,
441         jsonObjectEnd,
442         HAP_MODULE_INFO_IS_MODULE_JSON,
443         hapModuleInfo.isModuleJson,
444         JsonType::BOOLEAN,
445         false,
446         parseResult,
447         ArrayType::NOT_ARRAY);
448     GetValueIfFindKey<bool>(jsonObject,
449         jsonObjectEnd,
450         HAP_MODULE_INFO_IS_STAGE_BASED_MODEL,
451         hapModuleInfo.isStageBasedModel,
452         JsonType::BOOLEAN,
453         false,
454         parseResult,
455         ArrayType::NOT_ARRAY);
456     GetValueIfFindKey<std::map<std::string, bool>>(jsonObject,
457         jsonObjectEnd,
458         HAP_MODULE_INFO_IS_REMOVABLE,
459         hapModuleInfo.isRemovable,
460         JsonType::OBJECT,
461         false,
462         parseResult,
463         ArrayType::NOT_ARRAY);
464     GetValueIfFindKey<int32_t>(jsonObject,
465         jsonObjectEnd,
466         HAP_MODULE_INFO_UPGRADE_FLAG,
467         hapModuleInfo.upgradeFlag,
468         JsonType::NUMBER,
469         false,
470         parseResult,
471         ArrayType::NOT_ARRAY);
472     GetValueIfFindKey<ModuleType>(jsonObject,
473         jsonObjectEnd,
474         HAP_MODULE_INFO_MODULE_TYPE,
475         hapModuleInfo.moduleType,
476         JsonType::NUMBER,
477         false,
478         parseResult,
479         ArrayType::NOT_ARRAY);
480     GetValueIfFindKey<std::vector<ExtensionAbilityInfo>>(jsonObject,
481         jsonObjectEnd,
482         HAP_MODULE_INFO_EXTENSION_INFOS,
483         hapModuleInfo.extensionInfos,
484         JsonType::ARRAY,
485         false,
486         parseResult,
487         ArrayType::OBJECT);
488     GetValueIfFindKey<std::vector<Metadata>>(jsonObject,
489         jsonObjectEnd,
490         HAP_MODULE_INFO_META_DATA,
491         hapModuleInfo.metadata,
492         JsonType::ARRAY,
493         false,
494         parseResult,
495         ArrayType::OBJECT);
496     GetValueIfFindKey<std::vector<Dependency>>(jsonObject,
497         jsonObjectEnd,
498         HAP_MODULE_INFO_DEPENDENCIES,
499         hapModuleInfo.dependencies,
500         JsonType::ARRAY,
501         false,
502         parseResult,
503         ArrayType::OBJECT);
504     GetValueIfFindKey<CompileMode>(jsonObject,
505         jsonObjectEnd,
506         HAP_MODULE_INFO_COMPILE_MODE,
507         hapModuleInfo.compileMode,
508         JsonType::NUMBER,
509         false,
510         parseResult,
511         ArrayType::NOT_ARRAY);
512     GetValueIfFindKey<bool>(jsonObject,
513         jsonObjectEnd,
514         HAP_MODULE_INFO_IS_LIB_ISOLATED,
515         hapModuleInfo.isLibIsolated,
516         JsonType::BOOLEAN,
517         false,
518         parseResult,
519         ArrayType::NOT_ARRAY);
520     GetValueIfFindKey<std::string>(jsonObject,
521         jsonObjectEnd,
522         HAP_MODULE_INFO_NATIVE_LIBRARY_PATH,
523         hapModuleInfo.nativeLibraryPath,
524         JsonType::STRING,
525         false,
526         parseResult,
527         ArrayType::NOT_ARRAY);
528     GetValueIfFindKey<std::string>(jsonObject,
529         jsonObjectEnd,
530         HAP_MODULE_INFO_CPU_ABI,
531         hapModuleInfo.cpuAbi,
532         JsonType::STRING,
533         false,
534         parseResult,
535         ArrayType::NOT_ARRAY);
536     GetValueIfFindKey<std::string>(jsonObject,
537         jsonObjectEnd,
538         HAP_MODULE_INFO_MODULE_SOURCE_DIR,
539         hapModuleInfo.moduleSourceDir,
540         JsonType::STRING,
541         false,
542         parseResult,
543         ArrayType::NOT_ARRAY);
544     GetValueIfFindKey<AtomicServiceModuleType>(jsonObject,
545         jsonObjectEnd,
546         HAP_MODULE_INFO_ATOMIC_SERVICE_MODULE_TYPE,
547         hapModuleInfo.atomicServiceModuleType,
548         JsonType::NUMBER,
549         false,
550         parseResult,
551         ArrayType::NOT_ARRAY);
552     GetValueIfFindKey<std::vector<PreloadItem>>(jsonObject,
553         jsonObjectEnd,
554         HAP_MODULE_INFO_PRELOADS,
555         hapModuleInfo.preloads,
556         JsonType::ARRAY,
557         false,
558         parseResult,
559         ArrayType::OBJECT);
560     GetValueIfFindKey<std::vector<ProxyData>>(jsonObject,
561         jsonObjectEnd,
562         HAP_MODULE_INFO_PROXY_DATAS,
563         hapModuleInfo.proxyDatas,
564         JsonType::ARRAY,
565         false,
566         parseResult,
567         ArrayType::OBJECT);
568     GetValueIfFindKey<std::string>(jsonObject,
569         jsonObjectEnd,
570         HAP_MODULE_INFO_BUILD_HASH,
571         hapModuleInfo.buildHash,
572         JsonType::STRING,
573         false,
574         parseResult,
575         ArrayType::NOT_ARRAY);
576     GetValueIfFindKey<IsolationMode>(jsonObject,
577         jsonObjectEnd,
578         HAP_MODULE_INFO_ISOLATION_MODE,
579         hapModuleInfo.isolationMode,
580         JsonType::NUMBER,
581         false,
582         parseResult,
583         ArrayType::NOT_ARRAY);
584     GetValueIfFindKey<AOTCompileStatus>(jsonObject,
585         jsonObjectEnd,
586         HAP_MODULE_INFO_AOT_COMPILE_STATUS,
587         hapModuleInfo.aotCompileStatus,
588         JsonType::NUMBER,
589         false,
590         parseResult,
591         ArrayType::NOT_ARRAY);
592     GetValueIfFindKey<bool>(jsonObject,
593         jsonObjectEnd,
594         HAP_MODULE_INFO_COMPRESS_NATIVE_LIBS,
595         hapModuleInfo.compressNativeLibs,
596         JsonType::BOOLEAN,
597         false,
598         parseResult,
599         ArrayType::NOT_ARRAY);
600     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
601         jsonObjectEnd,
602         HAP_MODULE_INFO_NATIVE_LIBRARY_FILE_NAMES,
603         hapModuleInfo.nativeLibraryFileNames,
604         JsonType::ARRAY,
605         false,
606         parseResult,
607         ArrayType::STRING);
608     if (parseResult != ERR_OK) {
609         TAG_LOGE(AAFwkTag::ABILITY_SIM, "HapModuleInfo error:%{public}d", parseResult);
610     }
611 }
612 }  // namespace AppExecFwk
613 }  // namespace OHOS
614