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_MGR_INTERFACE_H 17 #define OHOS_FORM_FWK_FORM_MGR_INTERFACE_H 18 19 #include <vector> 20 #include "form_info.h" 21 #include "form_info_filter.h" 22 #include "form_js_info.h" 23 #include "form_provider_data.h" 24 #include "form_share_info.h" 25 #include "form_state_info.h" 26 #include "ipc_types.h" 27 #include "iremote_broker.h" 28 29 #include "want.h" 30 31 namespace OHOS { 32 namespace AppExecFwk { 33 using OHOS::AAFwk::Want; 34 35 /** 36 * @class IFormMgr 37 * IFormMgr interface is used to access form manager service. 38 */ 39 class IFormMgr : public OHOS::IRemoteBroker { 40 public: 41 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.FormMgr") 42 43 /** 44 * @brief Add form with want, send want to form manager service. 45 * @param formId The Id of the forms to add. 46 * @param want The want of the form to add. 47 * @param callerToken Caller ability token. 48 * @param formInfo Form info. 49 * @return Returns ERR_OK on success, others on failure. 50 */ 51 virtual int AddForm(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken, 52 FormJsInfo &formInfo) = 0; 53 54 /** 55 * @brief Delete forms with formIds, send formIds to form manager service. 56 * @param formId The Id of the forms to delete. 57 * @param callerToken Caller ability token. 58 * @return Returns ERR_OK on success, others on failure. 59 */ 60 virtual int DeleteForm(const int64_t formId, const sptr<IRemoteObject> &callerToken) = 0; 61 62 /** 63 * @brief Stop rendering form. 64 * @param formId The Id of the forms to delete. 65 * @param compId The compId of the forms to delete. 66 * @return Returns ERR_OK on success, others on failure. 67 */ StopRenderingForm(const int64_t formId,const std::string & compId)68 virtual int StopRenderingForm(const int64_t formId, const std::string &compId) 69 { 70 return ERR_OK; 71 }; 72 73 /** 74 * @brief Release forms with formIds, send formIds to form manager service. 75 * @param formId The Id of the forms to release. 76 * @param callerToken Caller ability token. 77 * @param delCache Delete Cache or not. 78 * @return Returns ERR_OK on success, others on failure. 79 */ 80 virtual int ReleaseForm(const int64_t formId, const sptr<IRemoteObject> &callerToken, const bool delCache) = 0; 81 82 /** 83 * @brief Update form with formId, send formId to form manager service. 84 * @param formId The Id of the form to update. 85 * @param formProviderData Form binding data. 86 * @return Returns ERR_OK on success, others on failure. 87 */ 88 virtual int UpdateForm(const int64_t formId, const FormProviderData &formProviderData) = 0; 89 90 /** 91 * @brief Set next refresh time. 92 * @param formId The Id of the form to update. 93 * @param nextTime Next refresh time. 94 * @return Returns ERR_OK on success, others on failure. 95 */ 96 virtual int SetNextRefreshTime(const int64_t formId, const int64_t nextTime) = 0; 97 98 /** 99 * @brief Request to publish a form to the form host. 100 * 101 * @param want The want of the form to publish. 102 * @param withFormBindingData Indicates whether the formBindingData is carried with. 103 * @param formBindingData Indicates the form data. 104 * @param formId Return the form id to be published. 105 * @return Returns ERR_OK on success, others on failure. 106 */ 107 virtual ErrCode RequestPublishForm(Want &want, bool withFormBindingData, 108 std::unique_ptr<FormProviderData> &formBindingData, int64_t &formId) = 0; 109 110 /** 111 * @brief Lifecycle update. 112 * @param formIds The Id of the forms. 113 * @param callerToken Caller ability token. 114 * @param updateType update type, enable if true and disable if false. 115 * @return Returns ERR_OK on success, others on failure. 116 */ 117 virtual int LifecycleUpdate(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken, 118 bool updateType) = 0; 119 120 /** 121 * @brief Request form with formId and want, send formId and want to form manager service. 122 * @param formId The Id of the form to request. 123 * @param callerToken Caller ability token. 124 * @param want The want of the form to add. 125 * @return Returns ERR_OK on success, others on failure. 126 */ 127 virtual int RequestForm(const int64_t formId, const sptr<IRemoteObject> &callerToken, const Want &want) = 0; 128 129 /** 130 * @brief Form visible/invisible notify, send formIds to form manager service. 131 * @param formIds The Id list of the forms to notify. 132 * @param callerToken Caller ability token. 133 * @param formVisibleType The form visible type, including FORM_VISIBLE and FORM_INVISIBLE. 134 * @return Returns ERR_OK on success, others on failure. 135 */ 136 virtual int NotifyWhetherVisibleForms(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken, 137 const int32_t formVisibleType) = 0; 138 139 /** 140 * @brief temp form to normal form. 141 * @param formId The Id of the form. 142 * @param callerToken Caller ability token. 143 * @return Returns ERR_OK on success, others on failure. 144 */ 145 virtual int CastTempForm(const int64_t formId, const sptr<IRemoteObject> &callerToken) = 0; 146 147 /** 148 * @brief Dump all of form storage infos. 149 * @param formInfos All of form storage infos. 150 * @return Returns ERR_OK on success, others on failure. 151 */ 152 virtual int DumpStorageFormInfos(std::string &formInfos) = 0; 153 /** 154 * @brief Dump form info by a bundle name. 155 * @param bundleName The bundle name of form provider. 156 * @param formInfos Form infos. 157 * @return Returns ERR_OK on success, others on failure. 158 */ 159 virtual int DumpFormInfoByBundleName(const std::string &bundleName, std::string &formInfos) = 0; 160 /** 161 * @brief Dump form info by a bundle name. 162 * @param formId The id of the form. 163 * @param formInfo Form info. 164 * @return Returns ERR_OK on success, others on failure. 165 */ 166 virtual int DumpFormInfoByFormId(const std::int64_t formId, std::string &formInfo) = 0; 167 /** 168 * @brief Dump form timer by form id. 169 * @param formId The id of the form. 170 * @param formInfo Form timer. 171 * @return Returns ERR_OK on success, others on failure. 172 */ 173 virtual int DumpFormTimerByFormId(const std::int64_t formId, std::string &isTimingService) = 0; 174 /** 175 * @brief Process js message event. 176 * @param formId Indicates the unique id of form. 177 * @param want information passed to supplier. 178 * @param callerToken Caller ability token. 179 * @return Returns true if execute success, false otherwise. 180 */ 181 virtual int MessageEvent(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken) = 0; 182 183 /** 184 * @brief Process Background event. 185 * @param formId Indicates the unique id of form. 186 * @param want the want of the ability to start. 187 * @param callerToken Caller ability token. 188 * @return Returns true if execute success, false otherwise. 189 */ 190 virtual int BackgroundEvent(const int64_t formId, Want &want, const sptr<IRemoteObject> &callerToken) = 0; 191 192 /** 193 * @brief Process js router event. 194 * @param formId Indicates the unique id of form. 195 * @param want the want of the ability to start. 196 * @param callerToken Caller ability token. 197 * @return Returns true if execute success, false otherwise. 198 */ 199 virtual int RouterEvent(const int64_t formId, Want &want, const sptr<IRemoteObject> &callerToken) = 0; 200 201 /** 202 * @brief Delete the invalid forms. 203 * @param formIds Indicates the ID of the valid forms. 204 * @param callerToken Caller ability token. 205 * @param numFormsDeleted Returns the number of the deleted forms. 206 * @return Returns ERR_OK on success, others on failure. 207 */ 208 virtual int DeleteInvalidForms(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken, 209 int32_t &numFormsDeleted) = 0; 210 211 /** 212 * @brief Acquire form state info by passing a set of parameters (using Want) to the form provider. 213 * @param want Indicates a set of parameters to be transparently passed to the form provider. 214 * @param callerToken Caller ability token. 215 * @param stateInfo Returns the form's state info of the specify. 216 * @return Returns ERR_OK on success, others on failure. 217 */ 218 virtual int AcquireFormState(const Want &want, const sptr<IRemoteObject> &callerToken, 219 FormStateInfo &stateInfo) = 0; 220 221 /** 222 * @brief Notify the form is visible or not. 223 * @param formIds Indicates the ID of the forms. 224 * @param isVisible Visible or not. 225 * @param callerToken Host client. 226 * @return Returns ERR_OK on success, others on failure. 227 */ 228 virtual int NotifyFormsVisible(const std::vector<int64_t> &formIds, bool isVisible, 229 const sptr<IRemoteObject> &callerToken) = 0; 230 231 /** 232 * @brief Notify the form is privacy protected or not. 233 * @param formIds Indicates the ID of the forms. 234 * @param isProtected isProtected or not. 235 * @param callerToken Host client. 236 * @return Returns ERR_OK on success, others on failure. 237 */ 238 virtual int NotifyFormsPrivacyProtected(const std::vector<int64_t> &formIds, bool isProtected, 239 const sptr<IRemoteObject> &callerToken) = 0; 240 241 /** 242 * @brief Notify the form is enable to be updated or not. 243 * @param formIds Indicates the ID of the forms. 244 * @param isEnableUpdate enable update or not. 245 * @param callerToken Host client. 246 * @return Returns ERR_OK on success, others on failure. 247 */ 248 virtual int NotifyFormsEnableUpdate(const std::vector<int64_t> &formIds, bool isEnableUpdate, 249 const sptr<IRemoteObject> &callerToken) = 0; 250 251 /** 252 * @brief Get All FormsInfo. 253 * @param formInfos Return the forms' information of all forms provided. 254 * @return Returns ERR_OK on success, others on failure. 255 */ 256 virtual int GetAllFormsInfo(std::vector<FormInfo> &formInfos) = 0; 257 258 /** 259 * @brief Get forms info by bundle name . 260 * @param bundleName Application name. 261 * @param formInfos Return the forms' information of the specify application name. 262 * @return Returns ERR_OK on success, others on failure. 263 */ 264 virtual int GetFormsInfoByApp(std::string &bundleName, std::vector<FormInfo> &formInfos) = 0; 265 266 /** 267 * @brief Get forms info by bundle name and module name. 268 * @param bundleName bundle name. 269 * @param moduleName Module name of hap. 270 * @param formInfos Return the forms' information of the specify bundle name and module name. 271 * @return Returns ERR_OK on success, others on failure. 272 */ 273 virtual int GetFormsInfoByModule(std::string &bundleName, std::string &moduleName, 274 std::vector<FormInfo> &formInfos) = 0; 275 276 /** 277 * @brief This function is called by formProvider and gets forms info by the bundle name of the calling ability. 278 * The bundle name will be retrieved by form service manager. 279 * @param filter Filter that contains attributes that the formInfos have to have. 280 * @param formInfos Return the forms' information of the calling bundle name 281 * @return Returns ERR_OK on success, others on failure. 282 */ 283 virtual int32_t GetFormsInfo(const FormInfoFilter &filter, std::vector<FormInfo> &formInfos) = 0; 284 285 /** 286 * @brief Check if the request of publishing a form is supported by the host. 287 * @return Returns true if the request is supported and false otherwise. 288 */ 289 virtual bool IsRequestPublishFormSupported() = 0; 290 291 /** 292 * @brief Start an ability. This function can only be called by a form extension of a system app. 293 * @param want includes ability name, parameters and relative info sending to an ability. 294 * @param callerToken token of the ability that initially calls this function. 295 * @return Returns ERR_OK on success, others on failure. 296 */ 297 virtual int32_t StartAbility(const Want &want, const sptr<IRemoteObject> &callerToken) = 0; 298 299 /** 300 * @brief Share form by formID and deviceID. 301 * @param formId Indicates the unique id of form. 302 * @param deviceId Indicates the remote device ID. 303 * @param callerToken Host client. 304 * @param requestCode Indicates the request code of this share form. 305 * @return Returns ERR_OK on success, others on failure. 306 */ 307 virtual int32_t ShareForm(int64_t formId, const std::string &deviceId, const sptr<IRemoteObject> &callerToken, 308 int64_t requestCode) = 0; 309 310 /** 311 * @brief Receive form sharing information from remote. 312 * @param info Indicates form sharing information. 313 * @return Returns ERR_OK on success, others on failure. 314 */ 315 virtual int32_t RecvFormShareInfoFromRemote(const FormShareInfo &info) = 0; 316 317 /** 318 * @brief Check form manager service ready. 319 * @return Return true if form manager service Ready; return false otherwise. 320 */ 321 virtual bool CheckFMSReady() = 0; 322 323 enum class Message { 324 // ipc id 1-1000 for kit 325 // ipc id 1001-2000 for DMS 326 // ipc id 2001-3000 for tools 327 // ipc id for create (3001) 328 FORM_MGR_ADD_FORM = 3001, 329 FORM_MGR_ADD_FORM_OHOS, 330 FORM_MGR_DELETE_FORM, 331 FORM_MGR_UPDATE_FORM, 332 FORM_MGR_LIFECYCLE_UPDATE, 333 FORM_MGR_REQUEST_FORM, 334 FORM_MGR_RELEASE_FORM, 335 FORM_MGR_RELEASE_CACHED_FORM, 336 FORM_MGR_CAST_TEMP_FORM, 337 FORM_MGR_EVENT_NOTIFY, 338 FORM_MGR_CHECK_AND_DELETE_INVALID_FORMS, 339 FORM_MGR_SET_NEXT_REFRESH_TIME, 340 FORM_MGR_NOTIFY_FORM_WHETHER_VISIBLE, 341 FORM_MGR_STORAGE_FORM_INFOS, 342 FORM_MGR_FORM_INFOS_BY_NAME, 343 FORM_MGR_FORM_INFOS_BY_ID, 344 FORM_MGR_FORM_TIMER_INFO_BY_ID, 345 FORM_MGR_MESSAGE_EVENT, 346 FORM_MGR_BATCH_ADD_FORM_RECORDS_ST, 347 FORM_MGR_CLEAR_FORM_RECORDS_ST, 348 FORM_MGR_DISTRIBUTED_DATA_ADD_FORM__ST, 349 FORM_MGR_DISTRIBUTED_DATA_DELETE_FORM__ST, 350 FORM_MGR_DELETE_INVALID_FORMS, 351 FORM_MGR_ACQUIRE_FORM_STATE, 352 FORM_MGR_NOTIFY_FORMS_VISIBLE, 353 FORM_MGR_NOTIFY_FORMS_ENABLE_UPDATE, 354 FORM_MGR_GET_ALL_FORMS_INFO, 355 FORM_MGR_GET_FORMS_INFO_BY_APP, 356 FORM_MGR_GET_FORMS_INFO_BY_MODULE, 357 FORM_MGR_GET_FORMS_INFO, 358 FORM_MGR_ROUTER_EVENT, 359 FORM_MGR_UPDATE_ROUTER_ACTION, 360 FORM_MGR_ADD_FORM_INFO, 361 FORM_MGR_REMOVE_FORM_INFO, 362 FORM_MGR_REQUEST_PUBLISH_FORM, 363 FORM_MGR_IS_REQUEST_PUBLISH_FORM_SUPPORTED, 364 FORM_MGR_SHARE_FORM, 365 FORM_MGR_RECV_FORM_SHARE_INFO_FROM_REMOTE, 366 FORM_MGR_START_ABILITY, 367 FORM_MGR_NOTIFY_FORMS_PRIVACY_PROTECTED, 368 FORM_MGR_CHECK_FMS_READY, 369 FORM_MGR_BACKGROUND_EVENT, 370 FORM_MGR_STOP_RENDERING_FORM, 371 }; 372 }; 373 } // namespace AppExecFwk 374 } // namespace OHOS 375 #endif // OHOS_FORM_FWK_FORM_MGR_INTERFACE_H 376