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_PROXY_H 17 #define OHOS_FORM_FWK_FORM_SUPPLY_PROXY_H 18 19 #include "form_supply_interface.h" 20 #include "iremote_proxy.h" 21 22 namespace OHOS { 23 namespace AppExecFwk { 24 /** 25 * @class FormSupplyProxy 26 * FormSupplyProxy is used to access form supply service. 27 */ 28 class FormSupplyProxy : public IRemoteProxy<IFormSupply> { 29 public: FormSupplyProxy(const sptr<IRemoteObject> & impl)30 explicit FormSupplyProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IFormSupply>(impl) 31 {} 32 33 virtual ~FormSupplyProxy() = default; 34 35 /** 36 * @brief Send form binding data from form provider to fms. 37 * @param providerFormInfo Form binding data. 38 * @param want input data. 39 * @return Returns ERR_OK on success, others on failure. 40 */ 41 virtual int OnAcquire(const FormProviderInfo &formInfo, const Want &want) override; 42 43 /** 44 * @brief Send other event to fms. 45 * @param want input data. 46 * @return Returns ERR_OK on success, others on failure. 47 */ 48 virtual int OnEventHandle(const Want &want) override; 49 50 /** 51 * @brief Accept form state from form provider. 52 * @param state Form state. 53 * @param provider provider info. 54 * @param wantArg The want of onAcquireFormState. 55 * @param want input data. 56 * @return Returns ERR_OK on success, others on failure. 57 */ 58 virtual int OnAcquireStateResult(FormState state, const std::string &provider, const Want &wantArg, 59 const Want &want) override; 60 61 /** 62 * @brief Accept form sharing data from form provider. 63 * @param formId The Id of the from. 64 * @param remoteDeviceId Indicates the remote device ID. 65 * @param wantParams Indicates the data information shared by the form. 66 * @param requestCode Indicates the requested id. 67 * @param result Indicates the results of parsing shared data. 68 * @return Returns ERR_OK on success, others on failure. 69 */ 70 void OnShareAcquire(int64_t formId, const std::string &remoteDeviceId, 71 const AAFwk::WantParams &wantParams, int64_t requestCode, const bool &result) override; 72 73 /** 74 * @brief Accept form data from form provider. 75 * @param wantParams Indicates the data information acquired by the form. 76 * @param requestCode Indicates the requested id. 77 * @return Returns ERR_OK on success, others on failure. 78 */ 79 virtual int OnAcquireDataResult(const AAFwk::WantParams &wantParams, int64_t requestCode) override; 80 81 /** 82 * @brief Accept form render task done from render service. 83 * @param formId The Id of the form. 84 * @param want input data. 85 * @return Returns ERR_OK on success, others on failure. 86 */ 87 int32_t OnRenderTaskDone(int64_t formId, const Want &want) override; 88 89 /** 90 * @brief Accept form stop rendering task done from render service. 91 * @param formId The Id of the form. 92 * @param want input data. 93 * @return Returns ERR_OK on success, others on failure. 94 */ 95 int32_t OnStopRenderingTaskDone(int64_t formId, const Want &want) override; 96 97 /** 98 * @brief Accept rendering block from render service. 99 * @param bundleName The block of bundleName. 100 * @return Returns ERR_OK on success, others on failure. 101 */ 102 int32_t OnRenderingBlock(const std::string &bundleName) override; 103 104 /** 105 * @brief Accept status data of form to be recycled from render service. 106 * @param formId The id of the form. 107 * @param want Input data. 108 * @return Returns ERR_OK on success, others on failure. 109 */ 110 int32_t OnRecycleForm(const int64_t &formId, const Want &want) override; 111 112 /** 113 * @brief Trigger card recover when configuration changes occur. 114 * @param formIds The ids of the forms. 115 * @return Returns ERR_OK on success, others on failure. 116 */ 117 int32_t OnRecoverFormsByConfigUpdate(std::vector<int64_t> &formIds) override; 118 119 int32_t OnNotifyRefreshForm(const int64_t &formId) override; 120 121 private: 122 template<typename T> 123 int GetParcelableInfos(MessageParcel &reply, std::vector<T> &parcelableInfos); 124 bool WriteInterfaceToken(MessageParcel &data); 125 int SendTransactCmd(IFormSupply::Message code, MessageParcel &data, 126 MessageParcel &reply, MessageOption &option); 127 128 private: 129 static inline BrokerDelegator<FormSupplyProxy> delegator_; 130 }; 131 } // namespace AppExecFwk 132 } // namespace OHOS 133 #endif // OHOS_FORM_FWK_FORM_SUPPLY_PROXY_H 134