1 /* 2 * Copyright (c) 2021 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 FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_FORMMGR_FORM_MGR_INTERFACE_H 17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_FORMMGR_FORM_MGR_INTERFACE_H 18 19 #include <vector> 20 #include "form_info.h" 21 #include "form_js_info.h" 22 #include "form_provider_data.h" 23 #include "form_state_info.h" 24 #include "ipc_types.h" 25 #include "iremote_broker.h" 26 27 #include "want.h" 28 29 namespace OHOS { 30 namespace AppExecFwk { 31 using OHOS::AAFwk::Want; 32 33 /** 34 * @class IFormMgr 35 * IFormMgr interface is used to access form manager service. 36 */ 37 class IFormMgr : public OHOS::IRemoteBroker { 38 public: 39 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.FormMgr") 40 41 /** 42 * @brief Add form with want, send want to form manager service. 43 * @param formId The Id of the forms to add. 44 * @param want The want of the form to add. 45 * @param callerToken Caller ability token. 46 * @param formInfo Form info. 47 * @return Returns ERR_OK on success, others on failure. 48 */ 49 virtual int AddForm(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken, 50 FormJsInfo &formInfo) = 0; 51 52 /** 53 * @brief Delete forms with formIds, send formIds to form manager service. 54 * @param formId The Id of the forms to delete. 55 * @param callerToken Caller ability token. 56 * @return Returns ERR_OK on success, others on failure. 57 */ 58 virtual int DeleteForm(const int64_t formId, const sptr<IRemoteObject> &callerToken) = 0; 59 60 /** 61 * @brief Release forms with formIds, send formIds to form manager service. 62 * @param formId The Id of the forms to release. 63 * @param callerToken Caller ability token. 64 * @param delCache Delete Cache or not. 65 * @return Returns ERR_OK on success, others on failure. 66 */ 67 virtual int ReleaseForm(const int64_t formId, const sptr<IRemoteObject> &callerToken, const bool delCache) = 0; 68 69 /** 70 * @brief Update form with formId, send formId to form manager service. 71 * @param formId The Id of the form to update. 72 * @param formProviderData Form binding data. 73 * @return Returns ERR_OK on success, others on failure. 74 */ 75 virtual int UpdateForm(const int64_t formId, const FormProviderData &formProviderData) = 0; 76 77 /** 78 * @brief Set next refresh time. 79 * @param formId The Id of the form to update. 80 * @param nextTime Next refresh time. 81 * @return Returns ERR_OK on success, others on failure. 82 */ 83 virtual int SetNextRefreshTime(const int64_t formId, const int64_t nextTime) = 0; 84 85 /** 86 * @brief Lifecycle update. 87 * @param formIds The Id of the forms. 88 * @param callerToken Caller ability token. 89 * @param updateType update type. 90 * @return Returns ERR_OK on success, others on failure. 91 */ 92 virtual int LifecycleUpdate(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken, 93 const int32_t updateType) = 0; 94 95 /** 96 * @brief Request form with formId and want, send formId and want to form manager service. 97 * @param formId The Id of the form to request. 98 * @param callerToken Caller ability token. 99 * @param want The want of the form to add. 100 * @return Returns ERR_OK on success, others on failure. 101 */ 102 virtual int RequestForm(const int64_t formId, const sptr<IRemoteObject> &callerToken, const Want &want) = 0; 103 104 /** 105 * @brief Form visible/invisible notify, send formIds to form manager service. 106 * @param formIds The Id list of the forms to notify. 107 * @param callerToken Caller ability token. 108 * @param formVisibleType The form visible type, including FORM_VISIBLE and FORM_INVISIBLE. 109 * @return Returns ERR_OK on success, others on failure. 110 */ 111 virtual int NotifyWhetherVisibleForms(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken, 112 const int32_t formVisibleType) = 0; 113 114 /** 115 * @brief temp form to normal form. 116 * @param formId The Id of the form. 117 * @param callerToken Caller ability token. 118 * @return Returns ERR_OK on success, others on failure. 119 */ 120 virtual int CastTempForm(const int64_t formId, const sptr<IRemoteObject> &callerToken) = 0; 121 122 /** 123 * @brief Dump all of form storage infos. 124 * @param formInfos All of form storage infos. 125 * @return Returns ERR_OK on success, others on failure. 126 */ 127 virtual int DumpStorageFormInfos(std::string &formInfos) = 0; 128 /** 129 * @brief Dump form info by a bundle name. 130 * @param bundleName The bundle name of form provider. 131 * @param formInfos Form infos. 132 * @return Returns ERR_OK on success, others on failure. 133 */ 134 virtual int DumpFormInfoByBundleName(const std::string &bundleName, std::string &formInfos) = 0; 135 /** 136 * @brief Dump form info by a bundle name. 137 * @param formId The id of the form. 138 * @param formInfo Form info. 139 * @return Returns ERR_OK on success, others on failure. 140 */ 141 virtual int DumpFormInfoByFormId(const std::int64_t formId, std::string &formInfo) = 0; 142 /** 143 * @brief Dump form timer by form id. 144 * @param formId The id of the form. 145 * @param formInfo Form timer. 146 * @return Returns ERR_OK on success, others on failure. 147 */ 148 virtual int DumpFormTimerByFormId(const std::int64_t formId, std::string &isTimingService) = 0; 149 /** 150 * @brief Process js message event. 151 * @param formId Indicates the unique id of form. 152 * @param want information passed to supplier. 153 * @param callerToken Caller ability token. 154 * @return Returns true if execute success, false otherwise. 155 */ 156 virtual int MessageEvent(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken) = 0; 157 158 /** 159 * @brief Process js router event. 160 * @param formId Indicates the unique id of form. 161 * @param want the want of the ability to start. 162 * @return Returns true if execute success, false otherwise. 163 */ 164 virtual int RouterEvent(const int64_t formId, Want &want) = 0; 165 166 /** 167 * @brief Batch add forms to form records for st limit value test. 168 * @param want The want of the form to add. 169 * @return Returns ERR_OK on success, others on failure. 170 */ 171 virtual int BatchAddFormRecords(const Want &want) = 0; 172 /** 173 * @brief Clear form records for st limit value test. 174 * @return Returns ERR_OK on success, others on failure. 175 */ 176 virtual int ClearFormRecords() = 0; 177 178 /** 179 * @brief Add forms to storage for st . 180 * @param Want The Want of the form to add. 181 * @return Returns ERR_OK on success, others on failure. 182 */ 183 virtual int DistributedDataAddForm(const Want &want) = 0; 184 185 /** 186 * @brief Delete form form storage for st. 187 * @param formId The formId of the form to delete. 188 * @return Returns ERR_OK on success, others on failure. 189 */ 190 virtual int DistributedDataDeleteForm(const std::string &formId) = 0; 191 192 /** 193 * @brief Delete the invalid forms. 194 * @param formIds Indicates the ID of the valid forms. 195 * @param callerToken Caller ability token. 196 * @param numFormsDeleted Returns the number of the deleted forms. 197 * @return Returns ERR_OK on success, others on failure. 198 */ 199 virtual int DeleteInvalidForms(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken, 200 int32_t &numFormsDeleted) = 0; 201 202 /** 203 * @brief Acquire form state info by passing a set of parameters (using Want) to the form provider. 204 * @param want Indicates a set of parameters to be transparently passed to the form provider. 205 * @param callerToken Caller ability token. 206 * @param stateInfo Returns the form's state info of the specify. 207 * @return Returns ERR_OK on success, others on failure. 208 */ 209 virtual int AcquireFormState(const Want &want, const sptr<IRemoteObject> &callerToken, 210 FormStateInfo &stateInfo) = 0; 211 212 /** 213 * @brief Notify the form is visible or not. 214 * @param formIds Indicates the ID of the forms. 215 * @param isVisible Visible or not. 216 * @param callerToken Host client. 217 * @return Returns ERR_OK on success, others on failure. 218 */ 219 virtual int NotifyFormsVisible(const std::vector<int64_t> &formIds, bool isVisible, 220 const sptr<IRemoteObject> &callerToken) = 0; 221 222 /** 223 * @brief Notify the form is enable to be updated or not. 224 * @param formIds Indicates the ID of the forms. 225 * @param isEnableUpdate enable update or not. 226 * @param callerToken Host client. 227 * @return Returns ERR_OK on success, others on failure. 228 */ 229 virtual int NotifyFormsEnableUpdate(const std::vector<int64_t> &formIds, bool isEnableUpdate, 230 const sptr<IRemoteObject> &callerToken) = 0; 231 232 /** 233 * @brief Get All FormsInfo. 234 * @param formInfos Return the forms' information of all forms provided. 235 * @return Returns ERR_OK on success, others on failure. 236 */ 237 virtual int GetAllFormsInfo(std::vector<FormInfo> &formInfos) = 0; 238 239 /** 240 * @brief Get forms info by bundle name . 241 * @param bundleName Application name. 242 * @param formInfos Return the forms' information of the specify application name. 243 * @return Returns ERR_OK on success, others on failure. 244 */ 245 virtual int GetFormsInfoByApp(std::string &bundleName, std::vector<FormInfo> &formInfos) = 0; 246 247 /** 248 * @brief Get forms info by bundle name and module name. 249 * @param bundleName bundle name. 250 * @param moduleName Module name of hap. 251 * @param formInfos Return the forms' information of the specify bundle name and module name. 252 * @return Returns ERR_OK on success, others on failure. 253 */ 254 virtual int GetFormsInfoByModule(std::string &bundleName, std::string &moduleName, 255 std::vector<FormInfo> &formInfos) = 0; 256 257 /** 258 * @brief Update action string for router event. 259 * @param formId Indicates the unique id of form. 260 * @param action Indicates the origin action string. 261 * @return Returns ERR_OK on success, others on failure. 262 */ 263 virtual int UpdateRouterAction(const int64_t formId, std::string &action) = 0; 264 265 enum class Message { 266 // ipc id 1-1000 for kit 267 // ipc id 1001-2000 for DMS 268 // ipc id 2001-3000 for tools 269 // ipc id for create (3001) 270 FORM_MGR_ADD_FORM = 3001, 271 FORM_MGR_ADD_FORM_OHOS, 272 FORM_MGR_DELETE_FORM, 273 FORM_MGR_UPDATE_FORM, 274 FORM_MGR_LIFECYCLE_UPDATE, 275 FORM_MGR_REQUEST_FORM, 276 FORM_MGR_RELEASE_FORM, 277 FORM_MGR_RELEASE_CACHED_FORM, 278 FORM_MGR_CAST_TEMP_FORM, 279 FORM_MGR_EVENT_NOTIFY, 280 FORM_MGR_CHECK_AND_DELETE_INVALID_FORMS, 281 FORM_MGR_SET_NEXT_REFRESH_TIME, 282 FORM_MGR_NOTIFY_FORM_WHETHER_VISIBLE, 283 FORM_MGR_STORAGE_FORM_INFOS, 284 FORM_MGR_FORM_INFOS_BY_NAME, 285 FORM_MGR_FORM_INFOS_BY_ID, 286 FORM_MGR_FORM_TIMER_INFO_BY_ID, 287 FORM_MGR_MESSAGE_EVENT, 288 FORM_MGR_BATCH_ADD_FORM_RECORDS_ST, 289 FORM_MGR_CLEAR_FORM_RECORDS_ST, 290 FORM_MGR_DISTRIBUTED_DATA_ADD_FORM__ST, 291 FORM_MGR_DISTRIBUTED_DATA_DELETE_FORM__ST, 292 FORM_MGR_DELETE_INVALID_FORMS, 293 FORM_MGR_ACQUIRE_FORM_STATE, 294 FORM_MGR_NOTIFY_FORMS_VISIBLE, 295 FORM_MGR_NOTIFY_FORMS_ENABLE_UPDATE, 296 FORM_MGR_GET_ALL_FORMS_INFO, 297 FORM_MGR_GET_FORMS_INFO_BY_APP, 298 FORM_MGR_GET_FORMS_INFO_BY_MODULE, 299 FORM_MGR_UPDATE_ROUTER_ACTION, 300 FORM_MGR_ROUTER_EVENT, 301 }; 302 }; 303 } // namespace AppExecFwk 304 } // namespace OHOS 305 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_FORMMGR_FORM_MGR_INTERFACE_H 306