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 16 #ifndef OHOS_FORM_FWK_FORM_ITEM_INFO_H 17 #define OHOS_FORM_FWK_FORM_ITEM_INFO_H 18 19 #include <string> 20 #include <unordered_map> 21 #include <vector> 22 #include "form_constants.h" 23 #include "form_record.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 class FormItemInfo { 28 public: 29 /** 30 * @brief Get formId_. 31 * @return formId_. 32 */ 33 int64_t GetFormId() const; 34 /** 35 * @brief Set value of formId_. 36 * @param formId Form Id. 37 */ 38 void SetFormId(int64_t formId); 39 /** 40 * @brief Get packageName_. 41 * @return packageName_. 42 */ 43 std::string GetPackageName() const; 44 /** 45 * @brief Set value of packageName_. 46 * @param packageName Package name. 47 */ 48 void SetPackageName(const std::string &packageName); 49 /** 50 * @brief Get providerBundleName_. 51 * @return providerBundleName_. 52 */ 53 std::string GetProviderBundleName() const; 54 /** 55 * @brief Set value of providerBundleName_. 56 * @param providerBundleName Provider bundle Name. 57 */ 58 void SetProviderBundleName(const std::string &providerBundleName); 59 /** 60 * @brief Get hostBundleName_. 61 * @return hostBundleName_. 62 */ 63 std::string GetHostBundleName() const; 64 /** 65 * @brief Set value of hostBundleName_. 66 * @param hostBundleName_ Host bundle Name. 67 */ 68 void SetHostBundleName(const std::string &hostBundleName); 69 /** 70 * @brief Get moduleName_. 71 * @return moduleName_. 72 */ 73 std::string GetModuleName() const; 74 /** 75 * @brief Set value of moduleName_. 76 * @param moduleName Module Name. 77 */ 78 void SetModuleName(const std::string &moduleName); 79 /** 80 * @brief Get abilityName_. 81 * @return abilityName_. 82 */ 83 std::string GetAbilityName() const; 84 /** 85 * @brief Set value of abilityName_. 86 * @param abilityName Ability name. 87 */ 88 void SetAbilityName(const std::string &abilityName); 89 /** 90 * @brief Get formName_. 91 * @return formName_. 92 */ 93 std::string GetFormName() const; 94 /** 95 * @brief Set value of formName_. 96 * @param formName Form name. 97 */ 98 void SetFormName(const std::string &formName); 99 /** 100 * @brief Get jsComponentName_. 101 * @return jsComponentName_. 102 */ 103 std::string GetJsComponentName() const; 104 /** 105 * @brief Set value of jsComponentName_. 106 * @param jsComponentName Js component name. 107 */ 108 void SetJsComponentName(const std::string &jsComponentName); 109 /** 110 * @brief Get abilityModuleName_. 111 * @return abilityModuleName_. 112 */ 113 std::string GetAbilityModuleName() const; 114 /** 115 * @brief Set value of abilityModuleName_. 116 * @param abilityModuleName ability module name_. 117 */ 118 void SetAbilityModuleName(const std::string &abilityModuleName); 119 /** 120 * @brief Get specificationId_. 121 * @return specificationId_. 122 */ 123 int GetSpecificationId() const; 124 /** 125 * @brief Set value of specificationId_. 126 * @param specificationId Specification id. 127 */ 128 void SetSpecificationId(const int specificationId); 129 130 /** 131 * @brief Obtains the updateFlag. 132 * @return Returns updateFlag. 133 */ 134 bool IsEnableUpdateFlag() const; 135 /** 136 * @brief Set value of updateFlag_. 137 * @param isEnableUpdateFlag Enable update flag or not. 138 */ 139 void SetEnableUpdateFlag(bool isEnableUpdateFlag); 140 /** 141 * @brief Get updateDuration_. 142 * @return updateDuration_. 143 */ 144 int GetUpdateDuration() const; 145 /** 146 * @brief Set value of updateDuration_. 147 * @param updateDuration Update duration. 148 */ 149 void SetUpdateDuration(int updateDuration); 150 /** 151 * @brief Get scheduledUpdateTime_. 152 * @return scheduledUpdateTime_. 153 */ 154 std::string GetScheduledUpdateTime() const; 155 /** 156 * @brief Set value of scheduledUpdateTime_. 157 * @param scheduledUpdateTime Scheduled update time. 158 */ 159 void SetScheduledUpdateTime(const std::string &scheduledUpdateTime); 160 /** 161 * @brief Get hapSourceDirs_. 162 * @param dirs Hap source dirs. 163 * @return Returns true on success, false on failure. 164 */ 165 bool GetHapSourceDirs(std::vector<std::string> &dirs) const; 166 /** 167 * @brief Add hap source dir. 168 * @param hapSourceDir Hap source dir. 169 */ 170 void AddHapSourceDirs(const std::string &hapSourceDir); 171 /** 172 * @brief Set value of hapSourceDirs_. 173 * @param hapSourceDirs Hap source dirs. 174 */ 175 void SetHapSourceDirs(const std::vector<std::string> &hapSourceDirs); 176 /** 177 * @brief Obtains the temporaryFlag. 178 * @return Returns temporaryFlag. 179 */ 180 bool IsTemporaryForm() const; 181 /** 182 * @brief Set value of temporaryFlag_. 183 * @param temporaryFlag Temporary flag. 184 */ 185 void SetTemporaryFlag(bool temporaryFlag); 186 /** 187 * @brief Obtains the hap source by ability module name. 188 * @param moduleName ability module name 189 * @return Returns hap source. 190 */ 191 std::string GetHapSourceByModuleName(const std::string &moduleName) const; 192 /** 193 * @brief Add module info. 194 * @param moduleName Module name. 195 * @param moduleSourceDir Module source dir. 196 */ 197 void AddModuleInfo(const std::string &moduleName, const std::string &moduleSourceDir); 198 /** 199 * @brief Add module package name. 200 * @param moduleName Module name. 201 * @param packageName Package name. 202 */ 203 void AddModulePkgName(const std::string &moduleName, const std::string &packageName); 204 /** 205 * @brief Get module package name map. 206 * @return Module package name map 207 */ 208 const std::map<std::string, std::string>& GetModulePkgNameMap() const; 209 /** 210 * @brief Check if item valid or not. 211 * @return Valid or not 212 */ 213 bool IsValidItem() const; 214 /** 215 * @brief Check if item match or not. 216 * @return Match or not 217 */ 218 bool IsMatch(const FormRecord &record) const; 219 /** 220 * @brief Check if form config same or not. 221 * @return Same or not 222 */ 223 bool IsSameFormConfig(const FormRecord &record) const; 224 /** 225 * @brief Check if visible notify or not. 226 * @return visible notify or not 227 */ 228 bool IsFormVisibleNotify() const; 229 /** 230 * @brief Set value of formVisibleNotify_. 231 * @param isFormVisibleNotify visible notify or not. 232 */ 233 void SetFormVisibleNotify(bool isFormVisibleNotify); 234 /** 235 * @brief Get formSrc_. 236 * @return formSrc_. 237 */ 238 std::string GetFormSrc() const; 239 /** 240 * @brief Set value of formSrc_. 241 * @param formSrc form src. 242 */ 243 void SetFormSrc(const std::string &formSrc); 244 /** 245 * @brief Get formWindow_. 246 * @return formWindow_. 247 */ 248 FormWindow GetFormWindow() const; 249 /** 250 * @brief Set value of formWindow_. 251 * @param formWindow form window. 252 */ 253 void SetFormWindow(const FormWindow &formWindow); 254 /** 255 * @brief Get versionCode_. 256 * @return versionCode_. 257 */ 258 uint32_t GetVersionCode() const; 259 /** 260 * @brief Set value of versionCode_. 261 * @param versionCode bundle version code. 262 */ 263 void SetVersionCode(const uint32_t versionCode); 264 /** 265 * @brief Get versionName_. 266 * @return versionName_. 267 */ 268 std::string GetVersionName() const; 269 /** 270 * @brief Set value of versionName_. 271 * @param versionName bundle version name. 272 */ 273 void SetVersionName(const std::string &versionName); 274 /** 275 * @brief Get compatibleVersion_. 276 * @return compatibleVersion_. 277 */ 278 uint32_t GetCompatibleVersion() const; 279 /** 280 * @brief Set value of compatibleVersion_. 281 * @param compatibleVersion API compatible version. 282 */ 283 void SetCompatibleVersion(const uint32_t &compatibleVersion); 284 /** 285 * @brief Get icon_. 286 * @return icon_. 287 */ 288 std::string GetIcon() const; 289 /** 290 * @brief Get deviceId_. 291 * @return deviceId_. 292 */ 293 std::string GetDeviceId(); 294 /** 295 * @brief Set value of deviceId_. 296 * @param deviceId. 297 */ 298 void SetDeviceId(const std::string &deviceId); 299 /** 300 * @brief Get type_. 301 * @return type_. 302 */ 303 FormType GetType() const; 304 /** 305 * @brief Set value of type_. 306 * @param type. 307 */ 308 void SetType(const FormType &type); 309 /** 310 * @brief Obtains the isDynamic. 311 * @return Returns isDynamic. 312 */ 313 bool IsDynamic() const; 314 /** 315 * @brief Set value of isDynamic. 316 * @param isDynamic isDynamic flag. 317 */ 318 void SetIsDynamic(bool isDynamic); 319 /** 320 * @brief Obtains the transparencyEnabled. 321 * @return Returns transparencyEnabled. 322 */ 323 bool IsTransparencyEnabled() const; 324 /** 325 * @brief Set value of transparencyEnabled. 326 * @param isTransparencyEnabled transparencyEnabled flag. 327 */ 328 void SetTransparencyEnabled(bool isTransparencyEnabled); 329 /** 330 * @brief Obtains the privacyLevel. 331 * @return Returns privacyLevel. 332 */ 333 int32_t GetPrivacyLevel() const; 334 /** 335 * @brief Set value of privacyLevel. 336 * @param level privacyLevel. 337 */ 338 void SetPrivacyLevel(int32_t level); 339 /** 340 * @brief Get uiSyntax. 341 * @return uiSyntax. 342 */ 343 FormType GetUiSyntax() const; 344 /** 345 * @brief Set value of uiSyntax. 346 * @param uiSyntax. 347 */ 348 void SetUiSyntax(const FormType &uiSyntax); 349 /** 350 * @brief Set value of isSystemApp. 351 * @param isSystemApp systemAppFlag. 352 */ 353 void SetSystemAppFlag(bool isSystemApp); 354 /** 355 * @brief Get systemAppFlag. 356 * @return systemAppFlag. 357 */ 358 bool GetSystemAppFlag() const; 359 360 void SetDataProxyFlag(bool dataProxyEnabled); 361 bool GetDataProxyFlag() const; 362 363 /** 364 * @brief save the uid of formProvider. 365 * @param uid the uid of formProvider. 366 */ 367 void SetProviderUid(int32_t uid); 368 /** 369 * @brief Get the uid of formProvider. 370 * @return uid. 371 */ 372 int32_t GetProviderUid() const; 373 374 /** 375 * @brief Save the description of formInfo. 376 * @param description The description of formInfo. 377 */ 378 void SetDescription(const std::string &description); 379 /** 380 * @brief Get the description of formInfo. 381 * @return description. 382 */ 383 std::string GetDescription() const; 384 385 /** 386 * @brief Get the formLocation of formInfo. 387 * @return formLocation. 388 */ 389 Constants::FormLocation GetFormLocation() const; 390 391 /** 392 * @brief set the formLocation. 393 * @param formLocation The FormLocation. 394 */ 395 void SetFormLocation(Constants::FormLocation formLocation); 396 397 /** 398 * @brief Get whether it belongs to theme form. 399 * @return is theme form or not. 400 */ 401 bool GetIsThemeForm() const; 402 403 /** 404 * @brief Set whether it belongs to theme form. 405 * @param isThemeForm is theme form or not. 406 */ 407 void SetIsThemeForm(bool isThemeForm); 408 409 /** 410 * @brief Get bundleType of formProvider. 411 * @return bundleType of from. 412 */ 413 BundleType GetFormBundleType() const; 414 415 /** 416 * @brief Set bundleType of formProvider. 417 * @param formBundleType formBundleType 418 */ 419 void SetFormBundleType(BundleType formBundleType); 420 421 /** 422 * @brief Get whether form bundle is enable. 423 * @return True for enable form bundle, false for disable form bundle. 424 */ 425 bool IsEnableForm() const; 426 427 /** 428 * @brief Set whether form bundle is enable. 429 * @param enableForm True for enable form bundle, false for disable form bundle. 430 */ 431 void SetEnableForm(bool enableForm); 432 433 /** 434 * @brief Get renderingMode of form. 435 * @return renderingMode of from. 436 */ 437 Constants::RenderingMode GetRenderingMode() const; 438 439 /** 440 * @brief Set renderingMode of form. 441 * @param renderingMode renderingMode 442 */ 443 void SetRenderingMode(Constants::RenderingMode renderingMode); 444 445 private: 446 /** 447 * @brief Equal or not. 448 * @param left left string. 449 * @param right right string. 450 * @return Equal or not 451 */ 452 bool IsEqual(const std::string &left, const std::string &right); 453 454 private: 455 int64_t formId_ = -1; 456 std::string packageName_ = ""; 457 std::string providerBundleName_ = ""; 458 std::string hostBundleName_ = ""; 459 std::string moduleName_ = ""; 460 std::string abilityName_ = ""; 461 std::string formName_ = ""; 462 int32_t specificationId_ = 0; 463 bool updateFlag_ = false; 464 int32_t updateDuration_ = 0; 465 std::string scheduledUpdateTime_ = ""; 466 std::vector<std::string> hapSourceDirs_; 467 bool temporaryFlag_ = false; 468 bool formVisibleNotify_ = false; 469 std::string formSrc_ = ""; 470 FormWindow formWindow_; 471 uint32_t versionCode_ = 0; 472 std::string versionName_ = ""; 473 uint32_t compatibleVersion_ = 0; 474 FormType type_ = FormType::JS; 475 FormType uiSyntax_ = FormType::JS; 476 std::string icon_ = ""; 477 bool isDynamic_ = true; 478 bool transparencyEnabled_ = false; 479 int32_t privacyLevel_ = 0; 480 std::string jsComponentName_ = ""; 481 std::string abilityModuleName_ = ""; 482 std::unordered_map<std::string, std::string> moduleInfoMap_; 483 std::map<std::string, std::string> modulePkgNameMap_; 484 std::string deviceId_ = ""; 485 bool dataProxyEnabled_ = false; 486 bool isSystemApp_ = false; 487 int32_t uid_ = -1; 488 std::string description_ = ""; 489 Constants::FormLocation formLocation_; 490 bool isThemeForm_ = false; 491 BundleType bundleType_ = BundleType::APP; 492 bool enableForm_ = true; 493 Constants::RenderingMode renderingMode_ = Constants::RenderingMode::FULL_COLOR; 494 }; 495 } // namespace AppExecFwk 496 } // namespace OHOS 497 498 #endif // OHOS_FORM_FWK_FORM_ITEM_INFO_H 499