• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, const 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      *
50      * @return Returns ERR_OK on success, others on failure.
51      */
52     int32_t StopRenderingForm(
53         const FormJsInfo &formJsInfo, const Want &want, const sptr<IRemoteObject> &callerToken) override;
54 
55     /**
56      * @brief When host is died, clean resources. This is async API.
57      * @param hostToken Caller ability token.
58      * @return Returns ERR_OK on success, others on failure.
59      */
60     int32_t CleanFormHost(const sptr<IRemoteObject> &hostToken) override;
61 
62     int32_t ReloadForm(const std::vector<int64_t> &&formIds, const Want &want) override;
63 
64 private:
65     template<typename T>
66     int32_t GetParcelableInfos(MessageParcel &reply, std::vector<T> &parcelableInfos);
67     bool WriteInterfaceToken(MessageParcel &data);
68 
69 private:
70     static inline BrokerDelegator<FormRenderProxy> delegator_;
71 };
72 } // namespace AppExecFwk
73 } // namespace OHOS
74 #endif // OHOS_FORM_FWK_FORM_RENDER_PROXY_H
75