• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 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_event_handler.h"
27 #include "form_mgr_stub.h"
28 #include "form_provider_data.h"
29 #include "iremote_object.h"
30 
31 namespace OHOS {
32 namespace AppExecFwk {
33 /**
34  * @class MockFormMgrService
35  */
36 class MockFormMgrService : public FormMgrStub,
37                        public std::enable_shared_from_this<MockFormMgrService> {
38 public:
39     MockFormMgrService() = default;
40     virtual~MockFormMgrService() = default;
AddForm(const int64_t formId,const Want & want,const sptr<IRemoteObject> & callerToken,FormJsInfo & formInfo)41     int32_t AddForm(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken,
42         FormJsInfo &formInfo) override
43     {
44         return ERR_OK;
45     };
DeleteForm(const int64_t formId,const sptr<IRemoteObject> & callerToken)46     int32_t DeleteForm(const int64_t formId, const sptr<IRemoteObject> &callerToken) override
47     {
48         return ERR_OK;
49     };
ReleaseForm(const int64_t formId,const sptr<IRemoteObject> & callerToken,const bool delCache)50     int32_t ReleaseForm(const int64_t formId, const sptr<IRemoteObject> &callerToken, const bool delCache) override
51     {
52         return ERR_OK;
53     };
UpdateForm(const int64_t formId,const FormProviderData & FormProviderData)54     int32_t UpdateForm(const int64_t formId, const FormProviderData &FormProviderData) override
55     {
56         return ERR_OK;
57     };
SetNextRefreshTime(const int64_t formId,const int64_t nextTime)58     int32_t SetNextRefreshTime(const int64_t formId, const int64_t nextTime) override
59     {
60         return ERR_OK;
61     };
LifecycleUpdate(const std::vector<int64_t> & formIds,const sptr<IRemoteObject> & callerToken,const bool updateType)62     int32_t LifecycleUpdate(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken,
63         const bool updateType) override
64     {
65         return ERR_OK;
66     };
RequestPublishForm(Want & want,bool withFormBindingData,std::unique_ptr<FormProviderData> & formBindingData,int64_t & formId)67     ErrCode RequestPublishForm(Want &want, bool withFormBindingData,
68         std::unique_ptr<FormProviderData> &formBindingData, int64_t &formId) override
69     {
70         return ERR_OK;
71     };
RequestForm(const int64_t formId,const sptr<IRemoteObject> & callerToken,const Want & want)72     int32_t RequestForm(const int64_t formId, const sptr<IRemoteObject> &callerToken, const Want &want) override
73     {
74         return ERR_OK;
75     };
NotifyWhetherVisibleForms(const std::vector<int64_t> & formIds,const sptr<IRemoteObject> & callerToken,const int32_t formVisibleType)76     int32_t NotifyWhetherVisibleForms(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken,
77         const int32_t formVisibleType) override
78     {
79         return ERR_OK;
80     };
CastTempForm(const int64_t formId,const sptr<IRemoteObject> & callerToken)81     int32_t CastTempForm(const int64_t formId, const sptr<IRemoteObject> &callerToken) override
82     {
83         return ERR_OK;
84     };
DumpStorageFormInfos(std::string & formInfos)85     int32_t DumpStorageFormInfos(std::string &formInfos) override
86     {
87         return ERR_OK;
88     };
DumpFormInfoByBundleName(const std::string & bundleName,std::string & formInfos)89     int32_t DumpFormInfoByBundleName(const std::string &bundleName, std::string &formInfos) override
90     {
91         return ERR_OK;
92     };
DumpFormInfoByFormId(const std::int64_t formId,std::string & formInfo)93     int32_t DumpFormInfoByFormId(const std::int64_t formId, std::string &formInfo) override
94     {
95         return ERR_OK;
96     };
DumpFormTimerByFormId(const std::int64_t formId,std::string & isTimingService)97     int32_t DumpFormTimerByFormId(const std::int64_t formId, std::string &isTimingService) override
98     {
99         return ERR_OK;
100     };
MessageEvent(const int64_t formId,const Want & want,const sptr<IRemoteObject> & callerToken)101     int32_t MessageEvent(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken) override
102     {
103         return ERR_OK;
104     };
RouterEvent(const int64_t formId,Want & want,const sptr<IRemoteObject> & callerToken)105     int32_t RouterEvent(const int64_t formId, Want &want, const sptr<IRemoteObject> &callerToken) override
106     {
107         return ERR_OK;
108     };
BackgroundEvent(const int64_t formId,Want & want,const sptr<IRemoteObject> & callerToken)109     int32_t BackgroundEvent(const int64_t formId, Want &want, const sptr<IRemoteObject> &callerToken) override
110     {
111         return ERR_OK;
112     };
DeleteInvalidForms(const std::vector<int64_t> & formIds,const sptr<IRemoteObject> & callerToken,int32_t & numFormsDeleted)113     int32_t DeleteInvalidForms(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken,
114                                    int32_t &numFormsDeleted) override
115     {
116         return ERR_OK;
117     };
AcquireFormState(const Want & want,const sptr<IRemoteObject> & callerToken,FormStateInfo & stateInfo)118     int32_t AcquireFormState(const Want &want, const sptr<IRemoteObject> &callerToken,
119                                  FormStateInfo &stateInfo) override
120     {
121         return ERR_OK;
122     };
NotifyFormsVisible(const std::vector<int64_t> & formIds,bool isVisible,const sptr<IRemoteObject> & callerToken)123     int32_t NotifyFormsVisible(const std::vector<int64_t> &formIds, bool isVisible,
124                                    const sptr<IRemoteObject> &callerToken) override
125     {
126         return ERR_OK;
127     };
NotifyFormsPrivacyProtected(const std::vector<int64_t> & formIds,bool isProtected,const sptr<IRemoteObject> & callerToken)128     int32_t NotifyFormsPrivacyProtected(const std::vector<int64_t> &formIds, bool isProtected,
129                                         const sptr<IRemoteObject> &callerToken) override
130     {
131         return ERR_OK;
132     };
NotifyFormsEnableUpdate(const std::vector<int64_t> & formIds,bool isEnableUpdate,const sptr<IRemoteObject> & callerToken)133     int32_t NotifyFormsEnableUpdate(const std::vector<int64_t> &formIds, bool isEnableUpdate,
134                                         const sptr<IRemoteObject> &callerToken) override
135     {
136         return ERR_OK;
137     };
GetAllFormsInfo(std::vector<FormInfo> & formInfos)138     int32_t GetAllFormsInfo(std::vector<FormInfo> &formInfos) override
139     {
140         return ERR_OK;
141     };
GetFormsInfoByApp(std::string & bundleName,std::vector<FormInfo> & formInfos)142     int32_t GetFormsInfoByApp(std::string &bundleName, std::vector<FormInfo> &formInfos) override
143     {
144         return ERR_OK;
145     };
GetFormsInfoByModule(std::string & bundleName,std::string & moduleName,std::vector<FormInfo> & formInfos)146     int32_t GetFormsInfoByModule(std::string &bundleName, std::string &moduleName,
147                              std::vector<FormInfo> &formInfos) override
148     {
149         return ERR_OK;
150     };
ShareForm(const int64_t formId,const std::string & deviceId,const sptr<IRemoteObject> & callerToken,const int64_t requestCode)151     int32_t ShareForm(const int64_t formId, const std::string &deviceId,
152         const sptr<IRemoteObject> &callerToken, const int64_t requestCode) override
153     {
154         return ERR_OK;
155     };
RecvFormShareInfoFromRemote(const FormShareInfo & info)156     int32_t RecvFormShareInfoFromRemote(const FormShareInfo &info) override
157     {
158         return ERR_OK;
159     };
IsRequestPublishFormSupported()160     bool IsRequestPublishFormSupported() override
161     {
162         return true;
163     };
StartAbility(const Want & want,const sptr<IRemoteObject> & callerToken)164     int32_t StartAbility(const Want &want, const sptr<IRemoteObject> &callerToken) override
165     {
166         return ERR_OK;
167     };
GetFormsInfo(const FormInfoFilter & filter,std::vector<FormInfo> & formInfos)168     int32_t GetFormsInfo(const FormInfoFilter &filter, std::vector<FormInfo> &formInfos) override
169     {
170         return ERR_OK;
171     };
CheckFMSReady()172     bool CheckFMSReady() override
173     {
174         return false;
175     };
SetBackgroundFunction(const std::string method,const std::string params)176     int32_t SetBackgroundFunction(const std::string method, const std::string params) override
177     {
178         return ERR_OK;
179     };
180 };
181 }  // namespace AppExecFwk
182 }  // namespace OHOS
183 #endif  // FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_MGR_SERVICE_H
184