1 /*
2 * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "module_profile.h"
17
18 #include <sstream>
19 #include <unordered_set>
20
21 #include "parameter.h"
22 #include "parameters.h"
23
24 namespace OHOS {
25 namespace AppExecFwk {
26 namespace {
27 constexpr uint8_t MAX_MODULE_NAME = 128;
28 const std::string COMPRESS_NATIVE_LIBS = "persist.bms.supportCompressNativeLibs";
29 const int32_t THRESHOLD_VAL_LEN = 40;
IsSupportCompressNativeLibs()30 bool IsSupportCompressNativeLibs()
31 {
32 char compressNativeLibs[THRESHOLD_VAL_LEN] = {0};
33 int32_t ret = GetParameter(COMPRESS_NATIVE_LIBS.c_str(), "", compressNativeLibs, THRESHOLD_VAL_LEN);
34 if (ret <= 0) {
35 APP_LOGD("GetParameter %{public}s failed", COMPRESS_NATIVE_LIBS.c_str());
36 return false;
37 }
38 if (std::strcmp(compressNativeLibs, "true") == 0) {
39 return true;
40 }
41 return false;
42 }
43 }
44
45 namespace Profile {
46 int32_t g_parseResult = ERR_OK;
47 std::mutex g_mutex;
48
49 const std::unordered_set<std::string> MODULE_TYPE_SET = {
50 "entry",
51 "feature",
52 "shared"
53 };
54
55 const std::unordered_set<std::string> VIRTUAL_MACHINE_SET = {
56 "ark",
57 "default"
58 };
59
60 constexpr const char* BACKGROUND_MODES_MAP_KEY[] = {
61 ProfileReader::KEY_DATA_TRANSFER,
62 ProfileReader::KEY_AUDIO_PLAYBACK,
63 ProfileReader::KEY_AUDIO_RECORDING,
64 ProfileReader::KEY_LOCATION,
65 ProfileReader::KEY_BLUETOOTH_INTERACTION,
66 ProfileReader::KEY_MULTI_DEVICE_CONNECTION,
67 ProfileReader::KEY_WIFI_INTERACTION,
68 ProfileReader::KEY_VOIP,
69 ProfileReader::KEY_TASK_KEEPING,
70 ProfileReader::KEY_PICTURE_IN_PICTURE,
71 ProfileReader::KEY_SCREEN_FETCH
72 };
73 const uint32_t BACKGROUND_MODES_MAP_VALUE[] = {
74 ProfileReader::VALUE_DATA_TRANSFER,
75 ProfileReader::VALUE_AUDIO_PLAYBACK,
76 ProfileReader::VALUE_AUDIO_RECORDING,
77 ProfileReader::VALUE_LOCATION,
78 ProfileReader::VALUE_BLUETOOTH_INTERACTION,
79 ProfileReader::VALUE_MULTI_DEVICE_CONNECTION,
80 ProfileReader::VALUE_WIFI_INTERACTION,
81 ProfileReader::VALUE_VOIP,
82 ProfileReader::VALUE_TASK_KEEPING,
83 ProfileReader::VALUE_PICTURE_IN_PICTURE,
84 ProfileReader::VALUE_SCREEN_FETCH
85 };
86
87 const std::unordered_set<std::string> GRANT_MODE_SET = {
88 "system_grant",
89 "user_grant"
90 };
91
92 const std::unordered_set<std::string> AVAILABLE_LEVEL_SET = {
93 "system_core",
94 "system_basic",
95 "normal"
96 };
97
98 const std::unordered_map<std::string, LaunchMode> LAUNCH_MODE_MAP = {
99 {"singleton", LaunchMode::SINGLETON},
100 {"standard", LaunchMode::STANDARD},
101 {"multiton", LaunchMode::STANDARD},
102 {"specified", LaunchMode::SPECIFIED}
103 };
104 constexpr const char* DISPLAY_ORIENTATION_MAP_KEY[] = {
105 "unspecified",
106 "landscape",
107 "portrait",
108 "follow_recent",
109 "landscape_inverted",
110 "portrait_inverted",
111 "auto_rotation",
112 "auto_rotation_landscape",
113 "auto_rotation_portrait",
114 "auto_rotation_restricted",
115 "auto_rotation_landscape_restricted",
116 "auto_rotation_portrait_restricted",
117 "locked",
118 "auto_rotation_unspecified",
119 "follow_desktop"
120 };
121 const DisplayOrientation DISPLAY_ORIENTATION_MAP_VALUE[] = {
122 DisplayOrientation::UNSPECIFIED,
123 DisplayOrientation::LANDSCAPE,
124 DisplayOrientation::PORTRAIT,
125 DisplayOrientation::FOLLOWRECENT,
126 DisplayOrientation::LANDSCAPE_INVERTED,
127 DisplayOrientation::PORTRAIT_INVERTED,
128 DisplayOrientation::AUTO_ROTATION,
129 DisplayOrientation::AUTO_ROTATION_LANDSCAPE,
130 DisplayOrientation::AUTO_ROTATION_PORTRAIT,
131 DisplayOrientation::AUTO_ROTATION_RESTRICTED,
132 DisplayOrientation::AUTO_ROTATION_LANDSCAPE_RESTRICTED,
133 DisplayOrientation::AUTO_ROTATION_PORTRAIT_RESTRICTED,
134 DisplayOrientation::LOCKED,
135 DisplayOrientation::AUTO_ROTATION_UNSPECIFIED,
136 DisplayOrientation::FOLLOW_DESKTOP
137 };
138 const std::unordered_map<std::string, SupportWindowMode> WINDOW_MODE_MAP = {
139 {"fullscreen", SupportWindowMode::FULLSCREEN},
140 {"split", SupportWindowMode::SPLIT},
141 {"floating", SupportWindowMode::FLOATING}
142 };
143 const std::unordered_map<std::string, BundleType> BUNDLE_TYPE_MAP = {
144 {"app", BundleType::APP},
145 {"atomicService", BundleType::ATOMIC_SERVICE},
146 {"shared", BundleType::SHARED},
147 {"appService", BundleType::APP_SERVICE_FWK}
148 };
149 const size_t MAX_QUERYSCHEMES_LENGTH = 50;
150
151 const std::unordered_map<std::string, MultiAppModeType> MULTI_APP_MODE_MAP = {
152 {"multiInstance", MultiAppModeType::MULTI_INSTANCE},
153 {"appClone", MultiAppModeType::APP_CLONE}
154 };
155
156 struct DeviceConfig {
157 // pair first : if exist in module.json then true, otherwise false
158 // pair second : actual value
159 std::pair<bool, int32_t> minAPIVersion = std::make_pair<>(false, 0);
160 std::pair<bool, bool> keepAlive = std::make_pair<>(false, false);
161 std::pair<bool, bool> removable = std::make_pair<>(false, true);
162 std::pair<bool, bool> singleton = std::make_pair<>(false, false);
163 std::pair<bool, bool> userDataClearable = std::make_pair<>(false, true);
164 std::pair<bool, bool> accessible = std::make_pair<>(false, true);
165 };
166
167 struct Metadata {
168 uint32_t valueId = 0;
169 std::string name;
170 std::string value;
171 std::string resource;
172 };
173
174 struct HnpPackage {
175 std::string package;
176 std::string type;
177 };
178
179 struct Ability {
180 bool visible = false;
181 bool continuable = false;
182 bool removeMissionAfterTerminate = false;
183 bool excludeFromMissions = false;
184 bool recoverable = false;
185 bool unclearableMission = false;
186 bool excludeFromDock = false;
187 bool isolationProcess = false;
188 uint32_t descriptionId = 0;
189 uint32_t iconId = 0;
190 uint32_t labelId = 0;
191 int32_t priority = 0;
192 uint32_t startWindowId = 0;
193 uint32_t startWindowIconId = 0;
194 uint32_t startWindowBackgroundId = 0;
195 uint32_t maxWindowWidth = 0;
196 uint32_t minWindowWidth = 0;
197 uint32_t maxWindowHeight = 0;
198 uint32_t minWindowHeight = 0;
199 uint32_t orientationId = 0;
200 double maxWindowRatio = 0;
201 double minWindowRatio = 0;
202 std::string name;
203 std::string srcEntrance;
204 std::string launchType = ABILITY_LAUNCH_TYPE_DEFAULT_VALUE;
205 std::string description;
206 std::string icon;
207 std::string label;
208 std::vector<std::string> permissions;
209 std::vector<Metadata> metadata;
210 std::vector<Skill> skills;
211 std::vector<std::string> backgroundModes;
212 std::string startWindow;
213 std::string startWindowIcon;
214 std::string startWindowBackground;
215 std::string orientation = "unspecified";
216 std::vector<std::string> windowModes;
217 std::string preferMultiWindowOrientation = "default";
218 std::vector<std::string> continueType;
219 std::vector<std::string> continueBundleNames;
220 std::string process;
221 };
222
223 struct Extension {
224 bool visible = false;
225 uint32_t iconId = 0;
226 uint32_t labelId = 0;
227 uint32_t descriptionId = 0;
228 int32_t priority = 0;
229 std::string name;
230 std::string srcEntrance;
231 std::string icon;
232 std::string label;
233 std::string description;
234 std::string type;
235 std::string readPermission;
236 std::string writePermission;
237 std::string uri;
238 std::vector<std::string> permissions;
239 std::vector<Skill> skills;
240 std::vector<Metadata> metadata;
241 std::string extensionProcessMode;
242 std::vector<std::string> dataGroupIds;
243 std::string customProcess;
244 };
245
246 struct MultiAppMode {
247 std::string multiAppModeType;
248 int32_t maxCount = 0;
249 };
250
251 struct App {
252 bool debug = false;
253 bool keepAlive = false;
254 bool singleton = false;
255 bool userDataClearable = true;
256 bool accessible = false;
257 bool multiProjects = false;
258 bool asanEnabled = false;
259 bool gwpAsanEnabled = false;
260 bool hwasanEnabled = false;
261 bool tsanEnabled = false;
262 bool ubsanEnabled = false;
263 bool cloudFileSyncEnabled = false;
264 uint32_t iconId = 0;
265 uint32_t labelId = 0;
266 uint32_t descriptionId = 0;
267 int32_t versionCode = 0;
268 int32_t minCompatibleVersionCode = -1;
269 uint32_t minAPIVersion = 0;
270 int32_t targetAPIVersion = 0;
271 int32_t targetPriority = 0;
272 int32_t maxChildProcess = OHOS::system::GetIntParameter(MAX_CHILD_PROCESS, 1);
273 std::string bundleName;
274 std::string icon;
275 std::string label;
276 std::string description;
277 std::string vendor;
278 std::string versionName;
279 std::string apiReleaseType = APP_API_RELEASETYPE_DEFAULT_VALUE;
280 std::pair<bool, bool> removable = std::make_pair<>(false, true);
281 std::vector<std::string> targetBundleList;
282 std::map<std::string, DeviceConfig> deviceConfigs;
283 std::string targetBundle;
284 std::string bundleType = Profile::BUNDLE_TYPE_APP;
285 std::string compileSdkVersion;
286 std::string compileSdkType = Profile::COMPILE_SDK_TYPE_OPEN_HARMONY;
287 std::vector<ApplicationEnvironment> appEnvironments;
288 MultiAppMode multiAppMode;
289 std::string configuration;
290 std::vector<std::string> assetAccessGroups;
291 };
292
293 struct Module {
294 bool deliveryWithInstall = false;
295 bool installationFree = false;
296 bool isLibIsolated = false;
297 bool compressNativeLibs = true;
298 uint32_t descriptionId = 0;
299 int32_t targetPriority = 0;
300 std::string name;
301 std::string type;
302 std::string srcEntrance;
303 std::string abilitySrcEntryDelegator;
304 std::string abilityStageSrcEntryDelegator;
305 std::string description;
306 std::string process;
307 std::string mainElement;
308 std::vector<std::string> deviceTypes;
309 std::string virtualMachine = MODULE_VIRTUAL_MACHINE_DEFAULT_VALUE;
310 std::string pages;
311 std::vector<Metadata> metadata;
312 std::vector<HnpPackage> hnpPackages;
313 std::vector<Ability> abilities;
314 std::vector<Extension> extensionAbilities;
315 std::vector<RequestPermission> requestPermissions;
316 std::vector<DefinePermission> definePermissions;
317 std::vector<Dependency> dependencies;
318 std::string compileMode;
319 std::string targetModule;
320 std::vector<ProxyData> proxyDatas;
321 std::vector<ProxyData> proxyData;
322 std::string buildHash;
323 std::string isolationMode;
324 std::string fileContextMenu;
325 std::vector<std::string> querySchemes;
326 std::string routerMap;
327 std::vector<AppEnvironment> appEnvironments;
328 std::string packageName;
329 std::string appStartup;
330 };
331
332 struct ModuleJson {
333 App app;
334 Module module;
335 };
336
from_json(const nlohmann::json & jsonObject,Metadata & metadata)337 void from_json(const nlohmann::json &jsonObject, Metadata &metadata)
338 {
339 APP_LOGD("read metadata tag from module.json");
340 const auto &jsonObjectEnd = jsonObject.end();
341 GetValueIfFindKey<uint32_t>(jsonObject,
342 jsonObjectEnd,
343 META_DATA_VALUEID,
344 metadata.valueId,
345 JsonType::NUMBER,
346 false,
347 g_parseResult,
348 ArrayType::NOT_ARRAY);
349 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
350 jsonObjectEnd,
351 META_DATA_NAME,
352 metadata.name,
353 false,
354 g_parseResult);
355 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
356 jsonObjectEnd,
357 META_DATA_VALUE,
358 metadata.value,
359 false,
360 g_parseResult);
361 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
362 jsonObjectEnd,
363 META_DATA_RESOURCE,
364 metadata.resource,
365 false,
366 g_parseResult);
367 }
368
from_json(const nlohmann::json & jsonObject,HnpPackage & hnpPackage)369 void from_json(const nlohmann::json &jsonObject, HnpPackage &hnpPackage)
370 {
371 APP_LOGD("read hnppackage tag from module.json");
372 const auto &jsonObjectEnd = jsonObject.end();
373 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
374 jsonObjectEnd,
375 HNP_PACKAGE,
376 hnpPackage.package,
377 false,
378 g_parseResult);
379 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
380 jsonObjectEnd,
381 HNP_TYPE,
382 hnpPackage.type,
383 false,
384 g_parseResult);
385 }
386
from_json(const nlohmann::json & jsonObject,Ability & ability)387 void from_json(const nlohmann::json &jsonObject, Ability &ability)
388 {
389 APP_LOGD("read ability tag from module.json");
390 const auto &jsonObjectEnd = jsonObject.end();
391 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
392 jsonObjectEnd,
393 ABILITY_NAME,
394 ability.name,
395 true,
396 g_parseResult);
397 // both srcEntry and srcEntrance can be configured, but srcEntry has higher priority
398 if (jsonObject.find(SRC_ENTRY) != jsonObject.end()) {
399 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
400 jsonObjectEnd,
401 SRC_ENTRY,
402 ability.srcEntrance,
403 true,
404 g_parseResult);
405 } else {
406 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
407 jsonObjectEnd,
408 SRC_ENTRANCE,
409 ability.srcEntrance,
410 true,
411 g_parseResult);
412 }
413 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
414 jsonObjectEnd,
415 ABILITY_LAUNCH_TYPE,
416 ability.launchType,
417 false,
418 g_parseResult);
419 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
420 jsonObjectEnd,
421 DESCRIPTION,
422 ability.description,
423 false,
424 g_parseResult);
425 GetValueIfFindKey<uint32_t>(jsonObject,
426 jsonObjectEnd,
427 DESCRIPTION_ID,
428 ability.descriptionId,
429 JsonType::NUMBER,
430 false,
431 g_parseResult,
432 ArrayType::NOT_ARRAY);
433 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
434 jsonObjectEnd,
435 ICON,
436 ability.icon,
437 false,
438 g_parseResult);
439 GetValueIfFindKey<uint32_t>(jsonObject,
440 jsonObjectEnd,
441 ICON_ID,
442 ability.iconId,
443 JsonType::NUMBER,
444 false,
445 g_parseResult,
446 ArrayType::NOT_ARRAY);
447 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
448 jsonObjectEnd,
449 LABEL,
450 ability.label,
451 false,
452 g_parseResult);
453 GetValueIfFindKey<uint32_t>(jsonObject,
454 jsonObjectEnd,
455 LABEL_ID,
456 ability.labelId,
457 JsonType::NUMBER,
458 false,
459 g_parseResult,
460 ArrayType::NOT_ARRAY);
461 GetValueIfFindKey<int32_t>(jsonObject,
462 jsonObjectEnd,
463 PRIORITY,
464 ability.priority,
465 JsonType::NUMBER,
466 false,
467 g_parseResult,
468 ArrayType::NOT_ARRAY);
469 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
470 jsonObjectEnd,
471 PERMISSIONS,
472 ability.permissions,
473 JsonType::ARRAY,
474 false,
475 g_parseResult,
476 ArrayType::STRING);
477 GetValueIfFindKey<std::vector<Metadata>>(jsonObject,
478 jsonObjectEnd,
479 META_DATA,
480 ability.metadata,
481 JsonType::ARRAY,
482 false,
483 g_parseResult,
484 ArrayType::OBJECT);
485 // both exported and visible can be configured, but exported has higher priority
486 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
487 jsonObjectEnd,
488 VISIBLE,
489 ability.visible,
490 false,
491 g_parseResult);
492 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
493 jsonObjectEnd,
494 EXPORTED,
495 ability.visible,
496 false,
497 g_parseResult);
498 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
499 jsonObjectEnd,
500 ABILITY_CONTINUABLE,
501 ability.continuable,
502 false,
503 g_parseResult);
504 GetValueIfFindKey<std::vector<Skill>>(jsonObject,
505 jsonObjectEnd,
506 SKILLS,
507 ability.skills,
508 JsonType::ARRAY,
509 false,
510 g_parseResult,
511 ArrayType::OBJECT);
512 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
513 jsonObjectEnd,
514 ABILITY_BACKGROUNDMODES,
515 ability.backgroundModes,
516 JsonType::ARRAY,
517 false,
518 g_parseResult,
519 ArrayType::STRING);
520 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
521 jsonObjectEnd,
522 ABILITY_START_WINDOW_ICON,
523 ability.startWindowIcon,
524 false,
525 g_parseResult);
526 GetValueIfFindKey<uint32_t>(jsonObject,
527 jsonObjectEnd,
528 ABILITY_START_WINDOW_ICON_ID,
529 ability.startWindowIconId,
530 JsonType::NUMBER,
531 false,
532 g_parseResult,
533 ArrayType::NOT_ARRAY);
534 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
535 jsonObjectEnd,
536 ABILITY_START_WINDOW_BACKGROUND,
537 ability.startWindowBackground,
538 false,
539 g_parseResult);
540 GetValueIfFindKey<uint32_t>(jsonObject,
541 jsonObjectEnd,
542 ABILITY_START_WINDOW_BACKGROUND_ID,
543 ability.startWindowBackgroundId,
544 JsonType::NUMBER,
545 false,
546 g_parseResult,
547 ArrayType::NOT_ARRAY);
548 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
549 jsonObjectEnd,
550 ABILITY_REMOVE_MISSION_AFTER_TERMINATE,
551 ability.removeMissionAfterTerminate,
552 false,
553 g_parseResult);
554 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
555 jsonObjectEnd,
556 ABILITY_ORIENTATION,
557 ability.orientation,
558 false,
559 g_parseResult);
560 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
561 jsonObjectEnd,
562 ABILITY_SUPPORT_WINDOW_MODE,
563 ability.windowModes,
564 JsonType::ARRAY,
565 false,
566 g_parseResult,
567 ArrayType::STRING);
568 GetValueIfFindKey<double>(jsonObject,
569 jsonObjectEnd,
570 ABILITY_MAX_WINDOW_RATIO,
571 ability.maxWindowRatio,
572 JsonType::NUMBER,
573 false,
574 g_parseResult,
575 ArrayType::NOT_ARRAY);
576 GetValueIfFindKey<double>(jsonObject,
577 jsonObjectEnd,
578 ABILITY_MIN_WINDOW_RATIO,
579 ability.minWindowRatio,
580 JsonType::NUMBER,
581 false,
582 g_parseResult,
583 ArrayType::NOT_ARRAY);
584 GetValueIfFindKey<uint32_t>(jsonObject,
585 jsonObjectEnd,
586 ABILITY_MAX_WINDOW_WIDTH,
587 ability.maxWindowWidth,
588 JsonType::NUMBER,
589 false,
590 g_parseResult,
591 ArrayType::NOT_ARRAY);
592 GetValueIfFindKey<uint32_t>(jsonObject,
593 jsonObjectEnd,
594 ABILITY_MIN_WINDOW_WIDTH,
595 ability.minWindowWidth,
596 JsonType::NUMBER,
597 false,
598 g_parseResult,
599 ArrayType::NOT_ARRAY);
600 GetValueIfFindKey<uint32_t>(jsonObject,
601 jsonObjectEnd,
602 ABILITY_MAX_WINDOW_HEIGHT,
603 ability.maxWindowHeight,
604 JsonType::NUMBER,
605 false,
606 g_parseResult,
607 ArrayType::NOT_ARRAY);
608 GetValueIfFindKey<uint32_t>(jsonObject,
609 jsonObjectEnd,
610 ABILITY_MIN_WINDOW_HEIGHT,
611 ability.minWindowHeight,
612 JsonType::NUMBER,
613 false,
614 g_parseResult,
615 ArrayType::NOT_ARRAY);
616 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
617 jsonObjectEnd,
618 ABILITY_EXCLUDE_FROM_MISSIONS,
619 ability.excludeFromMissions,
620 false,
621 g_parseResult);
622 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
623 jsonObjectEnd,
624 ABILITY_RECOVERABLE,
625 ability.recoverable,
626 false,
627 g_parseResult);
628 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
629 jsonObjectEnd,
630 ABILITY_UNCLEARABLE_MISSION,
631 ability.unclearableMission,
632 false,
633 g_parseResult);
634 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
635 jsonObjectEnd,
636 ABILITY_EXCLUDEFROMDOCK_MISSION,
637 ability.excludeFromDock,
638 false,
639 g_parseResult);
640 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
641 jsonObjectEnd,
642 ABILITY_PREFER_MULTI_WINDOW_ORIENTATION_MISSION,
643 ability.preferMultiWindowOrientation,
644 false,
645 g_parseResult);
646 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
647 jsonObjectEnd,
648 ABILITY_ISOLATION_PROCESS,
649 ability.isolationProcess,
650 false,
651 g_parseResult);
652 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
653 jsonObjectEnd,
654 ABILITY_CONTINUE_TYPE,
655 ability.continueType,
656 JsonType::ARRAY,
657 false,
658 g_parseResult,
659 ArrayType::STRING);
660 GetValueIfFindKey<uint32_t>(jsonObject,
661 jsonObjectEnd,
662 ABILITY_ORIENTATION_ID,
663 ability.orientationId,
664 JsonType::NUMBER,
665 false,
666 g_parseResult,
667 ArrayType::NOT_ARRAY);
668 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
669 jsonObjectEnd,
670 ABILITY_CONTINUE_BUNDLE_NAME,
671 ability.continueBundleNames,
672 JsonType::ARRAY,
673 false,
674 g_parseResult,
675 ArrayType::STRING);
676 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
677 jsonObjectEnd,
678 MODULE_PROCESS,
679 ability.process,
680 false,
681 g_parseResult);
682 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
683 jsonObjectEnd,
684 ABILITY_START_WINDOW,
685 ability.startWindow,
686 false,
687 g_parseResult);
688 GetValueIfFindKey<uint32_t>(jsonObject,
689 jsonObjectEnd,
690 ABILITY_START_WINDOW_ID,
691 ability.startWindowId,
692 JsonType::NUMBER,
693 false,
694 g_parseResult,
695 ArrayType::NOT_ARRAY);
696 }
697
from_json(const nlohmann::json & jsonObject,Extension & extension)698 void from_json(const nlohmann::json &jsonObject, Extension &extension)
699 {
700 APP_LOGD("read extension tag from module.json");
701 const auto &jsonObjectEnd = jsonObject.end();
702 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
703 jsonObjectEnd,
704 EXTENSION_ABILITY_NAME,
705 extension.name,
706 true,
707 g_parseResult);
708 // both srcEntry and srcEntrance can be configured, but srcEntry has higher priority
709 if (jsonObject.find(SRC_ENTRY) != jsonObject.end()) {
710 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
711 jsonObjectEnd,
712 SRC_ENTRY,
713 extension.srcEntrance,
714 true,
715 g_parseResult);
716 } else {
717 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
718 jsonObjectEnd,
719 SRC_ENTRANCE,
720 extension.srcEntrance,
721 true,
722 g_parseResult);
723 }
724 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
725 jsonObjectEnd,
726 ICON,
727 extension.icon,
728 false,
729 g_parseResult);
730 GetValueIfFindKey<uint32_t>(jsonObject,
731 jsonObjectEnd,
732 ICON_ID,
733 extension.iconId,
734 JsonType::NUMBER,
735 false,
736 g_parseResult,
737 ArrayType::NOT_ARRAY);
738 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
739 jsonObjectEnd,
740 LABEL,
741 extension.label,
742 false,
743 g_parseResult);
744 GetValueIfFindKey<uint32_t>(jsonObject,
745 jsonObjectEnd,
746 LABEL_ID,
747 extension.labelId,
748 JsonType::NUMBER,
749 false,
750 g_parseResult,
751 ArrayType::NOT_ARRAY);
752 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
753 jsonObjectEnd,
754 DESCRIPTION,
755 extension.description,
756 false,
757 g_parseResult);
758 GetValueIfFindKey<uint32_t>(jsonObject,
759 jsonObjectEnd,
760 DESCRIPTION_ID,
761 extension.descriptionId,
762 JsonType::NUMBER,
763 false,
764 g_parseResult,
765 ArrayType::NOT_ARRAY);
766 GetValueIfFindKey<int32_t>(jsonObject,
767 jsonObjectEnd,
768 PRIORITY,
769 extension.priority,
770 JsonType::NUMBER,
771 false,
772 g_parseResult,
773 ArrayType::NOT_ARRAY);
774 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
775 jsonObjectEnd,
776 EXTENSION_ABILITY_TYPE,
777 extension.type,
778 true,
779 g_parseResult);
780 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
781 jsonObjectEnd,
782 EXTENSION_ABILITY_READ_PERMISSION,
783 extension.readPermission,
784 false,
785 g_parseResult);
786 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
787 jsonObjectEnd,
788 EXTENSION_ABILITY_WRITE_PERMISSION,
789 extension.writePermission,
790 false,
791 g_parseResult);
792 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
793 jsonObjectEnd,
794 EXTENSION_URI,
795 extension.uri,
796 false,
797 g_parseResult);
798 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
799 jsonObjectEnd,
800 PERMISSIONS,
801 extension.permissions,
802 JsonType::ARRAY,
803 false,
804 g_parseResult,
805 ArrayType::STRING);
806 // both exported and visible can be configured, but exported has higher priority
807 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
808 jsonObjectEnd,
809 VISIBLE,
810 extension.visible,
811 false,
812 g_parseResult);
813 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
814 jsonObjectEnd,
815 EXPORTED,
816 extension.visible,
817 false,
818 g_parseResult);
819 GetValueIfFindKey<std::vector<Skill>>(jsonObject,
820 jsonObjectEnd,
821 SKILLS,
822 extension.skills,
823 JsonType::ARRAY,
824 false,
825 g_parseResult,
826 ArrayType::OBJECT);
827 GetValueIfFindKey<std::vector<Metadata>>(jsonObject,
828 jsonObjectEnd,
829 META_DATA,
830 extension.metadata,
831 JsonType::ARRAY,
832 false,
833 g_parseResult,
834 ArrayType::OBJECT);
835 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
836 jsonObjectEnd,
837 EXTENSION_PROCESS_MODE,
838 extension.extensionProcessMode,
839 false,
840 g_parseResult);
841 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
842 jsonObjectEnd,
843 DATA_GROUP_IDS,
844 extension.dataGroupIds,
845 JsonType::ARRAY,
846 false,
847 g_parseResult,
848 ArrayType::STRING);
849 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
850 jsonObjectEnd,
851 MODULE_PROCESS,
852 extension.customProcess,
853 false,
854 g_parseResult);
855 }
856
from_json(const nlohmann::json & jsonObject,DeviceConfig & deviceConfig)857 void from_json(const nlohmann::json &jsonObject, DeviceConfig &deviceConfig)
858 {
859 const auto &jsonObjectEnd = jsonObject.end();
860 if (jsonObject.find(MIN_API_VERSION) != jsonObjectEnd) {
861 deviceConfig.minAPIVersion.first = true;
862 GetValueIfFindKey<int32_t>(jsonObject,
863 jsonObjectEnd,
864 MIN_API_VERSION,
865 deviceConfig.minAPIVersion.second,
866 JsonType::NUMBER,
867 false,
868 g_parseResult,
869 ArrayType::NOT_ARRAY);
870 }
871 if (jsonObject.find(DEVICE_CONFIG_KEEP_ALIVE) != jsonObjectEnd) {
872 deviceConfig.keepAlive.first = true;
873 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
874 jsonObjectEnd,
875 DEVICE_CONFIG_KEEP_ALIVE,
876 deviceConfig.keepAlive.second,
877 false,
878 g_parseResult);
879 }
880 if (jsonObject.find(DEVICE_CONFIG_REMOVABLE) != jsonObjectEnd) {
881 deviceConfig.removable.first = true;
882 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
883 jsonObjectEnd,
884 DEVICE_CONFIG_REMOVABLE,
885 deviceConfig.removable.second,
886 false,
887 g_parseResult);
888 }
889 if (jsonObject.find(DEVICE_CONFIG_SINGLETON) != jsonObjectEnd) {
890 deviceConfig.singleton.first = true;
891 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
892 jsonObjectEnd,
893 DEVICE_CONFIG_SINGLETON,
894 deviceConfig.singleton.second,
895 false,
896 g_parseResult);
897 }
898 if (jsonObject.find(DEVICE_CONFIG_USER_DATA_CLEARABLE) != jsonObjectEnd) {
899 deviceConfig.userDataClearable.first = true;
900 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
901 jsonObjectEnd,
902 DEVICE_CONFIG_USER_DATA_CLEARABLE,
903 deviceConfig.userDataClearable.second,
904 false,
905 g_parseResult);
906 }
907 if (jsonObject.find(DEVICE_CONFIG_ACCESSIBLE) != jsonObjectEnd) {
908 deviceConfig.accessible.first = true;
909 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
910 jsonObjectEnd,
911 DEVICE_CONFIG_ACCESSIBLE,
912 deviceConfig.accessible.second,
913 false,
914 g_parseResult);
915 }
916 }
917
from_json(const nlohmann::json & jsonObject,MultiAppMode & multiAppMode)918 void from_json(const nlohmann::json &jsonObject, MultiAppMode &multiAppMode)
919 {
920 // these are required fields.
921 const auto &jsonObjectEnd = jsonObject.end();
922 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
923 jsonObjectEnd,
924 MULTI_APP_MODE_TYPE,
925 multiAppMode.multiAppModeType,
926 false,
927 g_parseResult);
928 GetValueIfFindKey<int32_t>(jsonObject,
929 jsonObjectEnd,
930 MULTI_APP_MODE_MAX_ADDITIONAL_NUMBER,
931 multiAppMode.maxCount,
932 JsonType::NUMBER,
933 false,
934 g_parseResult,
935 ArrayType::NOT_ARRAY);
936 }
937
from_json(const nlohmann::json & jsonObject,App & app)938 void from_json(const nlohmann::json &jsonObject, App &app)
939 {
940 APP_LOGD("read app tag from module.json");
941 const auto &jsonObjectEnd = jsonObject.end();
942 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
943 jsonObjectEnd,
944 APP_BUNDLE_NAME,
945 app.bundleName,
946 true,
947 g_parseResult);
948 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
949 jsonObjectEnd,
950 ICON,
951 app.icon,
952 true,
953 g_parseResult);
954 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
955 jsonObjectEnd,
956 LABEL,
957 app.label,
958 true,
959 g_parseResult);
960 GetValueIfFindKey<int32_t>(jsonObject,
961 jsonObjectEnd,
962 APP_VERSION_CODE,
963 app.versionCode,
964 JsonType::NUMBER,
965 true,
966 g_parseResult,
967 ArrayType::NOT_ARRAY);
968 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
969 jsonObjectEnd,
970 APP_VERSION_NAME,
971 app.versionName,
972 true,
973 g_parseResult);
974 GetValueIfFindKey<uint32_t>(jsonObject,
975 jsonObjectEnd,
976 APP_MIN_API_VERSION,
977 app.minAPIVersion,
978 JsonType::NUMBER,
979 true,
980 g_parseResult,
981 ArrayType::NOT_ARRAY);
982 GetValueIfFindKey<int32_t>(jsonObject,
983 jsonObjectEnd,
984 APP_TARGET_API_VERSION,
985 app.targetAPIVersion,
986 JsonType::NUMBER,
987 true,
988 g_parseResult,
989 ArrayType::NOT_ARRAY);
990 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
991 jsonObjectEnd,
992 APP_DEBUG,
993 app.debug,
994 false,
995 g_parseResult);
996 GetValueIfFindKey<uint32_t>(jsonObject,
997 jsonObjectEnd,
998 ICON_ID,
999 app.iconId,
1000 JsonType::NUMBER,
1001 false,
1002 g_parseResult,
1003 ArrayType::NOT_ARRAY);
1004 GetValueIfFindKey<uint32_t>(jsonObject,
1005 jsonObjectEnd,
1006 LABEL_ID,
1007 app.labelId,
1008 JsonType::NUMBER,
1009 false,
1010 g_parseResult,
1011 ArrayType::NOT_ARRAY);
1012 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1013 jsonObjectEnd,
1014 DESCRIPTION,
1015 app.description,
1016 false,
1017 g_parseResult);
1018 GetValueIfFindKey<uint32_t>(jsonObject,
1019 jsonObjectEnd,
1020 DESCRIPTION_ID,
1021 app.descriptionId,
1022 JsonType::NUMBER,
1023 false,
1024 g_parseResult,
1025 ArrayType::NOT_ARRAY);
1026 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1027 jsonObjectEnd,
1028 APP_VENDOR,
1029 app.vendor,
1030 false,
1031 g_parseResult);
1032 GetValueIfFindKey<int32_t>(jsonObject,
1033 jsonObjectEnd,
1034 APP_MIN_COMPATIBLE_VERSION_CODE,
1035 app.minCompatibleVersionCode,
1036 JsonType::NUMBER,
1037 false,
1038 g_parseResult,
1039 ArrayType::NOT_ARRAY);
1040 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1041 jsonObjectEnd,
1042 APP_API_RELEASETYPE,
1043 app.apiReleaseType,
1044 false,
1045 g_parseResult);
1046 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1047 jsonObjectEnd,
1048 APP_KEEP_ALIVE,
1049 app.keepAlive,
1050 false,
1051 g_parseResult);
1052 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
1053 jsonObjectEnd,
1054 APP_TARGETBUNDLELIST,
1055 app.targetBundleList,
1056 JsonType::ARRAY,
1057 false,
1058 g_parseResult,
1059 ArrayType::STRING);
1060 if (jsonObject.find(APP_REMOVABLE) != jsonObject.end()) {
1061 app.removable.first = true;
1062 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1063 jsonObjectEnd,
1064 APP_REMOVABLE,
1065 app.removable.second,
1066 false,
1067 g_parseResult);
1068 }
1069 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1070 jsonObjectEnd,
1071 APP_SINGLETON,
1072 app.singleton,
1073 false,
1074 g_parseResult);
1075 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1076 jsonObjectEnd,
1077 APP_USER_DATA_CLEARABLE,
1078 app.userDataClearable,
1079 false,
1080 g_parseResult);
1081 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1082 jsonObjectEnd,
1083 APP_ACCESSIBLE,
1084 app.accessible,
1085 false,
1086 g_parseResult);
1087 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1088 jsonObjectEnd,
1089 APP_ASAN_ENABLED,
1090 app.asanEnabled,
1091 false,
1092 g_parseResult);
1093 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1094 jsonObjectEnd,
1095 BUNDLE_TYPE,
1096 app.bundleType,
1097 false,
1098 g_parseResult);
1099 if (jsonObject.find(APP_PHONE) != jsonObjectEnd) {
1100 DeviceConfig deviceConfig;
1101 GetValueIfFindKey<DeviceConfig>(jsonObject,
1102 jsonObjectEnd,
1103 APP_PHONE,
1104 deviceConfig,
1105 JsonType::OBJECT,
1106 false,
1107 g_parseResult,
1108 ArrayType::NOT_ARRAY);
1109 app.deviceConfigs[APP_PHONE] = deviceConfig;
1110 }
1111 if (jsonObject.find(APP_TABLET) != jsonObjectEnd) {
1112 DeviceConfig deviceConfig;
1113 GetValueIfFindKey<DeviceConfig>(jsonObject,
1114 jsonObjectEnd,
1115 APP_TABLET,
1116 deviceConfig,
1117 JsonType::OBJECT,
1118 false,
1119 g_parseResult,
1120 ArrayType::NOT_ARRAY);
1121 app.deviceConfigs[APP_TABLET] = deviceConfig;
1122 }
1123 if (jsonObject.find(APP_TV) != jsonObjectEnd) {
1124 DeviceConfig deviceConfig;
1125 GetValueIfFindKey<DeviceConfig>(jsonObject,
1126 jsonObjectEnd,
1127 APP_TV,
1128 deviceConfig,
1129 JsonType::OBJECT,
1130 false,
1131 g_parseResult,
1132 ArrayType::NOT_ARRAY);
1133 app.deviceConfigs[APP_TV] = deviceConfig;
1134 }
1135 if (jsonObject.find(APP_WEARABLE) != jsonObjectEnd) {
1136 DeviceConfig deviceConfig;
1137 GetValueIfFindKey<DeviceConfig>(jsonObject,
1138 jsonObjectEnd,
1139 APP_WEARABLE,
1140 deviceConfig,
1141 JsonType::OBJECT,
1142 false,
1143 g_parseResult,
1144 ArrayType::NOT_ARRAY);
1145 app.deviceConfigs[APP_WEARABLE] = deviceConfig;
1146 }
1147 if (jsonObject.find(APP_LITE_WEARABLE) != jsonObjectEnd) {
1148 DeviceConfig deviceConfig;
1149 GetValueIfFindKey<DeviceConfig>(jsonObject,
1150 jsonObjectEnd,
1151 APP_LITE_WEARABLE,
1152 deviceConfig,
1153 JsonType::OBJECT,
1154 false,
1155 g_parseResult,
1156 ArrayType::NOT_ARRAY);
1157 app.deviceConfigs[APP_LITE_WEARABLE] = deviceConfig;
1158 }
1159 if (jsonObject.find(APP_CAR) != jsonObjectEnd) {
1160 DeviceConfig deviceConfig;
1161 GetValueIfFindKey<DeviceConfig>(jsonObject,
1162 jsonObjectEnd,
1163 APP_CAR,
1164 deviceConfig,
1165 JsonType::OBJECT,
1166 false,
1167 g_parseResult,
1168 ArrayType::NOT_ARRAY);
1169 app.deviceConfigs[APP_CAR] = deviceConfig;
1170 }
1171 if (jsonObject.find(APP_SMART_VISION) != jsonObjectEnd) {
1172 DeviceConfig deviceConfig;
1173 GetValueIfFindKey<DeviceConfig>(jsonObject,
1174 jsonObjectEnd,
1175 APP_SMART_VISION,
1176 deviceConfig,
1177 JsonType::OBJECT,
1178 false,
1179 g_parseResult,
1180 ArrayType::NOT_ARRAY);
1181 app.deviceConfigs[APP_SMART_VISION] = deviceConfig;
1182 }
1183 if (jsonObject.find(APP_ROUTER) != jsonObjectEnd) {
1184 DeviceConfig deviceConfig;
1185 GetValueIfFindKey<DeviceConfig>(jsonObject,
1186 jsonObjectEnd,
1187 APP_ROUTER,
1188 deviceConfig,
1189 JsonType::OBJECT,
1190 false,
1191 g_parseResult,
1192 ArrayType::NOT_ARRAY);
1193 app.deviceConfigs[APP_ROUTER] = deviceConfig;
1194 }
1195 if (jsonObject.find(APP_TWO_IN_ONE) != jsonObjectEnd) {
1196 DeviceConfig deviceConfig;
1197 GetValueIfFindKey<DeviceConfig>(jsonObject,
1198 jsonObjectEnd,
1199 APP_TWO_IN_ONE,
1200 deviceConfig,
1201 JsonType::OBJECT,
1202 false,
1203 g_parseResult,
1204 ArrayType::NOT_ARRAY);
1205 app.deviceConfigs[APP_TWO_IN_ONE] = deviceConfig;
1206 }
1207 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1208 jsonObjectEnd,
1209 APP_MULTI_PROJECTS,
1210 app.multiProjects,
1211 false,
1212 g_parseResult);
1213 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1214 jsonObjectEnd,
1215 APP_TARGET_BUNDLE_NAME,
1216 app.targetBundle,
1217 false,
1218 g_parseResult);
1219 GetValueIfFindKey<int32_t>(jsonObject,
1220 jsonObjectEnd,
1221 APP_TARGET_PRIORITY,
1222 app.targetPriority,
1223 JsonType::NUMBER,
1224 false,
1225 g_parseResult,
1226 ArrayType::NOT_ARRAY);
1227 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1228 jsonObjectEnd,
1229 COMPILE_SDK_VERSION,
1230 app.compileSdkVersion,
1231 false,
1232 g_parseResult);
1233 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1234 jsonObjectEnd,
1235 COMPILE_SDK_TYPE,
1236 app.compileSdkType,
1237 false,
1238 g_parseResult);
1239 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1240 jsonObjectEnd,
1241 APP_GWP_ASAN_ENABLED,
1242 app.gwpAsanEnabled,
1243 false,
1244 g_parseResult);
1245 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1246 jsonObjectEnd,
1247 APP_TSAN_ENABLED,
1248 app.tsanEnabled,
1249 false,
1250 g_parseResult);
1251 GetValueIfFindKey<std::vector<ApplicationEnvironment>>(jsonObject,
1252 jsonObjectEnd,
1253 MODULE_APP_ENVIRONMENTS,
1254 app.appEnvironments,
1255 JsonType::ARRAY,
1256 false,
1257 g_parseResult,
1258 ArrayType::OBJECT);
1259 GetValueIfFindKey<MultiAppMode>(jsonObject,
1260 jsonObjectEnd,
1261 APP_MULTI_APP_MODE,
1262 app.multiAppMode,
1263 JsonType::OBJECT,
1264 false,
1265 g_parseResult,
1266 ArrayType::NOT_ARRAY);
1267 GetValueIfFindKey<int32_t>(jsonObject,
1268 jsonObjectEnd,
1269 APP_MAX_CHILD_PROCESS,
1270 app.maxChildProcess,
1271 JsonType::NUMBER,
1272 false,
1273 g_parseResult,
1274 ArrayType::NOT_ARRAY);
1275 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1276 jsonObjectEnd,
1277 APP_HWASAN_ENABLED,
1278 app.hwasanEnabled,
1279 false,
1280 g_parseResult);
1281 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1282 jsonObjectEnd,
1283 APP_CONFIGURATION,
1284 app.configuration,
1285 false,
1286 g_parseResult);
1287 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1288 jsonObjectEnd,
1289 APP_CLOUD_FILE_SYNC_ENABLED,
1290 app.cloudFileSyncEnabled,
1291 false,
1292 g_parseResult);
1293 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1294 jsonObjectEnd,
1295 APP_UBSAN_ENABLED,
1296 app.ubsanEnabled,
1297 false,
1298 g_parseResult);
1299 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
1300 jsonObjectEnd,
1301 APP_ASSET_ACCESS_GROUPS,
1302 app.assetAccessGroups,
1303 JsonType::ARRAY,
1304 false,
1305 g_parseResult,
1306 ArrayType::STRING);
1307 }
1308
from_json(const nlohmann::json & jsonObject,Module & module)1309 void from_json(const nlohmann::json &jsonObject, Module &module)
1310 {
1311 APP_LOGD("read module tag from module.json");
1312 const auto &jsonObjectEnd = jsonObject.end();
1313 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1314 jsonObjectEnd,
1315 MODULE_NAME,
1316 module.name,
1317 true,
1318 g_parseResult);
1319 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1320 jsonObjectEnd,
1321 MODULE_TYPE,
1322 module.type,
1323 true,
1324 g_parseResult);
1325 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
1326 jsonObjectEnd,
1327 MODULE_DEVICE_TYPES,
1328 module.deviceTypes,
1329 JsonType::ARRAY,
1330 true,
1331 g_parseResult,
1332 ArrayType::STRING);
1333 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1334 jsonObjectEnd,
1335 MODULE_DELIVERY_WITH_INSTALL,
1336 module.deliveryWithInstall,
1337 true,
1338 g_parseResult);
1339 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1340 jsonObjectEnd,
1341 MODULE_PAGES,
1342 module.pages,
1343 false,
1344 g_parseResult);
1345 // both srcEntry and srcEntrance can be configured, but srcEntry has higher priority
1346 if (jsonObject.find(SRC_ENTRY) != jsonObject.end()) {
1347 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1348 jsonObjectEnd,
1349 SRC_ENTRY,
1350 module.srcEntrance,
1351 false,
1352 g_parseResult);
1353 } else {
1354 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1355 jsonObjectEnd,
1356 SRC_ENTRANCE,
1357 module.srcEntrance,
1358 false,
1359 g_parseResult);
1360 }
1361 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1362 jsonObjectEnd,
1363 MODULE_ABILITY_SRC_ENTRY_DELEGATOR,
1364 module.abilitySrcEntryDelegator,
1365 false,
1366 g_parseResult);
1367 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1368 jsonObjectEnd,
1369 MODULE_ABILITY_STAGE_SRC_ENTRY_DELEGATOR,
1370 module.abilityStageSrcEntryDelegator,
1371 false,
1372 g_parseResult);
1373 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1374 jsonObjectEnd,
1375 DESCRIPTION,
1376 module.description,
1377 false,
1378 g_parseResult);
1379 GetValueIfFindKey<uint32_t>(jsonObject,
1380 jsonObjectEnd,
1381 DESCRIPTION_ID,
1382 module.descriptionId,
1383 JsonType::NUMBER,
1384 false,
1385 g_parseResult,
1386 ArrayType::NOT_ARRAY);
1387 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1388 jsonObjectEnd,
1389 MODULE_PROCESS,
1390 module.process,
1391 false,
1392 g_parseResult);
1393 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1394 jsonObjectEnd,
1395 MODULE_MAIN_ELEMENT,
1396 module.mainElement,
1397 false,
1398 g_parseResult);
1399 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1400 jsonObjectEnd,
1401 MODULE_INSTALLATION_FREE,
1402 module.installationFree,
1403 false,
1404 g_parseResult);
1405 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1406 jsonObjectEnd,
1407 MODULE_VIRTUAL_MACHINE,
1408 module.virtualMachine,
1409 false,
1410 g_parseResult);
1411 GetValueIfFindKey<std::vector<Metadata>>(jsonObject,
1412 jsonObjectEnd,
1413 META_DATA,
1414 module.metadata,
1415 JsonType::ARRAY,
1416 false,
1417 g_parseResult,
1418 ArrayType::OBJECT);
1419 GetValueIfFindKey<std::vector<HnpPackage>>(jsonObject,
1420 jsonObjectEnd,
1421 MODULE_HNP_PACKAGE,
1422 module.hnpPackages,
1423 JsonType::ARRAY,
1424 false,
1425 g_parseResult,
1426 ArrayType::OBJECT);
1427 GetValueIfFindKey<std::vector<Ability>>(jsonObject,
1428 jsonObjectEnd,
1429 MODULE_ABILITIES,
1430 module.abilities,
1431 JsonType::ARRAY,
1432 false,
1433 g_parseResult,
1434 ArrayType::OBJECT);
1435 GetValueIfFindKey<std::vector<Extension>>(jsonObject,
1436 jsonObjectEnd,
1437 MODULE_EXTENSION_ABILITIES,
1438 module.extensionAbilities,
1439 JsonType::ARRAY,
1440 false,
1441 g_parseResult,
1442 ArrayType::OBJECT);
1443 GetValueIfFindKey<std::vector<RequestPermission>>(jsonObject,
1444 jsonObjectEnd,
1445 MODULE_REQUEST_PERMISSIONS,
1446 module.requestPermissions,
1447 JsonType::ARRAY,
1448 false,
1449 g_parseResult,
1450 ArrayType::OBJECT);
1451 GetValueIfFindKey<std::vector<DefinePermission>>(jsonObject,
1452 jsonObjectEnd,
1453 MODULE_DEFINE_PERMISSIONS,
1454 module.definePermissions,
1455 JsonType::ARRAY,
1456 false,
1457 g_parseResult,
1458 ArrayType::OBJECT);
1459 GetValueIfFindKey<std::vector<Dependency>>(jsonObject,
1460 jsonObjectEnd,
1461 MODULE_DEPENDENCIES,
1462 module.dependencies,
1463 JsonType::ARRAY,
1464 false,
1465 g_parseResult,
1466 ArrayType::OBJECT);
1467 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1468 jsonObjectEnd,
1469 MODULE_COMPILE_MODE,
1470 module.compileMode,
1471 false,
1472 g_parseResult);
1473 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1474 jsonObjectEnd,
1475 MODULE_IS_LIB_ISOLATED,
1476 module.isLibIsolated,
1477 false,
1478 g_parseResult);
1479 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1480 jsonObjectEnd,
1481 MODULE_TARGET_MODULE_NAME,
1482 module.targetModule,
1483 false,
1484 g_parseResult);
1485 GetValueIfFindKey<int32_t>(jsonObject,
1486 jsonObjectEnd,
1487 MODULE_TARGET_PRIORITY,
1488 module.targetPriority,
1489 JsonType::NUMBER,
1490 false,
1491 g_parseResult,
1492 ArrayType::NOT_ARRAY);
1493 GetValueIfFindKey<std::vector<ProxyData>>(jsonObject,
1494 jsonObjectEnd,
1495 MODULE_PROXY_DATAS,
1496 module.proxyDatas,
1497 JsonType::ARRAY,
1498 false,
1499 g_parseResult,
1500 ArrayType::OBJECT);
1501 GetValueIfFindKey<std::vector<ProxyData>>(jsonObject,
1502 jsonObjectEnd,
1503 MODULE_PROXY_DATA,
1504 module.proxyData,
1505 JsonType::ARRAY,
1506 false,
1507 g_parseResult,
1508 ArrayType::OBJECT);
1509 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1510 jsonObjectEnd,
1511 MODULE_BUILD_HASH,
1512 module.buildHash,
1513 false,
1514 g_parseResult);
1515 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1516 jsonObjectEnd,
1517 MODULE_ISOLATION_MODE,
1518 module.isolationMode,
1519 false,
1520 g_parseResult);
1521 if (IsSupportCompressNativeLibs()) {
1522 BMSJsonUtil::GetBoolValueIfFindKey(jsonObject,
1523 jsonObjectEnd,
1524 MODULE_COMPRESS_NATIVE_LIBS,
1525 module.compressNativeLibs,
1526 false,
1527 g_parseResult);
1528 }
1529 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1530 jsonObjectEnd,
1531 MODULE_FILE_CONTEXT_MENU,
1532 module.fileContextMenu,
1533 false,
1534 g_parseResult);
1535 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
1536 jsonObjectEnd,
1537 MODULE_QUERY_SCHEMES,
1538 module.querySchemes,
1539 JsonType::ARRAY,
1540 false,
1541 g_parseResult,
1542 ArrayType::STRING);
1543 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1544 jsonObjectEnd,
1545 MODULE_ROUTER_MAP,
1546 module.routerMap,
1547 false,
1548 g_parseResult);
1549 GetValueIfFindKey<std::vector<AppEnvironment>>(jsonObject,
1550 jsonObjectEnd,
1551 MODULE_APP_ENVIRONMENTS,
1552 module.appEnvironments,
1553 JsonType::ARRAY,
1554 false,
1555 g_parseResult,
1556 ArrayType::OBJECT);
1557 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1558 jsonObjectEnd,
1559 MODULE_PACKAGE_NAME,
1560 module.packageName,
1561 false,
1562 g_parseResult);
1563 BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
1564 jsonObjectEnd,
1565 MODULE_APP_STARTUP,
1566 module.appStartup,
1567 false,
1568 g_parseResult);
1569 }
1570
from_json(const nlohmann::json & jsonObject,ModuleJson & moduleJson)1571 void from_json(const nlohmann::json &jsonObject, ModuleJson &moduleJson)
1572 {
1573 const auto &jsonObjectEnd = jsonObject.end();
1574 GetValueIfFindKey<App>(jsonObject,
1575 jsonObjectEnd,
1576 APP,
1577 moduleJson.app,
1578 JsonType::OBJECT,
1579 true,
1580 g_parseResult,
1581 ArrayType::NOT_ARRAY);
1582 GetValueIfFindKey<Module>(jsonObject,
1583 jsonObjectEnd,
1584 MODULE,
1585 moduleJson.module,
1586 JsonType::OBJECT,
1587 true,
1588 g_parseResult,
1589 ArrayType::NOT_ARRAY);
1590 }
1591 } // namespace Profile
1592
1593 namespace {
1594 struct TransformParam {
1595 bool isSystemApp = false;
1596 bool isPreInstallApp = false;
1597 };
1598
GetMetadata(std::vector<Metadata> & metadata,const std::vector<Profile::Metadata> & profileMetadata)1599 void GetMetadata(std::vector<Metadata> &metadata, const std::vector<Profile::Metadata> &profileMetadata)
1600 {
1601 for (const Profile::Metadata &item : profileMetadata) {
1602 Metadata tmpMetadata;
1603 tmpMetadata.valueId = item.valueId;
1604 tmpMetadata.name = item.name;
1605 tmpMetadata.value = item.value;
1606 tmpMetadata.resource = item.resource;
1607 metadata.emplace_back(tmpMetadata);
1608 }
1609 }
1610
GetHnpPackage(std::vector<HnpPackage> & hnpPackage,const std::vector<Profile::HnpPackage> & profileHnpPackage)1611 void GetHnpPackage(std::vector<HnpPackage> &hnpPackage, const std::vector<Profile::HnpPackage> &profileHnpPackage)
1612 {
1613 for (const Profile::HnpPackage &item : profileHnpPackage) {
1614 HnpPackage tmpHnpPackage;
1615 tmpHnpPackage.package = item.package;
1616 tmpHnpPackage.type = item.type;
1617 hnpPackage.emplace_back(tmpHnpPackage);
1618 }
1619 }
1620
CheckBundleNameIsValid(const std::string & bundleName)1621 bool CheckBundleNameIsValid(const std::string &bundleName)
1622 {
1623 if (bundleName.empty()) {
1624 APP_LOGE("bundleName is empty");
1625 return false;
1626 }
1627 if (bundleName.size() < Constants::MIN_BUNDLE_NAME || bundleName.size() > Constants::MAX_BUNDLE_NAME) {
1628 APP_LOGE("bundleName size too long or too short");
1629 return false;
1630 }
1631 char head = bundleName.at(0);
1632 if (!isalpha(head)) {
1633 return false;
1634 }
1635 for (const auto &c : bundleName) {
1636 if (!isalnum(c) && (c != '.') && (c != '_')) {
1637 return false;
1638 }
1639 }
1640 return true;
1641 }
1642
CheckModuleNameIsValid(const std::string & moduleName)1643 bool CheckModuleNameIsValid(const std::string &moduleName)
1644 {
1645 if (moduleName.empty()) {
1646 APP_LOGE("module name is empty");
1647 return false;
1648 }
1649 if (moduleName.size() > MAX_MODULE_NAME) {
1650 APP_LOGE("module name size too long");
1651 return false;
1652 }
1653 if (moduleName.find(ServiceConstants::RELATIVE_PATH) != std::string::npos) {
1654 return false;
1655 }
1656 if (moduleName.find(ServiceConstants::MODULE_NAME_SEPARATOR) != std::string::npos) {
1657 APP_LOGE("module name should not contain ,");
1658 return false;
1659 }
1660 return true;
1661 }
1662
UpdateNativeSoAttrs(const std::string & cpuAbi,const std::string & soRelativePath,bool isLibIsolated,InnerBundleInfo & innerBundleInfo)1663 void UpdateNativeSoAttrs(
1664 const std::string &cpuAbi,
1665 const std::string &soRelativePath,
1666 bool isLibIsolated,
1667 InnerBundleInfo &innerBundleInfo)
1668 {
1669 APP_LOGD("cpuAbi %{public}s, soRelativePath : %{public}s, isLibIsolated : %{public}d",
1670 cpuAbi.c_str(), soRelativePath.c_str(), isLibIsolated);
1671 innerBundleInfo.SetCpuAbi(cpuAbi);
1672 if (!innerBundleInfo.IsCompressNativeLibs(innerBundleInfo.GetCurModuleName())) {
1673 APP_LOGD("UpdateNativeSoAttrs compressNativeLibs is false, no need to decompress so");
1674 if (!isLibIsolated) {
1675 innerBundleInfo.SetNativeLibraryPath(soRelativePath);
1676 }
1677 if (!soRelativePath.empty()) {
1678 innerBundleInfo.SetModuleNativeLibraryPath(ServiceConstants::LIBS + cpuAbi);
1679 innerBundleInfo.SetSharedModuleNativeLibraryPath(ServiceConstants::LIBS + cpuAbi);
1680 }
1681 innerBundleInfo.SetModuleCpuAbi(cpuAbi);
1682 return;
1683 }
1684 if (!isLibIsolated) {
1685 innerBundleInfo.SetNativeLibraryPath(soRelativePath);
1686 return;
1687 }
1688
1689 innerBundleInfo.SetModuleNativeLibraryPath(
1690 innerBundleInfo.GetCurModuleName() + ServiceConstants::PATH_SEPARATOR + soRelativePath);
1691 innerBundleInfo.SetSharedModuleNativeLibraryPath(
1692 innerBundleInfo.GetCurModuleName() + ServiceConstants::PATH_SEPARATOR + soRelativePath);
1693 innerBundleInfo.SetModuleCpuAbi(cpuAbi);
1694 }
1695
ParserNativeSo(const Profile::ModuleJson & moduleJson,const BundleExtractor & bundleExtractor,InnerBundleInfo & innerBundleInfo)1696 bool ParserNativeSo(
1697 const Profile::ModuleJson &moduleJson,
1698 const BundleExtractor &bundleExtractor,
1699 InnerBundleInfo &innerBundleInfo)
1700 {
1701 std::string abis = GetAbiList();
1702 std::vector<std::string> abiList;
1703 SplitStr(abis, ServiceConstants::ABI_SEPARATOR, abiList, false, false);
1704 if (abiList.empty()) {
1705 APP_LOGD("Abi is empty");
1706 return false;
1707 }
1708
1709 bool isDefault =
1710 std::find(abiList.begin(), abiList.end(), ServiceConstants::ABI_DEFAULT) != abiList.end();
1711 bool isSystemLib64Exist = BundleUtil::IsExistDir(ServiceConstants::SYSTEM_LIB64);
1712 APP_LOGD("abi list : %{public}s, isDefault : %{public}d", abis.c_str(), isDefault);
1713 std::string cpuAbi;
1714 std::string soRelativePath;
1715 bool soExist = bundleExtractor.IsDirExist(ServiceConstants::LIBS);
1716 if (!soExist) {
1717 APP_LOGD("so not exist");
1718 if (isDefault) {
1719 cpuAbi = isSystemLib64Exist ? ServiceConstants::ARM64_V8A : ServiceConstants::ARM_EABI_V7A;
1720 UpdateNativeSoAttrs(cpuAbi, soRelativePath, false, innerBundleInfo);
1721 return true;
1722 }
1723
1724 for (const auto &abi : abiList) {
1725 if (ServiceConstants::ABI_MAP.find(abi) != ServiceConstants::ABI_MAP.end()) {
1726 cpuAbi = abi;
1727 UpdateNativeSoAttrs(cpuAbi, soRelativePath, false, innerBundleInfo);
1728 return true;
1729 }
1730 }
1731
1732 return false;
1733 }
1734
1735 APP_LOGD("so exist");
1736 bool isLibIsolated = moduleJson.module.isLibIsolated;
1737 if (isDefault) {
1738 if (isSystemLib64Exist) {
1739 if (bundleExtractor.IsDirExist(std::string(ServiceConstants::LIBS) + ServiceConstants::ARM64_V8A)) {
1740 cpuAbi = ServiceConstants::ARM64_V8A;
1741 soRelativePath = ServiceConstants::LIBS + ServiceConstants::ABI_MAP.at(ServiceConstants::ARM64_V8A);
1742 UpdateNativeSoAttrs(cpuAbi, soRelativePath, isLibIsolated, innerBundleInfo);
1743 return true;
1744 }
1745
1746 return false;
1747 }
1748
1749 if (bundleExtractor.IsDirExist(std::string(ServiceConstants::LIBS) + ServiceConstants::ARM_EABI_V7A)) {
1750 cpuAbi = ServiceConstants::ARM_EABI_V7A;
1751 soRelativePath = ServiceConstants::LIBS + ServiceConstants::ABI_MAP.at(ServiceConstants::ARM_EABI_V7A);
1752 UpdateNativeSoAttrs(cpuAbi, soRelativePath, isLibIsolated, innerBundleInfo);
1753 return true;
1754 }
1755
1756 if (bundleExtractor.IsDirExist(std::string(ServiceConstants::LIBS) + ServiceConstants::ARM_EABI)) {
1757 cpuAbi = ServiceConstants::ARM_EABI;
1758 soRelativePath = ServiceConstants::LIBS + ServiceConstants::ABI_MAP.at(ServiceConstants::ARM_EABI);
1759 UpdateNativeSoAttrs(cpuAbi, soRelativePath, isLibIsolated, innerBundleInfo);
1760 return true;
1761 }
1762
1763 return false;
1764 }
1765
1766 for (const auto &abi : abiList) {
1767 std::string libsPath;
1768 libsPath.append(ServiceConstants::LIBS).append(abi).append(ServiceConstants::PATH_SEPARATOR);
1769 if (ServiceConstants::ABI_MAP.find(abi) != ServiceConstants::ABI_MAP.end() &&
1770 bundleExtractor.IsDirExist(libsPath)) {
1771 cpuAbi = abi;
1772 soRelativePath = ServiceConstants::LIBS + ServiceConstants::ABI_MAP.at(abi);
1773 UpdateNativeSoAttrs(cpuAbi, soRelativePath, isLibIsolated, innerBundleInfo);
1774 return true;
1775 }
1776 }
1777
1778 return false;
1779 }
1780
ParserAtomicModuleConfig(const nlohmann::json & jsonObject,InnerBundleInfo & innerBundleInfo)1781 bool ParserAtomicModuleConfig(const nlohmann::json &jsonObject, InnerBundleInfo &innerBundleInfo)
1782 {
1783 nlohmann::json moduleJson = jsonObject.at(Profile::MODULE);
1784 std::vector<std::string> preloads;
1785 std::string moduleName = moduleJson.at(Profile::MODULE_NAME);
1786 if (moduleJson.contains(Profile::ATOMIC_SERVICE)) {
1787 nlohmann::json moduleAtomicObj = moduleJson.at(Profile::ATOMIC_SERVICE);
1788 if (moduleAtomicObj.contains(Profile::MODULE_ATOMIC_SERVICE_PRELOADS)) {
1789 nlohmann::json preloadObj = moduleAtomicObj.at(Profile::MODULE_ATOMIC_SERVICE_PRELOADS);
1790 if (preloadObj.empty()) {
1791 APP_LOGD("preloadObj is empty");
1792 return true;
1793 }
1794 if (preloadObj.size() > Constants::MAX_JSON_ARRAY_LENGTH) {
1795 APP_LOGE("preloads config in module.json is oversize");
1796 return false;
1797 }
1798 for (const auto &preload : preloadObj) {
1799 if (preload.contains(Profile::PRELOADS_MODULE_NAME)) {
1800 std::string preloadName = preload.at(Profile::PRELOADS_MODULE_NAME);
1801 preloads.emplace_back(preloadName);
1802 } else {
1803 APP_LOGE("preloads must have moduleName");
1804 return false;
1805 }
1806 }
1807 }
1808 }
1809 innerBundleInfo.SetInnerModuleAtomicPreload(moduleName, preloads);
1810 return true;
1811 }
1812
ParserAtomicConfig(const nlohmann::json & jsonObject,InnerBundleInfo & innerBundleInfo)1813 bool ParserAtomicConfig(const nlohmann::json &jsonObject, InnerBundleInfo &innerBundleInfo)
1814 {
1815 if (!jsonObject.contains(Profile::MODULE) || !jsonObject.contains(Profile::APP)) {
1816 APP_LOGE("ParserAtomicConfig failed due to bad module.json");
1817 return false;
1818 }
1819 nlohmann::json appJson = jsonObject.at(Profile::APP);
1820 nlohmann::json moduleJson = jsonObject.at(Profile::MODULE);
1821 if (!moduleJson.is_object() || !appJson.is_object()) {
1822 APP_LOGE("module.json file lacks of invalid module or app properties");
1823 return false;
1824 }
1825 BundleType bundleType = BundleType::APP;
1826 if (appJson.contains(Profile::BUNDLE_TYPE)) {
1827 if (appJson.at(Profile::BUNDLE_TYPE) == Profile::BUNDLE_TYPE_ATOMIC_SERVICE) {
1828 bundleType = BundleType::ATOMIC_SERVICE;
1829 } else if (appJson.at(Profile::BUNDLE_TYPE) == Profile::BUNDLE_TYPE_SHARED) {
1830 bundleType = BundleType::SHARED;
1831 } else if (appJson.at(Profile::BUNDLE_TYPE) == Profile::BUNDLE_TYPE_APP_SERVICE_FWK) {
1832 bundleType = BundleType::APP_SERVICE_FWK;
1833 } else if (appJson.at(Profile::BUNDLE_TYPE) == Profile::BUNDLE_TYPE_PLUGIN) {
1834 bundleType = BundleType::APP_PLUGIN;
1835 }
1836 }
1837
1838 innerBundleInfo.SetApplicationBundleType(bundleType);
1839 if (!ParserAtomicModuleConfig(jsonObject, innerBundleInfo)) {
1840 APP_LOGE("parse module atomicService failed");
1841 return false;
1842 }
1843 return true;
1844 }
1845
ParserArkNativeFilePath(const Profile::ModuleJson & moduleJson,const BundleExtractor & bundleExtractor,InnerBundleInfo & innerBundleInfo)1846 bool ParserArkNativeFilePath(
1847 const Profile::ModuleJson &moduleJson,
1848 const BundleExtractor &bundleExtractor,
1849 InnerBundleInfo &innerBundleInfo)
1850 {
1851 std::string abis = GetAbiList();
1852 std::vector<std::string> abiList;
1853 SplitStr(abis, ServiceConstants::ABI_SEPARATOR, abiList, false, false);
1854 if (abiList.empty()) {
1855 APP_LOGD("Abi is empty");
1856 return false;
1857 }
1858
1859 bool isDefault =
1860 std::find(abiList.begin(), abiList.end(), ServiceConstants::ABI_DEFAULT) != abiList.end();
1861 bool isSystemLib64Exist = BundleUtil::IsExistDir(ServiceConstants::SYSTEM_LIB64);
1862 APP_LOGD("abi list : %{public}s, isDefault : %{public}d", abis.c_str(), isDefault);
1863 bool anExist = bundleExtractor.IsDirExist(ServiceConstants::AN);
1864 if (!anExist) {
1865 APP_LOGD("an not exist");
1866 return true;
1867 }
1868
1869 APP_LOGD("an exist");
1870 if (isDefault) {
1871 if (isSystemLib64Exist) {
1872 if (bundleExtractor.IsDirExist(std::string(ServiceConstants::AN) + ServiceConstants::ARM64_V8A)) {
1873 innerBundleInfo.SetArkNativeFileAbi(ServiceConstants::ARM64_V8A);
1874 return true;
1875 }
1876
1877 return false;
1878 }
1879
1880 if (bundleExtractor.IsDirExist(std::string(ServiceConstants::AN) + ServiceConstants::ARM_EABI_V7A)) {
1881 innerBundleInfo.SetArkNativeFileAbi(ServiceConstants::ARM_EABI_V7A);
1882 return true;
1883 }
1884
1885 if (bundleExtractor.IsDirExist(std::string(ServiceConstants::AN) + ServiceConstants::ARM_EABI)) {
1886 innerBundleInfo.SetArkNativeFileAbi(ServiceConstants::ARM_EABI);
1887 return true;
1888 }
1889
1890 return false;
1891 }
1892
1893 for (const auto &abi : abiList) {
1894 std::string libsPath;
1895 libsPath.append(ServiceConstants::AN).append(abi).append(ServiceConstants::PATH_SEPARATOR);
1896 if (ServiceConstants::ABI_MAP.find(abi) != ServiceConstants::ABI_MAP.end() &&
1897 bundleExtractor.IsDirExist(libsPath)) {
1898 innerBundleInfo.SetArkNativeFileAbi(abi);
1899 return true;
1900 }
1901 }
1902
1903 return false;
1904 }
1905
ToMultiAppModeType(const std::string & type)1906 MultiAppModeType ToMultiAppModeType(const std::string &type)
1907 {
1908 auto iter = Profile::MULTI_APP_MODE_MAP.find(type);
1909 if (iter != Profile::MULTI_APP_MODE_MAP.end()) {
1910 return iter->second;
1911 }
1912 return MultiAppModeType::UNSPECIFIED;
1913 }
1914
ToInnerProfileConfiguration(const BundleExtractor & bundleExtractor,const std::string & configuration,std::string & result)1915 void ToInnerProfileConfiguration(
1916 const BundleExtractor &bundleExtractor,
1917 const std::string &configuration,
1918 std::string &result)
1919 {
1920 constexpr const char* PROFILE_PATH = "resources/base/profile/";
1921 constexpr const char* PROFILE_PREFIX = "$profile:";
1922 constexpr const char* JSON_SUFFIX = ".json";
1923 auto pos = configuration.find(PROFILE_PREFIX);
1924 if (pos == std::string::npos) {
1925 APP_LOGE("invalid profile configuration");
1926 return;
1927 }
1928 std::string profileConfiguration = configuration.substr(pos + strlen(PROFILE_PREFIX));
1929 std::string profilePath = PROFILE_PATH + profileConfiguration + JSON_SUFFIX;
1930
1931 if (!bundleExtractor.HasEntry(profilePath)) {
1932 APP_LOGI("profile not exist");
1933 return;
1934 }
1935 std::stringstream profileStream;
1936 if (!bundleExtractor.ExtractByName(profilePath, profileStream)) {
1937 APP_LOGE("extract profile failed");
1938 return;
1939 }
1940 result = profileStream.str();
1941 }
1942
ToAbilityStartWindow(const BundleExtractor & bundleExtractor,const std::string & startWindow,StartWindowResource & startWindowResource)1943 void ToAbilityStartWindow(
1944 const BundleExtractor &bundleExtractor,
1945 const std::string &startWindow,
1946 StartWindowResource &startWindowResource)
1947 {
1948 auto pos = startWindow.find(ServiceConstants::PROFILE_PREFIX);
1949 if (pos == std::string::npos) {
1950 APP_LOGE("invalid profile configuration");
1951 return;
1952 }
1953 std::string startWindowName = startWindow.substr(pos + strlen(ServiceConstants::PROFILE_PREFIX));
1954 std::string profilePath = ServiceConstants::PROFILE_PATH + startWindowName + ServiceConstants::JSON_SUFFIX;
1955 if (!bundleExtractor.HasEntry(profilePath)) {
1956 APP_LOGI("profile not exist");
1957 return;
1958 }
1959 std::stringstream profileStream;
1960 if (!bundleExtractor.ExtractByName(profilePath, profileStream)) {
1961 APP_LOGE("extract profile failed");
1962 return;
1963 }
1964 nlohmann::json profileJson = nlohmann::json::parse(profileStream.str(), nullptr, false);
1965 if (profileJson.is_discarded()) {
1966 APP_LOGE("bad profile file");
1967 return;
1968 }
1969 startWindowResource.startWindowAppIconId = BundleUtil::ExtractNumberFromString(
1970 profileJson, Profile::START_WINDOW_APP_ICON);
1971 startWindowResource.startWindowIllustrationId = BundleUtil::ExtractNumberFromString(
1972 profileJson, Profile::START_WINDOW_ILLUSTRATION);
1973 startWindowResource.startWindowBrandingImageId = BundleUtil::ExtractNumberFromString(
1974 profileJson, Profile::START_WINDOW_BRANDING_IMAGE);
1975 startWindowResource.startWindowBackgroundColorId = BundleUtil::ExtractNumberFromString(
1976 profileJson, Profile::START_WINDOW_BACKGROUND_COLOR);
1977 startWindowResource.startWindowBackgroundImageId = BundleUtil::ExtractNumberFromString(
1978 profileJson, Profile::START_WINDOW_BACKGROUND_IMAGE);
1979 startWindowResource.startWindowBackgroundImageFit = BundleUtil::ExtractStringFromJson(
1980 profileJson, Profile::START_WINDOW_BACKGROUND_IMAGE_FIT);
1981 }
1982
ToApplicationInfo(const Profile::ModuleJson & moduleJson,const BundleExtractor & bundleExtractor,const TransformParam & transformParam,ApplicationInfo & applicationInfo)1983 bool ToApplicationInfo(
1984 const Profile::ModuleJson &moduleJson,
1985 const BundleExtractor &bundleExtractor,
1986 const TransformParam &transformParam,
1987 ApplicationInfo &applicationInfo)
1988 {
1989 APP_LOGD("transform ModuleJson to ApplicationInfo");
1990 auto app = moduleJson.app;
1991 applicationInfo.name = app.bundleName;
1992 applicationInfo.bundleName = app.bundleName;
1993
1994 applicationInfo.versionCode = static_cast<uint32_t>(app.versionCode);
1995 applicationInfo.versionName = app.versionName;
1996 if (app.minCompatibleVersionCode != -1) {
1997 applicationInfo.minCompatibleVersionCode = app.minCompatibleVersionCode;
1998 } else {
1999 applicationInfo.minCompatibleVersionCode = static_cast<int32_t>(applicationInfo.versionCode);
2000 }
2001
2002 applicationInfo.apiCompatibleVersion = app.minAPIVersion;
2003 applicationInfo.apiTargetVersion = app.targetAPIVersion;
2004
2005 applicationInfo.iconPath = app.icon;
2006 applicationInfo.iconId = app.iconId;
2007 applicationInfo.label = app.label;
2008 applicationInfo.labelId = app.labelId;
2009 applicationInfo.description = app.description;
2010 applicationInfo.descriptionId = app.descriptionId;
2011 applicationInfo.iconResource =
2012 BundleUtil::GetResource(app.bundleName, moduleJson.module.name, app.iconId);
2013 applicationInfo.labelResource =
2014 BundleUtil::GetResource(app.bundleName, moduleJson.module.name, app.labelId);
2015 applicationInfo.descriptionResource =
2016 BundleUtil::GetResource(app.bundleName, moduleJson.module.name, app.descriptionId);
2017 applicationInfo.targetBundleList = app.targetBundleList;
2018
2019 if (transformParam.isSystemApp && transformParam.isPreInstallApp) {
2020 applicationInfo.keepAlive = app.keepAlive;
2021 applicationInfo.singleton = app.singleton;
2022 applicationInfo.userDataClearable = app.userDataClearable;
2023 if (app.removable.first) {
2024 applicationInfo.removable = app.removable.second;
2025 } else {
2026 applicationInfo.removable = false;
2027 }
2028 applicationInfo.accessible = app.accessible;
2029 }
2030
2031 applicationInfo.apiReleaseType = app.apiReleaseType;
2032 applicationInfo.debug = app.debug;
2033 applicationInfo.deviceId = ServiceConstants::CURRENT_DEVICE_ID;
2034 applicationInfo.distributedNotificationEnabled = true;
2035 applicationInfo.entityType = Profile::APP_ENTITY_TYPE_DEFAULT_VALUE;
2036 applicationInfo.vendor = app.vendor;
2037 applicationInfo.asanEnabled = app.asanEnabled;
2038 if (app.bundleType == Profile::BUNDLE_TYPE_ATOMIC_SERVICE) {
2039 applicationInfo.bundleType = BundleType::ATOMIC_SERVICE;
2040 }
2041
2042 // device adapt
2043 std::string deviceType = GetDeviceType();
2044 APP_LOGD("deviceType : %{public}s", deviceType.c_str());
2045 if (app.deviceConfigs.find(deviceType) != app.deviceConfigs.end()) {
2046 Profile::DeviceConfig deviceConfig = app.deviceConfigs.at(deviceType);
2047 if (deviceConfig.minAPIVersion.first) {
2048 applicationInfo.apiCompatibleVersion = static_cast<uint32_t>(deviceConfig.minAPIVersion.second);
2049 }
2050 if (applicationInfo.isSystemApp && transformParam.isPreInstallApp) {
2051 if (deviceConfig.keepAlive.first) {
2052 applicationInfo.keepAlive = deviceConfig.keepAlive.second;
2053 }
2054 if (deviceConfig.singleton.first) {
2055 applicationInfo.singleton = deviceConfig.singleton.second;
2056 }
2057 if (deviceConfig.userDataClearable.first) {
2058 applicationInfo.userDataClearable = deviceConfig.userDataClearable.second;
2059 }
2060 if (deviceConfig.removable.first) {
2061 applicationInfo.removable = deviceConfig.removable.second;
2062 }
2063 if (deviceConfig.accessible.first) {
2064 applicationInfo.accessible = deviceConfig.accessible.second;
2065 }
2066 }
2067 }
2068
2069 applicationInfo.enabled = true;
2070 applicationInfo.multiProjects = app.multiProjects;
2071 applicationInfo.process = app.bundleName;
2072 applicationInfo.targetBundleName = app.targetBundle;
2073 applicationInfo.targetPriority = app.targetPriority;
2074
2075 auto iterBundleType = std::find_if(std::begin(Profile::BUNDLE_TYPE_MAP),
2076 std::end(Profile::BUNDLE_TYPE_MAP),
2077 [&app](const auto &item) { return item.first == app.bundleType; });
2078 if (iterBundleType != Profile::BUNDLE_TYPE_MAP.end()) {
2079 applicationInfo.bundleType = iterBundleType->second;
2080 }
2081 applicationInfo.compileSdkVersion = app.compileSdkVersion;
2082 applicationInfo.compileSdkType = app.compileSdkType;
2083 applicationInfo.gwpAsanEnabled = app.gwpAsanEnabled;
2084 applicationInfo.tsanEnabled = app.tsanEnabled;
2085 applicationInfo.hwasanEnabled = app.hwasanEnabled;
2086 applicationInfo.ubsanEnabled = app.ubsanEnabled;
2087 applicationInfo.appEnvironments = app.appEnvironments;
2088 if (moduleJson.module.type == Profile::MODULE_TYPE_ENTRY) {
2089 applicationInfo.assetAccessGroups = app.assetAccessGroups;
2090 }
2091 // bundleType is app && moduleType is entry or feature
2092 if (applicationInfo.bundleType == BundleType::APP &&
2093 (moduleJson.module.type == Profile::MODULE_TYPE_ENTRY ||
2094 moduleJson.module.type == Profile::MODULE_TYPE_FEATURE)) {
2095 applicationInfo.multiAppMode.multiAppModeType = ToMultiAppModeType(app.multiAppMode.multiAppModeType);
2096 applicationInfo.multiAppMode.maxCount = app.multiAppMode.maxCount;
2097 if (applicationInfo.multiAppMode.multiAppModeType == MultiAppModeType::APP_CLONE) {
2098 int32_t maxNumber = applicationInfo.multiAppMode.maxCount;
2099 if (maxNumber <= Constants::INITIAL_APP_INDEX || maxNumber > ServiceConstants::CLONE_APP_INDEX_MAX) {
2100 return false;
2101 }
2102 }
2103 }
2104 applicationInfo.maxChildProcess = app.maxChildProcess;
2105 if (app.configuration != "") {
2106 ToInnerProfileConfiguration(bundleExtractor, app.configuration, applicationInfo.configuration);
2107 }
2108 applicationInfo.cloudFileSyncEnabled = app.cloudFileSyncEnabled;
2109 return true;
2110 }
2111
ToBundleInfo(const ApplicationInfo & applicationInfo,const InnerModuleInfo & innerModuleInfo,const TransformParam & transformParam,BundleInfo & bundleInfo)2112 bool ToBundleInfo(
2113 const ApplicationInfo &applicationInfo,
2114 const InnerModuleInfo &innerModuleInfo,
2115 const TransformParam &transformParam,
2116 BundleInfo &bundleInfo)
2117 {
2118 bundleInfo.name = applicationInfo.bundleName;
2119
2120 bundleInfo.versionCode = static_cast<uint32_t>(applicationInfo.versionCode);
2121 bundleInfo.versionName = applicationInfo.versionName;
2122 bundleInfo.minCompatibleVersionCode = static_cast<uint32_t>(applicationInfo.minCompatibleVersionCode);
2123
2124 bundleInfo.compatibleVersion = static_cast<uint32_t>(applicationInfo.apiCompatibleVersion);
2125 bundleInfo.targetVersion = static_cast<uint32_t>(applicationInfo.apiTargetVersion);
2126
2127 bundleInfo.isKeepAlive = applicationInfo.keepAlive;
2128 bundleInfo.singleton = applicationInfo.singleton;
2129 bundleInfo.isPreInstallApp = transformParam.isPreInstallApp;
2130
2131 bundleInfo.vendor = applicationInfo.vendor;
2132 bundleInfo.releaseType = applicationInfo.apiReleaseType;
2133 bundleInfo.isNativeApp = false;
2134
2135 if (innerModuleInfo.isEntry) {
2136 bundleInfo.mainEntry = innerModuleInfo.moduleName;
2137 bundleInfo.entryModuleName = innerModuleInfo.moduleName;
2138 }
2139
2140 return true;
2141 }
2142
GetBackgroundModes(const std::vector<std::string> & backgroundModes)2143 uint32_t GetBackgroundModes(const std::vector<std::string> &backgroundModes)
2144 {
2145 uint32_t backgroundMode = 0;
2146 size_t len = sizeof(Profile::BACKGROUND_MODES_MAP_KEY) /
2147 sizeof(Profile::BACKGROUND_MODES_MAP_KEY[0]);
2148 for (const std::string &item : backgroundModes) {
2149 for (size_t i = 0; i < len; i++) {
2150 if (item == Profile::BACKGROUND_MODES_MAP_KEY[i]) {
2151 backgroundMode |= Profile::BACKGROUND_MODES_MAP_VALUE[i];
2152 break;
2153 }
2154 }
2155 }
2156 return backgroundMode;
2157 }
2158
ConvertCompileMode(const std::string & compileMode)2159 inline CompileMode ConvertCompileMode(const std::string& compileMode)
2160 {
2161 if (compileMode == Profile::COMPILE_MODE_ES_MODULE) {
2162 return CompileMode::ES_MODULE;
2163 } else {
2164 return CompileMode::JS_BUNDLE;
2165 }
2166 }
2167
ConvertToAbilityWindowMode(const std::vector<std::string> & windowModes,const std::unordered_map<std::string,SupportWindowMode> & windowMap)2168 std::set<SupportWindowMode> ConvertToAbilityWindowMode(const std::vector<std::string> &windowModes,
2169 const std::unordered_map<std::string, SupportWindowMode> &windowMap)
2170 {
2171 std::set<SupportWindowMode> modes;
2172 for_each(windowModes.begin(), windowModes.end(),
2173 [&windowMap, &modes](const auto &mode)->decltype(auto) {
2174 if (windowMap.find(mode) != windowMap.end()) {
2175 modes.emplace(windowMap.at(mode));
2176 }
2177 });
2178 if (modes.empty()) {
2179 modes.insert(SupportWindowMode::FULLSCREEN);
2180 modes.insert(SupportWindowMode::SPLIT);
2181 modes.insert(SupportWindowMode::FLOATING);
2182 }
2183 return modes;
2184 }
2185
ToAbilityInfo(const Profile::ModuleJson & moduleJson,const Profile::Ability & ability,const TransformParam & transformParam,AbilityInfo & abilityInfo)2186 bool ToAbilityInfo(
2187 const Profile::ModuleJson &moduleJson,
2188 const Profile::Ability &ability,
2189 const TransformParam &transformParam,
2190 AbilityInfo &abilityInfo)
2191 {
2192 APP_LOGD("transform ModuleJson to AbilityInfo");
2193 abilityInfo.name = ability.name;
2194 abilityInfo.srcEntrance = ability.srcEntrance;
2195 abilityInfo.description = ability.description;
2196 abilityInfo.descriptionId = ability.descriptionId;
2197 abilityInfo.iconPath = ability.icon;
2198 abilityInfo.iconId = ability.iconId;
2199 abilityInfo.label = ability.label;
2200 abilityInfo.labelId = ability.labelId;
2201 abilityInfo.priority = ability.priority;
2202 abilityInfo.excludeFromMissions = ability.excludeFromMissions;
2203 abilityInfo.unclearableMission = ability.unclearableMission;
2204 abilityInfo.excludeFromDock = ability.excludeFromDock;
2205 abilityInfo.preferMultiWindowOrientation = ability.preferMultiWindowOrientation;
2206 abilityInfo.recoverable = ability.recoverable;
2207 abilityInfo.permissions = ability.permissions;
2208 abilityInfo.visible = ability.visible;
2209 abilityInfo.continuable = ability.continuable;
2210 abilityInfo.isolationProcess = ability.isolationProcess;
2211 abilityInfo.backgroundModes = GetBackgroundModes(ability.backgroundModes);
2212 GetMetadata(abilityInfo.metadata, ability.metadata);
2213 abilityInfo.package = moduleJson.module.name;
2214 abilityInfo.bundleName = moduleJson.app.bundleName;
2215 abilityInfo.moduleName = moduleJson.module.name;
2216 abilityInfo.applicationName = moduleJson.app.bundleName;
2217 auto iterLaunch = std::find_if(std::begin(Profile::LAUNCH_MODE_MAP),
2218 std::end(Profile::LAUNCH_MODE_MAP),
2219 [&ability](const auto &item) { return item.first == ability.launchType; });
2220 if (iterLaunch != Profile::LAUNCH_MODE_MAP.end()) {
2221 abilityInfo.launchMode = iterLaunch->second;
2222 }
2223 abilityInfo.enabled = true;
2224 abilityInfo.isModuleJson = true;
2225 abilityInfo.isStageBasedModel = true;
2226 abilityInfo.type = AbilityType::PAGE;
2227 for (const std::string &deviceType : moduleJson.module.deviceTypes) {
2228 abilityInfo.deviceTypes.emplace_back(deviceType);
2229 }
2230 abilityInfo.startWindowIcon = ability.startWindowIcon;
2231 abilityInfo.startWindowIconId = ability.startWindowIconId;
2232 abilityInfo.startWindowBackground = ability.startWindowBackground;
2233 abilityInfo.startWindowBackgroundId = ability.startWindowBackgroundId;
2234 abilityInfo.startWindow = ability.startWindow;
2235 abilityInfo.startWindowId = ability.startWindowId;
2236 abilityInfo.removeMissionAfterTerminate = ability.removeMissionAfterTerminate;
2237 abilityInfo.compileMode = ConvertCompileMode(moduleJson.module.compileMode);
2238 size_t len = sizeof(Profile::DISPLAY_ORIENTATION_MAP_KEY) /
2239 sizeof(Profile::DISPLAY_ORIENTATION_MAP_KEY[0]);
2240 for (size_t i = 0; i < len; i++) {
2241 if (ability.orientation == Profile::DISPLAY_ORIENTATION_MAP_KEY[i]) {
2242 abilityInfo.orientation = Profile::DISPLAY_ORIENTATION_MAP_VALUE[i];
2243 break;
2244 }
2245 }
2246
2247 auto modesSet = ConvertToAbilityWindowMode(ability.windowModes, Profile::WINDOW_MODE_MAP);
2248 abilityInfo.windowModes.assign(modesSet.begin(), modesSet.end());
2249
2250 if (!ability.continueBundleNames.empty()) {
2251 abilityInfo.continueBundleNames.insert(ability.continueBundleNames.begin(), ability.continueBundleNames.end());
2252 }
2253
2254 abilityInfo.maxWindowRatio = ability.maxWindowRatio;
2255 abilityInfo.minWindowRatio = ability.minWindowRatio;
2256 abilityInfo.maxWindowWidth = ability.maxWindowWidth;
2257 abilityInfo.minWindowWidth = ability.minWindowWidth;
2258 abilityInfo.maxWindowHeight = ability.maxWindowHeight;
2259 abilityInfo.minWindowHeight = ability.minWindowHeight;
2260 if (ability.continueType.empty()) {
2261 abilityInfo.continueType.emplace_back(ability.name);
2262 } else {
2263 abilityInfo.continueType = ability.continueType;
2264 }
2265 abilityInfo.orientationId = ability.orientationId;
2266 abilityInfo.process = ability.process;
2267 return true;
2268 }
2269
ToAbilitySkills(const std::vector<Skill> & skills,AbilityInfo & abilityInfo)2270 void ToAbilitySkills(const std::vector<Skill> &skills, AbilityInfo &abilityInfo)
2271 {
2272 for (const Skill &skill : skills) {
2273 abilityInfo.skills.push_back(skill);
2274 }
2275 }
2276
ToExtensionAbilitySkills(const std::vector<Skill> & skills,ExtensionAbilityInfo & extensionInfo)2277 void ToExtensionAbilitySkills(const std::vector<Skill> &skills, ExtensionAbilityInfo &extensionInfo)
2278 {
2279 for (const Skill &skill : skills) {
2280 extensionInfo.skills.push_back(skill);
2281 }
2282 }
2283
ToExtensionInfo(const Profile::ModuleJson & moduleJson,const Profile::Extension & extension,const TransformParam & transformParam,ExtensionAbilityInfo & extensionInfo)2284 void ToExtensionInfo(
2285 const Profile::ModuleJson &moduleJson,
2286 const Profile::Extension &extension,
2287 const TransformParam &transformParam,
2288 ExtensionAbilityInfo &extensionInfo)
2289 {
2290 APP_LOGD("transform ModuleJson to ExtensionAbilityInfo");
2291 extensionInfo.type = ConvertToExtensionAbilityType(extension.type);
2292 extensionInfo.extensionTypeName = extension.type;
2293 extensionInfo.name = extension.name;
2294 extensionInfo.srcEntrance = extension.srcEntrance;
2295 extensionInfo.icon = extension.icon;
2296 extensionInfo.iconId = extension.iconId;
2297 extensionInfo.label = extension.label;
2298 extensionInfo.labelId = extension.labelId;
2299 extensionInfo.description = extension.description;
2300 extensionInfo.descriptionId = extension.descriptionId;
2301 if (transformParam.isSystemApp && transformParam.isPreInstallApp) {
2302 extensionInfo.readPermission = extension.readPermission;
2303 extensionInfo.writePermission = extension.writePermission;
2304 }
2305 extensionInfo.priority = extension.priority;
2306 extensionInfo.uri = extension.uri;
2307 extensionInfo.permissions = extension.permissions;
2308 extensionInfo.visible = extension.visible;
2309 GetMetadata(extensionInfo.metadata, extension.metadata);
2310 extensionInfo.bundleName = moduleJson.app.bundleName;
2311 extensionInfo.moduleName = moduleJson.module.name;
2312
2313 if (extensionInfo.type != ExtensionAbilityType::SERVICE &&
2314 extensionInfo.type != ExtensionAbilityType::DATASHARE) {
2315 extensionInfo.process = extensionInfo.bundleName;
2316 extensionInfo.process.append(":");
2317 extensionInfo.process.append(extensionInfo.extensionTypeName);
2318 }
2319
2320 extensionInfo.compileMode = ConvertCompileMode(moduleJson.module.compileMode);
2321 extensionInfo.extensionProcessMode = ConvertToExtensionProcessMode(extension.extensionProcessMode);
2322 for (const std::string &dataGroup : extension.dataGroupIds) {
2323 extensionInfo.dataGroupIds.emplace_back(dataGroup);
2324 }
2325 extensionInfo.customProcess = extension.customProcess;
2326 }
2327
GetPermissions(const Profile::ModuleJson & moduleJson,const TransformParam & transformParam,InnerModuleInfo & innerModuleInfo)2328 bool GetPermissions(
2329 const Profile::ModuleJson &moduleJson,
2330 const TransformParam &transformParam,
2331 InnerModuleInfo &innerModuleInfo)
2332 {
2333 if (moduleJson.app.bundleName == Profile::SYSTEM_RESOURCES_APP) {
2334 for (const DefinePermission &definePermission : moduleJson.module.definePermissions) {
2335 if (definePermission.name.empty()) {
2336 continue;
2337 }
2338 if (Profile::GRANT_MODE_SET.find(definePermission.grantMode) == Profile::GRANT_MODE_SET.end()) {
2339 continue;
2340 }
2341 if (Profile::AVAILABLE_LEVEL_SET.find(definePermission.availableLevel)
2342 == Profile::AVAILABLE_LEVEL_SET.end()) {
2343 continue;
2344 }
2345 if (!definePermission.availableType.empty() &&
2346 definePermission.availableType != Profile::DEFINEPERMISSION_AVAILABLE_TYPE_MDM) {
2347 APP_LOGE("availableType(%{public}s) invalid", definePermission.availableType.c_str());
2348 return false;
2349 }
2350 innerModuleInfo.definePermissions.emplace_back(definePermission);
2351 }
2352 }
2353 for (const RequestPermission &requestPermission : moduleJson.module.requestPermissions) {
2354 if (requestPermission.name.empty()) {
2355 continue;
2356 }
2357 innerModuleInfo.requestPermissions.emplace_back(requestPermission);
2358 }
2359 return true;
2360 }
2361
ToInnerModuleInfo(const Profile::ModuleJson & moduleJson,const TransformParam & transformParam,const OverlayMsg & overlayMsg,InnerModuleInfo & innerModuleInfo)2362 bool ToInnerModuleInfo(
2363 const Profile::ModuleJson &moduleJson,
2364 const TransformParam &transformParam,
2365 const OverlayMsg &overlayMsg,
2366 InnerModuleInfo &innerModuleInfo)
2367 {
2368 APP_LOGD("transform ModuleJson to InnerModuleInfo");
2369 innerModuleInfo.name = moduleJson.module.name;
2370 innerModuleInfo.modulePackage = moduleJson.module.name;
2371 innerModuleInfo.moduleName = moduleJson.module.name;
2372 innerModuleInfo.description = moduleJson.module.description;
2373 innerModuleInfo.descriptionId = moduleJson.module.descriptionId;
2374 GetMetadata(innerModuleInfo.metadata, moduleJson.module.metadata);
2375 GetHnpPackage(innerModuleInfo.hnpPackages, moduleJson.module.hnpPackages);
2376 innerModuleInfo.distro.deliveryWithInstall = moduleJson.module.deliveryWithInstall;
2377 innerModuleInfo.distro.installationFree = moduleJson.module.installationFree;
2378 innerModuleInfo.distro.moduleName = moduleJson.module.name;
2379 innerModuleInfo.installationFree = moduleJson.module.installationFree;
2380 if (Profile::MODULE_TYPE_SET.find(moduleJson.module.type) != Profile::MODULE_TYPE_SET.end()) {
2381 innerModuleInfo.distro.moduleType = moduleJson.module.type;
2382 if (moduleJson.module.type == Profile::MODULE_TYPE_ENTRY) {
2383 innerModuleInfo.isEntry = true;
2384 }
2385 }
2386
2387 innerModuleInfo.mainAbility = moduleJson.module.mainElement;
2388 innerModuleInfo.srcEntrance = moduleJson.module.srcEntrance;
2389 innerModuleInfo.process = moduleJson.module.process;
2390
2391 for (const std::string &deviceType : moduleJson.module.deviceTypes) {
2392 innerModuleInfo.deviceTypes.emplace_back(deviceType);
2393 }
2394
2395 if (Profile::VIRTUAL_MACHINE_SET.find(moduleJson.module.virtualMachine) != Profile::VIRTUAL_MACHINE_SET.end()) {
2396 innerModuleInfo.virtualMachine = moduleJson.module.virtualMachine;
2397 }
2398
2399 innerModuleInfo.uiSyntax = Profile::MODULE_UI_SYNTAX_DEFAULT_VALUE;
2400 innerModuleInfo.pages = moduleJson.module.pages;
2401 if (!GetPermissions(moduleJson, transformParam, innerModuleInfo)) {
2402 APP_LOGE("GetPermissions failed");
2403 return false;
2404 }
2405 innerModuleInfo.dependencies = moduleJson.module.dependencies;
2406 innerModuleInfo.compileMode = moduleJson.module.compileMode;
2407 innerModuleInfo.isModuleJson = true;
2408 innerModuleInfo.isStageBasedModel = true;
2409 innerModuleInfo.isLibIsolated = moduleJson.module.isLibIsolated;
2410 innerModuleInfo.targetModuleName = moduleJson.module.targetModule;
2411 if (overlayMsg.type != NON_OVERLAY_TYPE && !overlayMsg.isModulePriorityExisted) {
2412 innerModuleInfo.targetPriority = ServiceConstants::OVERLAY_MINIMUM_PRIORITY;
2413 } else {
2414 innerModuleInfo.targetPriority = moduleJson.module.targetPriority;
2415 }
2416 if (moduleJson.module.proxyDatas.empty()) {
2417 innerModuleInfo.proxyDatas = moduleJson.module.proxyData;
2418 } else {
2419 innerModuleInfo.proxyDatas = moduleJson.module.proxyDatas;
2420 }
2421 innerModuleInfo.buildHash = moduleJson.module.buildHash;
2422 innerModuleInfo.isolationMode = moduleJson.module.isolationMode;
2423 innerModuleInfo.compressNativeLibs = moduleJson.module.compressNativeLibs;
2424 innerModuleInfo.fileContextMenu = moduleJson.module.fileContextMenu;
2425
2426 if (moduleJson.module.querySchemes.size() > Profile::MAX_QUERYSCHEMES_LENGTH) {
2427 APP_LOGE("The length of the querySchemes exceeds the limit");
2428 return false;
2429 }
2430 for (const std::string &queryScheme : moduleJson.module.querySchemes) {
2431 innerModuleInfo.querySchemes.emplace_back(queryScheme);
2432 }
2433
2434 innerModuleInfo.routerMap = moduleJson.module.routerMap;
2435 // abilities and fileContextMenu store in InnerBundleInfo
2436 innerModuleInfo.appEnvironments = moduleJson.module.appEnvironments;
2437 innerModuleInfo.packageName = moduleJson.module.packageName;
2438 innerModuleInfo.appStartup = moduleJson.module.appStartup;
2439 innerModuleInfo.debug = moduleJson.app.debug;
2440 innerModuleInfo.abilitySrcEntryDelegator = moduleJson.module.abilitySrcEntryDelegator;
2441 innerModuleInfo.abilityStageSrcEntryDelegator = moduleJson.module.abilityStageSrcEntryDelegator;
2442 return true;
2443 }
2444
SetInstallationFree(InnerModuleInfo & innerModuleInfo,BundleType bundleType)2445 void SetInstallationFree(InnerModuleInfo &innerModuleInfo, BundleType bundleType)
2446 {
2447 if (bundleType == BundleType::ATOMIC_SERVICE) {
2448 innerModuleInfo.distro.installationFree = true;
2449 innerModuleInfo.installationFree = true;
2450 } else {
2451 innerModuleInfo.distro.installationFree = false;
2452 innerModuleInfo.installationFree = false;
2453 }
2454 }
2455
ToInnerBundleInfo(const Profile::ModuleJson & moduleJson,const BundleExtractor & bundleExtractor,const OverlayMsg & overlayMsg,InnerBundleInfo & innerBundleInfo)2456 bool ToInnerBundleInfo(
2457 const Profile::ModuleJson &moduleJson,
2458 const BundleExtractor &bundleExtractor,
2459 const OverlayMsg &overlayMsg,
2460 InnerBundleInfo &innerBundleInfo)
2461 {
2462 APP_LOGD("transform ModuleJson to InnerBundleInfo");
2463 if (!CheckBundleNameIsValid(moduleJson.app.bundleName) || !CheckModuleNameIsValid(moduleJson.module.name)) {
2464 APP_LOGE("bundle name or module name is invalid");
2465 return false;
2466 }
2467
2468 if (overlayMsg.type != NON_OVERLAY_TYPE && !CheckModuleNameIsValid(moduleJson.module.targetModule)) {
2469 APP_LOGE("target moduleName is invalid");
2470 }
2471
2472 if ((overlayMsg.type == OVERLAY_EXTERNAL_BUNDLE) && !CheckBundleNameIsValid(moduleJson.app.targetBundle)) {
2473 APP_LOGE("targetBundleName of the overlay hap is invalid");
2474 return false;
2475 }
2476
2477 TransformParam transformParam;
2478 transformParam.isPreInstallApp = innerBundleInfo.IsPreInstallApp();
2479
2480 ApplicationInfo applicationInfo;
2481 applicationInfo.isSystemApp = innerBundleInfo.GetAppType() == Constants::AppType::SYSTEM_APP;
2482 transformParam.isSystemApp = applicationInfo.isSystemApp;
2483 applicationInfo.isCompressNativeLibs = moduleJson.module.compressNativeLibs;
2484 if (!ToApplicationInfo(moduleJson, bundleExtractor, transformParam, applicationInfo)) {
2485 APP_LOGE("To applicationInfo failed");
2486 return false;
2487 }
2488
2489 InnerModuleInfo innerModuleInfo;
2490 if (!ToInnerModuleInfo(moduleJson, transformParam, overlayMsg, innerModuleInfo)) {
2491 APP_LOGE("To innerModuleInfo failed");
2492 return false;
2493 }
2494
2495 innerModuleInfo.asanEnabled = applicationInfo.asanEnabled;
2496 innerModuleInfo.gwpAsanEnabled = applicationInfo.gwpAsanEnabled;
2497 innerModuleInfo.tsanEnabled = applicationInfo.tsanEnabled;
2498 innerModuleInfo.innerModuleInfoFlag = applicationInfo.hwasanEnabled ? innerModuleInfo.innerModuleInfoFlag |
2499 innerBundleInfo.GetSanitizerFlag(GetInnerModuleInfoFlag::GET_INNER_MODULE_INFO_WITH_HWASANENABLED) :
2500 innerModuleInfo.innerModuleInfoFlag &
2501 (~innerBundleInfo.GetSanitizerFlag(GetInnerModuleInfoFlag::GET_INNER_MODULE_INFO_WITH_HWASANENABLED));
2502 innerModuleInfo.innerModuleInfoFlag = applicationInfo.ubsanEnabled ? innerModuleInfo.innerModuleInfoFlag |
2503 innerBundleInfo.GetSanitizerFlag(GetInnerModuleInfoFlag::GET_INNER_MODULE_INFO_WITH_UBSANENABLED) :
2504 innerModuleInfo.innerModuleInfoFlag &
2505 (~innerBundleInfo.GetSanitizerFlag(GetInnerModuleInfoFlag::GET_INNER_MODULE_INFO_WITH_UBSANENABLED));
2506 SetInstallationFree(innerModuleInfo, applicationInfo.bundleType);
2507
2508 BundleInfo bundleInfo;
2509 ToBundleInfo(applicationInfo, innerModuleInfo, transformParam, bundleInfo);
2510
2511 // handle abilities
2512 auto entryActionMatcher = [] (const std::string &action) {
2513 return action == Constants::ACTION_HOME || action == Constants::WANT_ACTION_HOME;
2514 };
2515 bool findEntry = false;
2516 for (const Profile::Ability &ability : moduleJson.module.abilities) {
2517 AbilityInfo abilityInfo;
2518 bool isMainElement = false;
2519 ToAbilityInfo(moduleJson, ability, transformParam, abilityInfo);
2520 if (innerModuleInfo.mainAbility == abilityInfo.name) {
2521 innerModuleInfo.icon = abilityInfo.iconPath;
2522 innerModuleInfo.iconId = abilityInfo.iconId;
2523 innerModuleInfo.label = abilityInfo.label;
2524 innerModuleInfo.labelId = abilityInfo.labelId;
2525 isMainElement = true;
2526 }
2527 std::string key;
2528 key.append(moduleJson.app.bundleName).append(".")
2529 .append(moduleJson.module.name).append(".").append(abilityInfo.name);
2530 innerModuleInfo.abilityKeys.emplace_back(key);
2531 innerModuleInfo.skillKeys.emplace_back(key);
2532 innerBundleInfo.InsertSkillInfo(key, ability.skills);
2533 ToAbilitySkills(ability.skills, abilityInfo);
2534 if (abilityInfo.startWindow != Constants::EMPTY_STRING) {
2535 ToAbilityStartWindow(bundleExtractor, abilityInfo.startWindow, abilityInfo.startWindowResource);
2536 }
2537 innerBundleInfo.InsertAbilitiesInfo(key, abilityInfo);
2538 if (findEntry && !isMainElement) {
2539 continue;
2540 }
2541 // get entry ability
2542 for (const auto &skill : ability.skills) {
2543 bool isEntryAction = std::find_if(skill.actions.begin(), skill.actions.end(),
2544 entryActionMatcher) != skill.actions.end();
2545 bool isEntryEntity = std::find(skill.entities.begin(), skill.entities.end(),
2546 Constants::ENTITY_HOME) != skill.entities.end();
2547 if (isEntryAction && isEntryEntity) {
2548 innerModuleInfo.entryAbilityKey = key;
2549 innerModuleInfo.label = ability.label;
2550 innerModuleInfo.labelId = ability.labelId;
2551 // get launcher application and ability
2552 bool isLauncherEntity = std::find(skill.entities.begin(), skill.entities.end(),
2553 ServiceConstants::FLAG_HOME_INTENT_FROM_SYSTEM) != skill.entities.end();
2554 if (isLauncherEntity && transformParam.isPreInstallApp) {
2555 applicationInfo.isLauncherApp = true;
2556 abilityInfo.isLauncherAbility = true;
2557 }
2558 findEntry = true;
2559 break;
2560 }
2561 }
2562 }
2563
2564 // handle extensionAbilities
2565 for (const Profile::Extension &extension : moduleJson.module.extensionAbilities) {
2566 ExtensionAbilityInfo extensionInfo;
2567 ToExtensionInfo(moduleJson, extension, transformParam, extensionInfo);
2568
2569 if (innerModuleInfo.mainAbility == extensionInfo.name) {
2570 innerModuleInfo.icon = extensionInfo.icon;
2571 innerModuleInfo.iconId = extensionInfo.iconId;
2572 innerModuleInfo.label = extensionInfo.label;
2573 innerModuleInfo.labelId = extensionInfo.labelId;
2574 }
2575
2576 if (transformParam.isPreInstallApp && !applicationInfo.isLauncherApp) {
2577 for (const auto &skill : extension.skills) {
2578 bool isEntryAction = std::find_if(skill.actions.cbegin(), skill.actions.cend(),
2579 entryActionMatcher) != skill.actions.cend();
2580 bool isEntryEntity = std::find(skill.entities.cbegin(), skill.entities.cend(),
2581 Constants::ENTITY_HOME) != skill.entities.cend();
2582 bool isLauncherEntity = std::find(skill.entities.cbegin(), skill.entities.cend(),
2583 ServiceConstants::FLAG_HOME_INTENT_FROM_SYSTEM) != skill.entities.cend();
2584 if (isEntryAction && isEntryEntity && isLauncherEntity) {
2585 applicationInfo.isLauncherApp = true;
2586 break;
2587 }
2588 }
2589 }
2590
2591 std::string key;
2592 key.append(moduleJson.app.bundleName).append(".")
2593 .append(moduleJson.module.name).append(".").append(extension.name);
2594 innerModuleInfo.extensionKeys.emplace_back(key);
2595 innerModuleInfo.extensionSkillKeys.emplace_back(key);
2596 innerBundleInfo.InsertExtensionSkillInfo(key, extension.skills);
2597 ToExtensionAbilitySkills(extension.skills, extensionInfo);
2598 innerBundleInfo.InsertExtensionInfo(key, extensionInfo);
2599 }
2600 if (!findEntry && !transformParam.isPreInstallApp) {
2601 applicationInfo.needAppDetail = true;
2602 if (BundleUtil::IsExistDir(ServiceConstants::SYSTEM_LIB64)) {
2603 applicationInfo.appDetailAbilityLibraryPath = Profile::APP_DETAIL_ABILITY_LIBRARY_PATH_64;
2604 } else {
2605 applicationInfo.appDetailAbilityLibraryPath = Profile::APP_DETAIL_ABILITY_LIBRARY_PATH;
2606 }
2607 if ((applicationInfo.labelId == 0) && (applicationInfo.label.empty())) {
2608 applicationInfo.label = applicationInfo.bundleName;
2609 }
2610 }
2611 innerBundleInfo.SetCurrentModulePackage(moduleJson.module.name);
2612 innerBundleInfo.SetBaseApplicationInfo(applicationInfo);
2613 innerBundleInfo.SetBaseBundleInfo(bundleInfo);
2614
2615 // Here also need verify module type is shared.
2616 if (applicationInfo.bundleType == BundleType::SHARED) {
2617 innerModuleInfo.bundleType = applicationInfo.bundleType;
2618 innerModuleInfo.versionCode = applicationInfo.versionCode;
2619 innerModuleInfo.versionName = applicationInfo.versionName;
2620 innerBundleInfo.InsertInnerSharedModuleInfo(moduleJson.module.name, innerModuleInfo);
2621 }
2622
2623 innerBundleInfo.InsertInnerModuleInfo(moduleJson.module.name, innerModuleInfo);
2624 innerBundleInfo.SetOverlayType(overlayMsg.type);
2625
2626 if (overlayMsg.type == OVERLAY_EXTERNAL_BUNDLE && !overlayMsg.isAppPriorityExisted) {
2627 innerBundleInfo.SetTargetPriority(ServiceConstants::OVERLAY_MINIMUM_PRIORITY);
2628 } else {
2629 innerBundleInfo.SetTargetPriority(moduleJson.app.targetPriority);
2630 }
2631 int32_t overlayState = overlayMsg.type == OVERLAY_EXTERNAL_BUNDLE ?
2632 ServiceConstants::DEFAULT_OVERLAY_ENABLE_STATUS :
2633 ServiceConstants::DEFAULT_OVERLAY_DISABLE_STATUS;
2634 innerBundleInfo.SetOverlayState(overlayState);
2635 return true;
2636 }
2637 } // namespace
2638
ObtainOverlayType(const nlohmann::json & jsonObject) const2639 OverlayMsg ModuleProfile::ObtainOverlayType(const nlohmann::json &jsonObject) const
2640 {
2641 APP_LOGD("check if overlay installation");
2642 OverlayMsg overlayMsg;
2643 #ifdef BUNDLE_FRAMEWORK_OVERLAY_INSTALLATION
2644 if (!jsonObject.contains(Profile::MODULE) || !jsonObject.contains(Profile::APP)) {
2645 APP_LOGE("ObtainOverlayType failed due to bad module.json");
2646 Profile::g_parseResult = ERR_APPEXECFWK_INSTALL_FAILED_PROFILE_PARSE_FAIL;
2647 return overlayMsg;
2648 }
2649 nlohmann::json moduleJson = jsonObject.at(Profile::MODULE);
2650 nlohmann::json appJson = jsonObject.at(Profile::APP);
2651 if (!moduleJson.is_object() || !appJson.is_object()) {
2652 APP_LOGE("module.json file lacks of invalid module or app properties");
2653 Profile::g_parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
2654 return overlayMsg;
2655 }
2656
2657 auto isTargetBundleExisted = appJson.contains(Profile::APP_TARGET_BUNDLE_NAME);
2658 auto isAppPriorityExisted = appJson.contains(Profile::APP_TARGET_PRIORITY);
2659 auto isTargetModuleNameExisted = moduleJson.contains(Profile::MODULE_TARGET_MODULE_NAME);
2660 auto isModulePriorityExisted = moduleJson.contains(Profile::MODULE_TARGET_PRIORITY);
2661 if (!isTargetBundleExisted && !isAppPriorityExisted && !isTargetModuleNameExisted &&
2662 !isModulePriorityExisted) {
2663 APP_LOGD("not overlayed hap");
2664 return overlayMsg;
2665 }
2666 if (!isTargetModuleNameExisted) {
2667 Profile::g_parseResult = ERR_BUNDLEMANAGER_OVERLAY_INSTALLATION_FAILED_TARGET_MODULE_NAME_MISSED;
2668 APP_LOGE("overlay hap with invalid configuration file");
2669 return overlayMsg;
2670 }
2671 if (!isTargetBundleExisted && isAppPriorityExisted) {
2672 Profile::g_parseResult = ERR_BUNDLEMANAGER_OVERLAY_INSTALLATION_FAILED_TARGET_BUNDLE_NAME_MISSED;
2673 APP_LOGE("overlay hap with invalid configuration file");
2674 return overlayMsg;
2675 }
2676
2677 APP_LOGI("overlay configuration file is about to parse");
2678 overlayMsg.type = isTargetBundleExisted ? OVERLAY_EXTERNAL_BUNDLE : OVERLAY_INTERNAL_BUNDLE;
2679 overlayMsg.isAppPriorityExisted = isAppPriorityExisted;
2680 overlayMsg.isModulePriorityExisted = isModulePriorityExisted;
2681 return overlayMsg;
2682 #else
2683 return overlayMsg;
2684 #endif
2685 }
2686
TransformTo(const std::ostringstream & source,const BundleExtractor & bundleExtractor,InnerBundleInfo & innerBundleInfo) const2687 ErrCode ModuleProfile::TransformTo(
2688 const std::ostringstream &source,
2689 const BundleExtractor &bundleExtractor,
2690 InnerBundleInfo &innerBundleInfo) const
2691 {
2692 APP_LOGD("transform module.json stream to InnerBundleInfo");
2693 nlohmann::json jsonObject = nlohmann::json::parse(source.str(), nullptr, false);
2694 if (jsonObject.is_discarded()) {
2695 APP_LOGE("bad profile");
2696 return ERR_APPEXECFWK_PARSE_BAD_PROFILE;
2697 }
2698 OverlayMsg overlayMsg;
2699 Profile::ModuleJson moduleJson;
2700 {
2701 std::lock_guard<std::mutex> lock(Profile::g_mutex);
2702 Profile::g_parseResult = ERR_OK;
2703 overlayMsg = ObtainOverlayType(jsonObject);
2704 if ((overlayMsg.type == NON_OVERLAY_TYPE) && (Profile::g_parseResult != ERR_OK)) {
2705 int32_t ret = Profile::g_parseResult;
2706 Profile::g_parseResult = ERR_OK;
2707 APP_LOGE("ObtainOverlayType g_parseResult %{public}d", ret);
2708 return ret;
2709 }
2710 APP_LOGD("overlay type of the hap is %{public}d", overlayMsg.type);
2711 Profile::g_parseResult = ERR_OK;
2712 moduleJson = jsonObject.get<Profile::ModuleJson>();
2713 if (Profile::g_parseResult != ERR_OK) {
2714 APP_LOGE("g_parseResult %{public}d", Profile::g_parseResult);
2715 int32_t ret = Profile::g_parseResult;
2716 // need recover parse result to ERR_OK
2717 Profile::g_parseResult = ERR_OK;
2718 return ret;
2719 }
2720 }
2721 if (!ToInnerBundleInfo(
2722 moduleJson, bundleExtractor, overlayMsg, innerBundleInfo)) {
2723 return ERR_APPEXECFWK_PARSE_PROFILE_PROP_CHECK_ERROR;
2724 }
2725 if (!ParserAtomicConfig(jsonObject, innerBundleInfo)) {
2726 APP_LOGE("Parser atomicService config failed");
2727 return ERR_APPEXECFWK_PARSE_PROFILE_PROP_CHECK_ERROR;
2728 }
2729 if (!ParserNativeSo(moduleJson, bundleExtractor, innerBundleInfo)) {
2730 #ifdef X86_EMULATOR_MODE
2731 APP_LOGE("Parser native so failed");
2732 return ERR_APPEXECFWK_PARSE_NATIVE_SO_FAILED;
2733 #endif
2734 APP_LOGW("Parser native so failed");
2735 }
2736 if (!ParserArkNativeFilePath(moduleJson, bundleExtractor, innerBundleInfo)) {
2737 #ifdef X86_EMULATOR_MODE
2738 APP_LOGE("Parser ark native file failed");
2739 return ERR_APPEXECFWK_PARSE_AN_FAILED;
2740 #endif
2741 APP_LOGW("Parser ark native file failed");
2742 }
2743 return ERR_OK;
2744 }
2745 } // namespace AppExecFwk
2746 } // namespace OHOS
2747