• 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 multiScheduledUpdateTime_.
128  * @return multiScheduledUpdateTime_.
129  */
GetMultiScheduledUpdateTime() const130 std::string FormItemInfo::GetMultiScheduledUpdateTime() const
131 {
132     return multiScheduledUpdateTime_;
133 }
134 
135 /**
136  * @brief Get hapSourceDirs_.
137  * @param dirs Hap source dirs.
138  * @return Returns true on success, false on failure.
139  */
GetHapSourceDirs(std::vector<std::string> & dirs) const140 bool FormItemInfo::GetHapSourceDirs(std::vector<std::string> &dirs) const
141 {
142     if (hapSourceDirs_.size() > 0) {
143         dirs.assign(hapSourceDirs_.begin(), hapSourceDirs_.end());
144         return true;
145     }
146     return false;
147 }
148 /**
149  * @brief Set value of hapSourceDirs_.
150  * @param hapSourceDirs Hap source dirs.
151  */
SetHapSourceDirs(const std::vector<std::string> & hapSourceDirs)152 void FormItemInfo::SetHapSourceDirs(const std::vector<std::string> &hapSourceDirs)
153 {
154     hapSourceDirs_ = hapSourceDirs;
155 }
156 /**
157  * @brief Obtains the temporaryFlag.
158  * @return Returns temporaryFlag.
159  */
IsTemporaryForm() const160 bool FormItemInfo::IsTemporaryForm() const
161 {
162     return temporaryFlag_;
163 }
164 
165 /**
166  * @brief Obtains the hap source by ability module name.
167  * @param moduleName ability module name
168  * @return Returns hap source.
169  */
GetHapSourceByModuleName(const std::string & moduleName) const170 std::string FormItemInfo::GetHapSourceByModuleName(const std::string &moduleName) const
171 {
172     auto iter = moduleInfoMap_.find(moduleName);
173     if (iter != moduleInfoMap_.end()) {
174         return iter->second;
175     }
176     return "";
177 }
178 /**
179  * @brief Check if item valid or not.
180  * @return Valid or not
181  */
IsValidItem() const182 bool FormItemInfo::IsValidItem() const
183 {
184     if (providerBundleName_.empty() || moduleName_.empty()
185         || abilityName_.empty() || formName_.empty()) {
186         return false;
187     }
188     return true;
189 }
190 /**
191  * @brief Check if item match or not.
192  * @return Match or not
193  */
IsMatch(const FormRecord & record) const194 bool FormItemInfo::IsMatch(const FormRecord &record) const
195 {
196     HILOG_DEBUG("match data");
197     HILOG_DEBUG("FormRecord.bundleName :%{public}s", record.bundleName.c_str());
198     HILOG_DEBUG("FormRecord.moduleName :%{public}s", record.moduleName.c_str());
199     HILOG_DEBUG("FormRecord.abilityName :%{public}s", record.abilityName.c_str());
200     HILOG_DEBUG("FormRecord.formName :%{public}s", record.formName.c_str());
201     HILOG_DEBUG("FormRecord.specification :%{public}d", record.specification);
202 
203     HILOG_DEBUG("FormItemInfo.providerBundleName_ :%{public}s", providerBundleName_.c_str());
204     HILOG_DEBUG("FormItemInfo.moduleName :%{public}s", moduleName_.c_str());
205     HILOG_DEBUG("FormItemInfo.abilityName :%{public}s", abilityName_.c_str());
206     HILOG_DEBUG("FormItemInfo.formName :%{public}s", formName_.c_str());
207     HILOG_DEBUG("FormItemInfo.specification :%{public}d", specificationId_);
208 
209     return (record.bundleName == providerBundleName_) && (record.moduleName == moduleName_)
210         && (record.abilityName == abilityName_) && (record.formName == formName_)
211         && (record.specification == specificationId_);
212 }
213 /**
214  * @brief Check if form config same or not.
215  * @return Same or not
216  */
IsSameFormConfig(const FormRecord & record) const217 bool FormItemInfo::IsSameFormConfig(const FormRecord &record) const
218 {
219     return (record.bundleName == providerBundleName_) && (record.moduleName == moduleName_)
220         && (record.abilityName == abilityName_) && (record.formName == formName_);
221 }
222 
223 /**
224  * @brief Check if visible notify or not.
225  * @return visible notify or not
226  */
IsFormVisibleNotify() const227 bool FormItemInfo::IsFormVisibleNotify() const
228 {
229     return formVisibleNotify_;
230 }
231 /**
232  * @brief Equal or not.
233  * @param left left string.
234  * @param right right string.
235  * @return Equal or not
236  */
IsEqual(const std::string & left,const std::string & right)237 bool FormItemInfo::IsEqual(const std::string &left, const std::string &right)
238 {
239     return left == right;
240 }
241 /**
242  * @brief Set value of formId_.
243  * @param formId Form Id.
244  */
SetFormId(int64_t formId)245 void FormItemInfo::SetFormId(int64_t formId)
246 {
247     formId_ = formId;
248 }
249 /**
250  * @brief Set value of packageName_.
251  * @param packageName Package name.
252  */
SetPackageName(const std::string & packageName)253 void FormItemInfo::SetPackageName(const std::string &packageName)
254 {
255     packageName_ = packageName;
256 }
257 /**
258  * @brief Set value of providerBundleName_.
259  * @param providerBundleName Provider bundle Name.
260  */
SetProviderBundleName(const std::string & providerBundleName)261 void FormItemInfo::SetProviderBundleName(const std::string &providerBundleName)
262 {
263     providerBundleName_ = providerBundleName;
264 }
265 /**
266  * @brief Set value of hostBundleName_.
267  * @param hostBundleName Host bundle Name.
268  */
SetHostBundleName(const std::string & hostBundleName)269 void FormItemInfo::SetHostBundleName(const std::string &hostBundleName)
270 {
271     hostBundleName_ = hostBundleName;
272 }
273 /**
274  * @brief Set value of moduleName_.
275  * @param moduleName Module Name.
276  */
SetModuleName(const std::string & moduleName)277 void FormItemInfo::SetModuleName(const std::string &moduleName)
278 {
279     moduleName_ = moduleName;
280 }
281 /**
282  * @brief Set value of abilityName_.
283  * @param abilityName Ability name.
284  */
SetAbilityName(const std::string & abilityName)285 void FormItemInfo::SetAbilityName(const std::string &abilityName)
286 {
287     abilityName_ = abilityName;
288 }
289 /**
290  * @brief Set value of formName_.
291  * @param formName Form name.
292  */
SetFormName(const std::string & formName)293 void FormItemInfo::SetFormName(const std::string &formName)
294 {
295     formName_ = formName;
296 }
297 /**
298  * @brief Set value of jsComponentName_.
299  * @param jsComponentName Js component name.
300  */
SetJsComponentName(const std::string & jsComponentName)301 void FormItemInfo::SetJsComponentName(const std::string &jsComponentName)
302 {
303     jsComponentName_ = jsComponentName;
304 }
305 /**
306  * @brief Set value of abilityModuleName_.
307  * @param abilityModuleName ability module name_.
308  */
SetAbilityModuleName(const std::string & abilityModuleName)309 void FormItemInfo::SetAbilityModuleName(const std::string &abilityModuleName)
310 {
311     abilityModuleName_ = abilityModuleName;
312 }
313 /**
314  * @brief Set value of specificationId_.
315  * @param specificationId Specification id.
316  */
SetSpecificationId(const int specificationId)317 void FormItemInfo::SetSpecificationId(const int specificationId)
318 {
319     specificationId_ = specificationId;
320 }
321 /**
322  * @brief Set value of updateFlag_.
323  * @param isEnableUpdateFlag Enable update flag or not.
324  */
SetEnableUpdateFlag(bool isEnableUpdateFlag)325 void FormItemInfo::SetEnableUpdateFlag(bool isEnableUpdateFlag)
326 {
327     updateFlag_ = isEnableUpdateFlag;
328 }
329 /**
330  * @brief Set value of updateDuration_.
331  * @param updateDuration Update duration.
332  */
SetUpdateDuration(int updateDuration)333 void FormItemInfo::SetUpdateDuration(int updateDuration)
334 {
335     updateDuration_ = updateDuration;
336 }
337 /**
338  * @brief Set value of scheduledUpdateTime_.
339  * @param scheduledUpdateTime Scheduled update time.
340  */
SetScheduledUpdateTime(const std::string & scheduledUpdateTime)341 void FormItemInfo::SetScheduledUpdateTime(const std::string &scheduledUpdateTime)
342 {
343     scheduledUpdateTime_ = scheduledUpdateTime;
344 }
345 /**
346  * @brief Set value of multiScheduledUpdateTime_.
347  * @param multiScheduledUpdateTime Scheduled update time.
348  */
SetMultiScheduledUpdateTime(const std::string & multiScheduledUpdateTime)349 void FormItemInfo::SetMultiScheduledUpdateTime(const std::string &multiScheduledUpdateTime)
350 {
351     multiScheduledUpdateTime_ = multiScheduledUpdateTime;
352 }
353 /**
354  * @brief Add hap source dir.
355  * @param hapSourceDir Hap source dir.
356  */
AddHapSourceDirs(const std::string & hapSourceDir)357 void FormItemInfo::AddHapSourceDirs(const std::string &hapSourceDir)
358 {
359     hapSourceDirs_.emplace_back(hapSourceDir);
360 }
361 /**
362  * @brief Set value of temporaryFlag_.
363  * @param temporaryFlag Temporary flag.
364  */
SetTemporaryFlag(bool temporaryFlag)365 void FormItemInfo::SetTemporaryFlag(bool temporaryFlag)
366 {
367     temporaryFlag_ = temporaryFlag;
368 }
369 /**
370  * @brief Add module info.
371  * @param moduleName Module name.
372  * @param moduleSourceDir Module source dir.
373  */
AddModuleInfo(const std::string & moduleName,const std::string & moduleSourceDir)374 void FormItemInfo::AddModuleInfo(const std::string &moduleName, const std::string &moduleSourceDir)
375 {
376     moduleInfoMap_.emplace(std::make_pair(moduleName, moduleSourceDir));
377 }
378 
AddModulePkgName(const std::string & moduleName,const std::string & packageName)379 void FormItemInfo::AddModulePkgName(const std::string &moduleName, const std::string &packageName)
380 {
381     modulePkgNameMap_.emplace(std::make_pair(moduleName, packageName));
382 }
383 
GetModulePkgNameMap() const384 const std::map<std::string, std::string>& FormItemInfo::GetModulePkgNameMap() const
385 {
386     return modulePkgNameMap_;
387 }
388 
389 /**
390  * @brief Set value of formVisibleNotify_.
391  * @param isFormVisibleNotify visible notify or not.
392  */
SetFormVisibleNotify(bool isFormVisibleNotify)393 void FormItemInfo::SetFormVisibleNotify(bool isFormVisibleNotify)
394 {
395     formVisibleNotify_ = isFormVisibleNotify;
396 }
397 /**
398  * @brief Get formSrc_.
399  * @return formSrc_.
400  */
GetFormSrc() const401 std::string FormItemInfo::GetFormSrc() const
402 {
403     return formSrc_;
404 }
405 /**
406  * @brief Set value of formSrc_.
407  * @param formSrc form src.
408  */
SetFormSrc(const std::string & formSrc)409 void FormItemInfo::SetFormSrc(const std::string &formSrc)
410 {
411     formSrc_ = formSrc;
412 }
413 /**
414  * @brief Get formWindow_.
415  * @return formWindow_.
416  */
GetFormWindow() const417 FormWindow FormItemInfo::GetFormWindow() const
418 {
419     return formWindow_;
420 }
421 /**
422  * @brief Set value of formWindow_.
423  * @param formWindow form window.
424  */
SetFormWindow(const FormWindow & formWindow)425 void FormItemInfo::SetFormWindow(const FormWindow &formWindow)
426 {
427     formWindow_.autoDesignWidth = formWindow.autoDesignWidth;
428     formWindow_.designWidth = formWindow.designWidth;
429 }
430 /**
431  * @brief Get versionCode_.
432  * @return versionCode_.
433  */
GetVersionCode() const434 uint32_t FormItemInfo::GetVersionCode() const
435 {
436     return versionCode_;
437 }
438 /**
439  * @brief Set value of versionCode_.
440  * @param versionCode bundle version code.
441  */
SetVersionCode(const uint32_t versionCode)442 void FormItemInfo::SetVersionCode(const uint32_t versionCode)
443 {
444     versionCode_ = versionCode;
445 }
446 /**
447  * @brief Get versionName_.
448  * @return versionName_.
449  */
GetVersionName() const450 std::string FormItemInfo::GetVersionName() const
451 {
452     return versionName_;
453 }
454 /**
455  * @brief Set value of versionName_.
456  * @param versionName bundle version name.
457  */
SetVersionName(const std::string & versionName)458 void FormItemInfo::SetVersionName(const std::string &versionName)
459 {
460     versionName_ = versionName;
461 }
462 /**
463  * @brief Get compatibleVersion_.
464  * @return compatibleVersion_.
465  */
GetCompatibleVersion() const466 uint32_t FormItemInfo::GetCompatibleVersion() const
467 {
468     return compatibleVersion_;
469 }
470 /**
471  * @brief Set value of compatibleVersion_.
472  * @param compatibleVersion bundle version name.
473  */
SetCompatibleVersion(const uint32_t & compatibleVersion)474 void FormItemInfo::SetCompatibleVersion(const uint32_t &compatibleVersion)
475 {
476     compatibleVersion_ = compatibleVersion;
477 }
478 /**
479  * @brief Get icon_.
480  * @return icon_.
481  */
GetIcon() const482 std::string FormItemInfo::GetIcon() const
483 {
484     return icon_;
485 }
486 /**
487  * @brief Get deviceId_.
488  * @return deviceId_.
489  */
GetDeviceId()490 std::string FormItemInfo::GetDeviceId()
491 {
492     return deviceId_;
493 }
494 
495 /**
496  * @brief Set value of  deviceId_.
497  * @param deviceId.
498  */
SetDeviceId(const std::string & deviceId)499 void FormItemInfo::SetDeviceId(const std::string &deviceId)
500 {
501     deviceId_ = deviceId;
502 }
503 
GetType() const504 FormType FormItemInfo::GetType() const
505 {
506     return type_;
507 }
508 
SetType(const FormType & type)509 void FormItemInfo::SetType(const FormType &type)
510 {
511     type_ = type;
512 }
513 
IsDynamic() const514 bool FormItemInfo::IsDynamic() const
515 {
516     return isDynamic_;
517 }
518 
SetIsDynamic(bool isDynamic)519 void FormItemInfo::SetIsDynamic(bool isDynamic)
520 {
521     isDynamic_ = isDynamic;
522 }
523 
IsTransparencyEnabled() const524 bool FormItemInfo::IsTransparencyEnabled() const
525 {
526     return transparencyEnabled_;
527 }
528 
SetTransparencyEnabled(bool isTransparencyEnabled)529 void FormItemInfo::SetTransparencyEnabled(bool isTransparencyEnabled)
530 {
531     transparencyEnabled_ = isTransparencyEnabled;
532 }
533 
GetPrivacyLevel() const534 int32_t FormItemInfo::GetPrivacyLevel() const
535 {
536     return privacyLevel_;
537 }
538 
SetPrivacyLevel(int32_t level)539 void FormItemInfo::SetPrivacyLevel(int32_t level)
540 {
541     privacyLevel_ = level;
542 }
543 
GetUiSyntax() const544 FormType FormItemInfo::GetUiSyntax() const
545 {
546     return uiSyntax_;
547 }
548 
SetUiSyntax(const FormType & uiSyntax)549 void FormItemInfo::SetUiSyntax(const FormType &uiSyntax)
550 {
551     uiSyntax_ = uiSyntax;
552 }
553 
SetSystemAppFlag(bool isSystemApp)554 void FormItemInfo::SetSystemAppFlag(bool isSystemApp)
555 {
556     isSystemApp_ = isSystemApp;
557 }
558 
GetSystemAppFlag() const559 bool FormItemInfo::GetSystemAppFlag() const
560 {
561     return isSystemApp_;
562 }
563 
SetDataProxyFlag(bool dataProxyEnabled)564 void FormItemInfo::SetDataProxyFlag(bool dataProxyEnabled)
565 {
566     dataProxyEnabled_ = dataProxyEnabled;
567 }
568 
GetDataProxyFlag() const569 bool FormItemInfo::GetDataProxyFlag() const
570 {
571     return dataProxyEnabled_;
572 }
573 
SetProviderUid(int32_t uid)574 void FormItemInfo::SetProviderUid(int32_t uid)
575 {
576     uid_ = uid;
577 }
578 
GetProviderUid() const579 int32_t FormItemInfo::GetProviderUid() const
580 {
581     return uid_;
582 }
583 
SetDescription(const std::string & description)584 void FormItemInfo::SetDescription(const std::string &description)
585 {
586     description_ = description;
587 }
588 
GetDescription() const589 std::string FormItemInfo::GetDescription() const
590 {
591     return description_;
592 }
593 
GetFormLocation() const594 Constants::FormLocation FormItemInfo::GetFormLocation() const
595 {
596     return formLocation_;
597 }
598 
SetFormLocation(Constants::FormLocation formLocation)599 void FormItemInfo::SetFormLocation(Constants::FormLocation formLocation)
600 {
601     formLocation_ = formLocation;
602 }
603 
GetIsThemeForm() const604 bool FormItemInfo::GetIsThemeForm() const
605 {
606     return isThemeForm_;
607 }
608 
SetIsThemeForm(bool isThemeForm)609 void FormItemInfo::SetIsThemeForm(bool isThemeForm)
610 {
611     isThemeForm_ = isThemeForm;
612 }
613 
GetFormBundleType() const614 BundleType FormItemInfo::GetFormBundleType() const
615 {
616     return bundleType_;
617 }
618 
SetFormBundleType(BundleType formBundleType)619 void FormItemInfo::SetFormBundleType(BundleType formBundleType)
620 {
621     bundleType_ = formBundleType;
622 }
623 
IsEnableForm() const624 bool FormItemInfo::IsEnableForm() const
625 {
626     return enableForm_;
627 }
628 
SetEnableForm(bool enableForm)629 void FormItemInfo::SetEnableForm(bool enableForm)
630 {
631     enableForm_ = enableForm;
632 }
633 
GetConditionUpdate() const634 std::vector<int32_t> FormItemInfo::GetConditionUpdate() const
635 {
636     return conditionUpdate_;
637 }
638 
SetConditionUpdate(const std::vector<int32_t> & conditionUpdate)639 void FormItemInfo::SetConditionUpdate(const std::vector<int32_t> &conditionUpdate)
640 {
641     conditionUpdate_ = conditionUpdate;
642 }
643 
GetRenderingMode() const644 Constants::RenderingMode FormItemInfo::GetRenderingMode() const
645 {
646     return renderingMode_;
647 }
648 
SetRenderingMode(Constants::RenderingMode renderingMode)649 void FormItemInfo::SetRenderingMode(Constants::RenderingMode renderingMode)
650 {
651     renderingMode_ = renderingMode;
652 }
653 
IsLockForm() const654 bool FormItemInfo::IsLockForm() const
655 {
656     return lockForm_;
657 }
658 
SetLockForm(bool lockForm)659 void FormItemInfo::SetLockForm(bool lockForm)
660 {
661     lockForm_ = lockForm;
662 }
663 
IsProtectForm() const664 bool FormItemInfo::IsProtectForm() const
665 {
666     return protectForm_;
667 }
668 
SetProtectForm(bool protectForm)669 void FormItemInfo::SetProtectForm(bool protectForm)
670 {
671     protectForm_ = protectForm;
672 }
673 }  // namespace AppExecFwk
674 }  // namespace OHOS