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_MGR_STUB_H 17 #define OHOS_FORM_FWK_FORM_MGR_STUB_H 18 19 #include <map> 20 21 #include "form_mgr_interface.h" 22 #include "form_instance.h" 23 #include "form_instances_filter.h" 24 #include "iremote_object.h" 25 #include "iremote_stub.h" 26 27 namespace OHOS { 28 namespace AppExecFwk { 29 /** 30 * @class FormMgrStub 31 * Form manager service stub. 32 */ 33 class FormMgrStub : public IRemoteStub<IFormMgr> { 34 public: 35 FormMgrStub(); 36 virtual ~FormMgrStub(); 37 /** 38 * @brief Handle remote request. 39 * @param data input param. 40 * @param reply output param. 41 * @param option message option. 42 * @return Returns ERR_OK on success, others on failure. 43 */ 44 virtual int OnRemoteRequest( 45 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 46 47 private: 48 /** 49 * @brief Handle AddForm message. 50 * @param data input param. 51 * @param reply output param. 52 * @return Returns ERR_OK on success, others on failure. 53 */ 54 int32_t HandleAddForm(MessageParcel &data, MessageParcel &reply); 55 /** 56 * @brief Handle DeleteForm message. 57 * @param data input param. 58 * @param reply output param. 59 * @return Returns ERR_OK on success, others on failure. 60 */ 61 int32_t HandleDeleteForm(MessageParcel &data, MessageParcel &reply); 62 63 /** 64 * @brief Handle StopRenderingForm message. 65 * @param data input param. 66 * @param reply output param. 67 * @return Returns ERR_OK on success, others on failure. 68 */ 69 int32_t HandleStopRenderingForm(MessageParcel &data, MessageParcel &reply); 70 /** 71 * @brief Handle ReleaseForm message. 72 * @param data input param. 73 * @param reply output param. 74 * @return Returns ERR_OK on success, others on failure. 75 */ 76 int32_t HandleReleaseForm(MessageParcel &data, MessageParcel &reply); 77 /** 78 * @brief Handle UpdateForm message. 79 * @param data input param. 80 * @param reply output param. 81 * @return Returns ERR_OK on success, others on failure. 82 */ 83 int32_t HandleUpdateForm(MessageParcel &data, MessageParcel &reply); 84 85 /** 86 * @brief handle LifecycleUpdate message. 87 * @param data input param. 88 * @param reply output param. 89 * @return Returns ERR_OK on success, others on failure. 90 */ 91 int32_t HandleLifecycleUpdate(MessageParcel &data, MessageParcel &reply); 92 /** 93 * @brief handle SetNextRefreshTime message. 94 * @param data input param. 95 * @param reply output param. 96 * @return Returns ERR_OK on success, others on failure. 97 */ 98 int32_t HandleSetNextRefreshTime(MessageParcel &data, MessageParcel &reply); 99 100 /** 101 * @brief handle ReleaseRenderer message. 102 * @param data input param. 103 * @param reply output param. 104 * @return Returns ERR_OK on success, others on failure. 105 */ 106 int32_t HandleReleaseRenderer(MessageParcel &data, MessageParcel &reply); 107 108 /** 109 * @brief handle RequestPublishForm message. 110 * @param data input param. 111 * @param reply output param. 112 * @return Returns ERR_OK on success, others on failure. 113 */ 114 ErrCode HandleRequestPublishForm(MessageParcel &data, MessageParcel &reply); 115 116 /** 117 * @brief Handle RequestForm message. 118 * @param data input param. 119 * @param reply output param. 120 * @return Returns ERR_OK on success, others on failure. 121 */ 122 int32_t HandleRequestForm(MessageParcel &data, MessageParcel &reply); 123 /** 124 * @brief Handle NotifyWhetherVisibleForms message. 125 * @param data input param. 126 * @param reply output param. 127 * @return Returns ERR_OK on success, others on failure. 128 */ 129 int32_t HandleNotifyWhetherVisibleForms(MessageParcel &data, MessageParcel &reply); 130 /** 131 * @brief Handle CastTempForm message. 132 * @param data input param. 133 * @param reply output param. 134 * @return Returns ERR_OK on success, others on failure. 135 */ 136 int32_t HandleCastTempForm(MessageParcel &data, MessageParcel &reply); 137 /** 138 * @brief Handle DumpStorageFormInfos message. 139 * @param data input param. 140 * @param reply output param. 141 * @return Returns ERR_OK on success, others on failure. 142 */ 143 int32_t HandleDumpStorageFormInfos(MessageParcel &data, MessageParcel &reply); 144 /** 145 * @brief Handle DumpFormInfoByBundleName message. 146 * @param data input param. 147 * @param reply output param. 148 * @return Returns ERR_OK on success, others on failure. 149 */ 150 int32_t HandleDumpFormInfoByBundleName(MessageParcel &data, MessageParcel &reply); 151 /** 152 * @brief Handle DumpFormInfoByFormId message. 153 * @param data input param. 154 * @param reply output param. 155 * @return Returns ERR_OK on success, others on failure. 156 */ 157 int32_t HandleDumpFormInfoByFormId(MessageParcel &data, MessageParcel &reply); 158 /** 159 * @brief Handle DumpFormTimerByFormId message. 160 * @param data input param. 161 * @param reply output param. 162 * @return Returns ERR_OK on success, others on failure. 163 */ 164 int32_t HandleDumpFormTimerByFormId(MessageParcel &data, MessageParcel &reply); 165 /** 166 * @brief Handle DumpFormInfoByFormId message. 167 * @param data input param. 168 * @param reply output param. 169 * @return Returns ERR_OK on success, others on failure. 170 */ 171 int32_t HandleMessageEvent(MessageParcel &data, MessageParcel &reply); 172 173 /** 174 * @brief Handle HandleRouterEvent message. 175 * @param data input param. 176 * @param reply output param. 177 * @return Returns ERR_OK on success, others on failure. 178 */ 179 int32_t HandleRouterEvent(MessageParcel &data, MessageParcel &reply); 180 181 /** 182 * @brief Handle Background message. 183 * @param data input param. 184 * @param reply output param. 185 * @return Returns ERR_OK on success, others on failure. 186 */ 187 int32_t HandleBackgroundEvent(MessageParcel &data, MessageParcel &reply); 188 189 /** 190 * @brief Handle DeleteInvalidForms message. 191 * @param data input param. 192 * @param reply output param. 193 * @return Returns ERR_OK on success, others on failure. 194 */ 195 int32_t HandleDeleteInvalidForms(MessageParcel &data, MessageParcel &reply); 196 /** 197 * @brief Handle AcquireFormState message. 198 * @param data input param. 199 * @param reply output param. 200 * @return Returns ERR_OK on success, others on failure. 201 */ 202 int32_t HandleAcquireFormState(MessageParcel &data, MessageParcel &reply); 203 /** 204 * @brief Handle NotifyFormsVisible message. 205 * @param data input param. 206 * @param reply output param. 207 * @return Returns ERR_OK on success, others on failure. 208 */ 209 int32_t HandleNotifyFormsVisible(MessageParcel &data, MessageParcel &reply); 210 /** 211 * @brief Handle NotifyFormsPrivacyProtected message. 212 * @param data input param. 213 * @param reply output param. 214 * @return Returns ERR_OK on success, others on failure. 215 */ 216 int32_t HandleNotifyFormsPrivacyProtected(MessageParcel &data, MessageParcel &reply); 217 /** 218 * @brief Handle NotifyFormsEnableUpdate message. 219 * @param data input param. 220 * @param reply output param. 221 * @return Returns ERR_OK on success, others on failure. 222 */ 223 int32_t HandleNotifyFormsEnableUpdate(MessageParcel &data, MessageParcel &reply); 224 /** 225 * @brief Handle GetAllFormsInfo message. 226 * @param data input param. 227 * @param reply output param. 228 * @return Returns ERR_OK on success, others on failure. 229 */ 230 int32_t HandleGetAllFormsInfo(MessageParcel &data, MessageParcel &reply); 231 /** 232 * @brief Handle GetFormsInfoByApp message. 233 * @param data input param. 234 * @param reply output param. 235 * @return Returns ERR_OK on success, others on failure. 236 */ 237 int32_t HandleGetFormsInfoByApp(MessageParcel &data, MessageParcel &reply); 238 /** 239 * @brief Handle GetFormsInfoByModule message. 240 * @param data input param. 241 * @param reply output param. 242 * @return Returns ERR_OK on success, others on failure. 243 */ 244 int32_t HandleGetFormsInfoByModule(MessageParcel &data, MessageParcel &reply); 245 /** 246 * @brief Handle GetFormsInfo message. 247 * @param data input param. 248 * @param reply output param. 249 * @return Returns ERR_OK on success, others on failure. 250 */ 251 int32_t HandleGetFormsInfo(MessageParcel &data, MessageParcel &reply); 252 253 /** 254 * @brief Handle share form message. 255 * @param data input param. 256 * @param reply output param. 257 * @return Returns ERR_OK on success, others on failure. 258 */ 259 int32_t HandleShareForm(MessageParcel &data, MessageParcel &reply); 260 261 /** 262 * @brief Handle acquire form data. 263 * @param data input param. 264 * @param reply output param. 265 * @return Returns ERR_OK on success, others on failure. 266 */ 267 int32_t HandleAcquireFormData(MessageParcel &data, MessageParcel &reply); 268 269 /** 270 * @brief Receive form sharing information from remote. 271 * @param data input param. 272 * @param reply output param. 273 * @return Returns ERR_OK on success, others on failure. 274 */ 275 int32_t HandleRecvFormShareInfoFromRemote(MessageParcel &data, MessageParcel &reply); 276 277 /** 278 * @brief Handle IsRequestPublishFormSupported message. 279 * @param data input param. 280 * @param reply output param. 281 * @return Returns ERR_OK on success, others on failure. 282 */ 283 int32_t HandleIsRequestPublishFormSupported(MessageParcel &data, MessageParcel &reply); 284 285 /** 286 * @brief Handle StartAbility message. 287 * @param data input param. 288 * @param reply output param. 289 * @return Returns ERR_OK on success, others on failure. 290 */ 291 int32_t HandleStartAbility(MessageParcel &data, MessageParcel &reply); 292 293 /** 294 * @brief Check form manager service ready 295 * @param data input param 296 * @param reply output param 297 * @return Return ERR_OK on success, others on failure 298 */ 299 int32_t HandleCheckFMSReady(MessageParcel &data, MessageParcel &reply); 300 301 /** 302 * @brief Handle RegisterFormAddObserverByBundle message. 303 * @param data input param 304 * @param reply output param 305 * @return Return ERR_OK on success, others on failure 306 */ 307 int32_t HandleRegisterFormAddObserverByBundle(MessageParcel &data, MessageParcel &reply); 308 309 /** 310 * @brief Handle RegisterFormRemoveObserverByBundle message. 311 * @param data input param 312 * @param reply output param 313 * @return Return ERR_OK on success, others on failure 314 */ 315 int32_t HandleRegisterFormRemoveObserverByBundle(MessageParcel &data, MessageParcel &reply); 316 317 /** 318 * @brief Handle get forms count message. 319 * @param data input param. 320 * @param reply output param. 321 * @return Return ERR_OK on success, others on failure. 322 */ 323 int32_t HandleGetFormsCount(MessageParcel &data, MessageParcel &reply); 324 325 /** 326 * @brief Handle get host forms count message. 327 * @param data input param. 328 * @param reply output param. 329 * @return Return ERR_OK on success, others on failure. 330 */ 331 int32_t HandleGetHostFormsCount(MessageParcel &data, MessageParcel &reply); 332 333 /** 334 * @brief Handle get Running forms infos message. 335 * @param data input param. 336 * @param reply output param. 337 * @return Return ERR_OK on success, others on failure. 338 */ 339 ErrCode HandleGetRunningFormInfos(MessageParcel &data, MessageParcel &reply); 340 341 /** 342 * @brief Handle get Running forms infos by bundleName message. 343 * @param data input param. 344 * @param reply output param. 345 * @return Return ERR_OK on success, others on failure. 346 */ 347 ErrCode HandleGetRunningFormInfosByBundleName(MessageParcel &data, MessageParcel &reply); 348 349 /** 350 * @brief Get form instances by filter info. 351 * @param data input param 352 * @param reply output param 353 * @return Return ERR_OK on success, others on failure 354 */ 355 ErrCode HandleGetFormInstancesByFilter(MessageParcel &data, MessageParcel &reply); 356 357 /** 358 * @brief Get form instances by filter info. 359 * @param data input param 360 * @param reply output param 361 * @return Return ERR_OK on success, others on failure 362 */ 363 ErrCode HandleGetFormInstanceById(MessageParcel &data, MessageParcel &reply); 364 365 /** 366 * @brief Register form add observer. 367 * @param data input param 368 * @param reply output param 369 * @return Return ERR_OK on success, others on failure 370 */ 371 ErrCode HandleRegisterAddObserver(MessageParcel &data, MessageParcel &reply); 372 /** 373 * @brief Register form remove observer. 374 * @param data input param 375 * @param reply output param 376 * @return Return ERR_OK on success, others on failure 377 */ 378 ErrCode HandleRegisterRemoveObserver(MessageParcel &data, MessageParcel &reply); 379 380 /** 381 * @brief update proxy form. 382 * @param data input param 383 * @param reply output param 384 * @return Return ERR_OK on success, others on failure 385 */ 386 ErrCode HandleUpdateProxyForm(MessageParcel &data, MessageParcel &reply); 387 388 /** 389 * @brief handle request publish form message. 390 * @param data input param. 391 * @param reply output param. 392 * @return Returns ERR_OK on success, others on failure. 393 */ 394 ErrCode HandleRequestPublishProxyForm(MessageParcel &data, MessageParcel &reply); 395 396 /** 397 * @brief Register the callback to publish form. The callback is used to process the publish form request 398 * when the system handler is not found. 399 * @param interceptorCallback The injected callback, should implementation IFormPublishInterceptor. 400 * @return Returns ERR_OK on success, others on failure. 401 */ 402 int32_t HandleRegisterPublishFormInterceptor(MessageParcel &data, MessageParcel &reply); 403 404 /** 405 * @brief Unregister the callback to publish form. The callback is used to process the publish form request 406 * when the system handler is not found. 407 * @param interceptorCallback The injected callback, should implementation IFormPublishInterceptor. 408 * @return Returns ERR_OK on success, others on failure. 409 */ 410 int32_t HandleUnregisterPublishFormInterceptor(MessageParcel &data, MessageParcel &reply); 411 412 bool ReadFormDataProxies(MessageParcel &data, std::vector<FormDataProxy> &formDataProxies); 413 private: 414 using FormMgrFunc = int32_t (FormMgrStub::*)(MessageParcel &data, MessageParcel &reply); 415 std::map<uint32_t, FormMgrFunc> memberFuncMap_; 416 417 DISALLOW_COPY_AND_MOVE(FormMgrStub); 418 419 /** 420 * @brief Write a parcelabe vector objects to the proxy node. 421 * @param parcelableVector Indicates the objects to be write. 422 * @param reply Indicates the reply to be sent; 423 * @return Returns true if objects send successfully; returns false otherwise. 424 */ 425 template<typename T> 426 bool WriteParcelableVector(std::vector<T> &parcelableVector, Parcel &reply); 427 }; 428 } // namespace AppExecFwk 429 } // namespace OHOS 430 #endif // OHOS_FORM_FWK_FORM_MGR_STUB_H 431