• 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_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         const 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, const sptr<IRemoteObject> &callerToken) = 0;
55 
56     /**
57      * @brief When host is died, clean resources. This is async API.
58      * @param hostToken Caller ability token.
59      * @return Returns ERR_OK on success, others on failure.
60      */
61     virtual int32_t CleanFormHost(const sptr<IRemoteObject> &hostToken) = 0;
62 
ReloadForm(const std::vector<FormJsInfo> && formJsInfos,const Want & want)63     virtual int32_t ReloadForm(const std::vector<FormJsInfo> &&formJsInfos, const Want &want) { return ERR_OK; }
64 
ReleaseRenderer(int64_t formId,const std::string & compId,const std::string & uid)65     virtual int32_t ReleaseRenderer(
66         int64_t formId, const std::string &compId, const std::string &uid) { return ERR_OK; }
67 
OnUnlock()68     virtual int32_t OnUnlock() { return ERR_OK; }
69 
70     enum class Message {
71         // ipc id 1-1000 for kit
72         // ipc id 1001-2000 for DMS
73         // ipc id 2001-3000 for tools
74         // ipc id for form mgr (3001)
75         // ipc id for form provider (3051)
76         // ipc id for form render (3101)
77         // ipc id for form supply (3201)
78         // ipc id for form host (3681)
79 
80         FORM_RENDER_RENDER_FORM = 3101,
81         FORM_RENDER_STOP_RENDERING_FORM = 3102,
82         FORM_RENDER_FORM_HOST_DIED = 3103,
83         FORM_RENDER_RELOAD_FORM = 3104,
84         FORM_RENDER_RELEASE_RENDERER = 3105,
85         FORM_RENDER_UNLOCKED = 3106,
86     };
87 };
88 } // namespace AppExecFwk
89 } // namespace OHOS
90 
91 #endif // OHOS_FORM_FWK_FORM_RENDER_INTERFACE_H
92