1 /*
2 * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "ability_info.h"
17
18 #include <errno.h>
19 #include <fcntl.h>
20 #include <string.h>
21 #include <unistd.h>
22
23 #include "bundle_constants.h"
24 #include "hilog_tag_wrapper.h"
25 #include "json_util.h"
26 #include "nlohmann/json.hpp"
27 #include "string_ex.h"
28
29 namespace OHOS {
30 namespace AppExecFwk {
31 namespace {
32 const std::string JSON_KEY_PACKAGE = "package";
33 const std::string JSON_KEY_NAME = "name";
34 const std::string JSON_KEY_APPLICATION_NAME = "applicationName";
35 const std::string JSON_KEY_LABEL = "label";
36 const std::string JSON_KEY_DESCRIPTION = "description";
37 const std::string JSON_KEY_ICON_PATH = "iconPath";
38 const std::string JSON_KEY_THEME = "theme";
39 const std::string JSON_KEY_VISIBLE = "visible";
40 const std::string JSON_KEY_KIND = "kind";
41 const std::string JSON_KEY_TYPE = "type";
42 const std::string JSON_KEY_EXTENSION_ABILITY_TYPE = "extensionAbilityType";
43 const std::string JSON_KEY_ORIENTATION = "orientation";
44 const std::string JSON_KEY_LAUNCH_MODE = "launchMode";
45 const std::string JSON_KEY_CODE_PATH = "codePath";
46 const std::string JSON_KEY_RESOURCE_PATH = "resourcePath";
47 const std::string JSON_KEY_PERMISSIONS = "permissions";
48 const std::string JSON_KEY_PROCESS = "process";
49 const std::string JSON_KEY_DEVICE_TYPES = "deviceTypes";
50 const std::string JSON_KEY_DEVICE_CAPABILITIES = "deviceCapabilities";
51 const std::string JSON_KEY_URI = "uri";
52 const std::string JSON_KEY_IS_LAUNCHER_ABILITY = "isLauncherAbility";
53 const std::string JSON_KEY_REMOVE_MISSION_AFTER_TERMINATE = "removeMissionAfterTerminate";
54 const std::string JSON_KEY_IS_NATIVE_ABILITY = "isNativeAbility";
55 const std::string JSON_KEY_ENABLED = "enabled";
56 const std::string JSON_KEY_SUPPORT_PIP_MODE = "supportPipMode";
57 const std::string JSON_KEY_TARGET_ABILITY = "targetAbility";
58 const std::string JSON_KEY_READ_PERMISSION = "readPermission";
59 const std::string JSON_KEY_WRITE_PERMISSION = "writePermission";
60 const std::string JSON_KEY_CONFIG_CHANGES = "configChanges";
61 const std::string JSON_KEY_FORM = "form";
62 const std::string JSON_KEY_FORM_ENTITY = "formEntity";
63 const std::string JSON_KEY_MIN_FORM_HEIGHT = "minFormHeight";
64 const std::string JSON_KEY_DEFAULT_FORM_HEIGHT = "defaultFormHeight";
65 const std::string JSON_KEY_MIN_FORM_WIDTH = "minFormWidth";
66 const std::string JSON_KEY_DEFAULT_FORM_WIDTH = "defaultFormWidth";
67 const std::string JSON_KEY_BACKGROUND_MODES = "backgroundModes";
68 const std::string JSON_KEY_CUSTOMIZE_DATA = "customizeData";
69 const std::string JSON_KEY_META_DATA = "metaData";
70 const std::string JSON_KEY_META_VALUE = "value";
71 const std::string JSON_KEY_META_EXTRA = "extra";
72 const std::string JSON_KEY_LABEL_ID = "labelId";
73 const std::string JSON_KEY_DESCRIPTION_ID = "descriptionId";
74 const std::string JSON_KEY_ICON_ID = "iconId";
75 const std::string JSON_KEY_FORM_ENABLED = "formEnabled";
76 const std::string JSON_KEY_SRC_PATH = "srcPath";
77 const std::string JSON_KEY_SRC_LANGUAGE = "srcLanguage";
78 const std::string JSON_KEY_START_WINDOW = "startWindow";
79 const std::string JSON_KEY_START_WINDOW_ID = "startWindowId";
80 const std::string JSON_KEY_START_WINDOW_RESOURCE = "startWindowResource";
81 const std::string JSON_KEY_START_WINDOW_ICON = "startWindowIcon";
82 const std::string JSON_KEY_START_WINDOW_ICON_ID = "startWindowIconId";
83 const std::string JSON_KEY_START_WINDOW_BACKGROUND = "startWindowBackground";
84 const std::string JSON_KEY_START_WINDOW_BACKGROUND_ID = "startWindowBackgroundId";
85 const std::string JSON_KEY_COMPILE_MODE = "compileMode";
86 const std::string META_DATA = "metadata";
87 const std::string META_DATA_VALUEID = "valueId";
88 const std::string META_DATA_NAME = "name";
89 const std::string META_DATA_VALUE = "value";
90 const std::string META_DATA_RESOURCE = "resource";
91 const std::string SRC_ENTRANCE = "srcEntrance";
92 const std::string IS_MODULE_JSON = "isModuleJson";
93 const std::string IS_STAGE_BASED_MODEL = "isStageBasedModel";
94 const std::string CONTINUABLE = "continuable";
95 const std::string PRIORITY = "priority";
96 const std::string JOSN_KEY_SUPPORT_WINDOW_MODE = "supportWindowMode";
97 const std::string JOSN_KEY_MAX_WINDOW_RATIO = "maxWindowRatio";
98 const std::string JOSN_KEY_MIN_WINDOW_RATIO = "minWindowRatio";
99 const std::string JOSN_KEY_MAX_WINDOW_WIDTH = "maxWindowWidth";
100 const std::string JOSN_KEY_MIN_WINDOW_WIDTH = "minWindowWidth";
101 const std::string JOSN_KEY_MAX_WINDOW_HEIGHT = "maxWindowHeight";
102 const std::string JOSN_KEY_MIN_WINDOW_HEIGHT = "minWindowHeight";
103 const std::string JOSN_KEY_UID = "uid";
104 const std::string JOSN_KEY_EXCLUDE_FROM_MISSIONS = "excludeFromMissions";
105 const std::string JOSN_KEY_UNCLEARABLE_MISSION = "unclearableMission";
106 const std::string JSON_KEY_EXCLUDE_FROM_DOCK_MISSION = "excludeFromDock";
107 const std::string JSON_KEY_PREFER_MULTI_WINDOW_ORIENTATION_MISSION = "preferMultiWindowOrientation";
108 const std::string JSON_KEY_RECOVERABLE = "recoverable";
109 const std::string JSON_KEY_SUPPORT_EXT_NAMES = "supportExtNames";
110 const std::string JSON_KEY_SUPPORT_MIME_TYPES = "supportMimeTypes";
111 const std::string JSON_KEY_ISOLATION_PROCESS = "isolationProcess";
112 const std::string JSON_KEY_ORIENTATION_ID = "orientationId";
113 const std::string JSON_KEY_CONTINUE_BUNDLE_NAME = "continueBundleName";
114 const std::string JSON_KEY_CONTINUE_TYPE = "continueType";
115 const std::string JSON_KEY_APP_INDEX = "appIndex";
116 const std::string START_WINDOW_APP_ICON_ID = "startWindowAppIconId";
117 const std::string START_WINDOW_ILLUSTRATION_ID = "startWindowIllustrationId";
118 const std::string START_WINDOW_BRANDING_IMAGE_ID = "startWindowBrandingImageId";
119 const std::string START_WINDOW_BACKGROUND_COLOR_ID = "startWindowBackgroundColorId";
120 const std::string START_WINDOW_BACKGROUND_IMAGE_ID = "startWindowBackgroundImageId";
121 const std::string START_WINDOW_BACKGROUND_IMAGE_FIT = "startWindowBackgroundImageFit";
122 } // namespace
to_json(nlohmann::json & jsonObject,const CustomizeData & customizeData)123 void to_json(nlohmann::json &jsonObject, const CustomizeData &customizeData)
124 {
125 jsonObject = nlohmann::json {
126 {JSON_KEY_NAME, customizeData.name},
127 {JSON_KEY_META_VALUE, customizeData.value},
128 {JSON_KEY_META_EXTRA, customizeData.extra}
129 };
130 }
131
to_json(nlohmann::json & jsonObject,const MetaData & metaData)132 void to_json(nlohmann::json &jsonObject, const MetaData &metaData)
133 {
134 jsonObject = nlohmann::json {
135 {JSON_KEY_CUSTOMIZE_DATA, metaData.customizeData}
136 };
137 }
138
to_json(nlohmann::json & jsonObject,const Metadata & metadata)139 void to_json(nlohmann::json &jsonObject, const Metadata &metadata)
140 {
141 jsonObject = nlohmann::json {
142 {META_DATA_VALUEID, metadata.valueId},
143 {META_DATA_NAME, metadata.name},
144 {META_DATA_VALUE, metadata.value},
145 {META_DATA_RESOURCE, metadata.resource}
146 };
147 }
148
to_json(nlohmann::json & jsonObject,const StartWindowResource & startWindowResource)149 void to_json(nlohmann::json &jsonObject, const StartWindowResource &startWindowResource)
150 {
151 jsonObject = nlohmann::json {
152 {START_WINDOW_APP_ICON_ID, startWindowResource.startWindowAppIconId},
153 {START_WINDOW_ILLUSTRATION_ID, startWindowResource.startWindowIllustrationId},
154 {START_WINDOW_BRANDING_IMAGE_ID, startWindowResource.startWindowBrandingImageId},
155 {START_WINDOW_BACKGROUND_COLOR_ID, startWindowResource.startWindowBackgroundColorId},
156 {START_WINDOW_BACKGROUND_IMAGE_ID, startWindowResource.startWindowBackgroundImageId},
157 {START_WINDOW_BACKGROUND_IMAGE_FIT, startWindowResource.startWindowBackgroundImageFit}
158 };
159 }
160
to_json(nlohmann::json & jsonObject,const AbilityInfo & abilityInfo)161 void to_json(nlohmann::json &jsonObject, const AbilityInfo &abilityInfo)
162 {
163 TAG_LOGD(AAFwkTag::ABILITY_SIM, "called");
164 jsonObject = nlohmann::json {
165 {JSON_KEY_NAME, abilityInfo.name},
166 {JSON_KEY_LABEL, abilityInfo.label},
167 {JSON_KEY_DESCRIPTION, abilityInfo.description},
168 {JSON_KEY_ICON_PATH, abilityInfo.iconPath},
169 {JSON_KEY_LABEL_ID, abilityInfo.labelId},
170 {JSON_KEY_DESCRIPTION_ID, abilityInfo.descriptionId},
171 {JSON_KEY_ICON_ID, abilityInfo.iconId},
172 {JSON_KEY_THEME, abilityInfo.theme},
173 {JSON_KEY_VISIBLE, abilityInfo.visible},
174 {JSON_KEY_KIND, abilityInfo.kind},
175 {JSON_KEY_TYPE, abilityInfo.type},
176 {JSON_KEY_EXTENSION_ABILITY_TYPE, abilityInfo.extensionAbilityType},
177 {JSON_KEY_ORIENTATION, abilityInfo.orientation},
178 {JSON_KEY_LAUNCH_MODE, abilityInfo.launchMode},
179 {JSON_KEY_SRC_PATH, abilityInfo.srcPath},
180 {JSON_KEY_SRC_LANGUAGE, abilityInfo.srcLanguage},
181 {JSON_KEY_PERMISSIONS, abilityInfo.permissions},
182 {JSON_KEY_PROCESS, abilityInfo.process},
183 {JSON_KEY_DEVICE_TYPES, abilityInfo.deviceTypes},
184 {JSON_KEY_DEVICE_CAPABILITIES, abilityInfo.deviceCapabilities},
185 {JSON_KEY_URI, abilityInfo.uri},
186 {JSON_KEY_TARGET_ABILITY, abilityInfo.targetAbility},
187 {JSON_KEY_IS_LAUNCHER_ABILITY, abilityInfo.isLauncherAbility},
188 {JSON_KEY_IS_NATIVE_ABILITY, abilityInfo.isNativeAbility},
189 {JSON_KEY_ENABLED, abilityInfo.enabled},
190 {JSON_KEY_SUPPORT_PIP_MODE, abilityInfo.supportPipMode},
191 {JSON_KEY_FORM_ENABLED, abilityInfo.formEnabled},
192 {JSON_KEY_READ_PERMISSION, abilityInfo.readPermission},
193 {JSON_KEY_WRITE_PERMISSION, abilityInfo.writePermission},
194 {JSON_KEY_CONFIG_CHANGES, abilityInfo.configChanges},
195 {JSON_KEY_FORM_ENTITY, abilityInfo.formEntity},
196 {JSON_KEY_MIN_FORM_HEIGHT, abilityInfo.minFormHeight},
197 {JSON_KEY_DEFAULT_FORM_HEIGHT, abilityInfo.defaultFormHeight},
198 {JSON_KEY_MIN_FORM_WIDTH, abilityInfo.minFormWidth},
199 {JSON_KEY_DEFAULT_FORM_WIDTH, abilityInfo.defaultFormWidth},
200 {JSON_KEY_META_DATA, abilityInfo.metaData},
201 {JSON_KEY_BACKGROUND_MODES, abilityInfo.backgroundModes},
202 {JSON_KEY_PACKAGE, abilityInfo.package},
203 {Constants::BUNDLE_NAME, abilityInfo.bundleName},
204 {Constants::MODULE_NAME, abilityInfo.moduleName},
205 {JSON_KEY_APPLICATION_NAME, abilityInfo.applicationName},
206 {JSON_KEY_CODE_PATH, abilityInfo.codePath},
207 {JSON_KEY_RESOURCE_PATH, abilityInfo.resourcePath},
208 {Constants::HAP_PATH, abilityInfo.hapPath},
209 {SRC_ENTRANCE, abilityInfo.srcEntrance},
210 {META_DATA, abilityInfo.metadata},
211 {IS_MODULE_JSON, abilityInfo.isModuleJson},
212 {IS_STAGE_BASED_MODEL, abilityInfo.isStageBasedModel},
213 {CONTINUABLE, abilityInfo.continuable},
214 {PRIORITY, abilityInfo.priority},
215 {JSON_KEY_START_WINDOW, abilityInfo.startWindow},
216 {JSON_KEY_START_WINDOW_ICON, abilityInfo.startWindowIcon},
217 {JSON_KEY_START_WINDOW_ICON_ID, abilityInfo.startWindowIconId},
218 {JSON_KEY_START_WINDOW_BACKGROUND, abilityInfo.startWindowBackground},
219 {JSON_KEY_START_WINDOW_BACKGROUND_ID, abilityInfo.startWindowBackgroundId},
220 {JSON_KEY_REMOVE_MISSION_AFTER_TERMINATE, abilityInfo.removeMissionAfterTerminate},
221 {JSON_KEY_COMPILE_MODE, abilityInfo.compileMode},
222 {JOSN_KEY_SUPPORT_WINDOW_MODE, abilityInfo.windowModes},
223 {JOSN_KEY_MAX_WINDOW_WIDTH, abilityInfo.maxWindowWidth},
224 {JOSN_KEY_MIN_WINDOW_WIDTH, abilityInfo.minWindowWidth},
225 {JOSN_KEY_MAX_WINDOW_HEIGHT, abilityInfo.maxWindowHeight},
226 {JOSN_KEY_MIN_WINDOW_HEIGHT, abilityInfo.minWindowHeight},
227 {JOSN_KEY_UID, abilityInfo.uid},
228 {JOSN_KEY_EXCLUDE_FROM_MISSIONS, abilityInfo.excludeFromMissions},
229 {JOSN_KEY_UNCLEARABLE_MISSION, abilityInfo.unclearableMission},
230 {JSON_KEY_RECOVERABLE, abilityInfo.recoverable},
231 {JSON_KEY_SUPPORT_EXT_NAMES, abilityInfo.supportExtNames},
232 {JSON_KEY_SUPPORT_MIME_TYPES, abilityInfo.supportMimeTypes},
233 {JSON_KEY_ISOLATION_PROCESS, abilityInfo.isolationProcess},
234 {JSON_KEY_CONTINUE_TYPE, abilityInfo.continueType},
235 {JSON_KEY_CONTINUE_BUNDLE_NAME, abilityInfo.continueBundleNames},
236 {JSON_KEY_APP_INDEX, abilityInfo.appIndex},
237 {JSON_KEY_ORIENTATION_ID, abilityInfo.orientationId},
238 {JSON_KEY_START_WINDOW_RESOURCE, abilityInfo.startWindowResource}
239 };
240 if (abilityInfo.maxWindowRatio == 0) {
241 // maxWindowRatio in json string will be 0 instead of 0.0
242 jsonObject[JOSN_KEY_MAX_WINDOW_RATIO] = 0;
243 } else {
244 jsonObject[JOSN_KEY_MAX_WINDOW_RATIO] = abilityInfo.maxWindowRatio;
245 }
246
247 if (abilityInfo.minWindowRatio == 0) {
248 jsonObject[JOSN_KEY_MIN_WINDOW_RATIO] = 0;
249 } else {
250 jsonObject[JOSN_KEY_MIN_WINDOW_RATIO] = abilityInfo.minWindowRatio;
251 }
252 }
253
from_json(const nlohmann::json & jsonObject,CustomizeData & customizeData)254 void from_json(const nlohmann::json &jsonObject, CustomizeData &customizeData)
255 {
256 const auto &jsonObjectEnd = jsonObject.end();
257 int32_t parseResult = ERR_OK;
258 GetValueIfFindKey<std::string>(jsonObject,
259 jsonObjectEnd,
260 JSON_KEY_NAME,
261 customizeData.name,
262 JsonType::STRING,
263 false,
264 parseResult,
265 ArrayType::NOT_ARRAY);
266 GetValueIfFindKey<std::string>(jsonObject,
267 jsonObjectEnd,
268 JSON_KEY_META_VALUE,
269 customizeData.value,
270 JsonType::STRING,
271 false,
272 parseResult,
273 ArrayType::NOT_ARRAY);
274 GetValueIfFindKey<std::string>(jsonObject,
275 jsonObjectEnd,
276 JSON_KEY_META_EXTRA,
277 customizeData.extra,
278 JsonType::STRING,
279 false,
280 parseResult,
281 ArrayType::NOT_ARRAY);
282 }
283
from_json(const nlohmann::json & jsonObject,MetaData & metaData)284 void from_json(const nlohmann::json &jsonObject, MetaData &metaData)
285 {
286 const auto &jsonObjectEnd = jsonObject.end();
287 int32_t parseResult = ERR_OK;
288 GetValueIfFindKey<std::vector<CustomizeData>>(jsonObject,
289 jsonObjectEnd,
290 JSON_KEY_CUSTOMIZE_DATA,
291 metaData.customizeData,
292 JsonType::ARRAY,
293 false,
294 parseResult,
295 ArrayType::OBJECT);
296 }
297
from_json(const nlohmann::json & jsonObject,Metadata & metadata)298 void from_json(const nlohmann::json &jsonObject, Metadata &metadata)
299 {
300 const auto &jsonObjectEnd = jsonObject.end();
301 int32_t parseResult = ERR_OK;
302 GetValueIfFindKey<uint32_t>(jsonObject,
303 jsonObjectEnd,
304 META_DATA_VALUEID,
305 metadata.valueId,
306 JsonType::NUMBER,
307 false,
308 parseResult,
309 ArrayType::NOT_ARRAY);
310 GetValueIfFindKey<std::string>(jsonObject,
311 jsonObjectEnd,
312 META_DATA_NAME,
313 metadata.name,
314 JsonType::STRING,
315 false,
316 parseResult,
317 ArrayType::NOT_ARRAY);
318 GetValueIfFindKey<std::string>(jsonObject,
319 jsonObjectEnd,
320 META_DATA_VALUE,
321 metadata.value,
322 JsonType::STRING,
323 false,
324 parseResult,
325 ArrayType::NOT_ARRAY);
326 GetValueIfFindKey<std::string>(jsonObject,
327 jsonObjectEnd,
328 META_DATA_RESOURCE,
329 metadata.resource,
330 JsonType::STRING,
331 false,
332 parseResult,
333 ArrayType::NOT_ARRAY);
334 if (parseResult != ERR_OK) {
335 TAG_LOGD(
336 AAFwkTag::ABILITY_SIM, "read Ability Metadata error:%{public}d", parseResult);
337 }
338 }
339
from_json(const nlohmann::json & jsonObject,StartWindowResource & startWindowResource)340 void from_json(const nlohmann::json &jsonObject, StartWindowResource &startWindowResource)
341 {
342 const auto &jsonObjectEnd = jsonObject.end();
343 int32_t parseResult = ERR_OK;
344 GetValueIfFindKey<uint32_t>(jsonObject,
345 jsonObjectEnd,
346 START_WINDOW_APP_ICON_ID,
347 startWindowResource.startWindowAppIconId,
348 JsonType::NUMBER,
349 false,
350 parseResult,
351 ArrayType::NOT_ARRAY);
352 GetValueIfFindKey<uint32_t>(jsonObject,
353 jsonObjectEnd,
354 START_WINDOW_ILLUSTRATION_ID,
355 startWindowResource.startWindowIllustrationId,
356 JsonType::NUMBER,
357 false,
358 parseResult,
359 ArrayType::NOT_ARRAY);
360 GetValueIfFindKey<uint32_t>(jsonObject,
361 jsonObjectEnd,
362 START_WINDOW_BRANDING_IMAGE_ID,
363 startWindowResource.startWindowBrandingImageId,
364 JsonType::NUMBER,
365 false,
366 parseResult,
367 ArrayType::NOT_ARRAY);
368 GetValueIfFindKey<uint32_t>(jsonObject,
369 jsonObjectEnd,
370 START_WINDOW_BACKGROUND_COLOR_ID,
371 startWindowResource.startWindowBackgroundColorId,
372 JsonType::NUMBER,
373 false,
374 parseResult,
375 ArrayType::NOT_ARRAY);
376 GetValueIfFindKey<uint32_t>(jsonObject,
377 jsonObjectEnd,
378 START_WINDOW_BACKGROUND_IMAGE_ID,
379 startWindowResource.startWindowBackgroundImageId,
380 JsonType::NUMBER,
381 false,
382 parseResult,
383 ArrayType::NOT_ARRAY);
384 GetValueIfFindKey<std::string>(jsonObject,
385 jsonObjectEnd,
386 START_WINDOW_BACKGROUND_IMAGE_FIT,
387 startWindowResource.startWindowBackgroundImageFit,
388 JsonType::STRING,
389 false,
390 parseResult,
391 ArrayType::NOT_ARRAY);
392 if (parseResult != ERR_OK) {
393 TAG_LOGD(AAFwkTag::ABILITY_SIM, "read Resource error:%{public}d", parseResult);
394 }
395 }
396
from_json(const nlohmann::json & jsonObject,AbilityInfo & abilityInfo)397 void from_json(const nlohmann::json &jsonObject, AbilityInfo &abilityInfo)
398 {
399 TAG_LOGD(AAFwkTag::ABILITY_SIM, "called");
400 const auto &jsonObjectEnd = jsonObject.end();
401 int32_t parseResult = ERR_OK;
402 GetValueIfFindKey<std::string>(jsonObject,
403 jsonObjectEnd,
404 JSON_KEY_NAME,
405 abilityInfo.name,
406 JsonType::STRING,
407 false,
408 parseResult,
409 ArrayType::NOT_ARRAY);
410 GetValueIfFindKey<std::string>(jsonObject,
411 jsonObjectEnd,
412 JSON_KEY_LABEL,
413 abilityInfo.label,
414 JsonType::STRING,
415 false,
416 parseResult,
417 ArrayType::NOT_ARRAY);
418 GetValueIfFindKey<std::string>(jsonObject,
419 jsonObjectEnd,
420 JSON_KEY_DESCRIPTION,
421 abilityInfo.description,
422 JsonType::STRING,
423 false,
424 parseResult,
425 ArrayType::NOT_ARRAY);
426 GetValueIfFindKey<std::string>(jsonObject,
427 jsonObjectEnd,
428 JSON_KEY_ICON_PATH,
429 abilityInfo.iconPath,
430 JsonType::STRING,
431 false,
432 parseResult,
433 ArrayType::NOT_ARRAY);
434 GetValueIfFindKey<int32_t>(jsonObject,
435 jsonObjectEnd,
436 JSON_KEY_LABEL_ID,
437 abilityInfo.labelId,
438 JsonType::NUMBER,
439 false,
440 parseResult,
441 ArrayType::NOT_ARRAY);
442 GetValueIfFindKey<int32_t>(jsonObject,
443 jsonObjectEnd,
444 JSON_KEY_DESCRIPTION_ID,
445 abilityInfo.descriptionId,
446 JsonType::NUMBER,
447 false,
448 parseResult,
449 ArrayType::NOT_ARRAY);
450 GetValueIfFindKey<int32_t>(jsonObject,
451 jsonObjectEnd,
452 JSON_KEY_ICON_ID,
453 abilityInfo.iconId,
454 JsonType::NUMBER,
455 false,
456 parseResult,
457 ArrayType::NOT_ARRAY);
458 GetValueIfFindKey<std::string>(jsonObject,
459 jsonObjectEnd,
460 JSON_KEY_THEME,
461 abilityInfo.theme,
462 JsonType::STRING,
463 false,
464 parseResult,
465 ArrayType::NOT_ARRAY);
466 GetValueIfFindKey<bool>(jsonObject,
467 jsonObjectEnd,
468 JSON_KEY_VISIBLE,
469 abilityInfo.visible,
470 JsonType::BOOLEAN,
471 false,
472 parseResult,
473 ArrayType::NOT_ARRAY);
474 GetValueIfFindKey<std::string>(jsonObject,
475 jsonObjectEnd,
476 JSON_KEY_KIND,
477 abilityInfo.kind,
478 JsonType::STRING,
479 false,
480 parseResult,
481 ArrayType::NOT_ARRAY);
482 GetValueIfFindKey<AbilityType>(jsonObject,
483 jsonObjectEnd,
484 JSON_KEY_TYPE,
485 abilityInfo.type,
486 JsonType::NUMBER,
487 false,
488 parseResult,
489 ArrayType::NOT_ARRAY);
490 GetValueIfFindKey<ExtensionAbilityType>(jsonObject,
491 jsonObjectEnd,
492 JSON_KEY_EXTENSION_ABILITY_TYPE,
493 abilityInfo.extensionAbilityType,
494 JsonType::NUMBER,
495 false,
496 parseResult,
497 ArrayType::NOT_ARRAY);
498 GetValueIfFindKey<DisplayOrientation>(jsonObject,
499 jsonObjectEnd,
500 JSON_KEY_ORIENTATION,
501 abilityInfo.orientation,
502 JsonType::NUMBER,
503 false,
504 parseResult,
505 ArrayType::NOT_ARRAY);
506 GetValueIfFindKey<LaunchMode>(jsonObject,
507 jsonObjectEnd,
508 JSON_KEY_LAUNCH_MODE,
509 abilityInfo.launchMode,
510 JsonType::NUMBER,
511 false,
512 parseResult,
513 ArrayType::NOT_ARRAY);
514 GetValueIfFindKey<std::string>(jsonObject,
515 jsonObjectEnd,
516 JSON_KEY_SRC_PATH,
517 abilityInfo.srcPath,
518 JsonType::STRING,
519 false,
520 parseResult,
521 ArrayType::NOT_ARRAY);
522 GetValueIfFindKey<std::string>(jsonObject,
523 jsonObjectEnd,
524 JSON_KEY_SRC_LANGUAGE,
525 abilityInfo.srcLanguage,
526 JsonType::STRING,
527 false,
528 parseResult,
529 ArrayType::NOT_ARRAY);
530 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
531 jsonObjectEnd,
532 JSON_KEY_PERMISSIONS,
533 abilityInfo.permissions,
534 JsonType::ARRAY,
535 false,
536 parseResult,
537 ArrayType::STRING);
538 GetValueIfFindKey<std::string>(jsonObject,
539 jsonObjectEnd,
540 JSON_KEY_PROCESS,
541 abilityInfo.process,
542 JsonType::STRING,
543 false,
544 parseResult,
545 ArrayType::NOT_ARRAY);
546 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
547 jsonObjectEnd,
548 JSON_KEY_DEVICE_TYPES,
549 abilityInfo.deviceTypes,
550 JsonType::ARRAY,
551 false,
552 parseResult,
553 ArrayType::STRING);
554 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
555 jsonObjectEnd,
556 JSON_KEY_DEVICE_CAPABILITIES,
557 abilityInfo.deviceCapabilities,
558 JsonType::ARRAY,
559 false,
560 parseResult,
561 ArrayType::STRING);
562 GetValueIfFindKey<std::string>(jsonObject,
563 jsonObjectEnd,
564 JSON_KEY_URI,
565 abilityInfo.uri,
566 JsonType::STRING,
567 false,
568 parseResult,
569 ArrayType::NOT_ARRAY);
570 GetValueIfFindKey<std::string>(jsonObject,
571 jsonObjectEnd,
572 JSON_KEY_TARGET_ABILITY,
573 abilityInfo.targetAbility,
574 JsonType::STRING,
575 false,
576 parseResult,
577 ArrayType::NOT_ARRAY);
578 GetValueIfFindKey<bool>(jsonObject,
579 jsonObjectEnd,
580 JSON_KEY_IS_LAUNCHER_ABILITY,
581 abilityInfo.isLauncherAbility,
582 JsonType::BOOLEAN,
583 false,
584 parseResult,
585 ArrayType::NOT_ARRAY);
586 GetValueIfFindKey<bool>(jsonObject,
587 jsonObjectEnd,
588 JSON_KEY_IS_NATIVE_ABILITY,
589 abilityInfo.isNativeAbility,
590 JsonType::BOOLEAN,
591 false,
592 parseResult,
593 ArrayType::NOT_ARRAY);
594 GetValueIfFindKey<bool>(jsonObject,
595 jsonObjectEnd,
596 JSON_KEY_ENABLED,
597 abilityInfo.enabled,
598 JsonType::BOOLEAN,
599 false,
600 parseResult,
601 ArrayType::NOT_ARRAY);
602 GetValueIfFindKey<bool>(jsonObject,
603 jsonObjectEnd,
604 JSON_KEY_SUPPORT_PIP_MODE,
605 abilityInfo.supportPipMode,
606 JsonType::BOOLEAN,
607 false,
608 parseResult,
609 ArrayType::NOT_ARRAY);
610 GetValueIfFindKey<bool>(jsonObject,
611 jsonObjectEnd,
612 JSON_KEY_FORM_ENABLED,
613 abilityInfo.formEnabled,
614 JsonType::BOOLEAN,
615 false,
616 parseResult,
617 ArrayType::NOT_ARRAY);
618 GetValueIfFindKey<std::string>(jsonObject,
619 jsonObjectEnd,
620 JSON_KEY_READ_PERMISSION,
621 abilityInfo.readPermission,
622 JsonType::STRING,
623 false,
624 parseResult,
625 ArrayType::NOT_ARRAY);
626 GetValueIfFindKey<std::string>(jsonObject,
627 jsonObjectEnd,
628 JSON_KEY_WRITE_PERMISSION,
629 abilityInfo.writePermission,
630 JsonType::STRING,
631 false,
632 parseResult,
633 ArrayType::NOT_ARRAY);
634 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
635 jsonObjectEnd,
636 JSON_KEY_CONFIG_CHANGES,
637 abilityInfo.configChanges,
638 JsonType::ARRAY,
639 false,
640 parseResult,
641 ArrayType::STRING);
642 GetValueIfFindKey<uint32_t>(jsonObject,
643 jsonObjectEnd,
644 JSON_KEY_FORM_ENTITY,
645 abilityInfo.formEntity,
646 JsonType::NUMBER,
647 false,
648 parseResult,
649 ArrayType::NOT_ARRAY);
650 GetValueIfFindKey<int32_t>(jsonObject,
651 jsonObjectEnd,
652 JSON_KEY_MIN_FORM_HEIGHT,
653 abilityInfo.minFormHeight,
654 JsonType::NUMBER,
655 false,
656 parseResult,
657 ArrayType::NOT_ARRAY);
658 GetValueIfFindKey<int32_t>(jsonObject,
659 jsonObjectEnd,
660 JSON_KEY_DEFAULT_FORM_HEIGHT,
661 abilityInfo.defaultFormHeight,
662 JsonType::NUMBER,
663 false,
664 parseResult,
665 ArrayType::NOT_ARRAY);
666 GetValueIfFindKey<int32_t>(jsonObject,
667 jsonObjectEnd,
668 JSON_KEY_MIN_FORM_WIDTH,
669 abilityInfo.minFormWidth,
670 JsonType::NUMBER,
671 false,
672 parseResult,
673 ArrayType::NOT_ARRAY);
674 GetValueIfFindKey<int32_t>(jsonObject,
675 jsonObjectEnd,
676 JSON_KEY_DEFAULT_FORM_WIDTH,
677 abilityInfo.defaultFormWidth,
678 JsonType::NUMBER,
679 false,
680 parseResult,
681 ArrayType::NOT_ARRAY);
682 GetValueIfFindKey<MetaData>(jsonObject,
683 jsonObjectEnd,
684 JSON_KEY_META_DATA,
685 abilityInfo.metaData,
686 JsonType::OBJECT,
687 false,
688 parseResult,
689 ArrayType::NOT_ARRAY);
690 GetValueIfFindKey<uint32_t>(jsonObject,
691 jsonObjectEnd,
692 JSON_KEY_BACKGROUND_MODES,
693 abilityInfo.backgroundModes,
694 JsonType::NUMBER,
695 false,
696 parseResult,
697 ArrayType::NOT_ARRAY);
698 GetValueIfFindKey<std::string>(jsonObject,
699 jsonObjectEnd,
700 JSON_KEY_PACKAGE,
701 abilityInfo.package,
702 JsonType::STRING,
703 false,
704 parseResult,
705 ArrayType::NOT_ARRAY);
706 GetValueIfFindKey<std::string>(jsonObject,
707 jsonObjectEnd,
708 Constants::BUNDLE_NAME,
709 abilityInfo.bundleName,
710 JsonType::STRING,
711 false,
712 parseResult,
713 ArrayType::NOT_ARRAY);
714 GetValueIfFindKey<std::string>(jsonObject,
715 jsonObjectEnd,
716 Constants::MODULE_NAME,
717 abilityInfo.moduleName,
718 JsonType::STRING,
719 false,
720 parseResult,
721 ArrayType::NOT_ARRAY);
722 GetValueIfFindKey<std::string>(jsonObject,
723 jsonObjectEnd,
724 JSON_KEY_APPLICATION_NAME,
725 abilityInfo.applicationName,
726 JsonType::STRING,
727 false,
728 parseResult,
729 ArrayType::NOT_ARRAY);
730 GetValueIfFindKey<std::string>(jsonObject,
731 jsonObjectEnd,
732 JSON_KEY_CODE_PATH,
733 abilityInfo.codePath,
734 JsonType::STRING,
735 false,
736 parseResult,
737 ArrayType::NOT_ARRAY);
738 GetValueIfFindKey<std::string>(jsonObject,
739 jsonObjectEnd,
740 JSON_KEY_RESOURCE_PATH,
741 abilityInfo.resourcePath,
742 JsonType::STRING,
743 false,
744 parseResult,
745 ArrayType::NOT_ARRAY);
746 GetValueIfFindKey<std::string>(jsonObject,
747 jsonObjectEnd,
748 Constants::HAP_PATH,
749 abilityInfo.hapPath,
750 JsonType::STRING,
751 false,
752 parseResult,
753 ArrayType::NOT_ARRAY);
754 GetValueIfFindKey<std::string>(jsonObject,
755 jsonObjectEnd,
756 SRC_ENTRANCE,
757 abilityInfo.srcEntrance,
758 JsonType::STRING,
759 false,
760 parseResult,
761 ArrayType::NOT_ARRAY);
762 GetValueIfFindKey<std::vector<Metadata>>(jsonObject,
763 jsonObjectEnd,
764 META_DATA,
765 abilityInfo.metadata,
766 JsonType::ARRAY,
767 false,
768 parseResult,
769 ArrayType::OBJECT);
770 GetValueIfFindKey<bool>(jsonObject,
771 jsonObjectEnd,
772 IS_MODULE_JSON,
773 abilityInfo.isModuleJson,
774 JsonType::BOOLEAN,
775 false,
776 parseResult,
777 ArrayType::NOT_ARRAY);
778 GetValueIfFindKey<bool>(jsonObject,
779 jsonObjectEnd,
780 IS_STAGE_BASED_MODEL,
781 abilityInfo.isStageBasedModel,
782 JsonType::BOOLEAN,
783 false,
784 parseResult,
785 ArrayType::NOT_ARRAY);
786 GetValueIfFindKey<bool>(jsonObject,
787 jsonObjectEnd,
788 CONTINUABLE,
789 abilityInfo.continuable,
790 JsonType::BOOLEAN,
791 false,
792 parseResult,
793 ArrayType::NOT_ARRAY);
794 GetValueIfFindKey<int32_t>(jsonObject,
795 jsonObjectEnd,
796 PRIORITY,
797 abilityInfo.priority,
798 JsonType::NUMBER,
799 false,
800 parseResult,
801 ArrayType::NOT_ARRAY);
802 GetValueIfFindKey<std::string>(jsonObject,
803 jsonObjectEnd,
804 JSON_KEY_START_WINDOW_ICON,
805 abilityInfo.startWindowIcon,
806 JsonType::STRING,
807 false,
808 parseResult,
809 ArrayType::NOT_ARRAY);
810 GetValueIfFindKey<int32_t>(jsonObject,
811 jsonObjectEnd,
812 JSON_KEY_START_WINDOW_ICON_ID,
813 abilityInfo.startWindowIconId,
814 JsonType::NUMBER,
815 false,
816 parseResult,
817 ArrayType::NOT_ARRAY);
818 GetValueIfFindKey<std::string>(jsonObject,
819 jsonObjectEnd,
820 JSON_KEY_START_WINDOW_BACKGROUND,
821 abilityInfo.startWindowBackground,
822 JsonType::STRING,
823 false,
824 parseResult,
825 ArrayType::NOT_ARRAY);
826 GetValueIfFindKey<int32_t>(jsonObject,
827 jsonObjectEnd,
828 JSON_KEY_START_WINDOW_BACKGROUND_ID,
829 abilityInfo.startWindowBackgroundId,
830 JsonType::NUMBER,
831 false,
832 parseResult,
833 ArrayType::NOT_ARRAY);
834 GetValueIfFindKey<bool>(jsonObject,
835 jsonObjectEnd,
836 JSON_KEY_REMOVE_MISSION_AFTER_TERMINATE,
837 abilityInfo.removeMissionAfterTerminate,
838 JsonType::BOOLEAN,
839 false,
840 parseResult,
841 ArrayType::NOT_ARRAY);
842 GetValueIfFindKey<CompileMode>(jsonObject,
843 jsonObjectEnd,
844 JSON_KEY_COMPILE_MODE,
845 abilityInfo.compileMode,
846 JsonType::NUMBER,
847 false,
848 parseResult,
849 ArrayType::NOT_ARRAY);
850 GetValueIfFindKey<std::vector<SupportWindowMode>>(jsonObject,
851 jsonObjectEnd,
852 JOSN_KEY_SUPPORT_WINDOW_MODE,
853 abilityInfo.windowModes,
854 JsonType::ARRAY,
855 false,
856 parseResult,
857 ArrayType::NUMBER);
858 GetValueIfFindKey<double>(jsonObject,
859 jsonObjectEnd,
860 JOSN_KEY_MAX_WINDOW_RATIO,
861 abilityInfo.maxWindowRatio,
862 JsonType::NUMBER,
863 false,
864 parseResult,
865 ArrayType::NOT_ARRAY);
866 GetValueIfFindKey<double>(jsonObject,
867 jsonObjectEnd,
868 JOSN_KEY_MIN_WINDOW_RATIO,
869 abilityInfo.minWindowRatio,
870 JsonType::NUMBER,
871 false,
872 parseResult,
873 ArrayType::NOT_ARRAY);
874 GetValueIfFindKey<uint32_t>(jsonObject,
875 jsonObjectEnd,
876 JOSN_KEY_MAX_WINDOW_WIDTH,
877 abilityInfo.maxWindowWidth,
878 JsonType::NUMBER,
879 false,
880 parseResult,
881 ArrayType::NOT_ARRAY);
882 GetValueIfFindKey<uint32_t>(jsonObject,
883 jsonObjectEnd,
884 JOSN_KEY_MIN_WINDOW_WIDTH,
885 abilityInfo.minWindowWidth,
886 JsonType::NUMBER,
887 false,
888 parseResult,
889 ArrayType::NOT_ARRAY);
890 GetValueIfFindKey<uint32_t>(jsonObject,
891 jsonObjectEnd,
892 JOSN_KEY_MAX_WINDOW_HEIGHT,
893 abilityInfo.maxWindowHeight,
894 JsonType::NUMBER,
895 false,
896 parseResult,
897 ArrayType::NOT_ARRAY);
898 GetValueIfFindKey<uint32_t>(jsonObject,
899 jsonObjectEnd,
900 JOSN_KEY_MIN_WINDOW_HEIGHT,
901 abilityInfo.minWindowHeight,
902 JsonType::NUMBER,
903 false,
904 parseResult,
905 ArrayType::NOT_ARRAY);
906 GetValueIfFindKey<int32_t>(jsonObject,
907 jsonObjectEnd,
908 JOSN_KEY_UID,
909 abilityInfo.uid,
910 JsonType::NUMBER,
911 false,
912 parseResult,
913 ArrayType::NOT_ARRAY);
914 GetValueIfFindKey<bool>(jsonObject,
915 jsonObjectEnd,
916 JOSN_KEY_EXCLUDE_FROM_MISSIONS,
917 abilityInfo.excludeFromMissions,
918 JsonType::BOOLEAN,
919 false,
920 parseResult,
921 ArrayType::NOT_ARRAY);
922 GetValueIfFindKey<bool>(jsonObject,
923 jsonObjectEnd,
924 JOSN_KEY_UNCLEARABLE_MISSION,
925 abilityInfo.unclearableMission,
926 JsonType::BOOLEAN,
927 false,
928 parseResult,
929 ArrayType::NOT_ARRAY);
930 GetValueIfFindKey<bool>(jsonObject,
931 jsonObjectEnd,
932 JSON_KEY_RECOVERABLE,
933 abilityInfo.recoverable,
934 JsonType::BOOLEAN,
935 false,
936 parseResult,
937 ArrayType::NOT_ARRAY);
938 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
939 jsonObjectEnd,
940 JSON_KEY_SUPPORT_EXT_NAMES,
941 abilityInfo.supportExtNames,
942 JsonType::ARRAY,
943 false,
944 parseResult,
945 ArrayType::STRING);
946 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
947 jsonObjectEnd,
948 JSON_KEY_SUPPORT_MIME_TYPES,
949 abilityInfo.supportMimeTypes,
950 JsonType::ARRAY,
951 false,
952 parseResult,
953 ArrayType::STRING);
954 GetValueIfFindKey<bool>(jsonObject,
955 jsonObjectEnd,
956 JSON_KEY_ISOLATION_PROCESS,
957 abilityInfo.isolationProcess,
958 JsonType::BOOLEAN,
959 false,
960 parseResult,
961 ArrayType::NOT_ARRAY);
962 GetValueIfFindKey<std::vector<std::string>>(jsonObject,
963 jsonObjectEnd,
964 JSON_KEY_CONTINUE_TYPE,
965 abilityInfo.continueType,
966 JsonType::ARRAY,
967 false,
968 parseResult,
969 ArrayType::STRING);
970 GetValueIfFindKey<std::unordered_set<std::string>>(jsonObject,
971 jsonObjectEnd,
972 JSON_KEY_CONTINUE_BUNDLE_NAME,
973 abilityInfo.continueBundleNames,
974 JsonType::ARRAY,
975 false,
976 parseResult,
977 ArrayType::STRING);
978 GetValueIfFindKey<int32_t>(jsonObject,
979 jsonObjectEnd,
980 JSON_KEY_APP_INDEX,
981 abilityInfo.appIndex,
982 JsonType::NUMBER,
983 false,
984 parseResult,
985 ArrayType::NOT_ARRAY);
986 GetValueIfFindKey<uint32_t>(jsonObject,
987 jsonObjectEnd,
988 JSON_KEY_ORIENTATION_ID,
989 abilityInfo.orientationId,
990 JsonType::NUMBER,
991 false,
992 parseResult,
993 ArrayType::NOT_ARRAY);
994 GetValueIfFindKey<std::string>(jsonObject,
995 jsonObjectEnd,
996 JSON_KEY_START_WINDOW,
997 abilityInfo.startWindow,
998 JsonType::STRING,
999 false,
1000 parseResult,
1001 ArrayType::NOT_ARRAY);
1002 GetValueIfFindKey<uint32_t>(jsonObject,
1003 jsonObjectEnd,
1004 JSON_KEY_START_WINDOW_ID,
1005 abilityInfo.startWindowId,
1006 JsonType::NUMBER,
1007 false,
1008 parseResult,
1009 ArrayType::NOT_ARRAY);
1010 GetValueIfFindKey<StartWindowResource>(jsonObject,
1011 jsonObjectEnd,
1012 JSON_KEY_START_WINDOW_RESOURCE,
1013 abilityInfo.startWindowResource,
1014 JsonType::OBJECT,
1015 false,
1016 parseResult,
1017 ArrayType::NOT_ARRAY);
1018 if (parseResult != ERR_OK) {
1019 TAG_LOGE(AAFwkTag::ABILITY_SIM, "AbilityInfo from_json error:%{public}d", parseResult);
1020 }
1021 }
1022 } // namespace AppExecFwk
1023 } // namespace OHOS
1024