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 "application_info.h"
17 
18 #include <errno.h>
19 #include <fcntl.h>
20 #include <string.h>
21 #include <set>
22 #include <unistd.h>
23 
24 #include "bundle_constants.h"
25 #include "hilog_tag_wrapper.h"
26 #include "json_serializer.h"
27 #include "json_util.h"
28 #include "nlohmann/json.hpp"
29 #include "string_ex.h"
30 
31 namespace OHOS {
32 namespace AppExecFwk {
33 namespace {
34 const std::string APPLICATION_NAME = "name";
35 const std::string APPLICATION_VERSION_CODE = "versionCode";
36 const std::string APPLICATION_VERSION_NAME = "versionName";
37 const std::string APPLICATION_MIN_COMPATIBLE_VERSION_CODE = "minCompatibleVersionCode";
38 const std::string APPLICATION_API_COMPATIBLE_VERSION = "apiCompatibleVersion";
39 const std::string APPLICATION_API_TARGET_VERSION = "apiTargetVersion";
40 const std::string APPLICATION_ICON_PATH = "iconPath";
41 const std::string APPLICATION_ICON_ID = "iconId";
42 const std::string APPLICATION_LABEL = "label";
43 const std::string APPLICATION_LABEL_ID = "labelId";
44 const std::string APPLICATION_DESCRIPTION = "description";
45 const std::string APPLICATION_DESCRIPTION_ID = "descriptionId";
46 const std::string APPLICATION_KEEP_ALIVE = "keepAlive";
47 const std::string APPLICATION_REMOVABLE = "removable";
48 const std::string APPLICATION_SINGLETON = "singleton";
49 const std::string APPLICATION_USER_DATA_CLEARABLE = "userDataClearable";
50 const std::string APPLICATION_IS_SYSTEM_APP = "isSystemApp";
51 const std::string APPLICATION_IS_LAUNCHER_APP = "isLauncherApp";
52 const std::string APPLICATION_IS_FREEINSTALL_APP = "isFreeInstallApp";
53 const std::string APPLICATION_RUNNING_RESOURCES_APPLY = "runningResourcesApply";
54 const std::string APPLICATION_ASSOCIATED_WAKE_UP = "associatedWakeUp";
55 const std::string APPLICATION_HIDE_DESKTOP_ICON = "hideDesktopIcon";
56 const std::string APPLICATION_FORM_VISIBLE_NOTIFY = "formVisibleNotify";
57 const std::string APPLICATION_ALLOW_COMMON_EVENT = "allowCommonEvent";
58 const std::string APPLICATION_CODE_PATH = "codePath";
59 const std::string APPLICATION_DATA_DIR = "dataDir";
60 const std::string APPLICATION_DATA_BASE_DIR = "dataBaseDir";
61 const std::string APPLICATION_CACHE_DIR = "cacheDir";
62 const std::string APPLICATION_ENTRY_DIR = "entryDir";
63 const std::string APPLICATION_API_RELEASETYPE = "apiReleaseType";
64 const std::string APPLICATION_DEBUG = "debug";
65 const std::string APPLICATION_DEVICE_ID = "deviceId";
66 const std::string APPLICATION_DISTRIBUTED_NOTIFICATION_ENABLED = "distributedNotificationEnabled";
67 const std::string APPLICATION_ENTITY_TYPE = "entityType";
68 const std::string APPLICATION_PROCESS = "process";
69 const std::string APPLICATION_SUPPORTED_MODES = "supportedModes";
70 const std::string APPLICATION_VENDOR = "vendor";
71 const std::string APPLICATION_ACCESSIBLE = "accessible";
72 const std::string APPLICATION_PRIVILEGE_LEVEL = "appPrivilegeLevel";
73 const std::string APPLICATION_ACCESSTOKEN_ID = "accessTokenId";
74 const std::string APPLICATION_ACCESSTOKEN_ID_EX = "accessTokenIdEx";
75 const std::string APPLICATION_ENABLED = "enabled";
76 const std::string APPLICATION_UID = "uid";
77 const std::string APPLICATION_PERMISSIONS = "permissions";
78 const std::string APPLICATION_MODULE_SOURCE_DIRS = "moduleSourceDirs";
79 const std::string APPLICATION_MODULE_INFOS = "moduleInfos";
80 const std::string APPLICATION_META_DATA_CONFIG_JSON = "metaData";
81 const std::string APPLICATION_META_DATA_MODULE_JSON = "metadata";
82 const std::string APPLICATION_FINGERPRINT = "fingerprint";
83 const std::string APPLICATION_ICON = "icon";
84 const std::string APPLICATION_FLAGS = "flags";
85 const std::string APPLICATION_ENTRY_MODULE_NAME = "entryModuleName";
86 const std::string APPLICATION_NATIVE_LIBRARY_PATH = "nativeLibraryPath";
87 const std::string APPLICATION_CPU_ABI = "cpuAbi";
88 const std::string APPLICATION_ARK_NATIVE_FILE_PATH = "arkNativeFilePath";
89 const std::string APPLICATION_ARK_NATIVE_FILE_ABI = "arkNativeFileAbi";
90 const std::string APPLICATION_IS_COMPRESS_NATIVE_LIBS = "isCompressNativeLibs";
91 const std::string APPLICATION_SIGNATURE_KEY = "signatureKey";
92 const std::string APPLICATION_TARGETBUNDLELIST = "targetBundleList";
93 const std::string APPLICATION_APP_DISTRIBUTION_TYPE = "appDistributionType";
94 const std::string APPLICATION_APP_PROVISION_TYPE = "appProvisionType";
95 const std::string APPLICATION_ICON_RESOURCE = "iconResource";
96 const std::string APPLICATION_LABEL_RESOURCE = "labelResource";
97 const std::string APPLICATION_DESCRIPTION_RESOURCE = "descriptionResource";
98 const std::string APPLICATION_MULTI_PROJECTS = "multiProjects";
99 const std::string APPLICATION_CROWDTEST_DEADLINE = "crowdtestDeadline";
100 const std::string RESOURCE_ID = "id";
101 const std::string APPLICATION_NEED_APP_DETAIL = "needAppDetail";
102 const std::string APPLICATION_APP_DETAIL_ABILITY_LIBRARY_PATH = "appDetailAbilityLibraryPath";
103 const std::string APPLICATION_APP_TARGET_BUNDLE_NAME = "targetBundleName";
104 const std::string APPLICATION_APP_TARGET_PRIORITY = "targetPriority";
105 const std::string APPLICATION_APP_OVERLAY_STATE = "overlayState";
106 const std::string APPLICATION_ASAN_ENABLED = "asanEnabled";
107 const std::string APPLICATION_ASAN_LOG_PATH = "asanLogPath";
108 const std::string APPLICATION_APP_TYPE = "bundleType";
109 const std::string APPLICATION_COMPILE_SDK_VERSION = "compileSdkVersion";
110 const std::string APPLICATION_COMPILE_SDK_TYPE = "compileSdkType";
111 const std::string APPLICATION_RESOURCES_APPLY = "resourcesApply";
112 }
to_json(nlohmann::json & jsonObject,const Resource & resource)113 void to_json(nlohmann::json &jsonObject, const Resource &resource)
114 {
115     jsonObject = nlohmann::json {
116         {Constants::BUNDLE_NAME, resource.bundleName},
117         {Constants::MODULE_NAME, resource.moduleName},
118         {RESOURCE_ID, resource.id}
119     };
120 }
121 
from_json(const nlohmann::json & jsonObject,Resource & resource)122 void from_json(const nlohmann::json &jsonObject, Resource &resource)
123 {
124     const auto &jsonObjectEnd = jsonObject.end();
125     int32_t parseResult = ERR_OK;
126     GetValueIfFindKey<std::string>(jsonObject,
127         jsonObjectEnd,
128         Constants::BUNDLE_NAME,
129         resource.bundleName,
130         JsonType::STRING,
131         true,
132         parseResult,
133         ArrayType::NOT_ARRAY);
134     GetValueIfFindKey<std::string>(jsonObject,
135         jsonObjectEnd,
136         Constants::MODULE_NAME,
137         resource.moduleName,
138         JsonType::STRING,
139         true,
140         parseResult,
141         ArrayType::NOT_ARRAY);
142     GetValueIfFindKey<int32_t>(jsonObject,
143         jsonObjectEnd,
144         RESOURCE_ID,
145         resource.id,
146         JsonType::NUMBER,
147         true,
148         parseResult,
149         ArrayType::NOT_ARRAY);
150     if (parseResult != ERR_OK) {
151         TAG_LOGD(AAFwkTag::ABILITY_SIM, "read Resource from database error,:%{public}d", parseResult);
152     }
153 }
154 
to_json(nlohmann::json & jsonObject,const ApplicationInfo & applicationInfo)155 void to_json(nlohmann::json &jsonObject, const ApplicationInfo &applicationInfo)
156 {
157     jsonObject = nlohmann::json {
158         {APPLICATION_NAME, applicationInfo.name},
159         {Constants::BUNDLE_NAME, applicationInfo.bundleName},
160         {APPLICATION_VERSION_CODE, applicationInfo.versionCode},
161         {APPLICATION_VERSION_NAME, applicationInfo.versionName},
162         {APPLICATION_MIN_COMPATIBLE_VERSION_CODE, applicationInfo.minCompatibleVersionCode},
163         {APPLICATION_API_COMPATIBLE_VERSION, applicationInfo.apiCompatibleVersion},
164         {APPLICATION_API_TARGET_VERSION, applicationInfo.apiTargetVersion},
165         {APPLICATION_ICON_PATH, applicationInfo.iconPath},
166         {APPLICATION_ICON_ID, applicationInfo.iconId},
167         {APPLICATION_LABEL, applicationInfo.label},
168         {APPLICATION_LABEL_ID, applicationInfo.labelId},
169         {APPLICATION_DESCRIPTION, applicationInfo.description},
170         {APPLICATION_DESCRIPTION_ID, applicationInfo.descriptionId},
171         {APPLICATION_KEEP_ALIVE, applicationInfo.keepAlive},
172         {APPLICATION_REMOVABLE, applicationInfo.removable},
173         {APPLICATION_SINGLETON, applicationInfo.singleton},
174         {APPLICATION_USER_DATA_CLEARABLE, applicationInfo.userDataClearable},
175         {APPLICATION_ACCESSIBLE, applicationInfo.accessible},
176         {APPLICATION_IS_SYSTEM_APP, applicationInfo.isSystemApp},
177         {APPLICATION_IS_LAUNCHER_APP, applicationInfo.isLauncherApp},
178         {APPLICATION_IS_FREEINSTALL_APP, applicationInfo.isFreeInstallApp},
179         {APPLICATION_RUNNING_RESOURCES_APPLY, applicationInfo.runningResourcesApply},
180         {APPLICATION_ASSOCIATED_WAKE_UP, applicationInfo.associatedWakeUp},
181         {APPLICATION_HIDE_DESKTOP_ICON, applicationInfo.hideDesktopIcon},
182         {APPLICATION_FORM_VISIBLE_NOTIFY, applicationInfo.formVisibleNotify},
183         {APPLICATION_ALLOW_COMMON_EVENT, applicationInfo.allowCommonEvent},
184         {APPLICATION_CODE_PATH, applicationInfo.codePath},
185         {APPLICATION_DATA_DIR, applicationInfo.dataDir},
186         {APPLICATION_DATA_BASE_DIR, applicationInfo.dataBaseDir},
187         {APPLICATION_CACHE_DIR, applicationInfo.cacheDir},
188         {APPLICATION_ENTRY_DIR, applicationInfo.entryDir},
189         {APPLICATION_API_RELEASETYPE, applicationInfo.apiReleaseType},
190         {APPLICATION_DEBUG, applicationInfo.debug},
191         {APPLICATION_DEVICE_ID, applicationInfo.deviceId},
192         {APPLICATION_DISTRIBUTED_NOTIFICATION_ENABLED, applicationInfo.distributedNotificationEnabled},
193         {APPLICATION_ENTITY_TYPE, applicationInfo.entityType},
194         {APPLICATION_PROCESS, applicationInfo.process},
195         {APPLICATION_SUPPORTED_MODES, applicationInfo.supportedModes},
196         {APPLICATION_VENDOR, applicationInfo.vendor},
197         {APPLICATION_PRIVILEGE_LEVEL, applicationInfo.appPrivilegeLevel},
198         {APPLICATION_ACCESSTOKEN_ID, applicationInfo.accessTokenId},
199         {APPLICATION_ACCESSTOKEN_ID_EX, applicationInfo.accessTokenIdEx},
200         {APPLICATION_ENABLED, applicationInfo.enabled},
201         {APPLICATION_UID, applicationInfo.uid},
202         {APPLICATION_PERMISSIONS, applicationInfo.permissions},
203         {APPLICATION_MODULE_SOURCE_DIRS, applicationInfo.moduleSourceDirs},
204         {APPLICATION_MODULE_INFOS, applicationInfo.moduleInfos},
205         {APPLICATION_META_DATA_CONFIG_JSON, applicationInfo.metaData},
206         {APPLICATION_META_DATA_MODULE_JSON, applicationInfo.metadata},
207         {APPLICATION_FINGERPRINT, applicationInfo.fingerprint},
208         {APPLICATION_ICON, applicationInfo.icon},
209         {APPLICATION_FLAGS, applicationInfo.flags},
210         {APPLICATION_ENTRY_MODULE_NAME, applicationInfo.entryModuleName},
211         {APPLICATION_NATIVE_LIBRARY_PATH, applicationInfo.nativeLibraryPath},
212         {APPLICATION_CPU_ABI, applicationInfo.cpuAbi},
213         {APPLICATION_ARK_NATIVE_FILE_PATH, applicationInfo.arkNativeFilePath},
214         {APPLICATION_ARK_NATIVE_FILE_ABI, applicationInfo.arkNativeFileAbi},
215         {APPLICATION_IS_COMPRESS_NATIVE_LIBS, applicationInfo.isCompressNativeLibs},
216         {APPLICATION_SIGNATURE_KEY, applicationInfo.signatureKey},
217         {APPLICATION_TARGETBUNDLELIST, applicationInfo.targetBundleList},
218         {APPLICATION_APP_DISTRIBUTION_TYPE, applicationInfo.appDistributionType},
219         {APPLICATION_APP_PROVISION_TYPE, applicationInfo.appProvisionType},
220         {APPLICATION_ICON_RESOURCE, applicationInfo.iconResource},
221         {APPLICATION_LABEL_RESOURCE, applicationInfo.labelResource},
222         {APPLICATION_DESCRIPTION_RESOURCE, applicationInfo.descriptionResource},
223         {APPLICATION_MULTI_PROJECTS, applicationInfo.multiProjects},
224         {APPLICATION_CROWDTEST_DEADLINE, applicationInfo.crowdtestDeadline},
225         {APPLICATION_NEED_APP_DETAIL, applicationInfo.needAppDetail},
226         {APPLICATION_APP_DETAIL_ABILITY_LIBRARY_PATH, applicationInfo.appDetailAbilityLibraryPath},
227         {APPLICATION_APP_TARGET_BUNDLE_NAME, applicationInfo.targetBundleName},
228         {APPLICATION_APP_TARGET_PRIORITY, applicationInfo.targetPriority},
229         {APPLICATION_APP_OVERLAY_STATE, applicationInfo.overlayState},
230         {APPLICATION_ASAN_ENABLED, applicationInfo.asanEnabled},
231         {APPLICATION_ASAN_LOG_PATH, applicationInfo.asanLogPath},
232         {APPLICATION_APP_TYPE, applicationInfo.bundleType},
233         {APPLICATION_COMPILE_SDK_VERSION, applicationInfo.compileSdkVersion},
234         {APPLICATION_COMPILE_SDK_TYPE, applicationInfo.compileSdkType},
235         {APPLICATION_RESOURCES_APPLY, applicationInfo.resourcesApply},
236     };
237 }
238 
from_json(const nlohmann::json & jsonObject,ApplicationInfo & applicationInfo)239 void from_json(const nlohmann::json &jsonObject, ApplicationInfo &applicationInfo)
240 {
241     const auto &jsonObjectEnd = jsonObject.end();
242     int32_t parseResult = ERR_OK;
243     GetValueIfFindKey<std::string>(jsonObject,
244         jsonObjectEnd,
245         APPLICATION_NAME,
246         applicationInfo.name,
247         JsonType::STRING,
248         false,
249         parseResult,
250         ArrayType::NOT_ARRAY);
251     GetValueIfFindKey<std::string>(jsonObject,
252         jsonObjectEnd,
253         Constants::BUNDLE_NAME,
254         applicationInfo.bundleName,
255         JsonType::STRING,
256         false,
257         parseResult,
258         ArrayType::NOT_ARRAY);
259     GetValueIfFindKey<uint32_t>(jsonObject,
260         jsonObjectEnd,
261         APPLICATION_VERSION_CODE,
262         applicationInfo.versionCode,
263         JsonType::NUMBER,
264         false,
265         parseResult,
266         ArrayType::NOT_ARRAY);
267     GetValueIfFindKey<std::string>(jsonObject,
268         jsonObjectEnd,
269         APPLICATION_VERSION_NAME,
270         applicationInfo.versionName,
271         JsonType::STRING,
272         false,
273         parseResult,
274         ArrayType::NOT_ARRAY);
275     GetValueIfFindKey<int32_t>(jsonObject,
276         jsonObjectEnd,
277         APPLICATION_MIN_COMPATIBLE_VERSION_CODE,
278         applicationInfo.minCompatibleVersionCode,
279         JsonType::NUMBER,
280         false,
281         parseResult,
282         ArrayType::NOT_ARRAY);
283     GetValueIfFindKey<int32_t>(jsonObject,
284         jsonObjectEnd,
285         APPLICATION_API_COMPATIBLE_VERSION,
286         applicationInfo.apiCompatibleVersion,
287         JsonType::NUMBER,
288         false,
289         parseResult,
290         ArrayType::NOT_ARRAY);
291     GetValueIfFindKey<int32_t>(jsonObject,
292         jsonObjectEnd,
293         APPLICATION_API_TARGET_VERSION,
294         applicationInfo.apiTargetVersion,
295         JsonType::NUMBER,
296         false,
297         parseResult,
298         ArrayType::NOT_ARRAY);
299     GetValueIfFindKey<std::string>(jsonObject,
300         jsonObjectEnd,
301         APPLICATION_ICON_PATH,
302         applicationInfo.iconPath,
303         JsonType::STRING,
304         false,
305         parseResult,
306         ArrayType::NOT_ARRAY);
307     GetValueIfFindKey<int32_t>(jsonObject,
308         jsonObjectEnd,
309         APPLICATION_ICON_ID,
310         applicationInfo.iconId,
311         JsonType::NUMBER,
312         false,
313         parseResult,
314         ArrayType::NOT_ARRAY);
315     GetValueIfFindKey<std::string>(jsonObject,
316         jsonObjectEnd,
317         APPLICATION_LABEL,
318         applicationInfo.label,
319         JsonType::STRING,
320         false,
321         parseResult,
322         ArrayType::NOT_ARRAY);
323     GetValueIfFindKey<int32_t>(jsonObject,
324         jsonObjectEnd,
325         APPLICATION_LABEL_ID,
326         applicationInfo.labelId,
327         JsonType::NUMBER,
328         false,
329         parseResult,
330         ArrayType::NOT_ARRAY);
331     GetValueIfFindKey<std::string>(jsonObject,
332         jsonObjectEnd,
333         APPLICATION_DESCRIPTION,
334         applicationInfo.description,
335         JsonType::STRING,
336         false,
337         parseResult,
338         ArrayType::NOT_ARRAY);
339     GetValueIfFindKey<int32_t>(jsonObject,
340         jsonObjectEnd,
341         APPLICATION_DESCRIPTION_ID,
342         applicationInfo.descriptionId,
343         JsonType::NUMBER,
344         false,
345         parseResult,
346         ArrayType::NOT_ARRAY);
347     GetValueIfFindKey<bool>(jsonObject,
348         jsonObjectEnd,
349         APPLICATION_KEEP_ALIVE,
350         applicationInfo.keepAlive,
351         JsonType::BOOLEAN,
352         false,
353         parseResult,
354         ArrayType::NOT_ARRAY);
355     GetValueIfFindKey<bool>(jsonObject,
356         jsonObjectEnd,
357         APPLICATION_REMOVABLE,
358         applicationInfo.removable,
359         JsonType::BOOLEAN,
360         false,
361         parseResult,
362         ArrayType::NOT_ARRAY);
363     GetValueIfFindKey<bool>(jsonObject,
364         jsonObjectEnd,
365         APPLICATION_SINGLETON,
366         applicationInfo.singleton,
367         JsonType::BOOLEAN,
368         false,
369         parseResult,
370         ArrayType::NOT_ARRAY);
371     GetValueIfFindKey<bool>(jsonObject,
372         jsonObjectEnd,
373         APPLICATION_USER_DATA_CLEARABLE,
374         applicationInfo.userDataClearable,
375         JsonType::BOOLEAN,
376         false,
377         parseResult,
378         ArrayType::NOT_ARRAY);
379     GetValueIfFindKey<bool>(jsonObject,
380         jsonObjectEnd,
381         APPLICATION_ACCESSIBLE,
382         applicationInfo.accessible,
383         JsonType::BOOLEAN,
384         false,
385         parseResult,
386         ArrayType::NOT_ARRAY);
387     GetValueIfFindKey<bool>(jsonObject,
388         jsonObjectEnd,
389         APPLICATION_IS_SYSTEM_APP,
390         applicationInfo.isSystemApp,
391         JsonType::BOOLEAN,
392         false,
393         parseResult,
394         ArrayType::NOT_ARRAY);
395     GetValueIfFindKey<bool>(jsonObject,
396         jsonObjectEnd,
397         APPLICATION_IS_LAUNCHER_APP,
398         applicationInfo.isLauncherApp,
399         JsonType::BOOLEAN,
400         false,
401         parseResult,
402         ArrayType::NOT_ARRAY);
403     GetValueIfFindKey<bool>(jsonObject,
404         jsonObjectEnd,
405         APPLICATION_IS_FREEINSTALL_APP,
406         applicationInfo.isFreeInstallApp,
407         JsonType::BOOLEAN,
408         false,
409         parseResult,
410         ArrayType::NOT_ARRAY);
411     GetValueIfFindKey<bool>(jsonObject,
412         jsonObjectEnd,
413         APPLICATION_RUNNING_RESOURCES_APPLY,
414         applicationInfo.runningResourcesApply,
415         JsonType::BOOLEAN,
416         false,
417         parseResult,
418         ArrayType::NOT_ARRAY);
419     GetValueIfFindKey<bool>(jsonObject,
420         jsonObjectEnd,
421         APPLICATION_ASSOCIATED_WAKE_UP,
422         applicationInfo.associatedWakeUp,
423         JsonType::BOOLEAN,
424         false,
425         parseResult,
426         ArrayType::NOT_ARRAY);
427     GetValueIfFindKey<bool>(jsonObject,
428         jsonObjectEnd,
429         APPLICATION_HIDE_DESKTOP_ICON,
430         applicationInfo.hideDesktopIcon,
431         JsonType::BOOLEAN,
432         false,
433         parseResult,
434         ArrayType::NOT_ARRAY);
435     GetValueIfFindKey<bool>(jsonObject,
436         jsonObjectEnd,
437         APPLICATION_FORM_VISIBLE_NOTIFY,
438         applicationInfo.formVisibleNotify,
439         JsonType::BOOLEAN,
440         false,
441         parseResult,
442         ArrayType::NOT_ARRAY);
443     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
444         jsonObjectEnd,
445         APPLICATION_ALLOW_COMMON_EVENT,
446         applicationInfo.allowCommonEvent,
447         JsonType::ARRAY,
448         false,
449         parseResult,
450         ArrayType::STRING);
451     GetValueIfFindKey<std::string>(jsonObject,
452         jsonObjectEnd,
453         APPLICATION_CODE_PATH,
454         applicationInfo.codePath,
455         JsonType::STRING,
456         false,
457         parseResult,
458         ArrayType::NOT_ARRAY);
459     GetValueIfFindKey<std::string>(jsonObject,
460         jsonObjectEnd,
461         APPLICATION_DATA_DIR,
462         applicationInfo.dataDir,
463         JsonType::STRING,
464         false,
465         parseResult,
466         ArrayType::NOT_ARRAY);
467     GetValueIfFindKey<std::string>(jsonObject,
468         jsonObjectEnd,
469         APPLICATION_DATA_BASE_DIR,
470         applicationInfo.dataBaseDir,
471         JsonType::STRING,
472         false,
473         parseResult,
474         ArrayType::NOT_ARRAY);
475     GetValueIfFindKey<std::string>(jsonObject,
476         jsonObjectEnd,
477         APPLICATION_CACHE_DIR,
478         applicationInfo.cacheDir,
479         JsonType::STRING,
480         false,
481         parseResult,
482         ArrayType::NOT_ARRAY);
483     GetValueIfFindKey<std::string>(jsonObject,
484         jsonObjectEnd,
485         APPLICATION_ENTRY_DIR,
486         applicationInfo.entryDir,
487         JsonType::STRING,
488         false,
489         parseResult,
490         ArrayType::NOT_ARRAY);
491     GetValueIfFindKey<std::string>(jsonObject,
492         jsonObjectEnd,
493         APPLICATION_API_RELEASETYPE,
494         applicationInfo.apiReleaseType,
495         JsonType::STRING,
496         false,
497         parseResult,
498         ArrayType::NOT_ARRAY);
499     GetValueIfFindKey<bool>(jsonObject,
500         jsonObjectEnd,
501         APPLICATION_DEBUG,
502         applicationInfo.debug,
503         JsonType::BOOLEAN,
504         false,
505         parseResult,
506         ArrayType::NOT_ARRAY);
507     GetValueIfFindKey<std::string>(jsonObject,
508         jsonObjectEnd,
509         APPLICATION_DEVICE_ID,
510         applicationInfo.deviceId,
511         JsonType::STRING,
512         false,
513         parseResult,
514         ArrayType::NOT_ARRAY);
515     GetValueIfFindKey<bool>(jsonObject,
516         jsonObjectEnd,
517         APPLICATION_DISTRIBUTED_NOTIFICATION_ENABLED,
518         applicationInfo.distributedNotificationEnabled,
519         JsonType::BOOLEAN,
520         false,
521         parseResult,
522         ArrayType::NOT_ARRAY);
523     GetValueIfFindKey<std::string>(jsonObject,
524         jsonObjectEnd,
525         APPLICATION_ENTITY_TYPE,
526         applicationInfo.entityType,
527         JsonType::STRING,
528         false,
529         parseResult,
530         ArrayType::NOT_ARRAY);
531     GetValueIfFindKey<std::string>(jsonObject,
532         jsonObjectEnd,
533         APPLICATION_PROCESS,
534         applicationInfo.process,
535         JsonType::STRING,
536         false,
537         parseResult,
538         ArrayType::NOT_ARRAY);
539     GetValueIfFindKey<int>(jsonObject,
540         jsonObjectEnd,
541         APPLICATION_SUPPORTED_MODES,
542         applicationInfo.supportedModes,
543         JsonType::NUMBER,
544         false,
545         parseResult,
546         ArrayType::NOT_ARRAY);
547     GetValueIfFindKey<std::string>(jsonObject,
548         jsonObjectEnd,
549         APPLICATION_VENDOR,
550         applicationInfo.vendor,
551         JsonType::STRING,
552         false,
553         parseResult,
554         ArrayType::NOT_ARRAY);
555     GetValueIfFindKey<std::string>(jsonObject,
556         jsonObjectEnd,
557         APPLICATION_PRIVILEGE_LEVEL,
558         applicationInfo.appPrivilegeLevel,
559         JsonType::STRING,
560         false,
561         parseResult,
562         ArrayType::NOT_ARRAY);
563     GetValueIfFindKey<uint32_t>(jsonObject,
564         jsonObjectEnd,
565         APPLICATION_ACCESSTOKEN_ID,
566         applicationInfo.accessTokenId,
567         JsonType::NUMBER,
568         false,
569         parseResult,
570         ArrayType::NOT_ARRAY);
571     GetValueIfFindKey<uint64_t>(jsonObject,
572         jsonObjectEnd,
573         APPLICATION_ACCESSTOKEN_ID_EX,
574         applicationInfo.accessTokenIdEx,
575         JsonType::NUMBER,
576         false,
577         parseResult,
578         ArrayType::NOT_ARRAY);
579     GetValueIfFindKey<bool>(jsonObject,
580         jsonObjectEnd,
581         APPLICATION_ENABLED,
582         applicationInfo.enabled,
583         JsonType::BOOLEAN,
584         false,
585         parseResult,
586         ArrayType::NOT_ARRAY);
587     GetValueIfFindKey<int>(jsonObject,
588         jsonObjectEnd,
589         APPLICATION_UID,
590         applicationInfo.uid,
591         JsonType::NUMBER,
592         false,
593         parseResult,
594         ArrayType::NOT_ARRAY);
595     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
596         jsonObjectEnd,
597         APPLICATION_PERMISSIONS,
598         applicationInfo.permissions,
599         JsonType::ARRAY,
600         false,
601         parseResult,
602         ArrayType::STRING);
603     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
604         jsonObjectEnd,
605         APPLICATION_MODULE_SOURCE_DIRS,
606         applicationInfo.moduleSourceDirs,
607         JsonType::ARRAY,
608         false,
609         parseResult,
610         ArrayType::STRING);
611     GetValueIfFindKey<std::vector<ModuleInfo>>(jsonObject,
612         jsonObjectEnd,
613         APPLICATION_MODULE_INFOS,
614         applicationInfo.moduleInfos,
615         JsonType::ARRAY,
616         false,
617         parseResult,
618         ArrayType::OBJECT);
619     GetValueIfFindKey<std::map<std::string, std::vector<CustomizeData>>>(jsonObject,
620         jsonObjectEnd,
621         APPLICATION_META_DATA_CONFIG_JSON,
622         applicationInfo.metaData,
623         JsonType::OBJECT,
624         false,
625         parseResult,
626         ArrayType::NOT_ARRAY);
627     GetValueIfFindKey<std::map<std::string, std::vector<Metadata>>>(jsonObject,
628         jsonObjectEnd,
629         APPLICATION_META_DATA_MODULE_JSON,
630         applicationInfo.metadata,
631         JsonType::OBJECT,
632         false,
633         parseResult,
634         ArrayType::NOT_ARRAY);
635     GetValueIfFindKey<std::string>(jsonObject,
636         jsonObjectEnd,
637         APPLICATION_FINGERPRINT,
638         applicationInfo.fingerprint,
639         JsonType::STRING,
640         false,
641         parseResult,
642         ArrayType::NOT_ARRAY);
643     GetValueIfFindKey<std::string>(jsonObject,
644         jsonObjectEnd,
645         APPLICATION_ICON,
646         applicationInfo.icon,
647         JsonType::STRING,
648         false,
649         parseResult,
650         ArrayType::NOT_ARRAY);
651     GetValueIfFindKey<int>(jsonObject,
652         jsonObjectEnd,
653         APPLICATION_FLAGS,
654         applicationInfo.flags,
655         JsonType::NUMBER,
656         false,
657         parseResult,
658         ArrayType::NOT_ARRAY);
659     GetValueIfFindKey<std::string>(jsonObject,
660         jsonObjectEnd,
661         APPLICATION_ENTRY_MODULE_NAME,
662         applicationInfo.entryModuleName,
663         JsonType::STRING,
664         false,
665         parseResult,
666         ArrayType::NOT_ARRAY);
667     GetValueIfFindKey<std::string>(jsonObject,
668         jsonObjectEnd,
669         APPLICATION_NATIVE_LIBRARY_PATH,
670         applicationInfo.nativeLibraryPath,
671         JsonType::STRING,
672         false,
673         parseResult,
674         ArrayType::NOT_ARRAY);
675     GetValueIfFindKey<std::string>(jsonObject,
676         jsonObjectEnd,
677         APPLICATION_CPU_ABI,
678         applicationInfo.cpuAbi,
679         JsonType::STRING,
680         false,
681         parseResult,
682         ArrayType::NOT_ARRAY);
683     GetValueIfFindKey<std::string>(jsonObject,
684         jsonObjectEnd,
685         APPLICATION_ARK_NATIVE_FILE_PATH,
686         applicationInfo.arkNativeFilePath,
687         JsonType::STRING,
688         false,
689         parseResult,
690         ArrayType::NOT_ARRAY);
691     GetValueIfFindKey<std::string>(jsonObject,
692         jsonObjectEnd,
693         APPLICATION_ARK_NATIVE_FILE_ABI,
694         applicationInfo.arkNativeFileAbi,
695         JsonType::STRING,
696         false,
697         parseResult,
698         ArrayType::NOT_ARRAY);
699     GetValueIfFindKey<bool>(jsonObject,
700         jsonObjectEnd,
701         APPLICATION_IS_COMPRESS_NATIVE_LIBS,
702         applicationInfo.isCompressNativeLibs,
703         JsonType::BOOLEAN,
704         false,
705         parseResult,
706         ArrayType::NOT_ARRAY);
707     GetValueIfFindKey<std::string>(jsonObject,
708         jsonObjectEnd,
709         APPLICATION_SIGNATURE_KEY,
710         applicationInfo.signatureKey,
711         JsonType::STRING,
712         false,
713         parseResult,
714         ArrayType::NOT_ARRAY);
715     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
716         jsonObjectEnd,
717         APPLICATION_TARGETBUNDLELIST,
718         applicationInfo.targetBundleList,
719         JsonType::ARRAY,
720         false,
721         parseResult,
722         ArrayType::STRING);
723     GetValueIfFindKey<std::string>(jsonObject,
724         jsonObjectEnd,
725         APPLICATION_APP_DISTRIBUTION_TYPE,
726         applicationInfo.appDistributionType,
727         JsonType::STRING,
728         false,
729         parseResult,
730         ArrayType::NOT_ARRAY);
731     GetValueIfFindKey<std::string>(jsonObject,
732         jsonObjectEnd,
733         APPLICATION_APP_PROVISION_TYPE,
734         applicationInfo.appProvisionType,
735         JsonType::STRING,
736         false,
737         parseResult,
738         ArrayType::NOT_ARRAY);
739     GetValueIfFindKey<Resource>(jsonObject,
740         jsonObjectEnd,
741         APPLICATION_ICON_RESOURCE,
742         applicationInfo.iconResource,
743         JsonType::OBJECT,
744         false,
745         parseResult,
746         ArrayType::NOT_ARRAY);
747     GetValueIfFindKey<Resource>(jsonObject,
748         jsonObjectEnd,
749         APPLICATION_LABEL_RESOURCE,
750         applicationInfo.labelResource,
751         JsonType::OBJECT,
752         false,
753         parseResult,
754         ArrayType::NOT_ARRAY);
755     GetValueIfFindKey<Resource>(jsonObject,
756         jsonObjectEnd,
757         APPLICATION_DESCRIPTION_RESOURCE,
758         applicationInfo.descriptionResource,
759         JsonType::OBJECT,
760         false,
761         parseResult,
762         ArrayType::NOT_ARRAY);
763     GetValueIfFindKey<bool>(jsonObject,
764         jsonObjectEnd,
765         APPLICATION_MULTI_PROJECTS,
766         applicationInfo.multiProjects,
767         JsonType::BOOLEAN,
768         false,
769         parseResult,
770         ArrayType::NOT_ARRAY);
771     GetValueIfFindKey<int64_t>(jsonObject,
772         jsonObjectEnd,
773         APPLICATION_CROWDTEST_DEADLINE,
774         applicationInfo.crowdtestDeadline,
775         JsonType::NUMBER,
776         false,
777         parseResult,
778         ArrayType::NOT_ARRAY);
779     GetValueIfFindKey<bool>(jsonObject,
780         jsonObjectEnd,
781         APPLICATION_NEED_APP_DETAIL,
782         applicationInfo.needAppDetail,
783         JsonType::BOOLEAN,
784         false,
785         parseResult,
786         ArrayType::NOT_ARRAY);
787     GetValueIfFindKey<std::string>(jsonObject,
788         jsonObjectEnd,
789         APPLICATION_APP_DETAIL_ABILITY_LIBRARY_PATH,
790         applicationInfo.appDetailAbilityLibraryPath,
791         JsonType::STRING,
792         false,
793         parseResult,
794         ArrayType::NOT_ARRAY);
795     GetValueIfFindKey<std::string>(jsonObject,
796         jsonObjectEnd,
797         APPLICATION_APP_TARGET_BUNDLE_NAME,
798         applicationInfo.targetBundleName,
799         JsonType::STRING,
800         false,
801         parseResult,
802         ArrayType::NOT_ARRAY);
803     GetValueIfFindKey<int>(jsonObject,
804         jsonObjectEnd,
805         APPLICATION_APP_TARGET_PRIORITY,
806         applicationInfo.targetPriority,
807         JsonType::NUMBER,
808         false,
809         parseResult,
810         ArrayType::NOT_ARRAY);
811     GetValueIfFindKey<int>(jsonObject,
812         jsonObjectEnd,
813         APPLICATION_APP_OVERLAY_STATE,
814         applicationInfo.overlayState,
815         JsonType::NUMBER,
816         false,
817         parseResult,
818         ArrayType::NOT_ARRAY);
819     GetValueIfFindKey<bool>(jsonObject,
820         jsonObjectEnd,
821         APPLICATION_ASAN_ENABLED,
822         applicationInfo.asanEnabled,
823         JsonType::BOOLEAN,
824         false,
825         parseResult,
826         ArrayType::NOT_ARRAY);
827     GetValueIfFindKey<std::string>(jsonObject,
828         jsonObjectEnd,
829         APPLICATION_ASAN_LOG_PATH,
830         applicationInfo.asanLogPath,
831         JsonType::STRING,
832         false,
833         parseResult,
834         ArrayType::NOT_ARRAY);
835     GetValueIfFindKey<BundleType>(jsonObject,
836         jsonObjectEnd,
837         APPLICATION_APP_TYPE,
838         applicationInfo.bundleType,
839         JsonType::NUMBER,
840         false,
841         parseResult,
842         ArrayType::NOT_ARRAY);
843     GetValueIfFindKey<std::string>(jsonObject,
844         jsonObjectEnd,
845         APPLICATION_COMPILE_SDK_VERSION,
846         applicationInfo.compileSdkVersion,
847         JsonType::STRING,
848         false,
849         parseResult,
850         ArrayType::NOT_ARRAY);
851     GetValueIfFindKey<std::string>(jsonObject,
852         jsonObjectEnd,
853         APPLICATION_COMPILE_SDK_TYPE,
854         applicationInfo.compileSdkType,
855         JsonType::STRING,
856         false,
857         parseResult,
858         ArrayType::NOT_ARRAY);
859     GetValueIfFindKey<std::vector<int32_t>>(jsonObject,
860         jsonObjectEnd,
861         APPLICATION_RESOURCES_APPLY,
862         applicationInfo.resourcesApply,
863         JsonType::ARRAY,
864         false,
865         parseResult,
866         ArrayType::NUMBER);
867     if (parseResult != ERR_OK) {
868         TAG_LOGE(AAFwkTag::ABILITY_SIM, "from_json error:%{public}d", parseResult);
869     }
870 }
871 }  // namespace AppExecFwk
872 }  // namespace OHOS
873