• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "form_item_info.h"
16 #include "fms_log_wrapper.h"
17 
18 namespace OHOS {
19 namespace AppExecFwk {
20 /**
21  * @brief Get formId_.
22  * @return formId_.
23  */
GetFormId() const24 int64_t FormItemInfo::GetFormId() const
25 {
26     return formId_;
27 }
28 /**
29  * @brief Get packageName_.
30  * @return packageName_.
31  */
GetPackageName() const32 std::string FormItemInfo::GetPackageName() const
33 {
34     return packageName_;
35 }
36 /**
37  * @brief Get providerBundleName_.
38  * @return providerBundleName_.
39  */
GetProviderBundleName() const40 std::string FormItemInfo::GetProviderBundleName() const
41 {
42     return providerBundleName_;
43 }
44 /**
45  * @brief Get hostBundleName_.
46  * @return hostBundleName_.
47  */
GetHostBundleName() const48 std::string FormItemInfo::GetHostBundleName() const
49 {
50     return hostBundleName_;
51 }
52 /**
53  * @brief Get moduleName_.
54  * @return moduleName_.
55  */
GetModuleName() const56 std::string FormItemInfo::GetModuleName() const
57 {
58     return moduleName_;
59 }
60 /**
61  * @brief Get abilityName_.
62  * @return abilityName_.
63  */
GetAbilityName() const64 std::string FormItemInfo::GetAbilityName() const
65 {
66     return abilityName_;
67 }
68 /**
69  * @brief Get formName_.
70  * @return formName_.
71  */
GetFormName() const72 std::string FormItemInfo::GetFormName() const
73 {
74     return formName_;
75 }
76 /**
77  * @brief Get jsComponentName_.
78  * @return jsComponentName_.
79  */
GetJsComponentName() const80 std::string FormItemInfo::GetJsComponentName() const
81 {
82     return jsComponentName_;
83 }
84 /**
85  * @brief Get abilityModuleName_.
86  * @return abilityModuleName_.
87  */
GetAbilityModuleName() const88 std::string FormItemInfo::GetAbilityModuleName() const
89 {
90     return abilityModuleName_;
91 }
92 /**
93  * @brief Get specificationId_.
94  * @return specificationId_.
95  */
GetSpecificationId() const96 int FormItemInfo::GetSpecificationId() const
97 {
98     return specificationId_;
99 }
100 
101 /**
102  * @brief Obtains the updateFlag.
103  * @return Returns updateFlag.
104  */
IsEnableUpdateFlag() const105 bool FormItemInfo::IsEnableUpdateFlag() const
106 {
107     return updateFlag_;
108 }
109 /**
110  * @brief Get updateDuration_.
111  * @return updateDuration_.
112  */
GetUpdateDuration() const113 int FormItemInfo::GetUpdateDuration() const
114 {
115     return updateDuration_;
116 }
117 /**
118  * @brief Get scheduledUpdateTime_.
119  * @return scheduledUpdateTime_.
120  */
GetScheduledUpdateTime() const121 std::string FormItemInfo::GetScheduledUpdateTime() const
122 {
123     return scheduledUpdateTime_;
124 }
125 
126 /**
127  * @brief Get hapSourceDirs_.
128  * @param dirs Hap source dirs.
129  * @return Returns true on success, false on failure.
130  */
GetHapSourceDirs(std::vector<std::string> & dirs) const131 bool FormItemInfo::GetHapSourceDirs(std::vector<std::string> &dirs) const
132 {
133     if (hapSourceDirs_.size() > 0) {
134         dirs.assign(hapSourceDirs_.begin(), hapSourceDirs_.end());
135         return true;
136     }
137     return false;
138 }
139 /**
140  * @brief Set value of hapSourceDirs_.
141  * @param hapSourceDirs Hap source dirs.
142  */
SetHapSourceDirs(const std::vector<std::string> & hapSourceDirs)143 void FormItemInfo::SetHapSourceDirs(const std::vector<std::string> &hapSourceDirs)
144 {
145     hapSourceDirs_ = hapSourceDirs;
146 }
147 /**
148  * @brief Obtains the temporaryFlag.
149  * @return Returns temporaryFlag.
150  */
IsTemporaryForm() const151 bool FormItemInfo::IsTemporaryForm() const
152 {
153     return temporaryFlag_;
154 }
155 
156 /**
157  * @brief Obtains the hap source by ability module name.
158  * @param moduleName ability module name
159  * @return Returns hap source.
160  */
GetHapSourceByModuleName(const std::string & moduleName) const161 std::string FormItemInfo::GetHapSourceByModuleName(const std::string &moduleName) const
162 {
163     auto iter = moduleInfoMap_.find(moduleName);
164     if (iter != moduleInfoMap_.end()) {
165         return iter->second;
166     }
167     return "";
168 }
169 /**
170  * @brief Check if item valid or not.
171  * @return Valid or not
172  */
IsValidItem() const173 bool FormItemInfo::IsValidItem() const
174 {
175     if (providerBundleName_.empty() || moduleName_.empty()
176         || abilityName_.empty() || formName_.empty()) {
177         return false;
178     }
179     return true;
180 }
181 /**
182  * @brief Check if item match or not.
183  * @return Match or not
184  */
IsMatch(const FormRecord & record) const185 bool FormItemInfo::IsMatch(const FormRecord &record) const
186 {
187     HILOG_DEBUG("match data");
188     HILOG_DEBUG("FormRecord.bundleName : %{public}s", record.bundleName.c_str());
189     HILOG_DEBUG("FormRecord.moduleName : %{public}s", record.moduleName.c_str());
190     HILOG_DEBUG("FormRecord.abilityName : %{public}s", record.abilityName.c_str());
191     HILOG_DEBUG("FormRecord.formName : %{public}s", record.formName.c_str());
192     HILOG_DEBUG("FormRecord.specification : %{public}d", record.specification);
193 
194     HILOG_DEBUG("FormItemInfo.providerBundleName_ : %{public}s", providerBundleName_.c_str());
195     HILOG_DEBUG("FormItemInfo.moduleName : %{public}s", moduleName_.c_str());
196     HILOG_DEBUG("FormItemInfo.abilityName : %{public}s", abilityName_.c_str());
197     HILOG_DEBUG("FormItemInfo.formName : %{public}s", formName_.c_str());
198     HILOG_DEBUG("FormItemInfo.specification : %{public}d", specificationId_);
199 
200     return (record.bundleName == providerBundleName_) && (record.moduleName == moduleName_)
201         && (record.abilityName == abilityName_) && (record.formName == formName_)
202         && (record.specification == specificationId_);
203 }
204 /**
205  * @brief Check if form config same or not.
206  * @return Same or not
207  */
IsSameFormConfig(const FormRecord & record) const208 bool FormItemInfo::IsSameFormConfig(const FormRecord &record) const
209 {
210     return (record.bundleName == providerBundleName_) && (record.moduleName == moduleName_)
211         && (record.abilityName == abilityName_) && (record.formName == formName_);
212 }
213 
214 /**
215  * @brief Check if visible notify or not.
216  * @return visible notify or not
217  */
IsFormVisibleNotify() const218 bool FormItemInfo::IsFormVisibleNotify() const
219 {
220     return formVisibleNotify_;
221 }
222 /**
223  * @brief Equal or not.
224  * @param left left string.
225  * @param right right string.
226  * @return Equal or not
227  */
IsEqual(const std::string & left,const std::string & right)228 bool FormItemInfo::IsEqual(const std::string &left, const std::string &right)
229 {
230     return left == right;
231 }
232 /**
233  * @brief Set value of formId_.
234  * @param formId Form Id.
235  */
SetFormId(int64_t formId)236 void FormItemInfo::SetFormId(int64_t formId)
237 {
238     formId_ = formId;
239 }
240 /**
241  * @brief Set value of packageName_.
242  * @param packageName Package name.
243  */
SetPackageName(const std::string & packageName)244 void FormItemInfo::SetPackageName(const std::string &packageName)
245 {
246     packageName_ = packageName;
247 }
248 /**
249  * @brief Set value of providerBundleName_.
250  * @param providerBundleName Provider bundle Name.
251  */
SetProviderBundleName(const std::string & providerBundleName)252 void FormItemInfo::SetProviderBundleName(const std::string &providerBundleName)
253 {
254     providerBundleName_ = providerBundleName;
255 }
256 /**
257  * @brief Set value of hostBundleName_.
258  * @param hostBundleName Host bundle Name.
259  */
SetHostBundleName(const std::string & hostBundleName)260 void FormItemInfo::SetHostBundleName(const std::string &hostBundleName)
261 {
262     hostBundleName_ = hostBundleName;
263 }
264 /**
265  * @brief Set value of moduleName_.
266  * @param moduleName Module Name.
267  */
SetModuleName(const std::string & moduleName)268 void FormItemInfo::SetModuleName(const std::string &moduleName)
269 {
270     moduleName_ = moduleName;
271 }
272 /**
273  * @brief Set value of abilityName_.
274  * @param abilityName Ability name.
275  */
SetAbilityName(const std::string & abilityName)276 void FormItemInfo::SetAbilityName(const std::string &abilityName)
277 {
278     abilityName_ = abilityName;
279 }
280 /**
281  * @brief Set value of formName_.
282  * @param formName Form name.
283  */
SetFormName(const std::string & formName)284 void FormItemInfo::SetFormName(const std::string &formName)
285 {
286     formName_ = formName;
287 }
288 /**
289  * @brief Set value of jsComponentName_.
290  * @param jsComponentName Js component name.
291  */
SetJsComponentName(const std::string & jsComponentName)292 void FormItemInfo::SetJsComponentName(const std::string &jsComponentName)
293 {
294     jsComponentName_ = jsComponentName;
295 }
296 /**
297  * @brief Set value of abilityModuleName_.
298  * @param abilityModuleName ability module name_.
299  */
SetAbilityModuleName(const std::string & abilityModuleName)300 void FormItemInfo::SetAbilityModuleName(const std::string &abilityModuleName)
301 {
302     abilityModuleName_ = abilityModuleName;
303 }
304 /**
305  * @brief Set value of specificationId_.
306  * @param specificationId Specification id.
307  */
SetSpecificationId(const int specificationId)308 void FormItemInfo::SetSpecificationId(const int specificationId)
309 {
310     specificationId_ = specificationId;
311 }
312 /**
313  * @brief Set value of updateFlag_.
314  * @param isEnableUpdateFlag Enable update flag or not.
315  */
SetEnableUpdateFlag(bool isEnableUpdateFlag)316 void FormItemInfo::SetEnableUpdateFlag(bool isEnableUpdateFlag)
317 {
318     updateFlag_ = isEnableUpdateFlag;
319 }
320 /**
321  * @brief Set value of updateDuration_.
322  * @param updateDuration Update duration.
323  */
SetUpdateDuration(int updateDuration)324 void FormItemInfo::SetUpdateDuration(int updateDuration)
325 {
326     updateDuration_ = updateDuration;
327 }
328 /**
329  * @brief Set value of scheduledUpdateTime_.
330  * @param scheduledUpdateTime Scheduled update time.
331  */
SetScheduledUpdateTime(const std::string & scheduledUpdateTime)332 void FormItemInfo::SetScheduledUpdateTime(const std::string &scheduledUpdateTime)
333 {
334     scheduledUpdateTime_ = scheduledUpdateTime;
335 }
336 /**
337  * @brief Add hap source dir.
338  * @param hapSourceDir Hap source dir.
339  */
AddHapSourceDirs(const std::string & hapSourceDir)340 void FormItemInfo::AddHapSourceDirs(const std::string &hapSourceDir)
341 {
342     hapSourceDirs_.emplace_back(hapSourceDir);
343 }
344 /**
345  * @brief Set value of temporaryFlag_.
346  * @param temporaryFlag Temporary flag.
347  */
SetTemporaryFlag(bool temporaryFlag)348 void FormItemInfo::SetTemporaryFlag(bool temporaryFlag)
349 {
350     temporaryFlag_ = temporaryFlag;
351 }
352 /**
353  * @brief Add module info.
354  * @param moduleName Module name.
355  * @param moduleSourceDir Module source dir.
356  */
AddModuleInfo(const std::string & moduleName,const std::string & moduleSourceDir)357 void FormItemInfo::AddModuleInfo(const std::string &moduleName, const std::string &moduleSourceDir)
358 {
359     moduleInfoMap_.emplace(std::make_pair(moduleName, moduleSourceDir));
360 }
361 /**
362  * @brief Set value of formVisibleNotify_.
363  * @param isFormVisibleNotify visible notify or not.
364  */
SetFormVisibleNotify(bool isFormVisibleNotify)365 void FormItemInfo::SetFormVisibleNotify(bool isFormVisibleNotify)
366 {
367     formVisibleNotify_ = isFormVisibleNotify;
368 }
369 /**
370  * @brief Get formSrc_.
371  * @return formSrc_.
372  */
GetFormSrc() const373 std::string FormItemInfo::GetFormSrc() const
374 {
375     return formSrc_;
376 }
377 /**
378  * @brief Set value of formSrc_.
379  * @param formSrc form src.
380  */
SetFormSrc(const std::string & formSrc)381 void FormItemInfo::SetFormSrc(const std::string &formSrc)
382 {
383     formSrc_ = formSrc;
384 }
385 /**
386  * @brief Get formWindow_.
387  * @return formWindow_.
388  */
GetFormWindow() const389 FormWindow FormItemInfo::GetFormWindow() const
390 {
391     return formWindow_;
392 }
393 /**
394  * @brief Set value of formWindow_.
395  * @param formWindow form window.
396  */
SetFormWindow(const FormWindow & formWindow)397 void FormItemInfo::SetFormWindow(const FormWindow &formWindow)
398 {
399     formWindow_.autoDesignWidth = formWindow.autoDesignWidth;
400     formWindow_.designWidth = formWindow.designWidth;
401 }
402 /**
403  * @brief Get versionCode_.
404  * @return versionCode_.
405  */
GetVersionCode() const406 uint32_t FormItemInfo::GetVersionCode() const
407 {
408     return versionCode_;
409 }
410 /**
411  * @brief Set value of versionCode_.
412  * @param versionCode bundle version code.
413  */
SetVersionCode(const uint32_t versionCode)414 void FormItemInfo::SetVersionCode(const uint32_t versionCode)
415 {
416     versionCode_ = versionCode;
417 }
418 /**
419  * @brief Get versionName_.
420  * @return versionName_.
421  */
GetVersionName() const422 std::string FormItemInfo::GetVersionName() const
423 {
424     return versionName_;
425 }
426 /**
427  * @brief Set value of versionName_.
428  * @param versionName bundle version name.
429  */
SetVersionName(const std::string & versionName)430 void FormItemInfo::SetVersionName(const std::string &versionName)
431 {
432     versionName_ = versionName;
433 }
434 /**
435  * @brief Get compatibleVersion_.
436  * @return compatibleVersion_.
437  */
GetCompatibleVersion() const438 uint32_t FormItemInfo::GetCompatibleVersion() const
439 {
440     return compatibleVersion_;
441 }
442 /**
443  * @brief Set value of compatibleVersion_.
444  * @param compatibleVersion bundle version name.
445  */
SetCompatibleVersion(const uint32_t & compatibleVersion)446 void FormItemInfo::SetCompatibleVersion(const uint32_t &compatibleVersion)
447 {
448     compatibleVersion_ = compatibleVersion;
449 }
450 /**
451  * @brief Get icon_.
452  * @return icon_.
453  */
GetIcon() const454 std::string FormItemInfo::GetIcon() const
455 {
456     return icon_;
457 }
458 /**
459  * @brief Get deviceId_.
460  * @return deviceId_.
461  */
GetDeviceId()462 std::string FormItemInfo::GetDeviceId()
463 {
464     return deviceId_;
465 }
466 
467 /**
468  * @brief Set value of  deviceId_.
469  * @param deviceId.
470  */
SetDeviceId(const std::string & deviceId)471 void FormItemInfo::SetDeviceId(const std::string &deviceId)
472 {
473     deviceId_ = deviceId;
474 }
475 
GetType() const476 FormType FormItemInfo::GetType() const
477 {
478     return type_;
479 }
480 
SetType(const FormType & type)481 void FormItemInfo::SetType(const FormType &type)
482 {
483     type_ = type;
484 }
485 
IsDynamic() const486 bool FormItemInfo::IsDynamic() const
487 {
488     return isDynamic_;
489 }
490 
SetIsDynamic(bool isDynamic)491 void FormItemInfo::SetIsDynamic(bool isDynamic)
492 {
493     isDynamic_ = isDynamic;
494 }
495 
GetUiSyntax() const496 FormType FormItemInfo::GetUiSyntax() const
497 {
498     return uiSyntax_;
499 }
500 
SetUiSyntax(const FormType & uiSyntax)501 void FormItemInfo::SetUiSyntax(const FormType &uiSyntax)
502 {
503     uiSyntax_ = uiSyntax;
504 }
505 
SetSystemAppFlag(bool isSystemApp)506 void FormItemInfo::SetSystemAppFlag(bool isSystemApp)
507 {
508     isSystemApp_ = isSystemApp;
509 }
510 
GetSystemAppFlag() const511 bool FormItemInfo::GetSystemAppFlag() const
512 {
513     return isSystemApp_;
514 }
SetDataProxyFlag(bool dataProxyEnabled)515 void FormItemInfo::SetDataProxyFlag(bool dataProxyEnabled)
516 {
517     dataProxyEnabled_ = dataProxyEnabled;
518 }
519 
GetDataProxyFlag() const520 bool FormItemInfo::GetDataProxyFlag() const
521 {
522     return dataProxyEnabled_;
523 }
524 }  // namespace AppExecFwk
525 }  // namespace OHOS