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_PROXY_H 17 #define OHOS_FORM_FWK_FORM_RENDER_PROXY_H 18 19 #include "form_render_interface.h" 20 #include "iremote_proxy.h" 21 22 namespace OHOS { 23 namespace AppExecFwk { 24 /** 25 * @class FormRenderProxy 26 * FormRenderProxy is used to access form render service. 27 */ 28 class FormRenderProxy : public IRemoteProxy<IFormRender> { 29 public: FormRenderProxy(const sptr<IRemoteObject> & impl)30 explicit FormRenderProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IFormRender>(impl) 31 {} 32 33 virtual ~FormRenderProxy() = default; 34 35 /** 36 * @brief Render form. This is sync API. 37 * @param formJsInfo The form js info. 38 * @param want Indicates the {@link Want} structure containing form info. 39 * @param callerToken Caller ability token. 40 * @return Returns ERR_OK on success, others on failure. 41 */ 42 int32_t RenderForm(const FormJsInfo &formJsInfo, const Want &want, sptr<IRemoteObject> callerToken) override; 43 44 /** 45 * @brief Stop rendering form. This is sync API. 46 * @param formJsInfo The form js info. 47 * @param want Indicates the {@link Want} structure containing form info. 48 * @param callerToken Caller ability token. 49 * @return Returns ERR_OK on success, others on failure. 50 */ 51 int32_t StopRenderingForm( 52 const FormJsInfo &formJsInfo, const Want &want, const sptr<IRemoteObject> &callerToken) override; 53 54 /** 55 * @brief When host is died, clean resources. This is async API. 56 * @param hostToken Caller ability token. 57 * @return Returns ERR_OK on success, others on failure. 58 */ 59 int32_t CleanFormHost(const sptr<IRemoteObject> &hostToken) override; 60 61 int32_t ReleaseRenderer(int64_t formId, const std::string &compId, const std::string &uid) override; 62 63 int32_t ReloadForm(const std::vector<FormJsInfo> &&formJsInfos, const Want &want) override; 64 65 int32_t OnUnlock() override; 66 67 int32_t SetVisibleChange(const int64_t &formId, bool isVisible, const Want &want) override; 68 69 int32_t RecycleForm(const int64_t &formId, const Want &want) override; 70 71 int32_t RecoverForm(const FormJsInfo &formJsInfo, const Want &want) override; 72 73 int32_t UpdateFormSize(const int64_t &formId, float width, float height, float borderWidth, 74 const std::string &uid) override; 75 76 void RunCachedConfigurationUpdated() override; 77 private: 78 bool WriteInterfaceToken(MessageParcel &data); 79 template<typename T> 80 int32_t WriteParcelableVector(const std::vector<T> &parcelableVector, MessageParcel &reply); 81 int SendTransactCmd(IFormRender::Message code, MessageParcel &data, 82 MessageParcel &reply, MessageOption &option); 83 84 private: 85 static inline BrokerDelegator<FormRenderProxy> delegator_; 86 }; 87 } // namespace AppExecFwk 88 } // namespace OHOS 89 #endif // OHOS_FORM_FWK_FORM_RENDER_PROXY_H 90