1 /*
2 * Copyright (c) 2023 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 "adapter/preview/external/ability/stage/stage_app_info.h"
17
18 namespace OHOS::Ace {
Parse(const std::unique_ptr<JsonValue> & root)19 void StageAppInfo::Parse(const std::unique_ptr<JsonValue>& root)
20 {
21 if (!root) {
22 LOGW("The information of stage model application is empty.");
23 return;
24 }
25 apiReleaseType_ = root->GetString("apiReleaseType");
26 bundleName_ = root->GetString("bundleName");
27 bundleType_ = root->GetString("bundleType");
28 icon_ = root->GetString("icon");
29 label_ = root->GetString("label");
30 vendor_ = root->GetString("vendor");
31 versionName_ = root->GetString("versionName");
32 debug_ = root->GetBool("debug", false);
33 distributedNotificationEnabled_ = root->GetBool("distributedNotificationEnabled", true);
34 iconId_ = root->GetUInt("iconId", 0);
35 labelId_ = root->GetUInt("labelId", 0);
36 minAPIVersion_ = root->GetUInt("minAPIVersion", 0);
37 targetAPIVersion_ = root->GetUInt("targetAPIVersion", 0);
38 versionCode_ = root->GetUInt("versionCode", 0);
39 }
40
GetApiReleaseType() const41 const std::string& StageAppInfo::GetApiReleaseType() const
42 {
43 return apiReleaseType_;
44 }
45
GetBundleName() const46 const std::string& StageAppInfo::GetBundleName() const
47 {
48 return bundleName_;
49 }
50
GetIcon() const51 const std::string& StageAppInfo::GetIcon() const
52 {
53 return icon_;
54 }
55
GetLabel() const56 const std::string& StageAppInfo::GetLabel() const
57 {
58 return label_;
59 }
60
GetVendor() const61 const std::string& StageAppInfo::GetVendor() const
62 {
63 return vendor_;
64 }
65
GetVersionName() const66 const std::string& StageAppInfo::GetVersionName() const
67 {
68 return versionName_;
69 }
70
GetDebug() const71 bool StageAppInfo::GetDebug() const
72 {
73 return debug_;
74 }
75
GetDistributedNotificationEnabled() const76 bool StageAppInfo::GetDistributedNotificationEnabled() const
77 {
78 return distributedNotificationEnabled_;
79 }
80
GetIconId() const81 uint32_t StageAppInfo::GetIconId() const
82 {
83 return iconId_;
84 }
85
GetLabelId() const86 uint32_t StageAppInfo::GetLabelId() const
87 {
88 return labelId_;
89 }
90
GetMinAPIVersion() const91 uint32_t StageAppInfo::GetMinAPIVersion() const
92 {
93 return minAPIVersion_;
94 }
95
GetTargetAPIVersion() const96 uint32_t StageAppInfo::GetTargetAPIVersion() const
97 {
98 return targetAPIVersion_;
99 }
100
GetVersionCode() const101 uint32_t StageAppInfo::GetVersionCode() const
102 {
103 return versionCode_;
104 }
105
IsInstallationFree() const106 bool StageAppInfo::IsInstallationFree() const
107 {
108 if (bundleType_ == "atomicService") {
109 return true;
110 }
111 return false;
112 }
113 } // namespace OHOS::Ace
114