• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 "json_util.h"
19 #include "parcel_macro.h"
20 #include "string_ex.h"
21 
22 namespace OHOS {
23 namespace AppExecFwk {
24 namespace {
25 const std::string BUNDLE_INFO_NAME = "name";
26 const std::string BUNDLE_INFO_LABEL = "label";
27 const std::string BUNDLE_INFO_DESCRIPTION = "description";
28 const std::string BUNDLE_INFO_VENDOR = "vendor";
29 const std::string BUNDLE_INFO_IS_KEEP_ALIVE = "isKeepAlive";
30 const std::string BUNDLE_INFO_SINGLETON = "singleton";
31 const std::string BUNDLE_INFO_IS_NATIVE_APP = "isNativeApp";
32 const std::string BUNDLE_INFO_IS_PREINSTALL_APP = "isPreInstallApp";
33 const std::string BUNDLE_INFO_IS_DIFFERENT_NAME = "isDifferentName";
34 const std::string BUNDLE_INFO_APPLICATION_INFO = "applicationInfo";
35 const std::string BUNDLE_INFO_ABILITY_INFOS = "abilityInfos";
36 const std::string BUNDLE_INFO_HAP_MODULE_INFOS = "hapModuleInfos";
37 const std::string BUNDLE_INFO_EXTENSION_ABILITY_INFOS = "extensionAbilityInfo";
38 const std::string BUNDLE_INFO_JOINT_USERID = "jointUserId";
39 const std::string BUNDLE_INFO_VERSION_CODE = "versionCode";
40 const std::string BUNDLE_INFO_MIN_COMPATIBLE_VERSION_CODE = "minCompatibleVersionCode";
41 const std::string BUNDLE_INFO_VERSION_NAME = "versionName";
42 const std::string BUNDLE_INFO_MIN_SDK_VERSION = "minSdkVersion";
43 const std::string BUNDLE_INFO_MAX_SDK_VERSION = "maxSdkVersion";
44 const std::string BUNDLE_INFO_MAIN_ENTRY = "mainEntry";
45 const std::string BUNDLE_INFO_CPU_ABI = "cpuAbi";
46 const std::string BUNDLE_INFO_APPID = "appId";
47 const std::string BUNDLE_INFO_COMPATIBLE_VERSION = "compatibleVersion";
48 const std::string BUNDLE_INFO_TARGET_VERSION = "targetVersion";
49 const std::string BUNDLE_INFO_RELEASE_TYPE = "releaseType";
50 const std::string BUNDLE_INFO_UID = "uid";
51 const std::string BUNDLE_INFO_GID = "gid";
52 const std::string BUNDLE_INFO_SEINFO = "seInfo";
53 const std::string BUNDLE_INFO_INSTALL_TIME = "installTime";
54 const std::string BUNDLE_INFO_UPDATE_TIME = "updateTime";
55 const std::string BUNDLE_INFO_ENTRY_MODULE_NAME = "entryModuleName";
56 const std::string BUNDLE_INFO_ENTRY_INSTALLATION_FREE = "entryInstallationFree";
57 const std::string BUNDLE_INFO_REQ_PERMISSIONS = "reqPermissions";
58 const std::string BUNDLE_INFO_REQ_PERMISSION_STATES = "reqPermissionStates";
59 const std::string BUNDLE_INFO_REQ_PERMISSION_DETAILS = "reqPermissionDetails";
60 const std::string BUNDLE_INFO_DEF_PERMISSIONS = "defPermissions";
61 const std::string BUNDLE_INFO_HAP_MODULE_NAMES = "hapModuleNames";
62 const std::string BUNDLE_INFO_MODULE_NAMES = "moduleNames";
63 const std::string BUNDLE_INFO_MODULE_PUBLIC_DIRS = "modulePublicDirs";
64 const std::string BUNDLE_INFO_MODULE_DIRS = "moduleDirs";
65 const std::string BUNDLE_INFO_MODULE_RES_PATHS = "moduleResPaths";
66 const std::string REQUESTPERMISSION_NAME = "name";
67 const std::string REQUESTPERMISSION_REASON = "reason";
68 const std::string REQUESTPERMISSION_REASON_ID = "reasonId";
69 const std::string REQUESTPERMISSION_USEDSCENE = "usedScene";
70 const std::string REQUESTPERMISSION_ABILITIES = "abilities";
71 const std::string REQUESTPERMISSION_ABILITY = "ability";
72 const std::string REQUESTPERMISSION_WHEN = "when";
73 const std::string SIGNATUREINFO_APPID = "appId";
74 const std::string SIGNATUREINFO_FINGERPRINT = "fingerprint";
75 const std::string BUNDLE_INFO_APP_INDEX = "appIndex";
76 const std::string BUNDLE_INFO_SIGNATURE_INFO = "signatureInfo";
77 const std::string BUNDLE_INFO_ASAN_ENABLED = "asanEnabled";
78 }
79 
ReadFromParcel(Parcel & parcel)80 bool RequestPermissionUsedScene::ReadFromParcel(Parcel &parcel)
81 {
82     int32_t size;
83     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, size);
84     CONTAINER_SECURITY_VERIFY(parcel, size, &abilities);
85     for (int32_t i = 0; i < size; i++) {
86         abilities.emplace_back(Str16ToStr8(parcel.ReadString16()));
87     }
88     when = Str16ToStr8(parcel.ReadString16());
89     return true;
90 }
91 
Marshalling(Parcel & parcel) const92 bool RequestPermissionUsedScene::Marshalling(Parcel &parcel) const
93 {
94     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, abilities.size());
95     for (auto &ability : abilities) {
96         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(ability));
97     }
98     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(when));
99     return true;
100 }
101 
Unmarshalling(Parcel & parcel)102 RequestPermissionUsedScene *RequestPermissionUsedScene::Unmarshalling(Parcel &parcel)
103 {
104     RequestPermissionUsedScene *info = new (std::nothrow) RequestPermissionUsedScene();
105     if (info && !info->ReadFromParcel(parcel)) {
106         APP_LOGW("read from parcel failed");
107         delete info;
108         info = nullptr;
109     }
110     return info;
111 }
112 
ReadFromParcel(Parcel & parcel)113 bool RequestPermission::ReadFromParcel(Parcel &parcel)
114 {
115     name = Str16ToStr8(parcel.ReadString16());
116     reason = Str16ToStr8(parcel.ReadString16());
117     reasonId = parcel.ReadInt32();
118     std::unique_ptr<RequestPermissionUsedScene> scene(parcel.ReadParcelable<RequestPermissionUsedScene>());
119     if (!scene) {
120         APP_LOGE("ReadParcelable<RequestPermissionUsedScene> failed");
121         return false;
122     }
123     usedScene = *scene;
124     return true;
125 }
126 
Marshalling(Parcel & parcel) const127 bool RequestPermission::Marshalling(Parcel &parcel) const
128 {
129     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(name));
130     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(reason));
131     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reasonId);
132     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &usedScene);
133     return true;
134 }
135 
Unmarshalling(Parcel & parcel)136 RequestPermission *RequestPermission::Unmarshalling(Parcel &parcel)
137 {
138     RequestPermission *info = new (std::nothrow) RequestPermission();
139     if (info && !info->ReadFromParcel(parcel)) {
140         APP_LOGW("read from parcel failed");
141         delete info;
142         info = nullptr;
143     }
144     return info;
145 }
146 
ReadFromParcel(Parcel & parcel)147 bool SignatureInfo::ReadFromParcel(Parcel &parcel)
148 {
149     appId = Str16ToStr8(parcel.ReadString16());
150     fingerprint = Str16ToStr8(parcel.ReadString16());
151     return true;
152 }
153 
Marshalling(Parcel & parcel) const154 bool SignatureInfo::Marshalling(Parcel &parcel) const
155 {
156     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(appId));
157     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(fingerprint));
158     return true;
159 }
160 
Unmarshalling(Parcel & parcel)161 SignatureInfo *SignatureInfo::Unmarshalling(Parcel &parcel)
162 {
163     SignatureInfo *info = new (std::nothrow) SignatureInfo();
164     if (info && !info->ReadFromParcel(parcel)) {
165         APP_LOGW("read from parcel failed");
166         delete info;
167         info = nullptr;
168     }
169     return info;
170 }
171 
ReadFromParcel(Parcel & parcel)172 bool BundleInfo::ReadFromParcel(Parcel &parcel)
173 {
174     name = Str16ToStr8(parcel.ReadString16());
175     versionCode = parcel.ReadUint32();
176     versionName = Str16ToStr8(parcel.ReadString16());
177     minCompatibleVersionCode = parcel.ReadUint32();
178     compatibleVersion = parcel.ReadUint32();
179     targetVersion = parcel.ReadUint32();
180     isKeepAlive = parcel.ReadBool();
181     singleton = parcel.ReadBool();
182     isPreInstallApp = parcel.ReadBool();
183 
184     vendor = Str16ToStr8(parcel.ReadString16());
185     releaseType = Str16ToStr8(parcel.ReadString16());
186     isNativeApp = parcel.ReadBool();
187 
188     mainEntry = Str16ToStr8(parcel.ReadString16());
189     entryModuleName = Str16ToStr8(parcel.ReadString16());
190     entryInstallationFree = parcel.ReadBool();
191 
192     appId = Str16ToStr8(parcel.ReadString16());
193     uid = parcel.ReadInt32();
194     gid = parcel.ReadInt32();
195     installTime = parcel.ReadInt64();
196     updateTime = parcel.ReadInt64();
197     std::unique_ptr<ApplicationInfo> appInfo(parcel.ReadParcelable<ApplicationInfo>());
198     if (!appInfo) {
199         APP_LOGE("ReadParcelable<ApplicationInfo> failed");
200         return false;
201     }
202     applicationInfo = *appInfo;
203 
204     int32_t abilityInfosSize;
205     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, abilityInfosSize);
206     CONTAINER_SECURITY_VERIFY(parcel, abilityInfosSize, &abilityInfos);
207     for (auto i = 0; i < abilityInfosSize; i++) {
208         std::unique_ptr<AbilityInfo> abilityInfo(parcel.ReadParcelable<AbilityInfo>());
209         if (!abilityInfo) {
210             APP_LOGE("ReadParcelable<AbilityInfo> failed");
211             return false;
212         }
213         abilityInfos.emplace_back(*abilityInfo);
214     }
215 
216     int32_t extensionInfosSize;
217     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, extensionInfosSize);
218     CONTAINER_SECURITY_VERIFY(parcel, extensionInfosSize, &extensionInfos);
219     for (auto i = 0; i < extensionInfosSize; i++) {
220         std::unique_ptr<ExtensionAbilityInfo> extensionAbilityInfo(parcel.ReadParcelable<ExtensionAbilityInfo>());
221         if (!extensionAbilityInfo) {
222             APP_LOGE("ReadParcelable<ExtensionAbilityInfo> failed");
223             return false;
224         }
225         extensionInfos.emplace_back(*extensionAbilityInfo);
226     }
227 
228     int32_t hapModuleInfosSize;
229     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, hapModuleInfosSize);
230     CONTAINER_SECURITY_VERIFY(parcel, hapModuleInfosSize, &hapModuleInfos);
231     for (auto i = 0; i < hapModuleInfosSize; i++) {
232         std::unique_ptr<HapModuleInfo> hapModuleInfo(parcel.ReadParcelable<HapModuleInfo>());
233         if (!hapModuleInfo) {
234             APP_LOGE("ReadParcelable<HapModuleInfo> failed");
235             return false;
236         }
237         hapModuleInfos.emplace_back(*hapModuleInfo);
238     }
239 
240     int32_t hapModuleNamesSize;
241     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, hapModuleNamesSize);
242     CONTAINER_SECURITY_VERIFY(parcel, hapModuleNamesSize, &hapModuleNames);
243     for (auto i = 0; i < hapModuleNamesSize; i++) {
244         hapModuleNames.emplace_back(Str16ToStr8(parcel.ReadString16()));
245     }
246 
247     int32_t moduleNamesSize;
248     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, moduleNamesSize);
249     CONTAINER_SECURITY_VERIFY(parcel, moduleNamesSize, &moduleNames);
250     for (auto i = 0; i < moduleNamesSize; i++) {
251         moduleNames.emplace_back(Str16ToStr8(parcel.ReadString16()));
252     }
253 
254     int32_t modulePublicDirsSize;
255     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, modulePublicDirsSize);
256     CONTAINER_SECURITY_VERIFY(parcel, modulePublicDirsSize, &modulePublicDirs);
257     for (auto i = 0; i < modulePublicDirsSize; i++) {
258         modulePublicDirs.emplace_back(Str16ToStr8(parcel.ReadString16()));
259     }
260 
261     int32_t moduleDirsSize;
262     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, moduleDirsSize);
263     CONTAINER_SECURITY_VERIFY(parcel, moduleDirsSize, &moduleDirs);
264     for (auto i = 0; i < moduleDirsSize; i++) {
265         moduleDirs.emplace_back(Str16ToStr8(parcel.ReadString16()));
266     }
267 
268     int32_t moduleResPathsSize;
269     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, moduleResPathsSize);
270     CONTAINER_SECURITY_VERIFY(parcel, moduleResPathsSize, &moduleResPaths);
271     for (auto i = 0; i < moduleResPathsSize; i++) {
272         moduleResPaths.emplace_back(Str16ToStr8(parcel.ReadString16()));
273     }
274 
275     int32_t reqPermissionsSize;
276     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reqPermissionsSize);
277     CONTAINER_SECURITY_VERIFY(parcel, reqPermissionsSize, &reqPermissions);
278     for (auto i = 0; i < reqPermissionsSize; i++) {
279         reqPermissions.emplace_back(Str16ToStr8(parcel.ReadString16()));
280     }
281 
282     int32_t defPermissionsSize;
283     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, defPermissionsSize);
284     CONTAINER_SECURITY_VERIFY(parcel, defPermissionsSize, &defPermissions);
285     for (auto i = 0; i < defPermissionsSize; i++) {
286         defPermissions.emplace_back(Str16ToStr8(parcel.ReadString16()));
287     }
288 
289     int32_t reqPermissionStatesSize;
290     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reqPermissionStatesSize);
291     CONTAINER_SECURITY_VERIFY(parcel, reqPermissionStatesSize, &reqPermissionStates);
292     for (auto i = 0; i < reqPermissionStatesSize; i++) {
293         reqPermissionStates.emplace_back(parcel.ReadInt32());
294     }
295 
296     int32_t reqPermissionDetailsSize;
297     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reqPermissionDetailsSize);
298     CONTAINER_SECURITY_VERIFY(parcel, reqPermissionDetailsSize, &reqPermissionDetails);
299     for (auto i = 0; i < reqPermissionDetailsSize; i++) {
300         std::unique_ptr<RequestPermission> requestPermission(parcel.ReadParcelable<RequestPermission>());
301         if (!requestPermission) {
302             APP_LOGE("ReadParcelable<RequestPermission> failed");
303             return false;
304         }
305         reqPermissionDetails.emplace_back(*requestPermission);
306     }
307 
308     cpuAbi = Str16ToStr8(parcel.ReadString16());
309     seInfo = Str16ToStr8(parcel.ReadString16());
310     label = Str16ToStr8(parcel.ReadString16());
311     description = Str16ToStr8(parcel.ReadString16());
312     jointUserId = Str16ToStr8(parcel.ReadString16());
313     minSdkVersion = parcel.ReadInt32();
314     maxSdkVersion = parcel.ReadInt32();
315     isDifferentName = parcel.ReadBool();
316     appIndex = parcel.ReadInt32();
317 
318     std::unique_ptr<SignatureInfo> sigInfo(parcel.ReadParcelable<SignatureInfo>());
319     if (!sigInfo) {
320         APP_LOGE("ReadParcelable<SignatureInfo> failed");
321         return false;
322     }
323     signatureInfo = *sigInfo;
324     asanEnabled = parcel.ReadBool();
325     return true;
326 }
327 
Marshalling(Parcel & parcel) const328 bool BundleInfo::Marshalling(Parcel &parcel) const
329 {
330     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(name));
331     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, versionCode);
332     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(versionName));
333     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, minCompatibleVersionCode);
334     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, compatibleVersion);
335     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, targetVersion);
336 
337     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isKeepAlive);
338     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, singleton);
339     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isPreInstallApp);
340 
341     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(vendor));
342     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(releaseType));
343     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isNativeApp);
344 
345     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(mainEntry));
346     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(entryModuleName));
347     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, entryInstallationFree);
348 
349     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(appId));
350 
351     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, uid);
352     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, gid);
353 
354     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, installTime);
355     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, updateTime);
356 
357     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &applicationInfo);
358 
359     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, abilityInfos.size());
360     for (auto &abilityInfo : abilityInfos) {
361         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &abilityInfo);
362     }
363 
364     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, extensionInfos.size());
365     for (auto &extensionInfo : extensionInfos) {
366         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &extensionInfo);
367     }
368 
369     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, hapModuleInfos.size());
370     for (auto &hapModuleInfo : hapModuleInfos) {
371         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &hapModuleInfo);
372     }
373 
374     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, hapModuleNames.size());
375     for (auto &hapModuleName : hapModuleNames) {
376         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(hapModuleName));
377     }
378 
379     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, moduleNames.size());
380     for (auto &moduleName : moduleNames) {
381         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleName));
382     }
383 
384     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, modulePublicDirs.size());
385     for (auto &modulePublicDir : modulePublicDirs) {
386         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(modulePublicDir));
387     }
388 
389     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, moduleDirs.size());
390     for (auto &moduleDir : moduleDirs) {
391         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleDir));
392     }
393 
394     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, moduleResPaths.size());
395     for (auto &moduleResPath : moduleResPaths) {
396         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleResPath));
397     }
398 
399     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reqPermissions.size());
400     for (auto &reqPermission : reqPermissions) {
401         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(reqPermission));
402     }
403 
404     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, defPermissions.size());
405     for (auto &defPermission : defPermissions) {
406         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(defPermission));
407     }
408 
409     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reqPermissionStates.size());
410     for (auto &reqPermissionState : reqPermissionStates) {
411         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reqPermissionState);
412     }
413 
414     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reqPermissionDetails.size());
415     for (auto &reqPermissionDetail : reqPermissionDetails) {
416         WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &reqPermissionDetail);
417     }
418 
419     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(cpuAbi));
420     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(seInfo));
421     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(label));
422     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(description));
423     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(jointUserId));
424     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, minSdkVersion);
425     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, maxSdkVersion);
426     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isDifferentName);
427     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, appIndex);
428     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &signatureInfo);
429     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, asanEnabled);
430     return true;
431 }
432 
Unmarshalling(Parcel & parcel)433 BundleInfo *BundleInfo::Unmarshalling(Parcel &parcel)
434 {
435     BundleInfo *info = new (std::nothrow) BundleInfo();
436     if (info && !info->ReadFromParcel(parcel)) {
437         APP_LOGW("read from parcel failed");
438         delete info;
439         info = nullptr;
440     }
441     return info;
442 }
443 
to_json(nlohmann::json & jsonObject,const RequestPermissionUsedScene & usedScene)444 void to_json(nlohmann::json &jsonObject, const RequestPermissionUsedScene &usedScene)
445 {
446     jsonObject = nlohmann::json {
447         {REQUESTPERMISSION_ABILITIES, usedScene.abilities},
448         {REQUESTPERMISSION_WHEN, usedScene.when}
449     };
450 }
451 
to_json(nlohmann::json & jsonObject,const RequestPermission & requestPermission)452 void to_json(nlohmann::json &jsonObject, const RequestPermission &requestPermission)
453 {
454     jsonObject = nlohmann::json {
455         {REQUESTPERMISSION_NAME, requestPermission.name},
456         {REQUESTPERMISSION_REASON, requestPermission.reason},
457         {REQUESTPERMISSION_REASON_ID, requestPermission.reasonId},
458         {REQUESTPERMISSION_USEDSCENE, requestPermission.usedScene}
459     };
460 }
461 
to_json(nlohmann::json & jsonObject,const SignatureInfo & signatureInfo)462 void to_json(nlohmann::json &jsonObject, const SignatureInfo &signatureInfo)
463 {
464     jsonObject = nlohmann::json {
465         {SIGNATUREINFO_APPID, signatureInfo.appId},
466         {SIGNATUREINFO_FINGERPRINT, signatureInfo.fingerprint}
467     };
468 }
469 
from_json(const nlohmann::json & jsonObject,RequestPermissionUsedScene & usedScene)470 void from_json(const nlohmann::json &jsonObject, RequestPermissionUsedScene &usedScene)
471 {
472     const auto &jsonObjectEnd = jsonObject.end();
473     int32_t parseResult = ERR_OK;
474     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
475         jsonObjectEnd,
476         REQUESTPERMISSION_ABILITIES,
477         usedScene.abilities,
478         JsonType::ARRAY,
479         false,
480         parseResult,
481         ArrayType::STRING);
482     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
483         jsonObjectEnd,
484         REQUESTPERMISSION_ABILITY,
485         usedScene.abilities,
486         JsonType::ARRAY,
487         false,
488         parseResult,
489         ArrayType::STRING);
490     GetValueIfFindKey<std::string>(jsonObject,
491         jsonObjectEnd,
492         REQUESTPERMISSION_WHEN,
493         usedScene.when,
494         JsonType::STRING,
495         false,
496         parseResult,
497         ArrayType::NOT_ARRAY);
498     if (parseResult != ERR_OK) {
499         APP_LOGE("read RequestPermissionUsedScene from database error, error code : %{public}d", parseResult);
500     }
501 }
502 
from_json(const nlohmann::json & jsonObject,RequestPermission & requestPermission)503 void from_json(const nlohmann::json &jsonObject, RequestPermission &requestPermission)
504 {
505     const auto &jsonObjectEnd = jsonObject.end();
506     int32_t parseResult = ERR_OK;
507     GetValueIfFindKey<std::string>(jsonObject,
508         jsonObjectEnd,
509         REQUESTPERMISSION_NAME,
510         requestPermission.name,
511         JsonType::STRING,
512         false,
513         parseResult,
514         ArrayType::NOT_ARRAY);
515     GetValueIfFindKey<std::string>(jsonObject,
516         jsonObjectEnd,
517         REQUESTPERMISSION_REASON,
518         requestPermission.reason,
519         JsonType::STRING,
520         false,
521         parseResult,
522         ArrayType::NOT_ARRAY);
523     GetValueIfFindKey<int32_t>(jsonObject,
524         jsonObjectEnd,
525         REQUESTPERMISSION_REASON_ID,
526         requestPermission.reasonId,
527         JsonType::NUMBER,
528         false,
529         parseResult,
530         ArrayType::NOT_ARRAY);
531     GetValueIfFindKey<RequestPermissionUsedScene>(jsonObject,
532         jsonObjectEnd,
533         REQUESTPERMISSION_USEDSCENE,
534         requestPermission.usedScene,
535         JsonType::OBJECT,
536         false,
537         parseResult,
538         ArrayType::NOT_ARRAY);
539     if (parseResult != ERR_OK) {
540         APP_LOGE("read RequestPermission from database error, error code : %{public}d", parseResult);
541     }
542 }
543 
from_json(const nlohmann::json & jsonObject,SignatureInfo & signatureInfo)544 void from_json(const nlohmann::json &jsonObject, SignatureInfo &signatureInfo)
545 {
546     const auto &jsonObjectEnd = jsonObject.end();
547     int32_t parseResult = ERR_OK;
548     GetValueIfFindKey<std::string>(jsonObject,
549         jsonObjectEnd,
550         SIGNATUREINFO_APPID,
551         signatureInfo.appId,
552         JsonType::STRING,
553         false,
554         parseResult,
555         ArrayType::NOT_ARRAY);
556     GetValueIfFindKey<std::string>(jsonObject,
557         jsonObjectEnd,
558         SIGNATUREINFO_FINGERPRINT,
559         signatureInfo.fingerprint,
560         JsonType::STRING,
561         false,
562         parseResult,
563         ArrayType::NOT_ARRAY);
564     if (parseResult != ERR_OK) {
565         APP_LOGE("read SignatureInfo from database error, error code : %{public}d", parseResult);
566     }
567 }
568 
to_json(nlohmann::json & jsonObject,const BundleInfo & bundleInfo)569 void to_json(nlohmann::json &jsonObject, const BundleInfo &bundleInfo)
570 {
571     jsonObject = nlohmann::json {
572         {BUNDLE_INFO_NAME, bundleInfo.name},
573         {BUNDLE_INFO_LABEL, bundleInfo.label},
574         {BUNDLE_INFO_DESCRIPTION, bundleInfo.description},
575         {BUNDLE_INFO_VENDOR, bundleInfo.vendor},
576         {BUNDLE_INFO_IS_KEEP_ALIVE, bundleInfo.isKeepAlive},
577         {BUNDLE_INFO_IS_NATIVE_APP, bundleInfo.isNativeApp},
578         {BUNDLE_INFO_IS_PREINSTALL_APP, bundleInfo.isPreInstallApp},
579         {BUNDLE_INFO_IS_DIFFERENT_NAME, bundleInfo.isDifferentName},
580         {BUNDLE_INFO_APPLICATION_INFO, bundleInfo.applicationInfo},
581         {BUNDLE_INFO_ABILITY_INFOS, bundleInfo.abilityInfos},
582         {BUNDLE_INFO_HAP_MODULE_INFOS, bundleInfo.hapModuleInfos},
583         {BUNDLE_INFO_EXTENSION_ABILITY_INFOS, bundleInfo.extensionInfos},
584         {BUNDLE_INFO_JOINT_USERID, bundleInfo.jointUserId},
585         {BUNDLE_INFO_VERSION_CODE, bundleInfo.versionCode},
586         {BUNDLE_INFO_MIN_COMPATIBLE_VERSION_CODE, bundleInfo.minCompatibleVersionCode},
587         {BUNDLE_INFO_VERSION_NAME, bundleInfo.versionName},
588         {BUNDLE_INFO_MIN_SDK_VERSION, bundleInfo.minSdkVersion},
589         {BUNDLE_INFO_MAX_SDK_VERSION, bundleInfo.maxSdkVersion},
590         {BUNDLE_INFO_MAIN_ENTRY, bundleInfo.mainEntry},
591         {BUNDLE_INFO_CPU_ABI, bundleInfo.cpuAbi},
592         {BUNDLE_INFO_APPID, bundleInfo.appId},
593         {BUNDLE_INFO_COMPATIBLE_VERSION, bundleInfo.compatibleVersion},
594         {BUNDLE_INFO_TARGET_VERSION, bundleInfo.targetVersion},
595         {BUNDLE_INFO_RELEASE_TYPE, bundleInfo.releaseType},
596         {BUNDLE_INFO_UID, bundleInfo.uid},
597         {BUNDLE_INFO_GID, bundleInfo.gid},
598         {BUNDLE_INFO_SEINFO, bundleInfo.seInfo},
599         {BUNDLE_INFO_INSTALL_TIME, bundleInfo.installTime},
600         {BUNDLE_INFO_UPDATE_TIME, bundleInfo.updateTime},
601         {BUNDLE_INFO_ENTRY_MODULE_NAME, bundleInfo.entryModuleName},
602         {BUNDLE_INFO_ENTRY_INSTALLATION_FREE, bundleInfo.entryInstallationFree},
603         {BUNDLE_INFO_REQ_PERMISSIONS, bundleInfo.reqPermissions},
604         {BUNDLE_INFO_REQ_PERMISSION_STATES, bundleInfo.reqPermissionStates},
605         {BUNDLE_INFO_REQ_PERMISSION_DETAILS, bundleInfo.reqPermissionDetails},
606         {BUNDLE_INFO_DEF_PERMISSIONS, bundleInfo.defPermissions},
607         {BUNDLE_INFO_HAP_MODULE_NAMES, bundleInfo.hapModuleNames},
608         {BUNDLE_INFO_MODULE_NAMES, bundleInfo.moduleNames},
609         {BUNDLE_INFO_MODULE_PUBLIC_DIRS, bundleInfo.modulePublicDirs},
610         {BUNDLE_INFO_MODULE_DIRS, bundleInfo.moduleDirs},
611         {BUNDLE_INFO_MODULE_RES_PATHS, bundleInfo.moduleResPaths},
612         {BUNDLE_INFO_SINGLETON, bundleInfo.singleton},
613         {BUNDLE_INFO_APP_INDEX, bundleInfo.appIndex},
614         {BUNDLE_INFO_SIGNATURE_INFO, bundleInfo.signatureInfo},
615         {BUNDLE_INFO_ASAN_ENABLED, bundleInfo.asanEnabled},
616     };
617 }
618 
from_json(const nlohmann::json & jsonObject,BundleInfo & bundleInfo)619 void from_json(const nlohmann::json &jsonObject, BundleInfo &bundleInfo)
620 {
621     const auto &jsonObjectEnd = jsonObject.end();
622     int32_t parseResult = ERR_OK;
623     GetValueIfFindKey<std::string>(jsonObject,
624         jsonObjectEnd,
625         BUNDLE_INFO_NAME,
626         bundleInfo.name,
627         JsonType::STRING,
628         false,
629         parseResult,
630         ArrayType::NOT_ARRAY);
631     GetValueIfFindKey<std::string>(jsonObject,
632         jsonObjectEnd,
633         BUNDLE_INFO_LABEL,
634         bundleInfo.label,
635         JsonType::STRING,
636         false,
637         parseResult,
638         ArrayType::NOT_ARRAY);
639     GetValueIfFindKey<std::string>(jsonObject,
640         jsonObjectEnd,
641         BUNDLE_INFO_DESCRIPTION,
642         bundleInfo.description,
643         JsonType::STRING,
644         false,
645         parseResult,
646         ArrayType::NOT_ARRAY);
647     GetValueIfFindKey<std::string>(jsonObject,
648         jsonObjectEnd,
649         BUNDLE_INFO_VENDOR,
650         bundleInfo.vendor,
651         JsonType::STRING,
652         false,
653         parseResult,
654         ArrayType::NOT_ARRAY);
655     GetValueIfFindKey<bool>(jsonObject,
656         jsonObjectEnd,
657         BUNDLE_INFO_IS_KEEP_ALIVE,
658         bundleInfo.isKeepAlive,
659         JsonType::BOOLEAN,
660         false,
661         parseResult,
662         ArrayType::NOT_ARRAY);
663     GetValueIfFindKey<bool>(jsonObject,
664         jsonObjectEnd,
665         BUNDLE_INFO_IS_NATIVE_APP,
666         bundleInfo.isNativeApp,
667         JsonType::BOOLEAN,
668         false,
669         parseResult,
670         ArrayType::NOT_ARRAY);
671     GetValueIfFindKey<bool>(jsonObject,
672         jsonObjectEnd,
673         BUNDLE_INFO_IS_PREINSTALL_APP,
674         bundleInfo.isPreInstallApp,
675         JsonType::BOOLEAN,
676         false,
677         parseResult,
678         ArrayType::NOT_ARRAY);
679     GetValueIfFindKey<bool>(jsonObject,
680         jsonObjectEnd,
681         BUNDLE_INFO_IS_DIFFERENT_NAME,
682         bundleInfo.isDifferentName,
683         JsonType::BOOLEAN,
684         false,
685         parseResult,
686         ArrayType::NOT_ARRAY);
687     GetValueIfFindKey<ApplicationInfo>(jsonObject,
688         jsonObjectEnd,
689         BUNDLE_INFO_APPLICATION_INFO,
690         bundleInfo.applicationInfo,
691         JsonType::OBJECT,
692         false,
693         parseResult,
694         ArrayType::NOT_ARRAY);
695     GetValueIfFindKey<std::vector<AbilityInfo>>(jsonObject,
696         jsonObjectEnd,
697         BUNDLE_INFO_ABILITY_INFOS,
698         bundleInfo.abilityInfos,
699         JsonType::ARRAY,
700         false,
701         parseResult,
702         ArrayType::OBJECT);
703     GetValueIfFindKey<std::vector<HapModuleInfo>>(jsonObject,
704         jsonObjectEnd,
705         BUNDLE_INFO_HAP_MODULE_INFOS,
706         bundleInfo.hapModuleInfos,
707         JsonType::ARRAY,
708         false,
709         parseResult,
710         ArrayType::OBJECT);
711     GetValueIfFindKey<uint32_t>(jsonObject,
712         jsonObjectEnd,
713         BUNDLE_INFO_VERSION_CODE,
714         bundleInfo.versionCode,
715         JsonType::NUMBER,
716         false,
717         parseResult,
718         ArrayType::NOT_ARRAY);
719     GetValueIfFindKey<uint32_t>(jsonObject,
720         jsonObjectEnd,
721         BUNDLE_INFO_MIN_COMPATIBLE_VERSION_CODE,
722         bundleInfo.minCompatibleVersionCode,
723         JsonType::NUMBER,
724         false,
725         parseResult,
726         ArrayType::NOT_ARRAY);
727     GetValueIfFindKey<std::string>(jsonObject,
728         jsonObjectEnd,
729         BUNDLE_INFO_VERSION_NAME,
730         bundleInfo.versionName,
731         JsonType::STRING,
732         false,
733         parseResult,
734         ArrayType::NOT_ARRAY);
735     GetValueIfFindKey<std::string>(jsonObject,
736         jsonObjectEnd,
737         BUNDLE_INFO_JOINT_USERID,
738         bundleInfo.jointUserId,
739         JsonType::STRING,
740         false,
741         parseResult,
742         ArrayType::NOT_ARRAY);
743     GetValueIfFindKey<int32_t>(jsonObject,
744         jsonObjectEnd,
745         BUNDLE_INFO_MIN_SDK_VERSION,
746         bundleInfo.minSdkVersion,
747         JsonType::NUMBER,
748         false,
749         parseResult,
750         ArrayType::NOT_ARRAY);
751     GetValueIfFindKey<int32_t>(jsonObject,
752         jsonObjectEnd,
753         BUNDLE_INFO_MAX_SDK_VERSION,
754         bundleInfo.maxSdkVersion,
755         JsonType::NUMBER,
756         false,
757         parseResult,
758         ArrayType::NOT_ARRAY);
759     GetValueIfFindKey<std::string>(jsonObject,
760         jsonObjectEnd,
761         BUNDLE_INFO_MAIN_ENTRY,
762         bundleInfo.mainEntry,
763         JsonType::STRING,
764         false,
765         parseResult,
766         ArrayType::NOT_ARRAY);
767     GetValueIfFindKey<std::string>(jsonObject,
768         jsonObjectEnd,
769         BUNDLE_INFO_CPU_ABI,
770         bundleInfo.cpuAbi,
771         JsonType::STRING,
772         false,
773         parseResult,
774         ArrayType::NOT_ARRAY);
775     GetValueIfFindKey<std::string>(jsonObject,
776         jsonObjectEnd,
777         BUNDLE_INFO_APPID,
778         bundleInfo.appId,
779         JsonType::STRING,
780         false,
781         parseResult,
782         ArrayType::NOT_ARRAY);
783     GetValueIfFindKey<int>(jsonObject,
784         jsonObjectEnd,
785         BUNDLE_INFO_COMPATIBLE_VERSION,
786         bundleInfo.compatibleVersion,
787         JsonType::NUMBER,
788         false,
789         parseResult,
790         ArrayType::NOT_ARRAY);
791     GetValueIfFindKey<uint32_t>(jsonObject,
792         jsonObjectEnd,
793         BUNDLE_INFO_TARGET_VERSION,
794         bundleInfo.targetVersion,
795         JsonType::NUMBER,
796         false,
797         parseResult,
798         ArrayType::NOT_ARRAY);
799     GetValueIfFindKey<std::string>(jsonObject,
800         jsonObjectEnd,
801         BUNDLE_INFO_RELEASE_TYPE,
802         bundleInfo.releaseType,
803         JsonType::STRING,
804         false,
805         parseResult,
806         ArrayType::NOT_ARRAY);
807     GetValueIfFindKey<int>(jsonObject,
808         jsonObjectEnd,
809         BUNDLE_INFO_UID,
810         bundleInfo.uid,
811         JsonType::NUMBER,
812         false,
813         parseResult,
814         ArrayType::NOT_ARRAY);
815     GetValueIfFindKey<int>(jsonObject,
816         jsonObjectEnd,
817         BUNDLE_INFO_GID,
818         bundleInfo.gid,
819         JsonType::NUMBER,
820         false,
821         parseResult,
822         ArrayType::NOT_ARRAY);
823     GetValueIfFindKey<std::string>(jsonObject,
824         jsonObjectEnd,
825         BUNDLE_INFO_SEINFO,
826         bundleInfo.seInfo,
827         JsonType::STRING,
828         false,
829         parseResult,
830         ArrayType::NOT_ARRAY);
831     GetValueIfFindKey<int64_t>(jsonObject,
832         jsonObjectEnd,
833         BUNDLE_INFO_INSTALL_TIME,
834         bundleInfo.installTime,
835         JsonType::NUMBER,
836         false,
837         parseResult,
838         ArrayType::NOT_ARRAY);
839     GetValueIfFindKey<int64_t>(jsonObject,
840         jsonObjectEnd,
841         BUNDLE_INFO_UPDATE_TIME,
842         bundleInfo.updateTime,
843         JsonType::NUMBER,
844         false,
845         parseResult,
846         ArrayType::NOT_ARRAY);
847     GetValueIfFindKey<std::string>(jsonObject,
848         jsonObjectEnd,
849         BUNDLE_INFO_ENTRY_MODULE_NAME,
850         bundleInfo.entryModuleName,
851         JsonType::STRING,
852         false,
853         parseResult,
854         ArrayType::NOT_ARRAY);
855     GetValueIfFindKey<bool>(jsonObject,
856         jsonObjectEnd,
857         BUNDLE_INFO_ENTRY_INSTALLATION_FREE,
858         bundleInfo.entryInstallationFree,
859         JsonType::BOOLEAN,
860         false,
861         parseResult,
862         ArrayType::NOT_ARRAY);
863     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
864         jsonObjectEnd,
865         BUNDLE_INFO_REQ_PERMISSIONS,
866         bundleInfo.reqPermissions,
867         JsonType::ARRAY,
868         false,
869         parseResult,
870         ArrayType::STRING);
871     GetValueIfFindKey<std::vector<int32_t>>(jsonObject,
872         jsonObjectEnd,
873         BUNDLE_INFO_REQ_PERMISSION_STATES,
874         bundleInfo.reqPermissionStates,
875         JsonType::ARRAY,
876         false,
877         parseResult,
878         ArrayType::NUMBER);
879     GetValueIfFindKey<std::vector<RequestPermission>>(jsonObject,
880         jsonObjectEnd,
881         BUNDLE_INFO_REQ_PERMISSION_DETAILS,
882         bundleInfo.reqPermissionDetails,
883         JsonType::ARRAY,
884         false,
885         parseResult,
886         ArrayType::OBJECT);
887     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
888         jsonObjectEnd,
889         BUNDLE_INFO_DEF_PERMISSIONS,
890         bundleInfo.defPermissions,
891         JsonType::ARRAY,
892         false,
893         parseResult,
894         ArrayType::STRING);
895     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
896         jsonObjectEnd,
897         BUNDLE_INFO_HAP_MODULE_NAMES,
898         bundleInfo.hapModuleNames,
899         JsonType::ARRAY,
900         false,
901         parseResult,
902         ArrayType::STRING);
903     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
904         jsonObjectEnd,
905         BUNDLE_INFO_MODULE_NAMES,
906         bundleInfo.moduleNames,
907         JsonType::ARRAY,
908         false,
909         parseResult,
910         ArrayType::STRING);
911     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
912         jsonObjectEnd,
913         BUNDLE_INFO_MODULE_PUBLIC_DIRS,
914         bundleInfo.modulePublicDirs,
915         JsonType::ARRAY,
916         false,
917         parseResult,
918         ArrayType::STRING);
919     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
920         jsonObjectEnd,
921         BUNDLE_INFO_MODULE_DIRS,
922         bundleInfo.moduleDirs,
923         JsonType::ARRAY,
924         false,
925         parseResult,
926         ArrayType::STRING);
927     GetValueIfFindKey<std::vector<std::string>>(jsonObject,
928         jsonObjectEnd,
929         BUNDLE_INFO_MODULE_RES_PATHS,
930         bundleInfo.moduleResPaths,
931         JsonType::ARRAY,
932         false,
933         parseResult,
934         ArrayType::STRING);
935     GetValueIfFindKey<bool>(jsonObject,
936         jsonObjectEnd,
937         BUNDLE_INFO_SINGLETON,
938         bundleInfo.singleton,
939         JsonType::BOOLEAN,
940         false,
941         parseResult,
942         ArrayType::NOT_ARRAY);
943     GetValueIfFindKey<std::vector<ExtensionAbilityInfo>>(jsonObject,
944         jsonObjectEnd,
945         BUNDLE_INFO_EXTENSION_ABILITY_INFOS,
946         bundleInfo.extensionInfos,
947         JsonType::ARRAY,
948         false,
949         parseResult,
950         ArrayType::OBJECT);
951     GetValueIfFindKey<int32_t>(jsonObject,
952         jsonObjectEnd,
953         BUNDLE_INFO_APP_INDEX,
954         bundleInfo.appIndex,
955         JsonType::NUMBER,
956         false,
957         parseResult,
958         ArrayType::NOT_ARRAY);
959     GetValueIfFindKey<SignatureInfo>(jsonObject,
960         jsonObjectEnd,
961         BUNDLE_INFO_SIGNATURE_INFO,
962         bundleInfo.signatureInfo,
963         JsonType::OBJECT,
964         false,
965         parseResult,
966         ArrayType::NOT_ARRAY);
967     GetValueIfFindKey<bool>(jsonObject,
968         jsonObjectEnd,
969         BUNDLE_INFO_ASAN_ENABLED,
970         bundleInfo.asanEnabled,
971         JsonType::BOOLEAN,
972         false,
973         parseResult,
974         ArrayType::NOT_ARRAY);
975     if (parseResult != ERR_OK) {
976         APP_LOGE("BundleInfo from_json error, error code : %{public}d", parseResult);
977     }
978 }
979 }  // namespace AppExecFwk
980 }  // namespace OHOS
981