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