/* * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_FORM_FWK_FORM_FORM_DATA_MGR_H #define OHOS_FORM_FWK_FORM_FORM_DATA_MGR_H #include #include #include #include #include #include "bundle_pack_info.h" #include "form_constants.h" #include "form_host_record.h" #include "form_id_key.h" #include "form_info.h" #include "form_instance.h" #include "form_instances_filter.h" #include "form_item_info.h" #include "form_js_info.h" #include "form_record.h" #include "form_state_info.h" #include "iremote_object.h" #include "libxml/parser.h" #include "libxml/tree.h" #include "running_form_info.h" namespace OHOS { namespace AppExecFwk { using Want = AAFwk::Want; /** * @class FormDataMgr * form data manager. */ class FormDataMgr final : public DelayedRefSingleton { DECLARE_DELAYED_REF_SINGLETON(FormDataMgr) public: DISALLOW_COPY_AND_MOVE(FormDataMgr); /** * @brief Allot form info by item info. * @param formInfo Form item info. * @param callingUid The UID of the proxy. * @param userId User ID. * @return Returns form record. */ FormRecord AllotFormRecord(const FormItemInfo &formInfo, const int callingUid, const int32_t userId = Constants::DEFAULT_USER_ID); /** * @brief Create form js info by form record. * @param formId The Id of the form. * @param record Form record. * @param formInfo Js info. */ void CreateFormJsInfo(const int64_t formId, const FormRecord &record, FormJsInfo &formInfo); /** * @brief Delete form js info by form record. * @param formId The Id of the form. * @return Returns true if this function is successfully called; returns false otherwise. */ bool DeleteFormRecord(const int64_t formId); /** * @brief Clean removed forms for host. * @param removedFormIds The id list of the forms. */ void CleanHostRemovedForms(const std::vector &removedFormIds); /** * @brief Allot form host record by caller token. * @param info The form item info. * @param callerToken callerToken * @param formId The Id of the form. * @param callingUid The UID of the proxy. * @return Returns true if this function is successfully called; returns false otherwise. */ bool AllotFormHostRecord(const FormItemInfo &info, const sptr &callerToken, const int64_t formId, const int callingUid); /** * @brief Check temp form count is max. * @return Returns ERR_OK if the temp form not reached; returns ERR_MAX_SYSTEM_TEMP_FORMS is reached. */ int CheckTempEnoughForm() const; /** * @brief Check form count is max. * @param currentUserId The current userId. * @param callingUid The UID of the proxy. * @return Returns true if this function is successfully called; returns false otherwise. */ int CheckEnoughForm(const int callingUid, const int32_t currentUserId = Constants::DEFAULT_USER_ID) const; /** * @brief Delete temp form. * @param formId The Id of the form. * @return Returns true if this function is successfully called; returns false otherwise. */ bool DeleteTempForm(const int64_t formId); /** * @brief Check temp form is exist. * @param formId The Id of the form. * @return Returns true if the temp form is exist; returns false is not exist. */ bool ExistTempForm(const int64_t formId) const; /** * @brief Modify form temp flag by formId. * @param formId The Id of the form. * @param formTempFlag The form temp flag. * @return Returns true if this function is successfully called; returns false otherwise. */ bool ModifyFormTempFlag(const int64_t formId, const bool formTempFlag); /** * @brief Add form user uid from form record. * @param formId The Id of the form. * @param formUserUid The form user uid. * @return Returns true if this function is successfully called; returns false otherwise. */ bool AddFormUserUid(const int64_t formId, const int formUserUid); /** * @brief Delete form user uid from form record. * @param formId The Id of the form. * @param uid calling user id. * @return Returns true if this function is successfully called; returns false otherwise. */ bool DeleteFormUserUid(const int64_t formId, const int uid); /** * @brief Update form record. * @param formId The Id of the form. * @param formRecord The form record. * @return Returns true if this function is successfully called; returns false otherwise. */ bool UpdateFormRecord(const int64_t formId, const FormRecord &formRecord); /** * @brief Get form record. * @param formId The Id of the form. * @param formRecord The form record. * @return Returns true if this function is successfully called; returns false otherwise. */ bool GetFormRecord(const int64_t formId, FormRecord &formRecord) const; /** * @brief Get form record. * @param bundleName Bundle name. * @param formInfos The form record list. * @return Returns true if this function is successfully called; returns false otherwise. */ bool GetFormRecord(const std::string &bundleName, std::vector &formInfos, int32_t userId = Constants::INVALID_USER_ID) const; /** * @brief Get temporary form record. * @param formTempRecords The temp form record. * @return Returns true if this function is successfully called; returns false otherwise. */ bool GetTempFormRecord(std::vector &formTempRecords); /** * @brief Check form record is exist. * @param formId The Id of the form. * @return Returns true if the form record is exist; returns false is not exist. */ bool ExistFormRecord(const int64_t formId) const; /** * @brief Has form user uids in form record. * @param formId The Id of the form. * @return Returns true if this form has form user uids; returns false is not has. */ bool HasFormUserUids(const int64_t formId) const; /** * @brief Get form host record. * @param formId The id of the form. * @param formHostRecords The form host records. */ void GetFormHostRecord(const int64_t formId, std::vector &formHostRecords) const; /** * @brief Get form host remote object. * @param formId The id of the form. * @param formHostObjs The form host remote object. */ void GetFormHostRemoteObj(const int64_t formId, std::vector> &formHostObjs) const; /** * @brief Delete form host record. * @param callerToken The client stub of the form host record. * @param formId The id of the form. * @return Returns true if this function is successfully called; returns false otherwise. */ bool DeleteHostRecord(const sptr &callerToken, const int64_t formId); /** * @brief Handle form host died. * @param remoteHost Form host proxy object. */ void HandleHostDied(const sptr &remoteHost); /** * @brief Refresh enable or not. * @param formId The Id of the form. * @return true on enable, false on disable. */ bool IsEnableRefresh(int64_t formId); /** * @brief update enable or not. * @param formId The Id of the form. * @return true on enable, false on disable. */ bool IsEnableUpdate(int64_t formId); /** * @brief Check calling uid is valid. * @param formUserUids The form user uids. * @return Returns true if this user uid is valid; returns false otherwise. */ bool IsCallingUidValid(const std::vector &formUserUids) const; /** * @brief Generate udid. * @return Returns true if this function is successfully called; returns false otherwise. */ bool GenerateUdidHash(); /** * @brief Padding udid hash. * @param formId The form id. * @return Padded form id. */ int64_t PaddingUdidHash(int64_t formId); /** * @brief Generate form id. * @return form id. */ int64_t GenerateFormId(); /** * @brief Get udid. * @return udid. */ int64_t GetUdidHash() const; /** * @brief Set udid. * @param udidHash udid. */ void SetUdidHash(const int64_t udidHash); /** * @brief Get the matched form host record by client stub. * * @param callerToken The client stub of the form host record. * @param formHostRecord The form host record. * @return Returns true if this function is successfully called, returns false otherwise. */ bool GetMatchedHostClient(const sptr &callerToken, FormHostRecord &formHostRecord) const; /** * @brief Set needRefresh for FormRecord. * @param formId The Id of the form. * @param needRefresh true or false. */ void SetNeedRefresh(const int64_t formId, const bool needRefresh); /** * @brief Set needAddForm for FormRecord. * @param formId The Id of the form. * @param needAddForm true or false. */ void SetNeedAddForm(const int64_t formId, const bool needAddForm); /** * @brief Set isCountTimerRefresh for FormRecord. * @param formId The Id of the form. * @param countTimerRefresh true or false. */ void SetCountTimerRefresh(const int64_t formId, const bool countTimerRefresh); /** * @brief Set timerRefresh for FormRecord. * @param formId The Id of the form. * @param timerRefresh true or false. */ void SetTimerRefresh(const int64_t formId, const bool timerRefresh); /** * @brief Get updated form info. * @param record FormRecord. * @param targetForms Target forms. * @param updatedForm Updated form info. * @return Returns true on success, false on failure. */ bool GetUpdatedForm(const FormRecord &record, const std::vector &targetForms, FormInfo &updatedForm); /** * @brief Set isEnableUpdate for FormRecord. * @param formId The Id of the form. * @param enableUpdate true or false. */ void SetEnableUpdate(const int64_t formId, const bool enableUpdate); /** * @brief Set update info for FormRecord. * @param formId The Id of the form. * @param enableUpdate true or false. * @param updateDuration Update duration. * @param updateAtHour Update at hour. * @param updateAtMin Update at minute. */ void SetUpdateInfo(const int64_t formId, const bool enableUpdate, const long updateDuration, const int updateAtHour, const int updateAtMin); /** * @brief Clean removed form records. * @param bundleName BundleName. * @param removedForms The id list of the forms. */ void CleanRemovedFormRecords(const std::string &bundleName, std::set &removedForms); /** * @brief Clean removed temp form records. * @param bundleName BundleName. * @param removedForms The id list of the forms. */ void CleanRemovedTempFormRecords(const std::string &bundleName, const int32_t userId, std::set &removedForms); /** * @brief Get recreate form records. * @param reCreateForms The id list of the forms. */ void GetReCreateFormRecordsByBundleName(const std::string &bundleName, std::set &reCreateForms); /** * @brief Set form isInited = true. * @param formId The Id of the form. * @param isInited isInited property */ void SetFormCacheInited(const int64_t formId, const bool isInited); /** * @brief Set versionUpgrade. * @param formId The Id of the form. * @param versionUpgrade true or false */ void SetVersionUpgrade(const int64_t formId, const bool versionUpgrade); /** * @brief Update form for host clients. * @param formId The Id of the form. * @param needRefresh true or false */ void UpdateHostNeedRefresh(const int64_t formId, const bool needRefresh); /** * @brief Update form for host clients. * @param formId The Id of the form. * @param formRecord The form info. * @return Returns true if form update, false if other. */ bool UpdateHostForm(const int64_t formId, const FormRecord &formRecord); /** * @brief handle update form flag. * @param formIDs The id of the forms. * @param callerToken Caller ability token. * @param flag form flag. * @param isOnlyEnableUpdate form enable update form flag. * @param refreshForms Refresh forms * @return Returns ERR_OK on success, others on failure. */ ErrCode UpdateHostFormFlag(const std::vector &formIds, const sptr &callerToken, bool flag, bool isOnlyEnableUpdate, std::vector &refreshForms); /** * @brief Find matched form id. * @param formId The form id. * @return Matched form id. */ int64_t FindMatchedFormId(const int64_t formId); /** * @brief Clear host data by uId. * @param uId The caller uId. */ void ClearHostDataByUId(const int uId); /** * @brief Get no host temp forms. * @param uid The caller uid. * @param noHostTempFormsMap no host temp forms. * @param foundFormsMap Form Id list. */ void GetNoHostTempForms(const int uid, std::map> &noHostTempFormsMap, std::map &foundFormsMap); /** * @brief delete forms by userId. * * @param userId user ID. * @param removedFormIds removed userId. */ void DeleteFormsByUserId(const int32_t userId, std::vector &removedFormIds); /** * @brief Clear form records for st limit value test. */ void ClearFormRecords(); /** * @brief handle get no host invalid temp forms. * @param userId User ID. * @param callingUid The UID of the proxy. * @param matchedFormIds The set of the valid forms. * @param noHostTempFormsMap The map of the no host forms. * @param foundFormsMap The map of the found forms. */ void GetNoHostInvalidTempForms(int32_t userId, int32_t callingUid, std::set &matchedFormIds, std::map> &noHostTempFormsMap, std::map &foundFormsMap); /** * @brief handle delete no host temp forms. * @param callingUid The UID of the proxy. * @param noHostTempFormsMap The map of the no host forms. * @param foundFormsMap The map of the found forms. */ void BatchDeleteNoHostTempForms(int32_t callingUid, std::map> &noHostTempFormsMap, std::map &foundFormsMap); /** * @brief delete invalid temp forms. * @param userId User ID. * @param callingUid The UID of the proxy. * @param matchedFormIds The set of the valid forms. * @param removedFormsMap The map of the removed invalid forms. * @return Returns ERR_OK on success, others on failure. */ int32_t DeleteInvalidTempForms(int32_t userId, int32_t callingUid, std::set &matchedFormIds, std::map &removedFormsMap); /** * @brief clear host data by invalid forms. * @param callingUid The UID of the proxy. * @param removedFormsMap The map of the removed invalid forms. * @return Returns ERR_OK on success, others on failure. */ int32_t ClearHostDataByInvalidForms(int32_t callingUid, std::map &removedFormsMap); /** * @brief delete publish forms temp data * @param userId User ID. * @param bundleName BundleName. * @param validFormIds The set of the valid forms. * @return Returns - */ void DeleteInvalidPublishForms(int32_t userId, std::string bundleName, std::set &validFormIds); /** * @brief Create form acquire data host record. * @param requestCode The request code of this acquire form. * @param info The form item info. * @param callerToken Caller ability token. * @param callingUid The UID of the proxy. * @return Returns true if this function is successfully called; returns false otherwise. */ bool CreateFormAcquireDataRecord(int64_t requestCode, const FormItemInfo &info, const sptr &callerToken, int callingUid); /** * @brief Create form state host record. * @param provider The provider of the form state * @param info The form item info. * @param callerToken The UID of the proxy. * @param callingUid The UID of the proxy. * @return Returns true if this function is successfully called; returns false otherwise. */ bool CreateFormStateRecord(std::string &provider, const FormItemInfo &info, const sptr &callerToken, int callingUid); /** * @brief acquire form state callback. * @param state form state. * @param provider provider info. * @param want The want of onAcquireFormState. * @return Returns true if this function is successfully called; returns false otherwise. */ ErrCode AcquireFormStateBack(AppExecFwk::FormState state, const std::string &provider, const Want &want); /** * @brief acquire form data callback. * @param wantParams Indicates the data information acquired by the form. * @param requestCode Indicates the requested id. * @return Returns true if this function is successfully called; returns false otherwise. */ ErrCode AcquireFormDataBack(const AAFwk::WantParams &wantParams, int64_t requestCode); /** * @brief Notify the form is visible or not. * @param formIds Indicates the ID of the forms. * @param isVisible Visible or not. * @param callerToken Host client. * @return Returns ERR_OK on success, others on failure. */ ErrCode NotifyFormsVisible(const std::vector &formIds, bool isVisible, const sptr &callerToken); /** * @brief set form record visible. * @param matchedFormId form id. * @param isVisible is visible. * @return Returns true if this function is successfully called; returns false otherwise. */ ErrCode SetRecordVisible(int64_t matchedFormId, bool isVisible); /** * @brief add request publish form info. * @param formId The form id of the form to publish. * @param want The want of the form to publish. * @param formProviderData The form data. * @return Returns ERR_OK on success, others on failure. */ ErrCode AddRequestPublishFormInfo(int64_t formId, const Want &want, std::unique_ptr &formProviderData); /** * @brief remove request publish form info. * @param formId The form id of the form to publish. * @return Returns true if this function is successfully called; returns false otherwise. */ ErrCode RemoveRequestPublishFormInfo(int64_t formId); /** * @brief check whether request publish form info. * @param formId The form id of the form to publish. * @return Returns true if this function is successfully called; returns false otherwise. */ bool IsRequestPublishForm(int64_t formId); /** * @brief get request publish form info. * @param formId The form id of the form to publish. * @param want The want of the form to publish. * @param formProviderData The form data. * @return Returns true if this function is successfully called; returns false otherwise. */ ErrCode GetRequestPublishFormInfo(int64_t formId, Want &want, std::unique_ptr &formProviderData); /** * @brief Get updated form info. * @param record Indicates the form record. * @param bundlePackInfo Indicates the BundlePackInfo object. * @param abilityFormInfo Indicates the obtained abilityFormInfo object. * @return Returns true on success, false on failure. */ bool GetPackageForm(const FormRecord &record, const BundlePackInfo &bundlePackInfo, AbilityFormInfo &abilityFormInfo); /** * @brief Set form free install flag. * @param formId Indicates the form ID. * @param isNeedFreeInstall Indicates the free install flag is true or false. * @return Returns true on success, false on failure. */ bool SetRecordNeedFreeInstall(int64_t formId, bool isNeedFreeInstall); /** * @brief StopRenderingForm. * @param formId The form id. */ void StopRenderingForm(int32_t formId); /** * @brief update host forms * @param updateFormIds */ void UpdateHostForms(const std::vector &updateFormIds); /** * @brief Checks that the form is valid. * @param formId Indicates the form ID. * @return Returns ERR_OK on success, others on failure. */ ErrCode CheckInvalidForm(const int64_t formId); /** * @brief get cast forms count. * @param formCount Returns the number of the cast form. * @return Return the cast forms number. */ int32_t GetCastFormsCount(int32_t &formCount); /** * @brief get temp forms count. * @param formCount Returns the number of the temp form. * @return Return the temp forms number. */ int32_t GetTempFormsCount(int32_t &formCount); /** * @brief get host forms count. * @param bundleName Indicates form host bundleName. * @param formCount Returns the number of the host form. * @return Return the host forms number. */ int32_t GetHostFormsCount(const std::string &bundleName, int32_t &formCount); /** * @brief handle form add observer. * @param hostBundleName the bundle name of form host. * @param formId Indicates the form ID. * @return Returns ERR_OK on success, others on failure. */ ErrCode HandleFormAddObserver(const std::string hostBundleName, const int64_t formId); /** * @brief handle form add observer. * @param hostBundleName the bundle name of form host. * @param runningFormInfo the running forms' infos of the specify application name. * @return Returns ERR_OK on success, others on failure. */ ErrCode HandleFormRemoveObserver(const std::string hostBundleName, const RunningFormInfo runningFormInfo); /** * @brief Get the running form infos by form id. * @param formId Indicates the form ID. * @param runningFormInfos Return the running forms' infos of the specify application name. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetRunningFormInfosByFormId(const int64_t formId, RunningFormInfo &runningFormInfo); /** * @brief Get all running form infos. * @param isUnusedIncluded Indicates whether to include unused forms. * @param runningFormInfos Return the running forms' infos currently. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetRunningFormInfos(bool isUnusedIncluded, std::vector &runningFormInfos); /** * @brief Get the running form infos by bundle name. * @param bundleName Application name. * @param isUnusedIncluded Indicates whether to include unused forms. * @param runningFormInfos Return the running forms' infos of the specify application name. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetRunningFormInfosByBundleName( const std::string &bundleName, bool isUnusedIncluded, std::vector &runningFormInfos); /** * @brief Get form instances by filter info. * @param formInstancesFilter includes bundleName, moduleName, formName, abilityName to get formInstances. * @param formInstances return formInstances * @return return ERR_OK on get info success,other on failure. */ ErrCode GetFormInstancesByFilter(const FormInstancesFilter &formInstancesFilter, std::vector &formInstances); /** * @brief Get form instance by formId. * @param formId formId Indicates the unique id of form. * @param formInstance return formInstance * @return return ERR_OK on get info success, others on failure. */ ErrCode GetFormInstanceById(const int64_t formId, FormInstance &formInstances); /** * @brief Get form instance by formId, include form store in DB. * @param formId formId Indicates the unique id of form. * @param isUnusedIncluded Indicates whether to include unused forms. * @param formInstance return formInstance * @return return ERR_OK on get info success, others on failure. */ ErrCode GetFormInstanceById(const int64_t formId, bool isUnusedIncluded, FormInstance &formInstances); /** * @brief Set form config map. * @param configMap form config map. */ void SetConfigMap(const std::map &configMap); /** * @brief Get form config param form map. * @param key the param's name. * @param value the return value. */ void GetConfigParamFormMap(const std::string &key, int32_t &value) const; /** * @brief Recycle all recyclable forms. */ void RecycleAllRecyclableForms() const; /** * @brief Recycle forms. * @param formIds Indicates the ID of the forms. * @param callingUid The uid of caller. * @param want The want of forms to be recycled. */ void RecycleForms(const std::vector &formIds, const int &callingUid, const Want &want) const; /** * @brief Update the form cloud update duration by bundleName. * @param bundleName The specified bundleName. * @param duration The form cloud update duration. */ void UpdateFormCloudUpdateDuration(const std::string &bundleName, int duration); /** * @brief Remove the form cloud update duration by bundleName. * @param bundleName The specified bundleName. */ void RemoveFormCloudUpdateDuration(const std::string &bundleName); /** * @brief Get the form cloud update duration by bundleName. * @param bundleName The specified bundleName. */ int GetFormCloudUpdateDuration(const std::string &bundleName) const; /** * @brief Determine if the form cloud update duration exists by bundleName. * @param bundleName The specified bundleName. */ bool HasFormCloudUpdateDuration(const std::string &bundleName) const; /** * @brief Update form location. * @param formId The Id of the form. * @param formLocation The form location. * @param hostBundleName the bundle name of form host. * @return Returns ERR_OK on success, others on failure. */ ErrCode UpdateFormLocation(const int64_t &formId, const int32_t &formLocation); /** * @brief Get the formRecords by refreshType. * @param formRefreshType form refresh type. * @param visibleFormRecords Return the visible forms' infos need to refresh. * @param invisibleFormRecords Return the invisible forms' infos need to refresh. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetRecordsByFormType(const int32_t formRefreshType, std::vector &visibleFormRecords, std::vector &invisibleFormRecords); /** * @brief Set form enable or disable. * @param formId The Id of the form. * @param enable Ture or false. */ ErrCode SetFormEnable(const int64_t formId, const bool enable); /** * @brief Set form refresh flag or in disable during. * @param formId The Id of the form. * @param enable Ture or false. */ ErrCode SetRefreshDuringDisableForm(const int64_t formId, const bool enable); /** * @brief Set form update flag or in disable during. * @param formId The Id of the form. * @param enable Ture or false. */ ErrCode SetUpdateDuringDisableForm(const int64_t formId, const bool enable); /** * @brief Enable forms style. * @param formRecords The Id list of the formRecord. * @param enable True is enable form, false is disable form. */ void EnableForms(const std::vector &&formRecords, const bool enable); /** * @brief Get all formIds by userId. * @param userId User ID. * @param formIds The list of formId. */ void GetFormIdsByUserId(int32_t userId, std::vector &formIds); /** * @brief Recheck whether need clean form host. * @param callerToken The client stub of the form host record. */ bool RecheckWhetherNeedCleanFormHost(const sptr &callerToken); private: /** * @brief Create form record. * @param formInfo The form item info. * @param callingUid The UID of the proxy. * @param userId User ID. * @return Form record. */ FormRecord CreateFormRecord(const FormItemInfo &formInfo, const int callingUid, const int32_t userId = Constants::DEFAULT_USER_ID) const; /** * @brief Create host record. * @param info The form item info. * @param callerToken The UID of the proxy. * @param callingUid The UID of the proxy. * @param record The form host record. * @return Returns true if this function is successfully called; returns false otherwise. */ bool CreateHostRecord(const FormItemInfo &info, const sptr &callerToken, const int callingUid, FormHostRecord &record); /** * @brief Parse update config. * @param record The form record. * @param info The form item info. * @return None. */ void ParseUpdateConfig(FormRecord &record, const FormItemInfo &info) const; /** * @brief Parse update interval config. * @param record The form record. * @param configDuration interval duration. */ void ParseIntervalConfig(FormRecord &record, const int configDuration) const; /** * @brief Parse at time config. * @param record The form record. * @param info form item info. */ void ParseAtTimerConfig(FormRecord &record, const FormItemInfo &info) const; /** * @brief Get the temp forms from host and delete temp form in cache. * @param record The form record. * @param recordTempForms the temp forms. */ void HandleHostDiedForTempForms(const FormHostRecord &record, std::vector &recordTempForms); /** * @brief Check if two forms is same or not. * @param record FormRecord. * @param formInfo FormInfo. * @return Returns true on success, false on failure. */ bool IsSameForm(const FormRecord &record, const FormInfo &formInfo); /** * @brief Check if two forms is same or not. * @param record Indicates the form record. * @param abilityFormInfo Indicates the AbilityFormInfo. * @return Returns true on success, false on failure. */ bool IsSameForm(const FormRecord &record, const AbilityFormInfo &abilityFormInfo); /** * @brief check if form cached. * @param record The form record. * @return Returns ERR_OK on cached, others on not cached. */ bool IsFormCached(const FormRecord record); /** * @brief handle update form flag. * @param formIDs The id of the forms. * @param flag form flag. * @param isOnlyEnableUpdate form enable update form flag. * @param formHostRecord form host record. * @param refreshForms Refresh forms * @return Returns ERR_OK on success, others on failure. */ ErrCode HandleUpdateHostFormFlag(const std::vector &formIds, bool flag, bool isOnlyEnableUpdate, FormHostRecord &formHostRecord, std::vector &refreshForms); /** * @brief Fill the basic running form info by form record. * @param formRecord The form record. * @param runningFormInfo Return the running forms' info. */ void FillBasicRunningFormInfoByFormRecord(const FormRecord &formRecord, RunningFormInfo &runningFormInfo); /** * @brief Get ability form info. * @param record Indicates form record. * @param abilities Indicates the ModuleAbilityInfo in FA model or ExtensionAbilities in stage model. * @param abilityFormInfo Indicates the obtained abilityFormInfo object. * @return Returns ERR_OK on success, others on failure. */ template bool GetAbilityFormInfo(const FormRecord &record, const std::vector &abilities, AbilityFormInfo &abilityFormInfo); private: void GetUnusedFormInstancesByFilter( const FormInstancesFilter &formInstancesFilter, std::vector &formInstances); ErrCode GetUnusedFormInstanceById(const int64_t formId, FormInstance &formInstance); void GetUnusedFormInfos(std::vector &runningFormInfos); void GetUnusedFormInfos(const std::string &bundleName, std::vector &runningFormInfos); mutable std::mutex formRecordMutex_; mutable std::mutex formHostRecordMutex_; mutable std::mutex formTempMutex_; mutable std::mutex formStateRecordMutex_; mutable std::mutex formRequestPublishFormsMutex_; mutable std::mutex formAcquireDataRecordMutex_; mutable std::mutex formConfigMapMutex_; mutable std::mutex formCloudUpdateDurationMapMutex_; std::map formRecords_; std::vector clientRecords_; std::vector tempForms_; std::map formStateRecord_; std::map>> formAddObservers_; std::map formAcquireDataRecord_; using FormRequestPublishFormInfo = std::pair>; std::map formRequestPublishForms_; int64_t udidHash_ = 0; std::vector> formObservers_; std::map formConfigMap_; std::unordered_map formCloudUpdateDurationMap_; }; } // namespace AppExecFwk } // namespace OHOS #endif // OHOS_FORM_FWK_FORM_FORM_DATA_MGR_H