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