1 /* 2 * Copyright (c) 2021-2024 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_MGR_ADAPTER_H 17 #define OHOS_FORM_FWK_FORM_MGR_ADAPTER_H 18 19 #include <singleton.h> 20 21 #include "bundle_info.h" 22 #include "bundle_mgr_interface.h" 23 #include "form_constants.h" 24 #include "form_info.h" 25 #include "form_info_filter.h" 26 #include "form_instance.h" 27 #include "form_instances_filter.h" 28 #include "form_item_info.h" 29 #include "form_js_info.h" 30 #include "form_provider_data.h" 31 #include "form_publish_interceptor_interface.h" 32 #include "form_serial_queue.h" 33 #include "form_state_info.h" 34 #include "form_task_mgr.h" 35 #include "iremote_object.h" 36 #include "running_form_info.h" 37 #include "want.h" 38 #ifdef THEME_MGR_ENABLE 39 #include "theme_manager_client.h" 40 #endif 41 42 namespace OHOS { 43 namespace AppExecFwk { 44 using Want = OHOS::AAFwk::Want; 45 using WantParams = OHOS::AAFwk::WantParams; 46 47 enum class AddFormResultErrorCode : int8_t { 48 UNKNOWN = 0, 49 SUCCESS, 50 FAILED, 51 TIMEOUT 52 }; 53 54 /** 55 * @class FormMgrAdapter 56 * Form request handler from form host. 57 */ 58 class FormMgrAdapter final : public DelayedRefSingleton<FormMgrAdapter> { 59 DECLARE_DELAYED_REF_SINGLETON(FormMgrAdapter) 60 public: 61 DISALLOW_COPY_AND_MOVE(FormMgrAdapter); 62 63 /** 64 * @brief Init properties like visibleNotifyDelayTime. 65 */ 66 void Init(); 67 68 /** 69 * @brief Add form with want, send want to form manager service. 70 * @param formId The Id of the forms to add. 71 * @param want The want of the form to add. 72 * @param callerToken Caller ability token. 73 * @param formInfo Form info. 74 * @return Returns ERR_OK on success, others on failure. 75 */ 76 int AddForm(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken, FormJsInfo &formInfo); 77 78 /** 79 * @brief Add form with want, send want to form manager service. 80 * @param want The want of the form to add. 81 * @param runningFormInfo Running form info. 82 * @return Returns ERR_OK on success, others on failure. 83 */ 84 int CreateForm(const Want &want, RunningFormInfo &runningFormInfo); 85 86 /** 87 * @brief Delete forms with formIds, send formIds to form manager service. 88 * @param formId The Id of the forms to delete. 89 * @param callerToken Caller ability token. 90 * @return Returns ERR_OK on success, others on failure. 91 */ 92 int DeleteForm(const int64_t formId, const sptr<IRemoteObject> &callerToken); 93 94 /** 95 * @brief Stop rendering form. 96 * @param formId The Id of the forms to delete. 97 * @param compId The compId of the forms to delete. 98 * @return Returns ERR_OK on success, others on failure. 99 */ 100 int StopRenderingForm(const int64_t formId, const std::string &compId); 101 102 /** 103 * @brief Release forms with formIds, send formIds to form Mgr service. 104 * @param formId The Id of the forms to release. 105 * @param callerToken Caller ability token. 106 * @param delCache Delete Cache or not. 107 * @return Returns ERR_OK on success, others on failure. 108 */ 109 int ReleaseForm(const int64_t formId, const sptr<IRemoteObject> &callerToken, const bool delCache); 110 111 /** 112 * @brief Update form with formId. 113 * @param formId The Id of the form to update. 114 * @param callingUid Provider ability uid. 115 * @param formProviderData form provider data. 116 * @param std::vector<FormDataProxy> Form proxy vector. 117 * @return Returns ERR_OK on success, others on failure. 118 */ 119 int UpdateForm(const int64_t formId, const int32_t callingUid, const FormProviderData &formProviderData, 120 const std::vector<FormDataProxy> &formDataProxies = {}); 121 122 /** 123 * @brief Request form with formId and want, send formId and want to form manager service. 124 * 125 * @param formId The Id of the form to update. 126 * @param callerToken Caller ability token. 127 * @param want The want of the form to request. 128 * @return Returns ERR_OK on success, others on failure. 129 */ 130 int RequestForm(const int64_t formId, const sptr<IRemoteObject> &callerToken, const Want &want); 131 132 /** 133 * @brief Form visible/invisible notify, send formIds to form manager service. 134 * 135 * @param formIds The vector of form Ids. 136 * @param callerToken Caller ability token. 137 * @param formVisibleType The form visible type, including FORM_VISIBLE and FORM_INVISIBLE. 138 * @return Returns ERR_OK on success, others on failure. 139 */ 140 ErrCode NotifyWhetherVisibleForms(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken, 141 const int32_t formVisibleType); 142 143 /** 144 * @brief Query whether has visible form by tokenId. 145 * @param tokenId Unique identification of application. 146 * @return Returns true if has visible form, false otherwise. 147 */ 148 bool HasFormVisible(const uint32_t tokenId); 149 150 /** 151 * @brief Padding the formInstances map for visibleNotify. 152 * @param formVisibleType The form visible type, including FORM_VISIBLE and FORM_INVISIBLE. 153 * @param formId Form Id. 154 * @param formInstanceMaps formInstances for visibleNotify. 155 */ 156 void PaddingNotifyVisibleFormsMap(const int32_t formVisibleType, int64_t formId, 157 std::map<std::string, std::vector<FormInstance>> &formInstanceMaps); 158 159 /** 160 * @brief temp form to normal form. 161 * @param formId The Id of the form. 162 * @param callerToken Caller ability token. 163 * @return Returns ERR_OK on success, others on failure. 164 */ 165 int CastTempForm(const int64_t formId, const sptr<IRemoteObject> &callerToken); 166 167 /** 168 * @brief Dump all of form storage infos. 169 * @param formInfos All of form storage infos. 170 * @return Returns ERR_OK on success, others on failure. 171 */ 172 int DumpStorageFormInfos(std::string &formInfos) const; 173 /** 174 * @brief Dump all of temporary form infos. 175 * @param formInfos All of temporary form infos. 176 * @return Returns ERR_OK on success, others on failure. 177 */ 178 int DumpTemporaryFormInfos(std::string &formInfos) const; 179 /** 180 * @brief Dump form infos of all bundles, this is static info. 181 * @param formInfos All of static form infos. 182 * @return Returns ERR_OK on success, others on failure. 183 */ 184 int DumpStaticBundleFormInfos(std::string &formInfos) const; 185 186 /** 187 * @brief Dump has form visible with bundleInfo. 188 * @param bundleInfo Bundle info like bundleName_userId_instIndex. 189 * @param formInfos Form dump infos. 190 * @return Returns ERR_OK on success, others on failure. 191 */ 192 int DumpHasFormVisible(const std::string &bundleInfo, std::string &formInfos) const; 193 194 /** 195 * @brief Dump form info by a bundle name. 196 * @param bundleName The bundle name of form provider. 197 * @param formInfos Form infos. 198 * @return Returns ERR_OK on success, others on failure. 199 */ 200 int DumpFormInfoByBundleName(const std::string &bundleName, std::string &formInfos) const; 201 /** 202 * @brief Dump form info by a bundle name. 203 * @param formId The id of the form. 204 * @param formInfo Form info. 205 * @return Returns ERR_OK on success, others on failure. 206 */ 207 int DumpFormInfoByFormId(const std::int64_t formId, std::string &formInfo) const; 208 /** 209 * @brief Dump form timer by form id. 210 * @param formId The id of the form. 211 * @param isTimingService "true" or "false". 212 * @return Returns ERR_OK on success, others on failure. 213 */ 214 int DumpFormTimerByFormId(const std::int64_t formId, std::string &isTimingService) const; 215 216 /** 217 * @brief Dump running form info. 218 * @param runningFormInfosResult The dump info of all the running form info. 219 * @return Returns ERR_OK on success, others on failure. 220 */ 221 int DumpFormRunningFormInfos(std::string &runningFormInfosResult) const; 222 223 /** 224 * @brief set next refresh time. 225 * @param formId The id of the form. 226 * @param nextTime next refresh time. 227 * @return Returns ERR_OK on success, others on failure. 228 */ 229 int SetNextRefreshTime(const int64_t formId, const int64_t nextTime); 230 231 /** 232 * @brief Release renderer. 233 * @param formId The Id of the forms to release. 234 * @param compId The compId of the forms to release. 235 * @return Returns ERR_OK on success, others on failure. 236 */ 237 int ReleaseRenderer(int64_t formId, const std::string &compId); 238 239 /** 240 * @brief Request to publish a form to the form host. 241 * 242 * @param want The want of the form to publish. 243 * @param withFormBindingData Indicates whether the formBindingData is carried with. 244 * @param formBindingData Indicates the form data. 245 * @param formId Return the form id to be published. 246 * @param needCheckFormPermission Indicates whether the app have system permissions.default value is true. 247 * @return Returns ERR_OK on success, others on failure. 248 */ 249 ErrCode RequestPublishForm(Want &want, bool withFormBindingData, 250 std::unique_ptr<FormProviderData> &formBindingData, int64_t &formId, 251 const std::vector<FormDataProxy> &formDataProxies = {}, bool needCheckFormPermission = true); 252 253 ErrCode SetPublishFormResult(const int64_t formId, Constants::PublishFormResult &errorCodeInfo); 254 255 ErrCode AcquireAddFormResult(const int64_t formId); 256 /** 257 * @brief Check if the request of publishing a form is supported by the host. 258 * @return Returns true if the request is supported and false otherwise. 259 */ 260 bool IsRequestPublishFormSupported(); 261 262 /** 263 * @brief enable update form. 264 * @param formIDs The id of the forms. 265 * @param callerToken Caller ability token. 266 * @return Returns ERR_OK on success, others on failure. 267 */ 268 int EnableUpdateForm(const std::vector<int64_t> formIDs, const sptr<IRemoteObject> &callerToken); 269 270 /** 271 * @brief disable update form. 272 * @param formIDs The id of the forms. 273 * @param callerToken Caller ability token. 274 * @return Returns ERR_OK on success, others on failure. 275 */ 276 int DisableUpdateForm(const std::vector<int64_t> formIDs, const sptr<IRemoteObject> &callerToken); 277 278 /** 279 * @brief Process js message event. 280 * @param formId Indicates the unique id of form. 281 * @param want information passed to supplier. 282 * @param callerToken Caller ability token. 283 * @return Returns true if execute success, false otherwise. 284 */ 285 int MessageEvent(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken); 286 287 /** 288 * @brief Process js router event. 289 * @param formId Indicates the unique id of form. 290 * @param want the want of the ability to start. 291 * @param callerToken Caller ability token. 292 * @return Returns true if execute success, false otherwise. 293 */ 294 int RouterEvent(const int64_t formId, Want &want, const sptr<IRemoteObject> &callerToken); 295 296 /** 297 * @brief Process background router event. 298 * @param formId Indicates the unique id of form. 299 * @param want the want of the ability to start. 300 * @param callerToken Caller ability token. 301 * @return Returns true if execute success, false otherwise. 302 */ 303 int BackgroundEvent(const int64_t formId, Want &want, const sptr<IRemoteObject> &callerToken); 304 305 /** 306 * @brief Acquire form data from form provider. 307 * @param formId The Id of the from. 308 * @param want The want of the request. 309 * @param remoteObject Form provider proxy object. 310 */ 311 void AcquireProviderFormInfo(const int64_t formId, const Want &want, const sptr<IRemoteObject> &remoteObject); 312 /** 313 * @brief Notify form provider for delete form. 314 * @param formId The Id of the from. 315 * @param want The want of the form. 316 * @param remoteObject Form provider proxy object. 317 * @return none. 318 */ 319 void NotifyFormDelete(const int64_t formId, const Want &want, const sptr<IRemoteObject> &remoteObject); 320 321 /** 322 * @brief Delete the invalid forms. 323 * @param formIds Indicates the ID of the valid forms. 324 * @param callerToken Caller ability token. 325 * @param numFormsDeleted Returns the number of the deleted forms. 326 * @return Returns ERR_OK on success, others on failure. 327 */ 328 int DeleteInvalidForms(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken, 329 int32_t &numFormsDeleted); 330 331 /** 332 * @brief Acquire form state info by passing a set of parameters (using Want) to the form provider. 333 * @param want Indicates a set of parameters to be transparently passed to the form provider. 334 * @param callerToken Caller ability token. 335 * @param stateInfo Returns the form's state info of the specify. 336 * @return Returns ERR_OK on success, others on failure. 337 */ 338 int AcquireFormState(const Want &want, const sptr<IRemoteObject> &callerToken, FormStateInfo &stateInfo); 339 340 /** 341 * @brief Acquire form data by formId. 342 * @param formId The Id of the form to acquire data. 343 * @param callerToken Indicates the host client. 344 * @param requestCode The request code of this acquire form. 345 * @param formData Return the forms' information of customization 346 * @return Returns ERR_OK on success, others on failure. 347 */ 348 int AcquireFormData(int64_t formId, int64_t requestCode, const sptr<IRemoteObject> &callerToken, 349 AAFwk::WantParams &formData); 350 351 /** 352 * @brief Notify the form is visible or not. 353 * @param formIds Indicates the ID of the forms. 354 * @param isVisible Visible or not. 355 * @param callerToken Host client. 356 * @return Returns ERR_OK on success, others on failure. 357 */ 358 int NotifyFormsVisible(const std::vector<int64_t> &formIds, bool isVisible, const sptr<IRemoteObject> &callerToken); 359 360 /** 361 * @brief Notify the form is enable to be updated or not. 362 * @param formIds Indicates the ID of the forms. 363 * @param isEnableUpdate enable update or not. 364 * @param callerToken Host client. 365 * @return Returns ERR_OK on success, others on failure. 366 */ 367 int NotifyFormsEnableUpdate(const std::vector<int64_t> &formIds, bool isEnableUpdate, 368 const sptr<IRemoteObject> &callerToken); 369 370 /** 371 * @brief Get All FormsInfo. 372 * @param formInfos Return the forms' information of all forms provided. 373 * @return Returns ERR_OK on success, others on failure. 374 */ 375 int GetAllFormsInfo(std::vector<FormInfo> &formInfos); 376 377 /** 378 * @brief Get forms info by bundle name . 379 * @param bundleName Application name. 380 * @param formInfos Return the forms' information of the specify application name. 381 * @return Returns ERR_OK on success, others on failure. 382 */ 383 int GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos); 384 385 /** 386 * @brief Get forms info by bundle name and module name. 387 * @param bundleName bundle name. 388 * @param moduleName Module name of hap. 389 * @param formInfos Return the forms' information of the specify bundle name and module name. 390 * @return Returns ERR_OK on success, others on failure. 391 */ 392 int GetFormsInfoByModule(const std::string &bundleName, const std::string &moduleName, 393 std::vector<FormInfo> &formInfos); 394 395 /** 396 * @brief Get forms info specfied by filter parameters. 397 * @param filter Filter that contains necessary conditions, such as bundle name, module name, dimensions. 398 * @param formInfos Return the forms' information specified by filter. 399 * @return Returns ERR_OK on success, others on failure. 400 */ 401 int GetFormsInfoByFilter(const FormInfoFilter &filter, std::vector<FormInfo> &formInfos); 402 403 /** 404 * @brief get forms count. 405 * @param isTempFormFlag Indicates temp form or not. 406 * @param formCount Returns the number of the cast or temp form. 407 * @return Returns ERR_OK on success, others on failure. 408 */ 409 int32_t GetFormsCount(bool isTempFormFlag, int32_t &formCount); 410 411 /** 412 * @brief get host forms count. 413 * @param bundleName Indicates form host bundleName. 414 * @param formCount Returns the number of the host form. 415 * @return Returns ERR_OK on success, others on failure. 416 */ 417 int32_t GetHostFormsCount(std::string &bundleName, int32_t &formCount); 418 419 /** 420 * @brief Handle form add observer. 421 * @return Returns ERR_OK on success, others on failure. 422 */ 423 ErrCode HandleFormAddObserver(const int64_t formId); 424 425 /** 426 * @brief Handle form add observer. 427 * @param runningFormInfo the running forms' infos of the specify application name. 428 * @return Returns ERR_OK on success, others on failure. 429 */ 430 ErrCode HandleFormRemoveObserver(const RunningFormInfo runningFormInfo); 431 432 /** 433 * @brief Register form add observer by bundle. 434 * @param bundleName BundleName of the form host 435 * @param callerToken Caller ability token. 436 * @return Returns ERR_OK on success, others on failure. 437 */ 438 ErrCode RegisterFormAddObserverByBundle(const std::string bundleName, const sptr<IRemoteObject> &callerToken); 439 440 /** 441 * @brief Register form remove observer by bundle. 442 * @param bundleName BundleName of the form host 443 * @param callerToken Caller ability token. 444 * @return Returns ERR_OK on success, others on failure. 445 */ 446 ErrCode RegisterFormRemoveObserverByBundle(const std::string bundleName, const sptr<IRemoteObject> &callerToken); 447 448 /** 449 * @brief Get all running form infos. 450 * @param isUnusedIncluded Indicates whether to include unused forms. 451 * @param runningFormInfos Return the running forms' infos currently. 452 * @return Returns ERR_OK on success, others on failure. 453 */ 454 ErrCode GetRunningFormInfos(bool isUnusedIncluded, std::vector<RunningFormInfo> &runningFormInfos); 455 456 /** 457 * @brief Get the running form infos by bundle name. 458 * @param bundleName Application name. 459 * @param isUnusedIncluded Indicates whether to include unused forms. 460 * @param runningFormInfos Return the running forms' infos of the specify application name. 461 * @return Returns ERR_OK on success, others on failure. 462 */ 463 ErrCode GetRunningFormInfosByBundleName( 464 const std::string &bundleName, bool isUnusedIncluded, std::vector<RunningFormInfo> &runningFormInfos); 465 466 /** 467 * @brief Get form instances by filter info. 468 * @param formInstancesFilter includes bundleName, moduleName, formName, abilityName to get formInstances. 469 * @param formInstances return formInstances 470 * @return return ERR_OK on get info success, others on failure. 471 */ 472 ErrCode GetFormInstancesByFilter(const FormInstancesFilter &formInstancesFilter, 473 std::vector<FormInstance> &formInstances); 474 475 /** 476 * @brief Get form instance by formId. 477 * @param formId formId Indicates the unique id of form. 478 * @param formInstance return formInstance 479 * @return return ERR_OK on get info success, others on failure. 480 */ 481 ErrCode GetFormInstanceById(const int64_t formId, FormInstance &formInstance); 482 483 /** 484 * @brief Get form instance by formId, include form store in DB. 485 * @param formId formId Indicates the unique id of form. 486 * @param isUnusedIncluded Indicates whether to include unused form. 487 * @param formInstance return formInstance 488 * @return return ERR_OK on get info success, others on failure. 489 */ 490 ErrCode GetFormInstanceById(const int64_t formId, bool isUnusedIncluded, FormInstance &formInstance); 491 492 /** 493 * @brief Register form add observer. 494 * @param bundleName BundleName of the form host 495 * @param callerToken Caller ability token. 496 * @return Returns ERR_OK on success, others on failure. 497 */ 498 ErrCode RegisterAddObserver(const std::string &bundleName, const sptr<IRemoteObject> &callerToken); 499 500 /** 501 * @brief Register form remove observer. 502 * @param bundleName BundleName of the form host 503 * @param callerToken Caller ability token. 504 * @return Returns ERR_OK on success, others on failure. 505 */ 506 ErrCode RegisterRemoveObserver(const std::string &bundleName, const sptr<IRemoteObject> &callerToken); 507 508 /** 509 * @brief Register form router event proxy. 510 * @param formIds Indicates the ID of the forms. 511 * @param callerToken Router proxy call back client. 512 * @return Returns ERR_OK on success, others on failure. 513 */ 514 ErrCode RegisterFormRouterProxy(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken); 515 516 /** 517 * @brief Unregister form router event proxy. 518 * @param formIds Indicates the ID of the forms. 519 * @return Returns ERR_OK on success, others on failure. 520 */ 521 ErrCode UnregisterFormRouterProxy(const std::vector<int64_t> &formIds); 522 523 /** 524 * @brief Registers the callback for publish form. The callback is used to process the publish form request 525 * when the system handler is not found. 526 * @param interceptorCallback The injected callback, should implementation IFormPublishInterceptor. 527 * @return Returns ERR_OK on success, others on failure. 528 */ 529 int32_t RegisterPublishFormInterceptor(const sptr<IRemoteObject> &interceptorCallback); 530 531 /** 532 * @brief Unregisters the callback for publish form. The callback is used to process the publish form request 533 * when the system handler is not found. 534 * @param interceptorCallback The injected callback, should implementation IFormPublishInterceptor. 535 * @return Returns ERR_OK on success, others on failure. 536 */ 537 int32_t UnregisterPublishFormInterceptor(const sptr<IRemoteObject> &interceptorCallback); 538 539 /** 540 * @brief Register click callback observer. 541 * @param bundleName BundleName of the form host. 542 * @param formEventType Form event type. 543 * @param callerToken Caller ability token. 544 * @return Returns ERR_OK on success, others on failure. 545 */ 546 ErrCode RegisterClickEventObserver( 547 const std::string &bundleName, const std::string &formEventType, const sptr<IRemoteObject> &observer); 548 549 /** 550 * @brief Unregister click callback observer. 551 * @param bundleName BundleName of the form host. 552 * @param formEventType Form event type. 553 * @param callerToken Caller ability token. 554 * @return Returns ERR_OK on success, others on failure. 555 */ 556 ErrCode UnregisterClickEventObserver( 557 const std::string &bundleName, const std::string &formEventType, const sptr<IRemoteObject> &observer); 558 559 /** 560 * @brief Compare the locally configured update duration with the update duration in additionalInfo and 561 * return a larger value. 562 * @param formId The Id of the form. 563 * @param updateDuration The valid form update duration. 564 * @return Returns true on success, false on failure. 565 */ 566 bool GetValidFormUpdateDuration(const int64_t formId, int64_t &updateDuration) const; 567 568 /** 569 * @brief Handle forms visible/invisible notify after delay time, notification will be cancelled when 570 * formVisibleState recovered during the delay time. 571 * @param formIds the Ids of forms need to notify. 572 * @param formInstanceMaps formInstances for visibleNotify. 573 * @param eventMaps eventMaps for event notify. 574 * @param formVisibleType The form visible type, including FORM_VISIBLE and FORM_INVISIBLE. 575 * @param callerToken Caller ability token. 576 */ 577 void HandlerNotifyWhetherVisibleForms(const std::vector<int64_t> &formIds, 578 std::map<std::string, std::vector<FormInstance>> formInstanceMaps, 579 std::map<std::string, std::vector<int64_t>> eventMaps, const int32_t formVisibleType, 580 const sptr<IRemoteObject> &callerToken); 581 582 /** 583 * @brief Set forms recyclable 584 * @param formIds Indicates the id of the forms. 585 * @return Returns ERR_OK on success, others on failure. 586 */ 587 int32_t SetFormsRecyclable(const std::vector<int64_t> &formIds); 588 589 /** 590 * @brief Recycle forms 591 * @param formIds Indicates the id of the forms. 592 * @param want The want of forms to be recycled. 593 * @param isCheckCallingUid is need check CallingUid, default is true. 594 * @return Returns ERR_OK on success, others on failure. 595 */ 596 int32_t RecycleForms(const std::vector<int64_t> &formIds, const Want &want, bool isCheckCallingUid = true); 597 598 /** 599 * @brief Recover recycled forms 600 * @param formIds Indicates the id of the forms. 601 * @param want The want of forms to be recovered. 602 * @return Returns ERR_OK on success, others on failure. 603 */ 604 int32_t RecoverForms(const std::vector<int64_t> &formIds, const Want &want); 605 606 /** 607 * @brief Update form cloud update duration when additionalInfo changed. 608 * @param bundleName The bundleName of the form with a specified update duration in app gallery. 609 */ 610 void UpdateFormCloudUpdateDuration(const std::string &bundleName); 611 612 /** 613 * @brief Update formLocation with formId. 614 * @param formId The Id of the form to update. 615 * @param formLocation formLocation. 616 * @return Returns ERR_OK on success, others on failure. 617 */ 618 ErrCode UpdateFormLocation(const int64_t &formId, const int32_t &formLocation); 619 620 /** 621 * @brief Update form with formRefreshType, send to form manager service. 622 * @param formRefreshType The type of the form to refresh, 0: AllForm 1: 2: AppForm 2: AtomicServiceForm 623 * @return Returns ERR_OK on success, others on failure. 624 */ 625 ErrCode BatchRefreshForms(const int32_t formRefreshType); 626 627 #ifdef RES_SCHEDULE_ENABLE 628 /** 629 * @brief Set the value which indicate whether Refresh Timer task should be triggered. 630 * @param isTimerTaskNeeded The value of whether Refresh Timer task should be triggered. 631 */ 632 void SetTimerTaskNeeded(bool isTimerTaskNeeded); 633 #endif // RES_SCHEDULE_ENABLE 634 635 /** 636 * @brief enable/disable form update. 637 * @param bundleName BundleName of the form host. 638 * @param enable True for enable form, false for disable form. 639 * @return Returns ERR_OK on success, others on failure. 640 */ 641 int32_t EnableForms(const std::string bundleName, const bool enable); 642 643 /** 644 * @brief Update form size. 645 * @param formId The Id of the form to update. 646 * @param width The width value to be updated. 647 * @param height The height value to be updated. 648 * @param borderWidth The borderWidth value to be updated. 649 * @return Returns ERR_OK on success, others on failure. 650 */ 651 ErrCode UpdateFormSize(const int64_t &formId, float width, float height, float borderWidth); 652 653 int32_t OnNotifyRefreshForm(const int64_t &formId); 654 private: 655 /** 656 * @brief Get form configure info. 657 * @param want The want of the request. 658 * @param formItemInfo Form configure info. 659 * @return Returns ERR_OK on success, others on failure. 660 */ 661 ErrCode GetFormConfigInfo(const Want& want, FormItemInfo &formItemInfo); 662 663 /** 664 * @brief Get bundle info. 665 * @param want The want of the request. 666 * @param bundleInfo Bundle info. 667 * @param packageName Package name. 668 * @return Returns ERR_OK on success, others on failure. 669 */ 670 ErrCode GetBundleInfo(const AAFwk::Want &want, BundleInfo &bundleInfo, std::string &packageName); 671 672 /** 673 * @brief Get form info. 674 * @param want The want of the request. 675 * @param formInfo Form info. 676 * @return Returns ERR_OK on success, others on failure. 677 */ 678 ErrCode GetFormInfo(const AAFwk::Want &want, FormInfo &formInfo); 679 680 /** 681 * @brief Get form configure info. 682 * @param want The want of the request. 683 * @param bundleInfo Bundle info. 684 * @param formInfo Form info. 685 * @param formItemInfo Form configure info. 686 * @return Returns ERR_OK on success, others on failure. 687 */ 688 ErrCode GetFormItemInfo(const AAFwk::Want &want, const BundleInfo &bundleInfo, const FormInfo &formInfo, 689 FormItemInfo &formItemInfo); 690 691 /** 692 * @brief Dimension valid check. 693 * @param formInfo Form info. 694 * @param dimensionId Dimension id. 695 * @return Returns true on success, false on failure. 696 */ 697 bool IsDimensionValid(const FormInfo &formInfo, int dimensionId) const; 698 699 /** 700 * @brief Create form configure info. 701 * @param bundleInfo Bundle info. 702 * @param formInfo Form info. 703 * @param itemInfo Form configure info. 704 * @param want The want of the request. 705 * @return Returns ERR_OK on success, others on failure. 706 */ 707 ErrCode CreateFormItemInfo(const BundleInfo& bundleInfo, const FormInfo& formInfo, FormItemInfo& itemInfo, 708 const AAFwk::Want &want); 709 710 /** 711 * @brief Set form item info params. 712 * @param bundleInfo Bundle info. 713 * @param formInfo Form info. 714 * @param itemInfo Form item info. 715 */ 716 void SetFormItemInfoParams(const BundleInfo& bundleInfo, const FormInfo& formInfo, FormItemInfo& itemInfo); 717 718 /** 719 * @brief Set form item module info. 720 * @param hapModuleInfo Hap module info. 721 * @param formInfo Form info. 722 * @param itemInfo Form item info. 723 */ 724 void SetFormItemModuleInfo(const HapModuleInfo& hapModuleInfo, const FormInfo& formInfo, 725 FormItemInfo& itemInfo); 726 727 /** 728 * @brief Allocate form by formId. 729 * @param info Form configure info. 730 * @param callerToken Caller ability token. 731 * @param wantParams WantParams of the request. 732 * @param formInfo Form info for form host. 733 * @return Returns ERR_OK on success, others on failure. 734 */ 735 ErrCode AllotFormById(const FormItemInfo &info, const sptr<IRemoteObject> &callerToken, 736 const WantParams &wantParams, FormJsInfo &formInfo); 737 738 /** 739 * @brief Allocate form by form configure info. 740 * @param info Form configure info. 741 * @param callerToken Caller ability token. 742 * @param wantParams WantParams of the request. 743 * @param formInfo Form info for form host. 744 * @return Returns ERR_OK on success, others on failure. 745 */ 746 ErrCode AllotFormByInfo(const FormItemInfo &info, const sptr<IRemoteObject> &callerToken, 747 const WantParams& wantParams, FormJsInfo &formInfo); 748 749 /** 750 * @brief Acquire form data from form provider. 751 * @param formId The Id of the form.. 752 * @param info Form configure info. 753 * @param wantParams WantParams of the request. 754 * @return Returns ERR_OK on success, others on failure. 755 */ 756 ErrCode AcquireProviderFormInfoAsync(const int64_t formId, const FormItemInfo &info, const WantParams &wantParams); 757 758 ErrCode InnerAcquireProviderFormInfoAsync(const int64_t formId, 759 const FormItemInfo &info, const WantParams &wantParams); 760 761 /** 762 * @brief Handle release form. 763 * @param formId The form id. 764 * @param callerToken Caller ability token. 765 * @return Returns ERR_OK on success, others on failure. 766 */ 767 ErrCode HandleReleaseForm(const int64_t formId, const sptr<IRemoteObject> &callerToken); 768 769 /** 770 * @brief Handle delete form. 771 * @param formId The form id. 772 * @param callerToken Caller ability token. 773 * @return Returns ERR_OK on success, others on failure. 774 */ 775 ErrCode HandleDeleteForm(const int64_t formId, const sptr<IRemoteObject> &callerToken); 776 777 /** 778 * @brief Handle delete temp form. 779 * @param formId The form id. 780 * @param callerToken Caller ability token. 781 * @return Returns ERR_OK on success, others on failure. 782 */ 783 ErrCode HandleDeleteTempForm(const int64_t formId, const sptr<IRemoteObject> &callerToken); 784 785 /** 786 * @brief Handle delete form storage. 787 * @param dbRecord Form storage information. 788 * @param uid calling user id. 789 * @param formId The form id. 790 * @return Function result and has other host flag. 791 */ 792 ErrCode HandleDeleteFormCache(FormRecord &dbRecord, const int uid, const int64_t formId); 793 794 /** 795 * @brief Add existed form record. 796 * @param info Form configure info. 797 * @param callerToken Caller ability token. 798 * @param record Form data. 799 * @param formId The form id. 800 * @param wantParams WantParams of the request. 801 * @param formInfo Form info for form host. 802 * @return Returns ERR_OK on success, others on failure. 803 */ 804 ErrCode AddExistFormRecord(const FormItemInfo &info, const sptr<IRemoteObject> &callerToken, 805 const FormRecord &record, const int64_t formId, const WantParams &wantParams, FormJsInfo &formInfo); 806 807 /** 808 * @brief Add new form record. 809 * @param info Form configure info. 810 * @param formId The form id. 811 * @param callerToken Caller ability token. 812 * @param wantParams WantParams of the request. 813 * @param formInfo Form info for form host. 814 * @return Returns ERR_OK on success, others on failure. 815 */ 816 ErrCode AddNewFormRecord(const FormItemInfo &info, const int64_t formId, 817 const sptr<IRemoteObject> &callerToken, const WantParams &wantParams, FormJsInfo &formInfo); 818 819 /** 820 * @brief Send event notify to form provider. The event notify type include FORM_VISIBLE and FORM_INVISIBLE. 821 * 822 * @param providerKey The provider key string which consists of the provider bundle name and ability name. 823 * @param formIdsByProvider The map of form Ids and their event type which have the same provider. 824 * @param formVisibleType The form visible type, including FORM_VISIBLE and FORM_INVISIBLE. 825 * @return Returns ERR_OK on success, others on failure. 826 */ 827 ErrCode HandleEventNotify(const std::string &providerKey, const std::vector<int64_t> &formIdsByProvider, 828 const int32_t formVisibleType); 829 830 /** 831 * @brief Increase the timer refresh count. 832 * 833 * @param formId The form id. 834 */ 835 void IncreaseTimerRefreshCount(const int64_t formId); 836 837 /** 838 * @brief handle update form flag. 839 * @param formIDs The id of the forms. 840 * @param callerToken Caller ability token. 841 * @param flag form flag. 842 * @param isOnlyEnableUpdate form enable update form flag. 843 * @return Returns ERR_OK on success, others on failure. 844 */ 845 ErrCode HandleUpdateFormFlag(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken, 846 bool flag, bool isOnlyEnableUpdate); 847 848 /** 849 * @brief check form cached. 850 * @param record Form information. 851 * @return Returns true on cached, false on not. 852 */ 853 bool IsFormCached(const FormRecord record); 854 855 /** 856 * @brief set next refresh time locked. 857 * @param formId The form's id. 858 * @param nextTime next refresh time. 859 * @param userId User ID. 860 * @return Returns ERR_OK on success, others on failure. 861 */ 862 int SetNextRefreshTimeLocked(const int64_t formId, const int64_t nextTime, const int32_t userId = 0); 863 864 /** 865 * @brief check if update is valid. 866 * @param formId The form's id. 867 * @param bundleName Provider ability bundleName. 868 * @return Returns true or false. 869 */ 870 bool IsUpdateValid(const int64_t formId, const std::string &bundleName); 871 /** 872 * @brief Handle cast temp form. 873 * @param formId The form id. 874 * @param record Form information. 875 * @return Returns ERR_OK on success, others on failure. 876 */ 877 ErrCode HandleCastTempForm(const int64_t formId, const FormRecord &record); 878 879 /** 880 * @brief Add form timer. 881 * @param formRecord Form information. 882 * @return Returns ERR_OK on success, others on failure. 883 */ 884 ErrCode AddFormTimer(const FormRecord &formRecord); 885 886 /** 887 * @brief Genera checking the publish form. 888 * @param want The want of the form to publish. 889 * @param bundleName BundleName 890 * @param needCheckFormPermission Indicates whether the app have system permissions.default value is true. 891 * @return Returns ERR_OK on success, others on failure. 892 */ 893 ErrCode CheckFormBundleName(Want &want, std::string &bundleName, bool needCheckFormPermission); 894 895 /** 896 * @brief check the publish form. 897 * @param want The want of the form to publish. 898 * @param needCheckFormPermission Indicates whether the app have system permissions.default value is true. 899 * @return Returns ERR_OK on success, others on failure. 900 */ 901 ErrCode CheckPublishForm(Want &want, bool needCheckFormPermission = true); 902 903 /** 904 * @brief Query the request host. 905 * @param want The want of the form to publish. 906 * @return Returns ERR_OK on success, others on failure. 907 */ 908 ErrCode QueryPublishFormToHost(Want &want); 909 910 /** 911 * @brief Post request publish form to host. 912 * @param want The want of the form to publish. 913 * @return Returns ERR_OK on success, others on failure. 914 */ 915 ErrCode RequestPublishFormToHost(Want &want); 916 917 /** 918 * @brief check request publish form want. 919 * @param want The want of the form to publish. 920 * @return Returns true if have snapshot info, others on none. 921 */ 922 bool CheckSnapshotWant(const Want &want); 923 924 /** 925 * @brief check the argv of AddRequestPublishForm. 926 * @param want The want of the form to add. 927 * @param formProviderWant The want of the form to publish from provider. 928 * @return Returns ERR_OK on success, others on failure. 929 */ 930 ErrCode CheckAddRequestPublishForm(const Want &want, const Want &formProviderWant); 931 932 /** 933 * @brief add request publish form. 934 * @param formItemInfo Form configure info. 935 * @param want The want of the form to add. 936 * @param callerToken Caller ability token. 937 * @param formJsInfo Return form info to form host. 938 * @return Returns ERR_OK on success, others on failure. 939 */ 940 ErrCode AddRequestPublishForm(const FormItemInfo &formItemInfo, const Want &want, 941 const sptr<IRemoteObject> &callerToken, FormJsInfo &formJsInfo); 942 943 /** 944 * @brief get bundleName. 945 * @param bundleName for output. 946 * @param needCheckFormPermission Indicates whether the app have system permissions.default value is true. 947 * @return Returns true on success, others on failure. 948 */ 949 bool GetBundleName(std::string &bundleName, bool needCheckFormPermission = true); 950 951 /** 952 * @brief Check if the form should update information to the host. 953 * 954 * @param matchedFormId The Id of the form 955 * @param userId User ID. 956 * @param callerToken Caller ability token. 957 * @param formRecord Form storage information 958 * @return Returns true on success, false on failure. 959 */ 960 bool isFormShouldUpdateProviderInfoToHost(const int64_t &matchedFormId, const int32_t &userId, 961 const sptr<IRemoteObject> &callerToken, FormRecord &formRecord); 962 963 /** 964 * @brief Update provider info to host 965 * 966 * @param matchedFormId The Id of the form 967 * @param userId User ID. 968 * @param callerToken Caller ability token. 969 * @param formVisibleType The form visible type, including FORM_VISIBLE and FORM_INVISIBLE. 970 * @param formRecord Form storage information 971 * @return Returns true on success, false on failure. 972 */ 973 bool UpdateProviderInfoToHost(const int64_t &matchedFormId, const int32_t &userId, 974 const sptr<IRemoteObject> &callerToken, const int32_t &formVisibleType, FormRecord &formRecord); 975 976 /** 977 * @brief if the ability have permission for keeping background running is true, 978 * @param iBundleMgr BundleManagerProxy 979 * @param bundleName BundleName 980 * @param userId UserId 981 * @return Returns true if the form provider is system app, false if not. 982 */ 983 bool CheckIsSystemAppByBundleName(const sptr<IBundleMgr> &iBundleMgr, 984 const int32_t &userId, const std::string &bundleName); 985 986 /** 987 * @brief if the ability have permission for keeping background running is true, 988 * @param iBundleMgr BundleManagerProxy 989 * @param bundleName BundleName 990 * @return Returns true if the ability have permission for keeping background running, false if not. 991 */ 992 bool CheckKeepBackgroundRunningPermission(const sptr<IBundleMgr> &iBundleMgr, const std::string &bundleName); 993 /** 994 * @brief Create eventMaps for event notify. 995 * 996 * @param matchedFormId The Id of the form 997 * @param formRecord Form storage information 998 * @param eventMaps eventMaps for event notify 999 * @return Returns true on success, false on failure. 1000 */ 1001 bool CreateHandleEventMap(const int64_t matchedFormId, const FormRecord &formRecord, 1002 std::map<std::string, std::vector<int64_t>> &eventMaps); 1003 /** 1004 * @brief Get current user ID. 1005 * @param callingUid calling Uid. 1006 * @return Returns user ID. 1007 */ 1008 int32_t GetCurrentUserId(const int callingUid); 1009 /** 1010 * @brief AcquireFormState want check. 1011 * @param bundleName The bundle name of the form. 1012 * @param abilityName The ability name of the form. 1013 * @param want The want of the form. 1014 * @param provider the provider info. 1015 * @return Returns ERR_OK on success, others on failure. 1016 */ 1017 ErrCode AcquireFormStateCheck(const std::string &bundleName, const std::string &abilityName, const Want &want, 1018 std::string &provider); 1019 /** 1020 * @brief check if the form host is system app 1021 * @param formRecord Form storage information 1022 * @return Returns true if the form host is system app, false if not. 1023 */ 1024 bool checkFormHostHasSaUid(const FormRecord &formRecord); 1025 1026 /** 1027 * @brief Check whether the caller for publish form is in the whitelist. 1028 * @param iBundleMgr BundleManagerProxy 1029 * @param bundleName BundleName of caller 1030 * @param want want of target form 1031 * @param needCheckFormPermission Indicates whether the app have system permissions.default value is true. 1032 * @return Returns true if the caller is in the whitelist, others if not. 1033 */ 1034 bool IsValidPublishEvent(const sptr<IBundleMgr> &iBundleMgr, const std::string &bundleName, const Want &want, 1035 bool needCheckFormPermission = true); 1036 1037 /** 1038 * @brief Allocate form by specific Id. 1039 * @param info Form configure info. 1040 * @param callerToken Caller ability token. 1041 * @param wantParams WantParams of the request. 1042 * @param formInfo Form info for form host. 1043 * @return Returns ERR_OK on success, others on failure. 1044 */ 1045 ErrCode AllotFormBySpecificId(const FormItemInfo &info, 1046 const sptr<IRemoteObject> &callerToken, const WantParams &wantParams, FormJsInfo &formInfo); 1047 1048 /** 1049 * @brief when form observer died clean the resource. 1050 * @param remote remote object. 1051 */ 1052 void CleanResource(const wptr<IRemoteObject> &remote); 1053 1054 /** 1055 * @brief Set value of deathRecipient_. 1056 * @param callerToken Caller ability token. 1057 * @param deathRecipient DeathRecipient object. 1058 */ 1059 void SetDeathRecipient(const sptr<IRemoteObject> &callerToken, 1060 const sptr<IRemoteObject::DeathRecipient> &deathRecipient); 1061 mutable std::mutex formObserversMutex_; 1062 mutable std::mutex deathRecipientsMutex_; 1063 std::map<std::string, std::vector<sptr<IRemoteObject>>> formObservers_; 1064 std::map<sptr<IRemoteObject>, sptr<IRemoteObject::DeathRecipient>> deathRecipients_; 1065 1066 void NotifyFormClickEvent(int64_t formId, const std::string &formClickType); 1067 1068 /** 1069 * @brief Get caller type. 1070 * @param bundleName the caller's bundle name. 1071 */ 1072 int32_t GetCallerType(std::string bundleName); 1073 1074 /** 1075 * @brief Check if the form is allow to publish. 1076 * @param bundleName the caller's bundle name. 1077 * @param wants Wants of the request. 1078 */ 1079 bool IsErmsSupportPublishForm(std::string bundleName, std::vector<Want> wants); 1080 1081 /** 1082 * @brief Check if the caller is formRenderService. 1083 * @param callingUid the caller's Uid. 1084 * @return Returns true if the caller is formRenderService, false if not. 1085 */ 1086 bool IsFormRenderServiceCall(int callingUid); 1087 1088 /** 1089 * @brief Notify forms visible/invisible to remoteCallers. 1090 * @param bundleName the caller's bundle name. 1091 * @param remoteObjects refs of remoteCallers. 1092 * @param formInstanceMaps formInstances for visibleNotify. 1093 * @param formVisibleType The form visible type, including FORM_VISIBLE and FORM_INVISIBLE. 1094 */ 1095 void NotifyWhetherFormsVisible(const std::string &bundleName, 1096 std::vector<sptr<IRemoteObject>> &remoteObjects, 1097 std::map<std::string, std::vector<FormInstance>> &formInstanceMaps, const int32_t formVisibleType); 1098 1099 /** 1100 * @brief Forms formInstanceMaps or eventMaps should remove when visible/invisible status recovered. 1101 * @param formInstanceMaps formInstances for visibleNotify. 1102 * @param eventMaps eventMaps for event notify. 1103 * @param formVisibleType The form visible type, including FORM_VISIBLE and FORM_INVISIBLE. 1104 */ 1105 void FilterDataByVisibleType(std::map<std::string, std::vector<FormInstance>> &formInstanceMaps, 1106 std::map<std::string, std::vector<int64_t>> &eventMaps, const int32_t formVisibleType); 1107 1108 /** 1109 * @brief Forms formInstanceMaps should remove when visible/invisible status recovered. 1110 * @param formInstanceMaps formInstances for visibleNotify. 1111 * @param formVisibleType The form visible type, including FORM_VISIBLE and FORM_INVISIBLE. 1112 * @param restoreFormRecords formRecords of forms no need to notify. 1113 */ 1114 void FilterFormInstanceMapsByVisibleType(std::map<std::string, std::vector<FormInstance>> &formInstanceMaps, 1115 const int32_t formVisibleType, std::map<int64_t, FormRecord> &restoreFormRecords); 1116 1117 /** 1118 * @brief Forms eventMaps should remove when visible/invisible status recovered. 1119 * @param eventMaps eventMaps for event notify. 1120 * @param formVisibleType The form visible type, including FORM_VISIBLE and FORM_INVISIBLE. 1121 * @param restoreFormRecords formRecords of forms no need to notify. 1122 */ 1123 void FilterEventMapsByVisibleType(std::map<std::string, std::vector<int64_t>> &eventMaps, 1124 const int32_t formVisibleType, std::map<int64_t, FormRecord> &restoreFormRecords); 1125 1126 ErrCode CheckFormCountLimit(const int64_t formId, const Want &want); 1127 1128 ErrCode AllotForm(const int64_t formId, const Want &want, 1129 const sptr<IRemoteObject> &callerToken, FormJsInfo &formInfo, const FormItemInfo &formItemInfo); 1130 1131 void GetUpdateDurationFromAdditionalInfo(const std::string &additionalInfo, std::vector<int> &durationArray) const; 1132 1133 void IncreaseAddFormRequestTimeOutTask(const int64_t formId); 1134 1135 void CancelAddFormRequestTimeOutTask(const int64_t formId, const int result); 1136 1137 ErrCode CheckAddFormTaskTimeoutOrFailed(const int64_t formId, AddFormResultErrorCode &formStates); 1138 1139 void RemoveFormIdMapElement(const int64_t formId); 1140 1141 void UpdateReUpdateFormMap(const int64_t formId); 1142 1143 void SetReUpdateFormMap(const int64_t formId); 1144 1145 ErrCode UpdateTimer(const int64_t formId, const FormRecord &record); 1146 /** 1147 * @class ClientDeathRecipient 1148 * notices IRemoteBroker died. 1149 */ 1150 class ClientDeathRecipient : public IRemoteObject::DeathRecipient { 1151 public: 1152 /** 1153 * @brief Constructor 1154 */ 1155 ClientDeathRecipient() = default; 1156 virtual ~ClientDeathRecipient() = default; 1157 /** 1158 * @brief handle remote object died event. 1159 * @param remote remote object. 1160 */ 1161 void OnRemoteDied(const wptr<IRemoteObject> &remote) override; 1162 }; 1163 1164 private: 1165 sptr<IFormPublishInterceptor> formPublishInterceptor_ = nullptr; 1166 int32_t visibleNotifyDelay_ = Constants::DEFAULT_VISIBLE_NOTIFY_DELAY; 1167 std::map<int64_t, AddFormResultErrorCode> formIdMap_; 1168 std::shared_ptr<FormSerialQueue> serialQueue_ = nullptr; 1169 std::mutex formResultMutex_; 1170 std::condition_variable condition_; 1171 #ifdef THEME_MGR_ENABLE 1172 /** 1173 * @brief Fill ThemeFormInfo with want and formId 1174 * @param formId Indicates the id of form. 1175 * @param themeFormInfo Info of theme form defined by ThemeManager. 1176 * @param want The want of form. 1177 */ 1178 void FillThemeFormInfo(const Want &want, ThemeManager::ThemeFormInfo &themeFormInfo, int64_t formId); 1179 1180 /** 1181 * @brief Call ThemeManager to delete form and clear record in database. 1182 * @param formId Indicates the id of form. 1183 * @return Returns ERR_OK on success, others on failure. 1184 */ 1185 int DeleteThemeForm(const int64_t formId); 1186 1187 /** 1188 * @brief Add theme form record in database. 1189 * @param want The want of form. 1190 * @param formId Indicates the id of form. 1191 * @return Returns ERR_OK on success, others on failure. 1192 */ 1193 int AddThemeDBRecord(const Want &want, int64_t formId); 1194 1195 /** 1196 * @brief Allot theme form record in FormDataMgr. 1197 * @param want The want of form. 1198 * @param formId Indicates the id of form. 1199 * @return Returns formrecord created. 1200 */ 1201 FormRecord AllotThemeRecord(const Want &want, int64_t formId); 1202 #endif 1203 1204 /** 1205 * @brief Delete common forms with formId. 1206 * @param formId Indicates the id of form. 1207 * @param callerToken Caller ability token. 1208 * @return Returns ERR_OK on success, others on failure. 1209 */ 1210 int DeleteCommonForm(const int64_t formId, const sptr<IRemoteObject> &callerToken); 1211 1212 void CheckUpdateFormRecord(const int64_t formId, const FormItemInfo &info, FormRecord &record); 1213 1214 void SetVisibleChange(const int64_t formId, const int32_t formVisibleType); 1215 1216 std::mutex reUpdateFormMapMutex_; 1217 std::unordered_map<int64_t, std::pair<int64_t, bool>> reUpdateFormMap_; 1218 }; 1219 } // namespace AppExecFwk 1220 } // namespace OHOS 1221 1222 #endif // OHOS_FORM_FWK_FORM_MGR_ADAPTER_H 1223