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_INTERFACE_H
17 #define OHOS_FORM_FWK_FORM_RENDER_INTERFACE_H
18 
19 #include <vector>
20 
21 #include "form_js_info.h"
22 #include "ipc_types.h"
23 #include "iremote_broker.h"
24 #include "want.h"
25 
26 namespace OHOS {
27 namespace AppExecFwk {
28 using OHOS::AAFwk::Want;
29 /**
30  * @class IFormProvider
31  * IFormProvider interface is used to access form render service.
32  */
33 class IFormRender : public IRemoteBroker {
34 public:
35     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.FormRender");
36 
37     /**
38      * @brief Render form. This is a sync API.
39      * @param formJsInfo The form js info.
40      * @param want Indicates the {@link Want} structure containing form info.
41      * @param callerToken Caller ability token.
42      * @return Returns ERR_OK on success, others on failure.
43      */
44     virtual int32_t RenderForm(const FormJsInfo &formJsInfo, const Want &want,
45         sptr<IRemoteObject> callerToken) = 0;
46 
47     /**
48      * @brief Stop rendering form. This is sync API.
49      * @param formId Indicates The Id of the form to stop rendering.
50      * @param want Indicates the {@link Want} structure containing form info.
51      * @param callerToken Caller ability token.
52      * @return Returns ERR_OK on success, others on failure.
53      */
54     virtual int32_t StopRenderingForm(const FormJsInfo &formJsInfo, const Want &want,
55         const sptr<IRemoteObject> &callerToken) = 0;
56 
57     /**
58      * @brief When host is died, clean resources. This is async API.
59      * @param hostToken Caller ability token.
60      * @return Returns ERR_OK on success, others on failure.
61      */
62     virtual int32_t CleanFormHost(const sptr<IRemoteObject> &hostToken) = 0;
63 
ReloadForm(const std::vector<FormJsInfo> && formJsInfos,const Want & want)64     virtual int32_t ReloadForm(const std::vector<FormJsInfo> &&formJsInfos, const Want &want) { return ERR_OK; }
65 
ReleaseRenderer(int64_t formId,const std::string & compId,const std::string & uid)66     virtual int32_t ReleaseRenderer(
67         int64_t formId, const std::string &compId, const std::string &uid) { return ERR_OK; }
68 
OnUnlock()69     virtual int32_t OnUnlock() { return ERR_OK; }
70 
SetVisibleChange(const int64_t & formId,bool isVisible,const Want & want)71     virtual int32_t SetVisibleChange(const int64_t &formId, bool isVisible, const Want &want) { return ERR_OK; }
72 
RecycleForm(const int64_t & formId,const Want & want)73     virtual int32_t RecycleForm(const int64_t &formId, const Want &want) { return ERR_OK; }
74 
RecoverForm(const FormJsInfo & formJsInfo,const Want & want)75     virtual int32_t RecoverForm(const FormJsInfo &formJsInfo, const Want &want) { return ERR_OK; }
76 
UpdateFormSize(const int64_t & formId,float width,float height,float borderWidth,const std::string & uid)77     virtual int32_t UpdateFormSize(const int64_t &formId, float width, float height, float borderWidth,
78         const std::string &uid) { return ERR_OK; }
79 
RunCachedConfigurationUpdated()80     virtual void RunCachedConfigurationUpdated() {}
81 
82     enum class Message {
83         // ipc id 1-1000 for kit
84         // ipc id 1001-2000 for DMS
85         // ipc id 2001-3000 for tools
86         // ipc id for form mgr (3001)
87         // ipc id for form provider (3051)
88         // ipc id for form render (3101)
89         // ipc id for form supply (3201)
90         // ipc id for form host (3681)
91 
92         FORM_RENDER_RENDER_FORM = 3101,
93         FORM_RENDER_STOP_RENDERING_FORM = 3102,
94         FORM_RENDER_FORM_HOST_DIED = 3103,
95         FORM_RENDER_RELOAD_FORM = 3104,
96         FORM_RENDER_RELEASE_RENDERER = 3105,
97         FORM_RENDER_UNLOCKED = 3106,
98         FORM_RECYCLE_FORM = 3107,
99         FORM_RECOVER_FORM = 3108,
100         FORM_RUN_CACHED_CONFIG = 3109,
101         FORM_SET_VISIBLE_CHANGE = 3110,
102         FORM_UPDATE_FORM_SIZE = 3111,
103     };
104 };
105 } // namespace AppExecFwk
106 } // namespace OHOS
107 
108 #endif // OHOS_FORM_FWK_FORM_RENDER_INTERFACE_H
109