• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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_PROVIDER_INTERFACE_H
17 #define OHOS_FORM_FWK_FORM_PROVIDER_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 #include "configuration.h"
26 #include "form_instance.h"
27 
28 namespace OHOS {
29 namespace AppExecFwk {
30 using OHOS::AAFwk::Want;
31 /**
32  * @class IFormProvider
33  * IFormProvider interface is used to access form provider service.
34  */
35 class IFormProvider : public OHOS::IRemoteBroker {
36 public:
37     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.FormProvider");
38 
39     /**
40      * @brief Acquire to give back an ProviderFormInfo. This is sync API.
41      * @param formJsInfo The form js info.
42      * @param want Indicates the {@link Want} structure containing form info.
43      * @param callerToken Caller ability token.
44      * @return Returns ERR_OK on success, others on failure.
45      */
46     virtual int AcquireProviderFormInfo(const FormJsInfo &formJsInfo, const Want &want,
47     const sptr<IRemoteObject> &callerToken) = 0;
48 
49     /**
50      * @brief Notify provider when the form was deleted.
51      * @param formId The Id of the form.
52      * @param want Indicates the structure containing form info.
53      * @param callerToken Caller ability token.
54      * @return Returns ERR_OK on success, others on failure.
55      */
56     virtual int NotifyFormDelete(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken) = 0;
57 
58     /**
59      * @brief Notify provider when the forms was deleted.
60      * @param formIds The id list of forms.
61      * @param want Indicates the structure containing form info.
62      * @param callerToken Caller ability token.
63      * @return Returns ERR_OK on success, others on failure.
64      */
65     virtual int NotifyFormsDelete(const std::vector<int64_t> &formIds, const Want &want,
66     const sptr<IRemoteObject> &callerToken) = 0;
67     /**
68      * @brief Notify provider when the form need update.
69      * @param formId The Id of the form.
70      * @param want Indicates the structure containing form info.
71      * @param callerToken Caller ability token.
72      * @return Returns ERR_OK on success, others on failure.
73      */
74     virtual int NotifyFormUpdate(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken) = 0;
75 
76     /**
77      * @brief Event notify when change the form visible.
78      *
79      * @param formIds The vector of form ids.
80      * @param formVisibleType The form visible type, including FORM_VISIBLE and FORM_INVISIBLE.
81      * @param want Indicates the structure containing form info.
82      * @param callerToken Caller ability token.
83      * @return Returns ERR_OK on success, others on failure.
84      */
85     virtual int EventNotify(const std::vector<int64_t> &formIds, const int32_t formVisibleType,
86         const Want &want, const sptr<IRemoteObject> &callerToken) = 0;
87 
88     /**
89      * @brief Notify provider when the temp form was cast to normal form.
90      * @param formId The Id of the form to update.
91      * @param want Indicates the structure containing form info.
92      * @param callerToken Caller ability token.
93      * @return Returns ERR_OK on success, others on failure.
94      */
95     virtual int NotifyFormCastTempForm(const int64_t formId, const Want &want,
96         const sptr<IRemoteObject> &callerToken) = 0;
97 
98     /**
99      * @brief Notify provider when the system configuration changed.
100      * @param configuration system configuration.
101      * @param want Indicates the structure containing form info.
102      * @param callerToken Caller ability token.
103      * @return Returns ERR_OK on success, others on failure.
104      */
105     virtual int NotifyConfigurationUpdate(const AppExecFwk::Configuration &configuration,
106         const Want &want, const sptr<IRemoteObject> &callerToken) = 0;
107 
108     /**
109      * @brief Fire message event to form provider.
110      * @param formId The Id of the from.
111      * @param message Event message.
112      * @param want The want of the request.
113      * @param callerToken Form provider proxy object.
114      * @return Returns ERR_OK on success, others on failure.
115      */
116     virtual int FireFormEvent(const int64_t formId, const std::string &message, const Want &want,
117         const sptr<IRemoteObject> &callerToken) = 0;
118 
119     /**
120      * @brief Acquire form state to form provider.
121      * @param wantArg The want of onAcquireFormState.
122      * @param provider The provider info.
123      * @param want The want of the request.
124      * @param callerToken Form provider proxy object.
125      * @return Returns ERR_OK on success, others on failure.
126      */
127     virtual int AcquireState(const Want &wantArg, const std::string &provider, const Want &want,
128                              const sptr<IRemoteObject> &callerToken) = 0;
129 
130     /**
131      * @brief Acquire to share form information data. This is sync API.
132      * @param formId The Id of the from.
133      * @param remoteDeviceId Indicates the remote device ID.
134      * @param formSupplyCallback Indicates lifecycle callbacks.
135      * @param requestCode Indicates the request code of this share form.
136      * @return Returns ERR_OK on success, others on failure.
137      */
138     virtual int32_t AcquireShareFormData(int64_t formId, const std::string &remoteDeviceId,
139         const sptr<IRemoteObject> &formSupplyCallback, int64_t requestCode) = 0;
140 
141     /**
142      * @brief Acquire to form data.
143      * @param formId The Id of the from.
144      * @param formSupplyCallback Indicates lifecycle callbacks.
145      * @param requestCode Indicates the request code.
146      * @return Returns ERR_OK on success, others on failure.
147      */
148     virtual int32_t AcquireFormData(int64_t formId, const sptr<IRemoteObject> &formSupplyCallback,
149         int64_t requestCode) = 0;
150 
151     /**
152      * @brief Notify provider when the form need update.
153      * @param formId The Id of the form.
154      * @param want Indicates the structure containing form info.
155      * @param callerToken Caller ability token.
156      * @return Returns ERR_OK on success, others on failure.
157      */
158     virtual int NotifyFormLocationUpdate(const int64_t formId, const Want &want,
159         const sptr<IRemoteObject> &callerToken) = 0;
160 
161     /**
162      * @brief Notify provider when the form size changed.
163      * @param formId The Id of the form to update.
164      * @param newDimension The dimension value to be updated.
165      * @param newRect The rect value to be updated.
166      * @param want Indicates the structure containing form info.
167      * @param callerToken Caller ability token.
168      * @return Returns ERR_OK on success, others on failure.
169      */
NotifySizeChanged(const int64_t formId,const int32_t newDimension,const Rect & newRect,const Want & want,const sptr<IRemoteObject> & callerToken)170     virtual int NotifySizeChanged(const int64_t formId, const int32_t newDimension, const Rect &newRect,
171         const Want &want, const sptr<IRemoteObject> &callerToken)
172     {
173         return 0;
174     };
175 
176     enum class Message {
177         // ipc id 1-1000 for kit
178         // ipc id 1001-2000 for DMS
179         // ipc id 2001-3000 for tools
180         // ipc id for add form (3001)
181         FORM_ACQUIRE_PROVIDER_FORM_INFO = 3051,
182 
183         // ipc id for delete form (3052)
184         FORM_PROVIDER_NOTIFY_FORM_DELETE,
185 
186         // ipc id for form done release form (3053)
187         FORM_PROVIDER_NOTIFY_FORMS_DELETE,
188 
189         // ipc id for connecting update form (3054)
190         FORM_PROVIDER_NOTIFY_FORM_UPDATE,
191 
192         // ipc id for form visible notify (3055)
193         FORM_PROVIDER_NOTIFY_TEMP_FORM_CAST,
194 
195         // ipc id for event notify (3056)
196         FORM_PROVIDER_EVENT_NOTIFY,
197 
198         // ipc id for event notify (3057)
199         FORM_PROVIDER_EVENT_MESSAGE,
200 
201         // ipc id for acquiring form state (3058)
202         FORM_PROVIDER_NOTIFY_STATE_ACQUIRE,
203 
204         // ipc id for Acquire provider share form info (3059)
205         FORM_ACQUIRE_PROVIDER_SHARE_FOMR_INFO,
206 
207         // ipc id for Acquire provider form data (3060)
208         FORM_ACQUIRE_PROVIDER_FOMR_DATA,
209 
210         // ipc id for system config update notify (3061)
211         FORM_PROVIDER_NOTIFY_CONFIGURATION_UPDATE,
212 
213         // ipc id for Acquire provider form data (3062)
214         FORM_PROVIDER_NOTIFY_FORM_LOCATION_UPDATE,
215 
216         // ipc id for notify provider size changed (3062)
217         FORM_PROVIDER_NOTIFY_SIZE_CHANGED,
218     };
219 };
220 }  // namespace AppExecFwk
221 }  // namespace OHOS
222 
223 #endif // OHOS_FORM_FWK_FORM_PROVIDER_INTERFACE_H
224