1 /*
2  * Copyright (c) 2021-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_SUPPLY_INTERFACE_H
17 #define OHOS_FORM_FWK_FORM_SUPPLY_INTERFACE_H
18 
19 #include <vector>
20 
21 #include "form_provider_info.h"
22 #include "form_state_info.h"
23 #include "ipc_types.h"
24 #include "iremote_broker.h"
25 
26 #include "want.h"
27 
28 namespace OHOS {
29 namespace AppExecFwk {
30 using OHOS::AAFwk::Want;
31 
32 /**
33  * @class IFormSupply
34  * IFormSupply interface is used to access form supply service.
35  */
36 class IFormSupply : public OHOS::IRemoteBroker {
37 public:
38     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.FormSupply");
39 
40     /**
41      * @brief Accept form binding data from form provider.
42      * @param providerFormInfo Form binding data.
43      * @param want input data.
44      * @return Returns ERR_OK on success, others on failure.
45      */
46     virtual int OnAcquire(const FormProviderInfo &formInfo, const Want &want) = 0;
47 
48     /**
49      * @brief Accept other event.
50      * @param want input data.
51      * @return Returns ERR_OK on success, others on failure.
52      */
53     virtual int OnEventHandle(const Want &want) = 0;
54 
55     /**
56      * @brief Accept form state from form provider.
57      * @param state Form state.
58      * @param provider provider info.
59      * @param wantArg The want of onAcquireFormState.
60      * @param want input data.
61      * @return Returns ERR_OK on success, others on failure.
62      */
63     virtual int OnAcquireStateResult(FormState state, const std::string &provider, const Want &wantArg,
64                                      const Want &want) = 0;
65 
66     /**
67      * @brief Accept form sharing data from form provider.
68      * @param formId The Id of the from.
69      * @param remoteDeviceId Indicates the remote device ID.
70      * @param wantParams Indicates the data information shared by the form.
71      * @param requestCode Indicates the requested id.
72      * @param result Indicates the results of parsing shared data.
73      * @return Returns ERR_OK on success, others on failure.
74      */
75     virtual void OnShareAcquire(int64_t formId, const std::string &remoteDeviceId,
76         const AAFwk::WantParams &wantParams, int64_t requestCode, const bool &result) = 0;
77 
78     /**
79      * @brief Accept form data from form provider.
80      * @param wantParams Indicates the data information acquired by the form.
81      * @param requestCode Indicates the requested id.
82      * @return Returns ERR_OK on success, others on failure.
83      */
84     virtual int OnAcquireDataResult(const AAFwk::WantParams &wantParams, int64_t requestCode) = 0;
85 
86     /**
87      * @brief Accept form render task done from render service.
88      * @param formId The Id of the form.
89      * @param want input data.
90      * @return Returns ERR_OK on success, others on failure.
91      */
92     virtual int32_t OnRenderTaskDone(int64_t formId, const Want &want) = 0;
93 
94     /**
95      * @brief Accept form stop rendering task done from render service.
96      * @param formId The Id of the form.
97      * @param want input data.
98      * @return Returns ERR_OK on success, others on failure.
99      */
100     virtual int32_t OnStopRenderingTaskDone(int64_t formId, const Want &want) = 0;
101 
102     /**
103      * @brief Accept rendering block from render service.
104      * @param bundleName The block of bundleName.
105      * @return Returns ERR_OK on success, others on failure.
106      */
OnRenderingBlock(const std::string & bundleName)107     virtual int32_t OnRenderingBlock(const std::string &bundleName) { return ERR_OK; }
108 
109     /**
110      * @brief Accept status data of form to be recycled from render service.
111      * @param formId The id of the form.
112      * @param want Input data.
113      * @return Returns ERR_OK on success, others on failure.
114      */
OnRecycleForm(const int64_t & formId,const Want & want)115     virtual int32_t OnRecycleForm(const int64_t &formId, const Want &want) { return ERR_OK; }
116 
117     /**
118      * @brief Trigger card recover when configuration changes occur.
119      * @param formIds The ids of the forms.
120      * @return Returns ERR_OK on success, others on failure.
121      */
OnRecoverFormsByConfigUpdate(std::vector<int64_t> & formIds)122     virtual int32_t OnRecoverFormsByConfigUpdate(std::vector<int64_t> &formIds) { return ERR_OK; }
123 
OnNotifyRefreshForm(const int64_t & formId)124     virtual int32_t OnNotifyRefreshForm(const int64_t &formId) { return ERR_OK; }
125 
126     enum class Message {
127         // ipc id 1-1000 for kit
128         // ipc id 1001-2000 for DMS
129         // ipc id 2001-3000 for tools
130         // ipc id for create (3201)
131         TRANSACTION_FORM_ACQUIRED = 3201,
132         TRANSACTION_EVENT_HANDLE,
133         TRANSACTION_FORM_STATE_ACQUIRED,
134         TRANSACTION_FORM_SHARE_ACQUIRED,
135         TRANSACTION_FORM_RENDER_TASK_DONE,
136         TRANSACTION_FORM_STOP_RENDERING_TASK_DONE,
137         TRANSACTION_FORM_ACQUIRED_DATA,
138         TRANSACTION_FORM_RENDERING_BLOCK,
139         TRANSACTION_FORM_RECYCLE_FORM,
140         TRANSACTION_FORM_RECOVER_FORM_BY_CONFIG_UPDATE,
141         TRANSACTION_NOTIFY_REFRESH,
142     };
143 };
144 }  // namespace AppExecFwk
145 }  // namespace OHOS
146 
147 #endif // OHOS_FORM_FWK_FORM_SUPPLY_INTERFACE_H
148