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_RENDER_STATUS_TASK_MGR_H 17 #define OHOS_FORM_FWK_FORM_RENDER_STATUS_TASK_MGR_H 18 19 #include <singleton.h> 20 #include "iremote_object.h" 21 #include "want.h" 22 23 #include "status_mgr_center/form_status_common.h" 24 #include "form_supply_proxy.h" 25 #include "form_render_serial_queue.h" 26 27 namespace OHOS { 28 namespace AppExecFwk { 29 namespace FormRender { 30 using Want = OHOS::AAFwk::Want; 31 class FormRenderStatusTaskMgr final : public DelayedRefSingleton<FormRenderStatusTaskMgr> { 32 DECLARE_DELAYED_REF_SINGLETON(FormRenderStatusTaskMgr) 33 public: 34 DISALLOW_COPY_AND_MOVE(FormRenderStatusTaskMgr); 35 SetSerialQueue(const std::shared_ptr<FormRenderSerialQueue> & serialQueue)36 void SetSerialQueue(const std::shared_ptr<FormRenderSerialQueue> &serialQueue) 37 { 38 if (serialQueue == nullptr) { 39 return; 40 } 41 serialQueue_ = serialQueue; 42 } 43 44 /** 45 * @brief Callback function after form rendering is completed 46 * @param formId Form ID 47 * @param event Form State Machine event 48 * @param formSupplyClient Smart pointer to form supply client 49 */ 50 void OnRenderFormDone(const int64_t formId, const FormFsmEvent event, const sptr<IFormSupply> formSupplyClient); 51 52 /** 53 * @brief Callback function after form recycling data is completed 54 * @param formId Form ID 55 * @param event Form State Machine event 56 * @param statusData Serialized form status data 57 * @param want Form parameter object 58 * @param formSupplyClient Smart pointer to form supply client 59 */ 60 void OnRecycleForm(const int64_t formId, const FormFsmEvent event, const std::string &statusData, const Want &want, 61 const sptr<IFormSupply> formSupplyClient); 62 63 /** 64 * Callback function after form recovery is completed 65 * @param formId Form ID 66 * @param event Form State Machine event 67 * @param formSupplyClient Smart pointer to form supply client 68 */ 69 void OnRecoverFormDone(const int64_t formId, const FormFsmEvent event, const sptr<IFormSupply> formSupplyClient); 70 71 /** 72 * @brief Callback function after form deletion is completed 73 * @param formId Form ID 74 * @param event Form State Machine event 75 * @param formSupplyClient Smart pointer to form supply client 76 */ 77 void OnDeleteFormDone(const int64_t formId, const FormFsmEvent event, const sptr<IFormSupply> formSupplyClient); 78 79 /** 80 * @brief Callback function after form recycling is completed 81 * @param formId Form ID 82 * @param event Form State Machine event 83 * @param formSupplyClient Smart pointer to form supply client 84 */ 85 void OnRecycleFormDone(const int64_t formId, const FormFsmEvent event, const sptr<IFormSupply> formSupplyClient); 86 87 /** 88 * @brief Schedules form recycle timeout task 89 * @param formId Form ID 90 * @return bool Returns true if the timeout was successfully scheduled, false otherwise 91 */ 92 bool ScheduleRecycleTimeout(const int64_t formId); 93 94 /** 95 * @brief Cancel form recycle timeout task 96 * @param formId Form ID 97 * @return bool Returns true if the timeout was successfully canceled, false otherwise 98 */ 99 bool CancelRecycleTimeout(const int64_t formId); 100 101 private: 102 std::mutex serialQueueMutex_; 103 std::shared_ptr<FormRenderSerialQueue> serialQueue_ = nullptr; 104 }; 105 } // namespace FormRender 106 } // namespace AppExecFwk 107 } // namespace OHOS 108 #endif // OHOS_FORM_FWK_FORM_RENDER_STATUS_TASK_MGR_H