1/*
2 * Copyright (c) 2021-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
16package ohos;
17
18import java.util.ArrayList;
19import java.util.HashMap;
20import java.util.List;
21
22/**
23 * Hap info.
24 *
25 */
26public class HapInfo {
27    /**
28     * Indicates hap is stage or FA.
29     */
30    public AppModel appModel = AppModel.FA;
31
32    /**
33     * Indicates the package of HapInfo.
34     */
35    public String packageStr = "";
36
37    /**
38     * Indicates the name of HapInfo.
39     */
40    public String name = "";
41
42    /**
43     * Indicates the description of HapInfo.
44     */
45    public String description = "";
46
47    /**
48     * Indicates the supportedModes of HapInfo.
49     */
50    public List<String> supportedModes = new ArrayList<String>();
51
52    /**
53     * Indicates the abilities of HapInfo.
54     */
55    public List<AbilityInfo> abilities = new ArrayList<AbilityInfo>();
56
57    /**
58     * Indicates the defPermissions of HapInfo.
59     * @Deprecated
60     */
61    public List<DefPermission> defPermissions = new ArrayList<DefPermission>();
62
63    /**
64     * Indicates the definePermissions of HapInfo.
65     * @Deprecated
66     */
67    public List<DefinePermission> definePermissions = new ArrayList<>();
68
69    /**
70     * Indicates the defPermissionsGroups of HapInfo.
71     * @Deprecated
72     */
73    public List<DefPermissionGroup> defPermissionsGroups = new ArrayList<DefPermissionGroup>();
74
75    /**
76     * Indicates the distro of HapInfo.
77     */
78    public Distro distro = null;
79
80    /**
81     * Indicates the reqCapabilities of HapInfo.
82     */
83    public List<String> reqCapabilities = new ArrayList<String>();
84
85    /**
86     * Indicates the deviceType of HapInfo.
87     */
88    public List<String> deviceType = new ArrayList<String>();
89
90    /**
91     * Indicates the metaData of HapInfo.
92     */
93    public MetaData metaData = new MetaData();
94
95    /**
96     * Indicates the dependency config.
97     */
98    public List<DependencyItem> dependencies = new ArrayList<>();
99
100    /**
101     * Indicates proxyData config.
102     */
103    public List<ProxyDataItem> proxyData = new ArrayList<>();
104
105    /**
106     * Indicates the HapInfo is Js app.
107     */
108    public boolean isJs = false;
109
110    /**
111     * Indicates the reqPermissions of HapInfo.
112     */
113    public List<ReqPermission> reqPermissions = new ArrayList<ReqPermission>();
114
115    /**
116     * Indicates the commonEvents of HapInfo.
117     */
118    public List<CommonEvent> commonEvents = new ArrayList<CommonEvent>();
119
120    /**
121     * Indicates the shortcuts of HapInfo.
122     */
123    public List<Shortcut> shortcuts = new ArrayList<Shortcut>();
124
125    /**
126     * Indicates the DistroFilter of HapInfo
127     */
128    public DistroFilter distroFilter = new DistroFilter();
129
130    // stage module character
131    /**
132     * Indicates the srcEntrance of ModuleInfo.
133     */
134    public String srcEntrance = "";
135
136    /**
137     * Indicates the process of ModuleInfo.
138     */
139    public String process = "";
140
141    /**
142     * Indicates the mainElement of ModuleInfo.
143     */
144    public String mainElement = "";
145
146    /**
147     * Indicates the uiSyntax of ModuleInfo.
148     */
149    public String uiSyntax = "hml";
150
151    /**
152     * Indicates the pages of ModuleInfo.
153     */
154    public List<String> pages = new ArrayList<>();
155
156    /**
157     * Indicates the extensionAbilityInfo of ModuleInfo.
158     */
159    public  List<ExtensionAbilityInfo> extensionAbilityInfos = new ArrayList<>();
160
161    /**
162     * Indicates the module atomic service of ModuleInfo.
163     */
164    public ModuleAtomicService moduleAtomicService = new ModuleAtomicService();
165
166    /**
167     * Indicates the form of module ModuleJson.
168     */
169    public List<AbilityFormInfo> formInfos = new ArrayList<>();
170
171    /**
172     * Indicates the compressed size of hap.
173     */
174    public long compressedSize = 0;
175
176    /**
177     * Indicates the original size of hap.
178     */
179    public long originalSize = 0;
180
181    /**
182     * Indicates the descriptions of HapInfo.
183     */
184    private HashMap<String, String> descriptions = new HashMap<>();
185
186    public void setDescriptions(HashMap<String, String> descriptions) {
187        this.descriptions = descriptions;
188    }
189
190    public HashMap<String, String> getDescriptions() {
191        return descriptions;
192    }
193
194    /**
195     * get the customize Data value defined in this module.
196     */
197    public String getCustomizeDataValue(String customizeDataName) {
198        for (CustomizeData data : metaData.customizeDatas) {
199            if (customizeDataName.equals(data.name)) {
200                return data.value;
201            }
202        }
203        return "";
204    }
205}
206