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_PROVIDER_INTERFACE_H 17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_FORMMGR_FORM_PROVIDER_INTERFACE_H 18 19 #include <vector> 20 21 #include "ipc_types.h" 22 #include "iremote_broker.h" 23 #include "want.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 using OHOS::AAFwk::Want; 28 /** 29 * @class IFormProvider 30 * IFormProvider interface is used to access form provider service. 31 */ 32 class IFormProvider : public OHOS::IRemoteBroker { 33 public: 34 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.FormProvider"); 35 36 /** 37 * @brief Acquire to give back an ProviderFormInfo. This is sync API. 38 * @param formId The Id of the from. 39 * @param want Indicates the {@link Want} structure containing form info. 40 * @param callerToken Caller ability token. 41 * @return Returns ERR_OK on success, others on failure. 42 */ 43 virtual int AcquireProviderFormInfo(const int64_t formId, const Want &want, 44 const sptr<IRemoteObject> &callerToken) = 0; 45 46 /** 47 * @brief Notify provider when the form was deleted. 48 * @param formId The Id of the form. 49 * @param want Indicates the structure containing form info. 50 * @param callerToken Caller ability token. 51 * @return Returns ERR_OK on success, others on failure. 52 */ 53 virtual int NotifyFormDelete(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken) = 0; 54 55 /** 56 * @brief Notify provider when the forms was deleted. 57 * @param formIds The id list of forms. 58 * @param want Indicates the structure containing form info. 59 * @param callerToken Caller ability token. 60 * @return Returns ERR_OK on success, others on failure. 61 */ 62 virtual int NotifyFormsDelete(const std::vector<int64_t> &formIds, const Want &want, 63 const sptr<IRemoteObject> &callerToken) = 0; 64 /** 65 * @brief Notify provider when the form need update. 66 * @param formId The Id of the form. 67 * @param want Indicates the structure containing form info. 68 * @param callerToken Caller ability token. 69 * @return Returns ERR_OK on success, others on failure. 70 */ 71 virtual int NotifyFormUpdate(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken) = 0; 72 73 /** 74 * @brief Event notify when change the form visible. 75 * 76 * @param formIds The vector of form ids. 77 * @param formVisibleType The form visible type, including FORM_VISIBLE and FORM_INVISIBLE. 78 * @param want Indicates the structure containing form info. 79 * @param callerToken Caller ability token. 80 * @return Returns ERR_OK on success, others on failure. 81 */ 82 virtual int EventNotify(const std::vector<int64_t> &formIds, const int32_t formVisibleType, 83 const Want &want, const sptr<IRemoteObject> &callerToken) = 0; 84 85 /** 86 * @brief Notify provider when the temp form was cast to normal form. 87 * @param formId The Id of the form to update. 88 * @param want Indicates the structure containing form info. 89 * @param callerToken Caller ability token. 90 * @return Returns ERR_OK on success, others on failure. 91 */ 92 virtual int NotifyFormCastTempForm(const int64_t formId, const Want &want, 93 const sptr<IRemoteObject> &callerToken) = 0; 94 95 /** 96 * @brief Fire message event to form provider. 97 * @param formId The Id of the from. 98 * @param message Event message. 99 * @param want The want of the request. 100 * @param callerToken Form provider proxy object. 101 * @return Returns ERR_OK on success, others on failure. 102 */ 103 virtual int FireFormEvent(const int64_t formId, const std::string &message, const Want &want, 104 const sptr<IRemoteObject> &callerToken) = 0; 105 106 /** 107 * @brief Acquire form state to form provider. 108 * @param wantArg The want of onAcquireFormState. 109 * @param provider The provider info. 110 * @param want The want of the request. 111 * @param callerToken Form provider proxy object. 112 * @return Returns ERR_OK on success, others on failure. 113 */ 114 virtual int AcquireState(const Want &wantArg, const std::string &provider, const Want &want, 115 const sptr<IRemoteObject> &callerToken) = 0; 116 117 enum class Message { 118 // ipc id 1-1000 for kit 119 // ipc id 1001-2000 for DMS 120 // ipc id 2001-3000 for tools 121 // ipc id for add form (3001) 122 FORM_ACQUIRE_PROVIDER_FORM_INFO = 3051, 123 124 // ipc id for delete form (3052) 125 FORM_PROVIDER_NOTIFY_FORM_DELETE, 126 127 // ipc id for form done release form (3053) 128 FORM_PROVIDER_NOTIFY_FORMS_DELETE, 129 130 // ipc id for connecting update form (3054) 131 FORM_PROVIDER_NOTIFY_FORM_UPDATE, 132 133 // ipc id for form visible notify (3055) 134 FORM_PROVIDER_NOTIFY_TEMP_FORM_CAST, 135 136 // ipc id for event notify (3056) 137 FORM_PROVIDER_EVENT_NOTIFY, 138 139 // ipc id for event notify (3057) 140 FORM_PROVIDER_EVENT_MESSAGE, 141 142 // ipc id for acquiring form state (3058) 143 FORM_PROVIDER_NOTIFY_STATE_ACQUIRE, 144 }; 145 }; 146 } // namespace AppExecFwk 147 } // namespace OHOS 148 149 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_FORMMGR_FORM_PROVIDER_INTERFACE_H 150