1 /* 2 * Copyright (c) 2023 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_IMPL_H 17 #define OHOS_FORM_FWK_FORM_RENDER_IMPL_H 18 19 #include "form_render_stub.h" 20 21 #include <memory> 22 #include <singleton.h> 23 24 #include "bundle_mgr_interface.h" 25 #include "context_impl.h" 26 #include "event_handler.h" 27 #include "form_render_record.h" 28 #include "form_render_serial_queue.h" 29 #include "form_supply_proxy.h" 30 #include "js_runtime.h" 31 #include "runtime.h" 32 #include "want.h" 33 34 namespace OHOS { 35 namespace AppExecFwk { 36 namespace FormRender { 37 using OHOS::AAFwk::Want; 38 using namespace AbilityRuntime; 39 40 class FormRenderImpl : public FormRenderStub, public std::enable_shared_from_this<FormRenderImpl> { 41 DECLARE_DELAYED_SINGLETON(FormRenderImpl) 42 public: 43 /** 44 * @brief Render form. This is sync API. 45 * @param formJsInfo The form js info. 46 * @param want Indicates the {@link Want} structure containing form info. 47 * @param callerToken Caller ability token. 48 * @return Returns ERR_OK on success, others on failure. 49 */ 50 int32_t RenderForm(const FormJsInfo &formJsInfo, const Want &want, sptr<IRemoteObject> callerToken) override; 51 52 /** 53 * @brief Stop rendering form. This is sync API. 54 * @param formJsInfo The form js info. 55 * @param want Indicates the {@link Want} structure containing form info. 56 * @param callerToken Caller ability token. 57 * @return Returns ERR_OK on success, others on failure. 58 */ 59 int32_t StopRenderingForm( 60 const FormJsInfo &formJsInfo, const Want &want, const sptr<IRemoteObject> &callerToken) override; 61 62 /** 63 * @brief When host is died, clean resources. This is async API. 64 * @param hostToken Caller ability token. 65 * @return Returns ERR_OK on success, others on failure. 66 */ 67 int32_t CleanFormHost(const sptr<IRemoteObject> &hostToken) override; 68 69 /** 70 * @brief Reload form When app updated. This is sync API. 71 * @param formIds the form id need to update. 72 * @param want Indicates the {@link Want} structure containing form info. 73 * @return int32_t Returns ERR_OK on success, others on failure. 74 */ 75 int32_t ReloadForm(const std::vector<FormJsInfo> &&formJsInfos, const Want &want) override; 76 77 void RunCachedConfigurationUpdated() override; 78 79 int32_t ReleaseRenderer( 80 int64_t formId, const std::string &compId, const std::string &uid, const Want &want) override; 81 82 int32_t OnUnlock() override; 83 84 int32_t SetVisibleChange(const int64_t &formId, bool isVisible, const Want &want) override; 85 86 int32_t RecycleForm(const int64_t &formId, const Want &want) override; 87 88 int32_t RecoverForm(const FormJsInfo &formJsInfo, const Want &want) override; 89 90 int32_t UpdateFormSize( 91 const int64_t &formId, float width, float height, float borderWidth, const std::string &uid) override; 92 93 protected: 94 int32_t CheckPermission() override; 95 96 private: 97 bool CheckIsFoundationCall(); 98 }; 99 } // namespace FormRender 100 } // namespace AppExecFwk 101 } // namespace OHOS 102 #endif // OHOS_FORM_FWK_FORM_RENDER_IMPL_H 103