1 /* 2 * Copyright (c) 2025 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_HOST_TASK_MGR_H 17 #define OHOS_FORM_FWK_FORM_HOST_TASK_MGR_H 18 19 #include <singleton.h> 20 #include "iremote_object.h" 21 #include "form_state_info.h" 22 #include "data_center/form_record/form_record.h" 23 24 namespace OHOS { 25 namespace AppExecFwk { 26 class FormHostTaskMgr final : public DelayedRefSingleton<FormHostTaskMgr> { 27 DECLARE_DELAYED_REF_SINGLETON(FormHostTaskMgr) 28 29 public: 30 DISALLOW_COPY_AND_MOVE(FormHostTaskMgr); 31 32 /** 33 * @brief Post form data to form host(task) when acquire form. 34 * @param formId The Id of the form. 35 * @param record form record. 36 * @param remoteObject Form provider proxy object. 37 */ 38 void PostAcquireTaskToHost(const int64_t formId, const FormRecord &record, const sptr<IRemoteObject> &remoteObject); 39 40 /** 41 * @brief Post form data to form host(task) when update form. 42 * @param formId The Id of the form. 43 * @param record form record. 44 * @param remoteObject Form provider proxy object. 45 */ 46 void PostUpdateTaskToHost(const int64_t formId, const FormRecord &record, const sptr<IRemoteObject> &remoteObject); 47 48 /** 49 * @brief Post uninstall message to form host(task). 50 * @param formIds The Id list of the forms. 51 * @param remoteObject Form provider proxy object. 52 */ 53 void PostUninstallTaskToHost(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &remoteObject); 54 55 /** 56 * @brief Post acquire form state message to form host(task). 57 * @param state The form state. 58 * @param want The want of onAcquireFormState. 59 * @param remoteObject Form provider proxy object. 60 */ 61 void PostAcquireStateTaskToHost(AppExecFwk::FormState state, const AAFwk::Want &want, 62 const sptr<IRemoteObject> &remoteObject); 63 64 /** 65 * @brief Post acquire form data message to form host(task). 66 * @param wantParams Indicates the data information acquired by the form. 67 * @param requestCode Indicates the requested id. 68 * @param remoteObject Form provider proxy object. 69 */ 70 void PostAcquireDataTaskToHost(const AAFwk::WantParams &wantParams, int64_t requestCode, 71 const sptr<IRemoteObject> &remoteObject); 72 73 /** 74 * @brief Post enable form task. 75 * @param formIds formIds The Id list of the forms. 76 * @param enable True or false. 77 * @param remoteObject Form host proxy object. 78 */ 79 void PostEnableFormsTaskToHost(const std::vector<int64_t> &formIds, const bool enable, 80 const sptr<IRemoteObject> &remoteObject); 81 82 /** 83 * @brief Post lock form task. 84 * @param formIds formIds The Id list of the forms. 85 * @param lock True or false. 86 * @param remoteObject Form host proxy object. 87 */ 88 void PostLockFormsTaskToHost(const std::vector<int64_t> &formIds, const bool lock, 89 const sptr<IRemoteObject> &remoteObject); 90 91 /** 92 * @brief Post re-add form task to form host when FormRenderService is died. 93 * @param remoteObject Form host proxy object. 94 */ 95 void PostFrsDiedTaskToHost(const sptr<IRemoteObject> &remoteObject); 96 97 /** 98 * @brief Post connect FRS failed task to form host when FormRenderService is died. 99 * @param formId The Id of the form. 100 * @param errorCode Indicates error-code of the form. 101 */ 102 void PostConnectFRSFailedTaskToHost(int64_t formId, int32_t errorCode); 103 104 /** 105 * @brief Handle form host died(task). 106 * @param remoteHost Form host proxy object. 107 */ 108 void PostHostDiedTask(const sptr<IRemoteObject> &remoteHost); 109 110 private: 111 /** 112 * @brief Post form data to form host when acquire form.. 113 * @param formId The Id of the form. 114 * @param record form record. 115 * @param remoteObject Form provider proxy object. 116 */ 117 void AcquireTaskToHost(const int64_t formId, const FormRecord &record, 118 const sptr<IRemoteObject> &remoteObject); 119 120 /** 121 * @brief Post form data to form host when update form. 122 * @param formId The Id of the form. 123 * @param record form record. 124 * @param remoteObject Form provider proxy object. 125 */ 126 void UpdateTaskToHost(const int64_t formId, const FormRecord &record, const sptr<IRemoteObject> &remoteObject); 127 128 /** 129 * @brief Handle uninstall message. 130 * @param formIds The Id list of the forms. 131 * @param remoteObject Form provider proxy object. 132 */ 133 void FormUninstall(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &remoteObject); 134 135 /** 136 * @brief Handle acquire state. 137 * @param state the form state. 138 * @param want The want of onAcquireFormState. 139 * @param remoteObject Form provider proxy object. 140 */ 141 void AcquireStateBack(AppExecFwk::FormState state, const AAFwk::Want &want, 142 const sptr <IRemoteObject> &remoteObject); 143 144 /** 145 * @brief Handle acquire data. 146 * @param wantParams Indicates the data information acquired by the form. 147 * @param requestCode Indicates the requested id. 148 * @param remoteObject Form provider proxy object. 149 */ 150 void AcquireFormDataBack(const AAFwk::WantParams &wantParams, int64_t requestCode, 151 const sptr<IRemoteObject> &remoteObject); 152 153 /** 154 * @brief Enable form or disable form. 155 * @param formIds formIds The Id list of the forms. 156 * @param enable True or false. 157 * @param remoteObject Form host proxy object. 158 */ 159 void EnableFormsTaskToHost(const std::vector<int64_t> &formIds, const bool enable, 160 const sptr<IRemoteObject> &remoteObject); 161 162 /** 163 * @brief Lock form or unlock form. 164 * @param formIds formIds The Id list of the forms. 165 * @param lock True or false. 166 * @param remoteObject Form host proxy object. 167 */ 168 void LockFormsTaskToHost(const std::vector<int64_t> &formIds, const bool lock, 169 const sptr<IRemoteObject> &remoteObject); 170 171 /** 172 * @brief Post re-add form task to form host when FormRenderService is died. 173 * @param remoteObject Form host proxy object. 174 */ 175 void FrsDiedTaskToHost(const sptr<IRemoteObject> &remoteObject); 176 177 /** 178 * @brief Post connect FRS failed task to form host when FormRenderService is died. 179 * @param formId The Id of the form. 180 * @param errorCode Indicates error-code of the form. 181 */ 182 void ConnectFRSFailedTaskToHost(int64_t formId, int32_t errorCode); 183 184 /** 185 * @brief Handle form host died. 186 * @param remoteHost Form host proxy object. 187 */ 188 void HostDied(const sptr<IRemoteObject> &remoteHost); 189 }; 190 } // namespace AppExecFwk 191 } // namespace OHOS 192 #endif // OHOS_FORM_FWK_FORM_HOST_TASK_MGR_H