1 /* 2 * Copyright (c) 2021 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 FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_PROVIDER_MGRR_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_PROVIDER_MGRR_H 18 #include <set> 19 #include <singleton.h> 20 #include "form_provider_info.h" 21 #include "form_record.h" 22 #include "want.h" 23 24 namespace OHOS { 25 namespace AppExecFwk { 26 using Want = OHOS::AAFwk::Want; 27 /** 28 * @class FormProviderMgr 29 * Form provider manager. 30 */ 31 class FormProviderMgr final : public DelayedRefSingleton<FormProviderMgr> { 32 DECLARE_DELAYED_REF_SINGLETON(FormProviderMgr) 33 public: 34 DISALLOW_COPY_AND_MOVE(FormProviderMgr); 35 36 /** 37 * @brief handle for acquire back event from provider. 38 * @param formId The id of the form. 39 * @param providerFormInfo provider form info. 40 * @return Returns ERR_OK on success, others on failure. 41 */ 42 ErrCode AcquireForm(const int64_t formId, const FormProviderInfo &formProviderInfo); 43 /** 44 * @brief handle for update form event from provider. 45 * @param formId The id of the form. 46 * @param providerFormInfo provider form info. 47 * @return Returns ERR_OK on success, others on failure. 48 */ 49 ErrCode UpdateForm(const int64_t formId, const FormProviderInfo &formProviderInfo); 50 /** 51 * handle for update form event from provider. 52 * 53 * @param formId The id of the form. 54 * @param formRecord The form's record. 55 * @param formProviderData provider form info. 56 * @return Returns ERR_OK on success, others on failure. 57 */ 58 ErrCode UpdateForm(const int64_t formId, FormRecord &formRecord, const FormProviderData &formProviderData); 59 /** 60 * @brief Refresh form. 61 * 62 * @param formId The form id. 63 * @param want The want of the form to request. 64 * @return Returns ERR_OK on success, others on failure. 65 */ 66 ErrCode RefreshForm(const int64_t formId, const Want &want); 67 /** 68 * @brief Connect ams for refresh form 69 * 70 * @param formId The form id. 71 * @param record Form data. 72 * @param want The want of the form. 73 * @param isTimerRefresh The flag of timer refresh. 74 * @return Returns ERR_OK on success, others on failure. 75 */ 76 ErrCode ConnectAmsForRefresh(const int64_t formId, const FormRecord &record, const Want &want, 77 const bool isTimerRefresh); 78 /** 79 * @brief Notify provider form delete. 80 * @param formId The form id. 81 * @param record Form information. 82 * @return Returns ERR_OK on success, others on failure. 83 */ 84 ErrCode NotifyProviderFormDelete(const int64_t formId, const FormRecord &formRecord); 85 /** 86 * @brief Notify provider forms batch delete. 87 * @param bundleName BundleName. 88 * @param bundleName AbilityName. 89 * @param formIds form id list. 90 * @return Returns ERR_OK on success, others on failure. 91 */ 92 ErrCode NotifyProviderFormsBatchDelete(const std::string &bundleName, const std::string &abilityName, 93 const std::set<int64_t> &formIds); 94 /** 95 * @brief Process js message event. 96 * @param formId Indicates the unique id of form. 97 * @param record Form record. 98 * @param want information passed to supplier. 99 * @return Returns true if execute success, false otherwise. 100 */ 101 int MessageEvent(const int64_t formId, const FormRecord &record, const Want &want); 102 private: 103 FormRecord GetFormAbilityInfo(const FormRecord &record) const; 104 /** 105 * @brief Increase the timer refresh count. 106 * 107 * @param formId The form id. 108 */ 109 void IncreaseTimerRefreshCount(const int64_t formId); 110 bool IsFormCached(const FormRecord &record); 111 }; 112 } // namespace AppExecFwk 113 } // namespace OHOS 114 115 #endif // FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_PROVIDER_MGRR_H