1 /* 2 * Copyright (c) 2022-2024 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_SERVICES_FORMMGR_INCLUDE_FORM_MGR_SERVICE_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_MGR_SERVICE_H 18 19 #include <codecvt> 20 #include <memory> 21 #include <singleton.h> 22 #include <system_ability.h> 23 #include <thread_ex.h> 24 #include <unordered_map> 25 26 #include "form_mgr_stub.h" 27 #include "form_provider_data.h" 28 #include "iremote_object.h" 29 30 namespace OHOS { 31 namespace AppExecFwk { 32 /** 33 * @class MockFormMgrService 34 */ 35 class MockFormMgrService : public FormMgrStub, 36 public std::enable_shared_from_this<MockFormMgrService> { 37 public: 38 MockFormMgrService() = default; 39 virtual~MockFormMgrService() = default; AddForm(const int64_t formId,const Want & want,const sptr<IRemoteObject> & callerToken,FormJsInfo & formInfo)40 int32_t AddForm(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken, 41 FormJsInfo &formInfo) override 42 { 43 return ERR_OK; 44 }; DeleteForm(const int64_t formId,const sptr<IRemoteObject> & callerToken)45 int32_t DeleteForm(const int64_t formId, const sptr<IRemoteObject> &callerToken) override 46 { 47 return ERR_OK; 48 }; ReleaseForm(const int64_t formId,const sptr<IRemoteObject> & callerToken,const bool delCache)49 int32_t ReleaseForm(const int64_t formId, const sptr<IRemoteObject> &callerToken, const bool delCache) override 50 { 51 return ERR_OK; 52 }; UpdateForm(const int64_t formId,const FormProviderData & FormProviderData)53 int32_t UpdateForm(const int64_t formId, const FormProviderData &FormProviderData) override 54 { 55 return ERR_OK; 56 }; SetNextRefreshTime(const int64_t formId,const int64_t nextTime)57 int32_t SetNextRefreshTime(const int64_t formId, const int64_t nextTime) override 58 { 59 return ERR_OK; 60 }; LifecycleUpdate(const std::vector<int64_t> & formIds,const sptr<IRemoteObject> & callerToken,const bool updateType)61 int32_t LifecycleUpdate(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken, 62 const bool updateType) override 63 { 64 return ERR_OK; 65 }; RequestPublishForm(Want & want,bool withFormBindingData,std::unique_ptr<FormProviderData> & formBindingData,int64_t & formId)66 ErrCode RequestPublishForm(Want &want, bool withFormBindingData, 67 std::unique_ptr<FormProviderData> &formBindingData, int64_t &formId) override 68 { 69 return ERR_OK; 70 }; RequestForm(const int64_t formId,const sptr<IRemoteObject> & callerToken,const Want & want)71 int32_t RequestForm(const int64_t formId, const sptr<IRemoteObject> &callerToken, const Want &want) override 72 { 73 return ERR_OK; 74 }; NotifyWhetherVisibleForms(const std::vector<int64_t> & formIds,const sptr<IRemoteObject> & callerToken,const int32_t formVisibleType)75 int32_t NotifyWhetherVisibleForms(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken, 76 const int32_t formVisibleType) override 77 { 78 return ERR_OK; 79 }; HasFormVisible(const uint32_t tokenId)80 bool HasFormVisible(const uint32_t tokenId) override 81 { 82 return false; 83 } CastTempForm(const int64_t formId,const sptr<IRemoteObject> & callerToken)84 int32_t CastTempForm(const int64_t formId, const sptr<IRemoteObject> &callerToken) override 85 { 86 return ERR_OK; 87 }; DumpStorageFormInfos(std::string & formInfos)88 int32_t DumpStorageFormInfos(std::string &formInfos) override 89 { 90 return ERR_OK; 91 }; DumpFormInfoByBundleName(const std::string & bundleName,std::string & formInfos)92 int32_t DumpFormInfoByBundleName(const std::string &bundleName, std::string &formInfos) override 93 { 94 return ERR_OK; 95 }; DumpFormInfoByFormId(const std::int64_t formId,std::string & formInfo)96 int32_t DumpFormInfoByFormId(const std::int64_t formId, std::string &formInfo) override 97 { 98 return ERR_OK; 99 }; DumpFormTimerByFormId(const std::int64_t formId,std::string & isTimingService)100 int32_t DumpFormTimerByFormId(const std::int64_t formId, std::string &isTimingService) override 101 { 102 return ERR_OK; 103 }; MessageEvent(const int64_t formId,const Want & want,const sptr<IRemoteObject> & callerToken)104 int32_t MessageEvent(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken) override 105 { 106 return ERR_OK; 107 }; RouterEvent(const int64_t formId,Want & want,const sptr<IRemoteObject> & callerToken)108 int32_t RouterEvent(const int64_t formId, Want &want, const sptr<IRemoteObject> &callerToken) override 109 { 110 return ERR_OK; 111 }; BackgroundEvent(const int64_t formId,Want & want,const sptr<IRemoteObject> & callerToken)112 int32_t BackgroundEvent(const int64_t formId, Want &want, const sptr<IRemoteObject> &callerToken) override 113 { 114 return ERR_OK; 115 }; DeleteInvalidForms(const std::vector<int64_t> & formIds,const sptr<IRemoteObject> & callerToken,int32_t & numFormsDeleted)116 int32_t DeleteInvalidForms(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken, 117 int32_t &numFormsDeleted) override 118 { 119 return ERR_OK; 120 }; AcquireFormState(const Want & want,const sptr<IRemoteObject> & callerToken,FormStateInfo & stateInfo)121 int32_t AcquireFormState(const Want &want, const sptr<IRemoteObject> &callerToken, 122 FormStateInfo &stateInfo) override 123 { 124 return ERR_OK; 125 }; NotifyFormsVisible(const std::vector<int64_t> & formIds,bool isVisible,const sptr<IRemoteObject> & callerToken)126 int32_t NotifyFormsVisible(const std::vector<int64_t> &formIds, bool isVisible, 127 const sptr<IRemoteObject> &callerToken) override 128 { 129 return ERR_OK; 130 }; NotifyFormsPrivacyProtected(const std::vector<int64_t> & formIds,bool isProtected,const sptr<IRemoteObject> & callerToken)131 int32_t NotifyFormsPrivacyProtected(const std::vector<int64_t> &formIds, bool isProtected, 132 const sptr<IRemoteObject> &callerToken) override 133 { 134 return ERR_OK; 135 }; NotifyFormsEnableUpdate(const std::vector<int64_t> & formIds,bool isEnableUpdate,const sptr<IRemoteObject> & callerToken)136 int32_t NotifyFormsEnableUpdate(const std::vector<int64_t> &formIds, bool isEnableUpdate, 137 const sptr<IRemoteObject> &callerToken) override 138 { 139 return ERR_OK; 140 }; GetAllFormsInfo(std::vector<FormInfo> & formInfos)141 int32_t GetAllFormsInfo(std::vector<FormInfo> &formInfos) override 142 { 143 return ERR_OK; 144 }; GetFormsInfoByApp(std::string & bundleName,std::vector<FormInfo> & formInfos)145 int32_t GetFormsInfoByApp(std::string &bundleName, std::vector<FormInfo> &formInfos) override 146 { 147 return ERR_OK; 148 }; GetFormsInfoByModule(std::string & bundleName,std::string & moduleName,std::vector<FormInfo> & formInfos)149 int32_t GetFormsInfoByModule(std::string &bundleName, std::string &moduleName, 150 std::vector<FormInfo> &formInfos) override 151 { 152 return ERR_OK; 153 }; ShareForm(const int64_t formId,const std::string & deviceId,const sptr<IRemoteObject> & callerToken,const int64_t requestCode)154 int32_t ShareForm(const int64_t formId, const std::string &deviceId, 155 const sptr<IRemoteObject> &callerToken, const int64_t requestCode) override 156 { 157 return ERR_OK; 158 }; AcquireFormData(int64_t formId,int64_t requestCode,const sptr<IRemoteObject> & callerToken,AAFwk::WantParams & formData)159 int32_t AcquireFormData(int64_t formId, int64_t requestCode, const sptr<IRemoteObject> &callerToken, 160 AAFwk::WantParams &formData) override 161 { 162 return ERR_OK; 163 }; RecvFormShareInfoFromRemote(const FormShareInfo & info)164 int32_t RecvFormShareInfoFromRemote(const FormShareInfo &info) override 165 { 166 return ERR_OK; 167 }; IsRequestPublishFormSupported()168 bool IsRequestPublishFormSupported() override 169 { 170 return true; 171 }; StartAbility(const Want & want,const sptr<IRemoteObject> & callerToken)172 int32_t StartAbility(const Want &want, const sptr<IRemoteObject> &callerToken) override 173 { 174 return ERR_OK; 175 }; GetFormsInfo(const FormInfoFilter & filter,std::vector<FormInfo> & formInfos)176 int32_t GetFormsInfo(const FormInfoFilter &filter, std::vector<FormInfo> &formInfos) override 177 { 178 return ERR_OK; 179 }; CheckFMSReady()180 bool CheckFMSReady() override 181 { 182 return false; 183 }; SetBackgroundFunction(const std::string method,const std::string params)184 int32_t SetBackgroundFunction(const std::string method, const std::string params) override 185 { 186 return ERR_OK; 187 }; GetFormsCount(bool isTempFormFlag,int32_t & formCount)188 int32_t GetFormsCount(bool isTempFormFlag, int32_t &formCount) override 189 { 190 return ERR_OK; 191 } GetHostFormsCount(std::string & bundleName,int32_t & formCount)192 int32_t GetHostFormsCount(std::string &bundleName, int32_t &formCount) override 193 { 194 return ERR_OK; 195 } GetRunningFormInfos(bool isUnusedIncluded,std::vector<RunningFormInfo> & runningFormInfos)196 ErrCode GetRunningFormInfos(bool isUnusedIncluded, std::vector<RunningFormInfo> &runningFormInfos) override 197 { 198 return ERR_OK; 199 } GetRunningFormInfosByBundleName(const std::string & bundleName,bool isUnusedIncluded,std::vector<RunningFormInfo> & runningFormInfos)200 ErrCode GetRunningFormInfosByBundleName( 201 const std::string &bundleName, bool isUnusedIncluded, std::vector<RunningFormInfo> &runningFormInfos) override 202 { 203 return ERR_OK; 204 } GetFormInstancesByFilter(const FormInstancesFilter & formInstancesFilter,std::vector<FormInstance> & formInstances)205 int32_t GetFormInstancesByFilter(const FormInstancesFilter &formInstancesFilter, 206 std::vector<FormInstance> &formInstances) override 207 { 208 return 0; 209 } GetFormInstanceById(const int64_t formId,FormInstance & formInstance)210 int32_t GetFormInstanceById(const int64_t formId, FormInstance &formInstance) override 211 { 212 return 0; 213 } RegisterFormAddObserverByBundle(const std::string bundleName,const sptr<IRemoteObject> & callerToken)214 ErrCode RegisterFormAddObserverByBundle(const std::string bundleName, 215 const sptr<IRemoteObject> &callerToken) override 216 { 217 return ERR_OK; 218 } RegisterFormRemoveObserverByBundle(const std::string bundleName,const sptr<IRemoteObject> & callerToken)219 ErrCode RegisterFormRemoveObserverByBundle(const std::string bundleName, 220 const sptr<IRemoteObject> &callerToken) override 221 { 222 return ERR_OK; 223 } RegisterAddObserver(const std::string & bundleName,const sptr<IRemoteObject> & callerToken)224 ErrCode RegisterAddObserver(const std::string &bundleName, const sptr<IRemoteObject> &callerToken) override 225 { 226 return ERR_OK; 227 } RegisterRemoveObserver(const std::string & bundleName,const sptr<IRemoteObject> & callerToken)228 ErrCode RegisterRemoveObserver(const std::string &bundleName, const sptr<IRemoteObject> &callerToken) override 229 { 230 return ERR_OK; 231 } RegisterFormRouterProxy(const std::vector<int64_t> & formIds,const sptr<IRemoteObject> & callerToken)232 ErrCode RegisterFormRouterProxy(const std::vector<int64_t> &formIds, 233 const sptr<IRemoteObject> &callerToken) override 234 { 235 return ERR_OK; 236 } UnregisterFormRouterProxy(const std::vector<int64_t> & formIds)237 ErrCode UnregisterFormRouterProxy(const std::vector<int64_t> &formIds) override 238 { 239 return ERR_OK; 240 } RegisterClickEventObserver(const std::string & bundleName,const std::string & formEventType,const sptr<IRemoteObject> & observer)241 ErrCode RegisterClickEventObserver( 242 const std::string &bundleName, const std::string &formEventType, const sptr<IRemoteObject> &observer) override 243 { 244 return ERR_OK; 245 } UnregisterClickEventObserver(const std::string & bundleName,const std::string & formEventType,const sptr<IRemoteObject> & observer)246 ErrCode UnregisterClickEventObserver( 247 const std::string &bundleName, const std::string &formEventType, const sptr<IRemoteObject> &observer) override 248 { 249 return ERR_OK; 250 } RequestPublishFormWithSnapshot(Want & want,bool withFormBindingData,std::unique_ptr<FormProviderData> & formBindingData,int64_t & formId)251 ErrCode RequestPublishFormWithSnapshot(Want &want, bool withFormBindingData, 252 std::unique_ptr<FormProviderData> &formBindingData, int64_t &formId) override 253 { 254 return ERR_OK; 255 }; 256 }; 257 } // namespace AppExecFwk 258 } // namespace OHOS 259 #endif // FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_MGR_SERVICE_H