1 /* 2 * Copyright (c) 2022-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 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 }; CastTempForm(const int64_t formId,const sptr<IRemoteObject> & callerToken)80 int32_t CastTempForm(const int64_t formId, const sptr<IRemoteObject> &callerToken) override 81 { 82 return ERR_OK; 83 }; DumpStorageFormInfos(std::string & formInfos)84 int32_t DumpStorageFormInfos(std::string &formInfos) override 85 { 86 return ERR_OK; 87 }; DumpFormInfoByBundleName(const std::string & bundleName,std::string & formInfos)88 int32_t DumpFormInfoByBundleName(const std::string &bundleName, std::string &formInfos) override 89 { 90 return ERR_OK; 91 }; DumpFormInfoByFormId(const std::int64_t formId,std::string & formInfo)92 int32_t DumpFormInfoByFormId(const std::int64_t formId, std::string &formInfo) override 93 { 94 return ERR_OK; 95 }; DumpFormTimerByFormId(const std::int64_t formId,std::string & isTimingService)96 int32_t DumpFormTimerByFormId(const std::int64_t formId, std::string &isTimingService) override 97 { 98 return ERR_OK; 99 }; MessageEvent(const int64_t formId,const Want & want,const sptr<IRemoteObject> & callerToken)100 int32_t MessageEvent(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken) override 101 { 102 return ERR_OK; 103 }; RouterEvent(const int64_t formId,Want & want,const sptr<IRemoteObject> & callerToken)104 int32_t RouterEvent(const int64_t formId, Want &want, const sptr<IRemoteObject> &callerToken) override 105 { 106 return ERR_OK; 107 }; BackgroundEvent(const int64_t formId,Want & want,const sptr<IRemoteObject> & callerToken)108 int32_t BackgroundEvent(const int64_t formId, Want &want, const sptr<IRemoteObject> &callerToken) override 109 { 110 return ERR_OK; 111 }; DeleteInvalidForms(const std::vector<int64_t> & formIds,const sptr<IRemoteObject> & callerToken,int32_t & numFormsDeleted)112 int32_t DeleteInvalidForms(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken, 113 int32_t &numFormsDeleted) override 114 { 115 return ERR_OK; 116 }; AcquireFormState(const Want & want,const sptr<IRemoteObject> & callerToken,FormStateInfo & stateInfo)117 int32_t AcquireFormState(const Want &want, const sptr<IRemoteObject> &callerToken, 118 FormStateInfo &stateInfo) override 119 { 120 return ERR_OK; 121 }; NotifyFormsVisible(const std::vector<int64_t> & formIds,bool isVisible,const sptr<IRemoteObject> & callerToken)122 int32_t NotifyFormsVisible(const std::vector<int64_t> &formIds, bool isVisible, 123 const sptr<IRemoteObject> &callerToken) override 124 { 125 return ERR_OK; 126 }; NotifyFormsPrivacyProtected(const std::vector<int64_t> & formIds,bool isProtected,const sptr<IRemoteObject> & callerToken)127 int32_t NotifyFormsPrivacyProtected(const std::vector<int64_t> &formIds, bool isProtected, 128 const sptr<IRemoteObject> &callerToken) override 129 { 130 return ERR_OK; 131 }; NotifyFormsEnableUpdate(const std::vector<int64_t> & formIds,bool isEnableUpdate,const sptr<IRemoteObject> & callerToken)132 int32_t NotifyFormsEnableUpdate(const std::vector<int64_t> &formIds, bool isEnableUpdate, 133 const sptr<IRemoteObject> &callerToken) override 134 { 135 return ERR_OK; 136 }; GetAllFormsInfo(std::vector<FormInfo> & formInfos)137 int32_t GetAllFormsInfo(std::vector<FormInfo> &formInfos) override 138 { 139 return ERR_OK; 140 }; GetFormsInfoByApp(std::string & bundleName,std::vector<FormInfo> & formInfos)141 int32_t GetFormsInfoByApp(std::string &bundleName, std::vector<FormInfo> &formInfos) override 142 { 143 return ERR_OK; 144 }; GetFormsInfoByModule(std::string & bundleName,std::string & moduleName,std::vector<FormInfo> & formInfos)145 int32_t GetFormsInfoByModule(std::string &bundleName, std::string &moduleName, 146 std::vector<FormInfo> &formInfos) override 147 { 148 return ERR_OK; 149 }; ShareForm(const int64_t formId,const std::string & deviceId,const sptr<IRemoteObject> & callerToken,const int64_t requestCode)150 int32_t ShareForm(const int64_t formId, const std::string &deviceId, 151 const sptr<IRemoteObject> &callerToken, const int64_t requestCode) override 152 { 153 return ERR_OK; 154 }; AcquireFormData(int64_t formId,int64_t requestCode,const sptr<IRemoteObject> & callerToken,AAFwk::WantParams & formData)155 int32_t AcquireFormData(int64_t formId, int64_t requestCode, const sptr<IRemoteObject> &callerToken, 156 AAFwk::WantParams &formData) override 157 { 158 return ERR_OK; 159 }; RecvFormShareInfoFromRemote(const FormShareInfo & info)160 int32_t RecvFormShareInfoFromRemote(const FormShareInfo &info) override 161 { 162 return ERR_OK; 163 }; IsRequestPublishFormSupported()164 bool IsRequestPublishFormSupported() override 165 { 166 return true; 167 }; StartAbility(const Want & want,const sptr<IRemoteObject> & callerToken)168 int32_t StartAbility(const Want &want, const sptr<IRemoteObject> &callerToken) override 169 { 170 return ERR_OK; 171 }; GetFormsInfo(const FormInfoFilter & filter,std::vector<FormInfo> & formInfos)172 int32_t GetFormsInfo(const FormInfoFilter &filter, std::vector<FormInfo> &formInfos) override 173 { 174 return ERR_OK; 175 }; CheckFMSReady()176 bool CheckFMSReady() override 177 { 178 return false; 179 }; SetBackgroundFunction(const std::string method,const std::string params)180 int32_t SetBackgroundFunction(const std::string method, const std::string params) override 181 { 182 return ERR_OK; 183 }; GetFormsCount(bool isTempFormFlag,int32_t & formCount)184 int32_t GetFormsCount(bool isTempFormFlag, int32_t &formCount) override 185 { 186 return ERR_OK; 187 } GetHostFormsCount(std::string & bundleName,int32_t & formCount)188 int32_t GetHostFormsCount(std::string &bundleName, int32_t &formCount) override 189 { 190 return ERR_OK; 191 } GetRunningFormInfos(bool isUnusedIncluded,std::vector<RunningFormInfo> & runningFormInfos)192 ErrCode GetRunningFormInfos(bool isUnusedIncluded, std::vector<RunningFormInfo> &runningFormInfos) override 193 { 194 return ERR_OK; 195 } GetRunningFormInfosByBundleName(const std::string & bundleName,bool isUnusedIncluded,std::vector<RunningFormInfo> & runningFormInfos)196 ErrCode GetRunningFormInfosByBundleName( 197 const std::string &bundleName, bool isUnusedIncluded, std::vector<RunningFormInfo> &runningFormInfos) override 198 { 199 return ERR_OK; 200 } GetFormInstancesByFilter(const FormInstancesFilter & formInstancesFilter,std::vector<FormInstance> & formInstances)201 int32_t GetFormInstancesByFilter(const FormInstancesFilter &formInstancesFilter, 202 std::vector<FormInstance> &formInstances) override 203 { 204 return 0; 205 } GetFormInstanceById(const int64_t formId,FormInstance & formInstance)206 int32_t GetFormInstanceById(const int64_t formId, FormInstance &formInstance) override 207 { 208 return 0; 209 } RegisterFormAddObserverByBundle(const std::string bundleName,const sptr<IRemoteObject> & callerToken)210 ErrCode RegisterFormAddObserverByBundle(const std::string bundleName, 211 const sptr<IRemoteObject> &callerToken) override 212 { 213 return ERR_OK; 214 } RegisterFormRemoveObserverByBundle(const std::string bundleName,const sptr<IRemoteObject> & callerToken)215 ErrCode RegisterFormRemoveObserverByBundle(const std::string bundleName, 216 const sptr<IRemoteObject> &callerToken) override 217 { 218 return ERR_OK; 219 } RegisterAddObserver(const std::string & bundleName,const sptr<IRemoteObject> & callerToken)220 ErrCode RegisterAddObserver(const std::string &bundleName, const sptr<IRemoteObject> &callerToken) override 221 { 222 return ERR_OK; 223 } RegisterRemoveObserver(const std::string & bundleName,const sptr<IRemoteObject> & callerToken)224 ErrCode RegisterRemoveObserver(const std::string &bundleName, const sptr<IRemoteObject> &callerToken) override 225 { 226 return ERR_OK; 227 } RegisterFormRouterProxy(const std::vector<int64_t> & formIds,const sptr<IRemoteObject> & callerToken)228 ErrCode RegisterFormRouterProxy(const std::vector<int64_t> &formIds, 229 const sptr<IRemoteObject> &callerToken) override 230 { 231 return ERR_OK; 232 } UnregisterFormRouterProxy(const std::vector<int64_t> & formIds)233 ErrCode UnregisterFormRouterProxy(const std::vector<int64_t> &formIds) override 234 { 235 return ERR_OK; 236 } RegisterClickEventObserver(const std::string & bundleName,const std::string & formEventType,const sptr<IRemoteObject> & observer)237 ErrCode RegisterClickEventObserver( 238 const std::string &bundleName, const std::string &formEventType, const sptr<IRemoteObject> &observer) override 239 { 240 return ERR_OK; 241 } UnregisterClickEventObserver(const std::string & bundleName,const std::string & formEventType,const sptr<IRemoteObject> & observer)242 ErrCode UnregisterClickEventObserver( 243 const std::string &bundleName, const std::string &formEventType, const sptr<IRemoteObject> &observer) override 244 { 245 return ERR_OK; 246 } 247 }; 248 } // namespace AppExecFwk 249 } // namespace OHOS 250 #endif // FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_MGR_SERVICE_H