1 /*
2 * Copyright (c) 2025 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 "bundle_info.h"
17
18 #include <cstdint>
19
20 #include "hilog_tag_wrapper.h"
21 #include "json_util.h"
22 #include "string_ex.h"
23
24 namespace OHOS {
25 namespace AppExecFwk {
26 namespace {
27 const char* BUNDLE_INFO_NAME = "name";
28 const char* BUNDLE_INFO_LABEL = "label";
29 const char* BUNDLE_INFO_DESCRIPTION = "description";
30 const char* BUNDLE_INFO_VENDOR = "vendor";
31 const char* BUNDLE_INFO_IS_KEEP_ALIVE = "isKeepAlive";
32 const char* BUNDLE_INFO_SINGLETON = "singleton";
33 const char* BUNDLE_INFO_IS_NATIVE_APP = "isNativeApp";
34 const char* BUNDLE_INFO_IS_PREINSTALL_APP = "isPreInstallApp";
35 const char* BUNDLE_INFO_IS_DIFFERENT_NAME = "isDifferentName";
36 const char* BUNDLE_INFO_ABILITY_INFOS = "abilityInfos";
37 const char* BUNDLE_INFO_HAP_MODULE_INFOS = "hapModuleInfos";
38 const char* BUNDLE_INFO_EXTENSION_ABILITY_INFOS = "extensionAbilityInfo";
39 const char* BUNDLE_INFO_JOINT_USERID = "jointUserId";
40 const char* BUNDLE_INFO_VERSION_CODE = "versionCode";
41 const char* BUNDLE_INFO_MIN_COMPATIBLE_VERSION_CODE = "minCompatibleVersionCode";
42 const char* BUNDLE_INFO_VERSION_NAME = "versionName";
43 const char* BUNDLE_INFO_MIN_SDK_VERSION = "minSdkVersion";
44 const char* BUNDLE_INFO_MAX_SDK_VERSION = "maxSdkVersion";
45 const char* BUNDLE_INFO_MAIN_ENTRY = "mainEntry";
46 const char* BUNDLE_INFO_CPU_ABI = "cpuAbi";
47 const char* BUNDLE_INFO_APPID = "appId";
48 const char* BUNDLE_INFO_COMPATIBLE_VERSION = "compatibleVersion";
49 const char* BUNDLE_INFO_TARGET_VERSION = "targetVersion";
50 const char* BUNDLE_INFO_RELEASE_TYPE = "releaseType";
51 const char* BUNDLE_INFO_UID = "uid";
52 const char* BUNDLE_INFO_GID = "gid";
53 const char* BUNDLE_INFO_SEINFO = "seInfo";
54 const char* BUNDLE_INFO_INSTALL_TIME = "installTime";
55 const char* BUNDLE_INFO_UPDATE_TIME = "updateTime";
56 const char* BUNDLE_INFO_FIRST_INSTALL_TIME = "firstInstallTime";
57 const char* BUNDLE_INFO_ENTRY_MODULE_NAME = "entryModuleName";
58 const char* BUNDLE_INFO_ENTRY_INSTALLATION_FREE = "entryInstallationFree";
59 const char* BUNDLE_INFO_REQ_PERMISSIONS = "reqPermissions";
60 const char* BUNDLE_INFO_REQ_PERMISSION_STATES = "reqPermissionStates";
61 const char* BUNDLE_INFO_REQ_PERMISSION_DETAILS = "reqPermissionDetails";
62 const char* BUNDLE_INFO_DEF_PERMISSIONS = "defPermissions";
63 const char* BUNDLE_INFO_HAP_MODULE_NAMES = "hapModuleNames";
64 const char* BUNDLE_INFO_MODULE_NAMES = "moduleNames";
65 const char* BUNDLE_INFO_MODULE_PUBLIC_DIRS = "modulePublicDirs";
66 const char* BUNDLE_INFO_MODULE_DIRS = "moduleDirs";
67 const char* BUNDLE_INFO_MODULE_RES_PATHS = "moduleResPaths";
68 const char* REQUESTPERMISSION_NAME = "name";
69 const char* REQUESTPERMISSION_REASON = "reason";
70 const char* REQUESTPERMISSION_REASON_ID = "reasonId";
71 const char* REQUESTPERMISSION_USEDSCENE = "usedScene";
72 const char* REQUESTPERMISSION_ABILITIES = "abilities";
73 const char* REQUESTPERMISSION_ABILITY = "ability";
74 const char* REQUESTPERMISSION_WHEN = "when";
75 const char* REQUESTPERMISSION_MODULE_NAME = "moduleName";
76 const char* SIGNATUREINFO_APPID = "appId";
77 const char* SIGNATUREINFO_FINGERPRINT = "fingerprint";
78 const char* BUNDLE_INFO_APP_INDEX = "appIndex";
79 const char* BUNDLE_INFO_ERROR_CODE = "errorCode";
80 const char* BUNDLE_INFO_SIGNATURE_INFO = "signatureInfo";
81 const char* OVERLAY_TYPE = "overlayType";
82 const char* OVERLAY_BUNDLE_INFO = "overlayBundleInfos";
83 const char* APP_IDENTIFIER = "appIdentifier";
84 const char* BUNDLE_INFO_OLD_APPIDS = "oldAppIds";
85 const char* BUNDLE_INFO_ROUTER_ARRAY = "routerArray";
86 const char* BUNDLE_INFO_IS_NEW_VERSION = "isNewVersion";
87 const char* BUNDLE_INFO_HAS_PLUGIN = "hasPlugin";
88 const uint32_t BUNDLE_CAPACITY = 204800; // 200K
89 }
90
to_json(nlohmann::json & jsonObject,const RequestPermissionUsedScene & usedScene)91 void to_json(nlohmann::json &jsonObject, const RequestPermissionUsedScene &usedScene)
92 {
93 jsonObject = nlohmann::json {
94 {REQUESTPERMISSION_ABILITIES, usedScene.abilities},
95 {REQUESTPERMISSION_WHEN, usedScene.when}
96 };
97 }
98
to_json(nlohmann::json & jsonObject,const RequestPermission & requestPermission)99 void to_json(nlohmann::json &jsonObject, const RequestPermission &requestPermission)
100 {
101 jsonObject = nlohmann::json {
102 {REQUESTPERMISSION_NAME, requestPermission.name},
103 {REQUESTPERMISSION_REASON, requestPermission.reason},
104 {REQUESTPERMISSION_REASON_ID, requestPermission.reasonId},
105 {REQUESTPERMISSION_USEDSCENE, requestPermission.usedScene},
106 {REQUESTPERMISSION_MODULE_NAME, requestPermission.moduleName}
107 };
108 }
109
to_json(nlohmann::json & jsonObject,const SignatureInfo & signatureInfo)110 void to_json(nlohmann::json &jsonObject, const SignatureInfo &signatureInfo)
111 {
112 jsonObject = nlohmann::json {
113 {SIGNATUREINFO_APPID, signatureInfo.appId},
114 {SIGNATUREINFO_FINGERPRINT, signatureInfo.fingerprint},
115 {APP_IDENTIFIER, signatureInfo.appIdentifier}
116 };
117 }
118
from_json(const nlohmann::json & jsonObject,RequestPermissionUsedScene & usedScene)119 void from_json(const nlohmann::json &jsonObject, RequestPermissionUsedScene &usedScene)
120 {
121 const auto &jsonObjectEnd = jsonObject.end();
122 int32_t parseResult = ERR_OK;
123 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
124 jsonObjectEnd,
125 REQUESTPERMISSION_ABILITIES,
126 usedScene.abilities,
127 JsonType::ARRAY,
128 false,
129 parseResult,
130 ArrayType::STRING);
131 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
132 jsonObjectEnd,
133 REQUESTPERMISSION_ABILITY,
134 usedScene.abilities,
135 JsonType::ARRAY,
136 false,
137 parseResult,
138 ArrayType::STRING);
139 GetValueIfFindKey<std::string>(jsonObject,
140 jsonObjectEnd,
141 REQUESTPERMISSION_WHEN,
142 usedScene.when,
143 JsonType::STRING,
144 false,
145 parseResult,
146 ArrayType::NOT_ARRAY);
147 if (parseResult != ERR_OK) {
148 TAG_LOGE(AAFwkTag::ABILITY_SIM, "read RequestPermissionUsedScene error : %{public}d", parseResult);
149 }
150 }
151
from_json(const nlohmann::json & jsonObject,RequestPermission & requestPermission)152 void from_json(const nlohmann::json &jsonObject, RequestPermission &requestPermission)
153 {
154 const auto &jsonObjectEnd = jsonObject.end();
155 int32_t parseResult = ERR_OK;
156 GetValueIfFindKey<std::string>(jsonObject,
157 jsonObjectEnd,
158 REQUESTPERMISSION_NAME,
159 requestPermission.name,
160 JsonType::STRING,
161 false,
162 parseResult,
163 ArrayType::NOT_ARRAY);
164 GetValueIfFindKey<std::string>(jsonObject,
165 jsonObjectEnd,
166 REQUESTPERMISSION_REASON,
167 requestPermission.reason,
168 JsonType::STRING,
169 false,
170 parseResult,
171 ArrayType::NOT_ARRAY);
172 GetValueIfFindKey<int32_t>(jsonObject,
173 jsonObjectEnd,
174 REQUESTPERMISSION_REASON_ID,
175 requestPermission.reasonId,
176 JsonType::NUMBER,
177 false,
178 parseResult,
179 ArrayType::NOT_ARRAY);
180 GetValueIfFindKey<RequestPermissionUsedScene>(jsonObject,
181 jsonObjectEnd,
182 REQUESTPERMISSION_USEDSCENE,
183 requestPermission.usedScene,
184 JsonType::OBJECT,
185 false,
186 parseResult,
187 ArrayType::NOT_ARRAY);
188 GetValueIfFindKey<std::string>(jsonObject,
189 jsonObjectEnd,
190 REQUESTPERMISSION_MODULE_NAME,
191 requestPermission.moduleName,
192 JsonType::STRING,
193 false,
194 parseResult,
195 ArrayType::NOT_ARRAY);
196 if (parseResult != ERR_OK) {
197 TAG_LOGE(AAFwkTag::ABILITY_SIM, "read RequestPermission error : %{public}d", parseResult);
198 }
199 }
200
from_json(const nlohmann::json & jsonObject,SignatureInfo & signatureInfo)201 void from_json(const nlohmann::json &jsonObject, SignatureInfo &signatureInfo)
202 {
203 const auto &jsonObjectEnd = jsonObject.end();
204 int32_t parseResult = ERR_OK;
205 GetValueIfFindKey<std::string>(jsonObject,
206 jsonObjectEnd,
207 SIGNATUREINFO_APPID,
208 signatureInfo.appId,
209 JsonType::STRING,
210 false,
211 parseResult,
212 ArrayType::NOT_ARRAY);
213 GetValueIfFindKey<std::string>(jsonObject,
214 jsonObjectEnd,
215 SIGNATUREINFO_FINGERPRINT,
216 signatureInfo.fingerprint,
217 JsonType::STRING,
218 false,
219 parseResult,
220 ArrayType::NOT_ARRAY);
221 GetValueIfFindKey<std::string>(jsonObject,
222 jsonObjectEnd,
223 APP_IDENTIFIER,
224 signatureInfo.appIdentifier,
225 JsonType::STRING,
226 false,
227 parseResult,
228 ArrayType::NOT_ARRAY);
229 if (parseResult != ERR_OK) {
230 TAG_LOGE(AAFwkTag::ABILITY_SIM, "read SignatureInfo error : %{public}d", parseResult);
231 }
232 }
233
to_json(nlohmann::json & jsonObject,const BundleInfo & bundleInfo)234 void to_json(nlohmann::json &jsonObject, const BundleInfo &bundleInfo)
235 {
236 jsonObject = nlohmann::json {
237 {BUNDLE_INFO_NAME, bundleInfo.name}, {BUNDLE_INFO_LABEL, bundleInfo.label},
238 {BUNDLE_INFO_DESCRIPTION, bundleInfo.description}, {BUNDLE_INFO_VENDOR, bundleInfo.vendor},
239 {BUNDLE_INFO_IS_KEEP_ALIVE, bundleInfo.isKeepAlive}, {BUNDLE_INFO_IS_NATIVE_APP, bundleInfo.isNativeApp},
240 {BUNDLE_INFO_IS_PREINSTALL_APP, bundleInfo.isPreInstallApp},
241 {BUNDLE_INFO_IS_DIFFERENT_NAME, bundleInfo.isDifferentName},
242 {BUNDLE_INFO_ABILITY_INFOS, bundleInfo.abilityInfos},
243 {BUNDLE_INFO_HAP_MODULE_INFOS, bundleInfo.hapModuleInfos},
244 {BUNDLE_INFO_EXTENSION_ABILITY_INFOS, bundleInfo.extensionInfos},
245 {BUNDLE_INFO_JOINT_USERID, bundleInfo.jointUserId},
246 {BUNDLE_INFO_VERSION_CODE, bundleInfo.versionCode},
247 {BUNDLE_INFO_MIN_COMPATIBLE_VERSION_CODE, bundleInfo.minCompatibleVersionCode},
248 {BUNDLE_INFO_VERSION_NAME, bundleInfo.versionName},
249 {BUNDLE_INFO_MIN_SDK_VERSION, bundleInfo.minSdkVersion},
250 {BUNDLE_INFO_MAX_SDK_VERSION, bundleInfo.maxSdkVersion},
251 {BUNDLE_INFO_MAIN_ENTRY, bundleInfo.mainEntry},
252 {BUNDLE_INFO_CPU_ABI, bundleInfo.cpuAbi},
253 {BUNDLE_INFO_APPID, bundleInfo.appId},
254 {BUNDLE_INFO_COMPATIBLE_VERSION, bundleInfo.compatibleVersion},
255 {BUNDLE_INFO_TARGET_VERSION, bundleInfo.targetVersion},
256 {BUNDLE_INFO_RELEASE_TYPE, bundleInfo.releaseType},
257 {BUNDLE_INFO_UID, bundleInfo.uid},
258 {BUNDLE_INFO_GID, bundleInfo.gid},
259 {BUNDLE_INFO_SEINFO, bundleInfo.seInfo},
260 {BUNDLE_INFO_INSTALL_TIME, bundleInfo.installTime},
261 {BUNDLE_INFO_UPDATE_TIME, bundleInfo.updateTime},
262 {BUNDLE_INFO_FIRST_INSTALL_TIME, bundleInfo.firstInstallTime},
263 {BUNDLE_INFO_ENTRY_MODULE_NAME, bundleInfo.entryModuleName},
264 {BUNDLE_INFO_ENTRY_INSTALLATION_FREE, bundleInfo.entryInstallationFree},
265 {BUNDLE_INFO_REQ_PERMISSIONS, bundleInfo.reqPermissions},
266 {BUNDLE_INFO_REQ_PERMISSION_STATES, bundleInfo.reqPermissionStates},
267 {BUNDLE_INFO_REQ_PERMISSION_DETAILS, bundleInfo.reqPermissionDetails},
268 {BUNDLE_INFO_DEF_PERMISSIONS, bundleInfo.defPermissions},
269 {BUNDLE_INFO_HAP_MODULE_NAMES, bundleInfo.hapModuleNames},
270 {BUNDLE_INFO_MODULE_NAMES, bundleInfo.moduleNames},
271 {BUNDLE_INFO_MODULE_PUBLIC_DIRS, bundleInfo.modulePublicDirs},
272 {BUNDLE_INFO_MODULE_DIRS, bundleInfo.moduleDirs},
273 {BUNDLE_INFO_MODULE_RES_PATHS, bundleInfo.moduleResPaths},
274 {BUNDLE_INFO_SINGLETON, bundleInfo.singleton},
275 {BUNDLE_INFO_APP_INDEX, bundleInfo.appIndex},
276 {BUNDLE_INFO_SIGNATURE_INFO, bundleInfo.signatureInfo},
277 {OVERLAY_TYPE, bundleInfo.overlayType},
278 {OVERLAY_BUNDLE_INFO, bundleInfo.overlayBundleInfos},
279 {BUNDLE_INFO_OLD_APPIDS, bundleInfo.oldAppIds},
280 {BUNDLE_INFO_ROUTER_ARRAY, bundleInfo.routerArray},
281 {BUNDLE_INFO_IS_NEW_VERSION, bundleInfo.isNewVersion},
282 {BUNDLE_INFO_HAS_PLUGIN, bundleInfo.hasPlugin}
283 };
284 }
285
from_json(const nlohmann::json & jsonObject,BundleInfo & bundleInfo)286 void from_json(const nlohmann::json &jsonObject, BundleInfo &bundleInfo)
287 {
288 const auto &jsonObjectEnd = jsonObject.end();
289 int32_t parseResult = ERR_OK;
290 GetValueIfFindKey<std::string>(jsonObject,
291 jsonObjectEnd,
292 BUNDLE_INFO_NAME,
293 bundleInfo.name,
294 JsonType::STRING,
295 false,
296 parseResult,
297 ArrayType::NOT_ARRAY);
298 GetValueIfFindKey<std::string>(jsonObject,
299 jsonObjectEnd,
300 BUNDLE_INFO_LABEL,
301 bundleInfo.label,
302 JsonType::STRING,
303 false,
304 parseResult,
305 ArrayType::NOT_ARRAY);
306 GetValueIfFindKey<std::string>(jsonObject,
307 jsonObjectEnd,
308 BUNDLE_INFO_DESCRIPTION,
309 bundleInfo.description,
310 JsonType::STRING,
311 false,
312 parseResult,
313 ArrayType::NOT_ARRAY);
314 GetValueIfFindKey<std::string>(jsonObject,
315 jsonObjectEnd,
316 BUNDLE_INFO_VENDOR,
317 bundleInfo.vendor,
318 JsonType::STRING,
319 false,
320 parseResult,
321 ArrayType::NOT_ARRAY);
322 GetValueIfFindKey<bool>(jsonObject,
323 jsonObjectEnd,
324 BUNDLE_INFO_IS_KEEP_ALIVE,
325 bundleInfo.isKeepAlive,
326 JsonType::BOOLEAN,
327 false,
328 parseResult,
329 ArrayType::NOT_ARRAY);
330 GetValueIfFindKey<bool>(jsonObject,
331 jsonObjectEnd,
332 BUNDLE_INFO_IS_NATIVE_APP,
333 bundleInfo.isNativeApp,
334 JsonType::BOOLEAN,
335 false,
336 parseResult,
337 ArrayType::NOT_ARRAY);
338 GetValueIfFindKey<bool>(jsonObject,
339 jsonObjectEnd,
340 BUNDLE_INFO_IS_PREINSTALL_APP,
341 bundleInfo.isPreInstallApp,
342 JsonType::BOOLEAN,
343 false,
344 parseResult,
345 ArrayType::NOT_ARRAY);
346 GetValueIfFindKey<bool>(jsonObject,
347 jsonObjectEnd,
348 BUNDLE_INFO_IS_DIFFERENT_NAME,
349 bundleInfo.isDifferentName,
350 JsonType::BOOLEAN,
351 false,
352 parseResult,
353 ArrayType::NOT_ARRAY);
354 GetValueIfFindKey<std::vector<AbilityInfo>>(jsonObject,
355 jsonObjectEnd,
356 BUNDLE_INFO_ABILITY_INFOS,
357 bundleInfo.abilityInfos,
358 JsonType::ARRAY,
359 false,
360 parseResult,
361 ArrayType::OBJECT);
362 GetValueIfFindKey<std::vector<HapModuleInfo>>(jsonObject,
363 jsonObjectEnd,
364 BUNDLE_INFO_HAP_MODULE_INFOS,
365 bundleInfo.hapModuleInfos,
366 JsonType::ARRAY,
367 false,
368 parseResult,
369 ArrayType::OBJECT);
370 GetValueIfFindKey<uint32_t>(jsonObject,
371 jsonObjectEnd,
372 BUNDLE_INFO_VERSION_CODE,
373 bundleInfo.versionCode,
374 JsonType::NUMBER,
375 false,
376 parseResult,
377 ArrayType::NOT_ARRAY);
378 GetValueIfFindKey<uint32_t>(jsonObject,
379 jsonObjectEnd,
380 BUNDLE_INFO_MIN_COMPATIBLE_VERSION_CODE,
381 bundleInfo.minCompatibleVersionCode,
382 JsonType::NUMBER,
383 false,
384 parseResult,
385 ArrayType::NOT_ARRAY);
386 GetValueIfFindKey<std::string>(jsonObject,
387 jsonObjectEnd,
388 BUNDLE_INFO_VERSION_NAME,
389 bundleInfo.versionName,
390 JsonType::STRING,
391 false,
392 parseResult,
393 ArrayType::NOT_ARRAY);
394 GetValueIfFindKey<std::string>(jsonObject,
395 jsonObjectEnd,
396 BUNDLE_INFO_JOINT_USERID,
397 bundleInfo.jointUserId,
398 JsonType::STRING,
399 false,
400 parseResult,
401 ArrayType::NOT_ARRAY);
402 GetValueIfFindKey<int32_t>(jsonObject,
403 jsonObjectEnd,
404 BUNDLE_INFO_MIN_SDK_VERSION,
405 bundleInfo.minSdkVersion,
406 JsonType::NUMBER,
407 false,
408 parseResult,
409 ArrayType::NOT_ARRAY);
410 GetValueIfFindKey<int32_t>(jsonObject,
411 jsonObjectEnd,
412 BUNDLE_INFO_MAX_SDK_VERSION,
413 bundleInfo.maxSdkVersion,
414 JsonType::NUMBER,
415 false,
416 parseResult,
417 ArrayType::NOT_ARRAY);
418 GetValueIfFindKey<std::string>(jsonObject,
419 jsonObjectEnd,
420 BUNDLE_INFO_MAIN_ENTRY,
421 bundleInfo.mainEntry,
422 JsonType::STRING,
423 false,
424 parseResult,
425 ArrayType::NOT_ARRAY);
426 GetValueIfFindKey<std::string>(jsonObject,
427 jsonObjectEnd,
428 BUNDLE_INFO_CPU_ABI,
429 bundleInfo.cpuAbi,
430 JsonType::STRING,
431 false,
432 parseResult,
433 ArrayType::NOT_ARRAY);
434 GetValueIfFindKey<std::string>(jsonObject,
435 jsonObjectEnd,
436 BUNDLE_INFO_APPID,
437 bundleInfo.appId,
438 JsonType::STRING,
439 false,
440 parseResult,
441 ArrayType::NOT_ARRAY);
442 GetValueIfFindKey<int>(jsonObject,
443 jsonObjectEnd,
444 BUNDLE_INFO_COMPATIBLE_VERSION,
445 bundleInfo.compatibleVersion,
446 JsonType::NUMBER,
447 false,
448 parseResult,
449 ArrayType::NOT_ARRAY);
450 GetValueIfFindKey<uint32_t>(jsonObject,
451 jsonObjectEnd,
452 BUNDLE_INFO_TARGET_VERSION,
453 bundleInfo.targetVersion,
454 JsonType::NUMBER,
455 false,
456 parseResult,
457 ArrayType::NOT_ARRAY);
458 GetValueIfFindKey<std::string>(jsonObject,
459 jsonObjectEnd,
460 BUNDLE_INFO_RELEASE_TYPE,
461 bundleInfo.releaseType,
462 JsonType::STRING,
463 false,
464 parseResult,
465 ArrayType::NOT_ARRAY);
466 GetValueIfFindKey<int>(jsonObject,
467 jsonObjectEnd,
468 BUNDLE_INFO_UID,
469 bundleInfo.uid,
470 JsonType::NUMBER,
471 false,
472 parseResult,
473 ArrayType::NOT_ARRAY);
474 GetValueIfFindKey<int>(jsonObject,
475 jsonObjectEnd,
476 BUNDLE_INFO_GID,
477 bundleInfo.gid,
478 JsonType::NUMBER,
479 false,
480 parseResult,
481 ArrayType::NOT_ARRAY);
482 GetValueIfFindKey<std::string>(jsonObject,
483 jsonObjectEnd,
484 BUNDLE_INFO_SEINFO,
485 bundleInfo.seInfo,
486 JsonType::STRING,
487 false,
488 parseResult,
489 ArrayType::NOT_ARRAY);
490 GetValueIfFindKey<int64_t>(jsonObject,
491 jsonObjectEnd,
492 BUNDLE_INFO_INSTALL_TIME,
493 bundleInfo.installTime,
494 JsonType::NUMBER,
495 false,
496 parseResult,
497 ArrayType::NOT_ARRAY);
498 GetValueIfFindKey<int64_t>(jsonObject,
499 jsonObjectEnd,
500 BUNDLE_INFO_UPDATE_TIME,
501 bundleInfo.updateTime,
502 JsonType::NUMBER,
503 false,
504 parseResult,
505 ArrayType::NOT_ARRAY);
506 GetValueIfFindKey<int64_t>(jsonObject,
507 jsonObjectEnd,
508 BUNDLE_INFO_FIRST_INSTALL_TIME,
509 bundleInfo.firstInstallTime,
510 JsonType::NUMBER,
511 false,
512 parseResult,
513 ArrayType::NOT_ARRAY);
514 GetValueIfFindKey<std::string>(jsonObject,
515 jsonObjectEnd,
516 BUNDLE_INFO_ENTRY_MODULE_NAME,
517 bundleInfo.entryModuleName,
518 JsonType::STRING,
519 false,
520 parseResult,
521 ArrayType::NOT_ARRAY);
522 GetValueIfFindKey<bool>(jsonObject,
523 jsonObjectEnd,
524 BUNDLE_INFO_ENTRY_INSTALLATION_FREE,
525 bundleInfo.entryInstallationFree,
526 JsonType::BOOLEAN,
527 false,
528 parseResult,
529 ArrayType::NOT_ARRAY);
530 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
531 jsonObjectEnd,
532 BUNDLE_INFO_REQ_PERMISSIONS,
533 bundleInfo.reqPermissions,
534 JsonType::ARRAY,
535 false,
536 parseResult,
537 ArrayType::STRING);
538 GetValueIfFindKey<std::vector<int32_t>>(jsonObject,
539 jsonObjectEnd,
540 BUNDLE_INFO_REQ_PERMISSION_STATES,
541 bundleInfo.reqPermissionStates,
542 JsonType::ARRAY,
543 false,
544 parseResult,
545 ArrayType::NUMBER);
546 GetValueIfFindKey<std::vector<RequestPermission>>(jsonObject,
547 jsonObjectEnd,
548 BUNDLE_INFO_REQ_PERMISSION_DETAILS,
549 bundleInfo.reqPermissionDetails,
550 JsonType::ARRAY,
551 false,
552 parseResult,
553 ArrayType::OBJECT);
554 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
555 jsonObjectEnd,
556 BUNDLE_INFO_DEF_PERMISSIONS,
557 bundleInfo.defPermissions,
558 JsonType::ARRAY,
559 false,
560 parseResult,
561 ArrayType::STRING);
562 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
563 jsonObjectEnd,
564 BUNDLE_INFO_HAP_MODULE_NAMES,
565 bundleInfo.hapModuleNames,
566 JsonType::ARRAY,
567 false,
568 parseResult,
569 ArrayType::STRING);
570 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
571 jsonObjectEnd,
572 BUNDLE_INFO_MODULE_NAMES,
573 bundleInfo.moduleNames,
574 JsonType::ARRAY,
575 false,
576 parseResult,
577 ArrayType::STRING);
578 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
579 jsonObjectEnd,
580 BUNDLE_INFO_MODULE_PUBLIC_DIRS,
581 bundleInfo.modulePublicDirs,
582 JsonType::ARRAY,
583 false,
584 parseResult,
585 ArrayType::STRING);
586 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
587 jsonObjectEnd,
588 BUNDLE_INFO_MODULE_DIRS,
589 bundleInfo.moduleDirs,
590 JsonType::ARRAY,
591 false,
592 parseResult,
593 ArrayType::STRING);
594 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
595 jsonObjectEnd,
596 BUNDLE_INFO_MODULE_RES_PATHS,
597 bundleInfo.moduleResPaths,
598 JsonType::ARRAY,
599 false,
600 parseResult,
601 ArrayType::STRING);
602 GetValueIfFindKey<bool>(jsonObject,
603 jsonObjectEnd,
604 BUNDLE_INFO_SINGLETON,
605 bundleInfo.singleton,
606 JsonType::BOOLEAN,
607 false,
608 parseResult,
609 ArrayType::NOT_ARRAY);
610 GetValueIfFindKey<std::vector<ExtensionAbilityInfo>>(jsonObject,
611 jsonObjectEnd,
612 BUNDLE_INFO_EXTENSION_ABILITY_INFOS,
613 bundleInfo.extensionInfos,
614 JsonType::ARRAY,
615 false,
616 parseResult,
617 ArrayType::OBJECT);
618 GetValueIfFindKey<int32_t>(jsonObject,
619 jsonObjectEnd,
620 BUNDLE_INFO_APP_INDEX,
621 bundleInfo.appIndex,
622 JsonType::NUMBER,
623 false,
624 parseResult,
625 ArrayType::NOT_ARRAY);
626 GetValueIfFindKey<SignatureInfo>(jsonObject,
627 jsonObjectEnd,
628 BUNDLE_INFO_SIGNATURE_INFO,
629 bundleInfo.signatureInfo,
630 JsonType::OBJECT,
631 false,
632 parseResult,
633 ArrayType::NOT_ARRAY);
634 GetValueIfFindKey<int32_t>(jsonObject,
635 jsonObjectEnd,
636 OVERLAY_TYPE,
637 bundleInfo.overlayType,
638 JsonType::NUMBER,
639 false,
640 parseResult,
641 ArrayType::NOT_ARRAY);
642 GetValueIfFindKey<std::vector<OverlayBundleInfo>>(jsonObject,
643 jsonObjectEnd,
644 OVERLAY_BUNDLE_INFO,
645 bundleInfo.overlayBundleInfos,
646 JsonType::ARRAY,
647 false,
648 parseResult,
649 ArrayType::OBJECT);
650 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
651 jsonObjectEnd,
652 BUNDLE_INFO_OLD_APPIDS,
653 bundleInfo.oldAppIds,
654 JsonType::ARRAY,
655 false,
656 parseResult,
657 ArrayType::STRING);
658 GetValueIfFindKey<std::vector<RouterItem>>(jsonObject,
659 jsonObjectEnd,
660 BUNDLE_INFO_ROUTER_ARRAY,
661 bundleInfo.routerArray,
662 JsonType::ARRAY,
663 false,
664 parseResult,
665 ArrayType::OBJECT);
666 GetValueIfFindKey<bool>(jsonObject,
667 jsonObjectEnd,
668 BUNDLE_INFO_IS_NEW_VERSION,
669 bundleInfo.isNewVersion,
670 JsonType::BOOLEAN,
671 false,
672 parseResult,
673 ArrayType::NOT_ARRAY);
674 GetValueIfFindKey<bool>(jsonObject,
675 jsonObjectEnd,
676 BUNDLE_INFO_HAS_PLUGIN,
677 bundleInfo.hasPlugin,
678 JsonType::BOOLEAN,
679 false,
680 parseResult,
681 ArrayType::NOT_ARRAY);
682 if (parseResult != ERR_OK) {
683 TAG_LOGE(AAFwkTag::ABILITY_SIM, "BundleInfo from_json error %{public}d", parseResult);
684 }
685 }
686 } // namespace AppExecFwk
687 } // namespace OHOS
688