• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #ifndef GET_PARAM_H
16 #define GET_PARAM_H
17 #include <memory>
18 #include <cstdint>
19 #include <string>
20 #include <vector>
21 
22 #include "ability.h"
23 #include "ability_context.h"
24 #include "ability_event_interface.h"
25 #include "ability_info.h"
26 #include "ability_handler.h"
27 #include "ability_manager.h"
28 #include "ability_manager_interface.h"
29 #include "async_common_event_result.h"
30 #include "bundle_info.h"
31 #include "common_event_manager.h"
32 #include "common_event_data.h"
33 #include "common_event_publish_info.h"
34 #include "common_event_subscribe_info.h"
35 #include "common_event_subscriber.h"
36 #include "common_event_support.h"
37 #include "data_uri_utils.h"
38 #include "dummy_component_container.h"
39 #include "dumper.h"
40 #include "element_name.h"
41 #include "event_handler.h"
42 #include "event_runner.h"
43 #include "inner_event.h"
44 #include "iremote_broker.h"
45 #include "iremote_object.h"
46 #include "key_event.h"
47 #include "logger.h"
48 #include "matching_skills.h"
49 #include "module_info.h"
50 #include "native_implement_eventhandler.h"
51 #include "pac_map.h"
52 #include "parcel.h"
53 #include "patterns_matcher.h"
54 #include "uri.h"
55 #include "want.h"
56 #include "bundle_mgr_proxy.h"
57 #include "ohos_application.h"
58 
59 namespace OHOS {
60 namespace EventFwk {
61 class TestDumper;
62 bool GetBoolParam();
63 uint8_t GetU8Param();
64 unsigned int GetUIntParam();
65 uint16_t GetU16Param();
66 uint32_t GetU32Param();
67 uint64_t GetU64Param();
68 int8_t GetS8Param();
69 int16_t GetS16Param();
70 int32_t GetS32Param();
71 int64_t GetS64Param();
72 char32_t GetChar32Param();
73 
74 short GetShortParam();
75 long GetLongParam();
76 int GetIntParam();
77 double GetDoubleParam();
78 float GetFloatParam();
79 char GetCharParam();
80 char *GetCharArryParam();
81 std::string GetStringParam();
82 std::vector<bool> GetBoolVectorParam();
83 std::vector<short> GetShortVectorParam();
84 std::vector<long> GetLongVectorParam();
85 std::vector<int> GetIntVectorParam();
86 std::vector<float> GetFloatVectorParam();
87 std::vector<double> GetDoubleVectorParam();
88 std::vector<char> GetCharVectorParam();
89 std::vector<char32_t> GetChar32VectorParam();
90 std::vector<std::string> GetStringVectorParam();
91 template <class T>
92 std::vector<T> GetUnsignVectorParam();
93 std::vector<int8_t> GetS8VectorParam();
94 std::vector<int16_t> GetS16VectorParam();
95 std::vector<int32_t> GetS32VectorParam();
96 std::vector<int64_t> GetS64VectorParam();
97 
98 std::shared_ptr<Parcel> GetParamParcel();
99 std::shared_ptr<Want> GetParamWant();
100 OHOS::AAFwk::Operation GetParamOperation();
101 std::shared_ptr<AsyncCommonEventResult> GetParamAsyncCommonEventResult();
102 std::shared_ptr<CommonEventData> GetParamCommonEventData();
103 std::shared_ptr<CommonEventManager> GetParamCommonEventManager();
104 std::shared_ptr<CommonEventPublishInfo> GetParamCommonEventPublishInfo();
105 std::shared_ptr<CommonEventSubscribeInfo> GetParamCommonEventSubscribeInfo();
106 std::shared_ptr<CommonEventSubscriber> GetParamCommonEventSubscriber();
107 std::shared_ptr<CommonEventSupport> GetParamCommonEventSupport();
108 std::shared_ptr<MatchingSkills> GetParamMatchingSkills();
109 sptr<IRemoteObject> GetParamSptrRemote();
110 std::shared_ptr<OHOS::AppExecFwk::EventRunner> GetParamEventRunner();
111 std::shared_ptr<OHOS::AppExecFwk::EventHandler> GetParamEventHandler();
112 std::shared_ptr<OHOS::AppExecFwk::EventQueue> GetParamEventQueue();
113 std::shared_ptr<EventRunnerNativeImplement> GetParamEventRunnerNativeImplement();
114 std::shared_ptr<OHOS::AppExecFwk::FileDescriptorListener> GetParamFileDescriptorListener();
115 std::shared_ptr<OHOS::AppExecFwk::Logger> GetParamLogger();
116 OHOS::AppExecFwk::EventQueue::Priority GetParamPriority();
117 TestDumper GetParamDumper();
118 OHOS::AppExecFwk::InnerEvent::Pointer GetParamInnerEvent();
119 OHOS::AppExecFwk::InnerEvent::Callback GetParamCallback();
120 OHOS::AppExecFwk::InnerEvent::TimePoint GetParamTimePoint();
121 CommonEventSubscribeInfo::ThreadMode GetParamThreadMode();
122 
123 std::shared_ptr<OHOS::AppExecFwk::AbilityContext> GetParamAbilityContext();
124 std::shared_ptr<OHOS::AppExecFwk::IAbilityEvent> GetParamIAbilityEvent();
125 std::shared_ptr<OHOS::AppExecFwk::AbilityHandler> GetParamAbilityHandler();
126 std::shared_ptr<OHOS::AppExecFwk::AbilityStartSetting> GetParamAbilityStartSetting();
127 std::shared_ptr<OHOS::AppExecFwk::Ability> GetParamAbility();
128 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> GetParamOHOSApplication();
129 OHOS::Uri GetParamUri();
130 
131 NativeRdb::ValuesBucket GetParamValuesBucket();
132 OHOS::AppExecFwk::Configuration GetParamConfiguration();
133 NativeRdb::DataAbilityPredicates GetParamDataAbilityPredicates();
134 OHOS::AppExecFwk::PacMap GetParamPacMap();
135 OHOS::AppExecFwk::NotificationRequest GetParamNotificationRequest();
136 std::shared_ptr<OHOS::AppExecFwk::ComponentContainer> GetParamComponentContainer();
137 sptr<OHOS::AAFwk::IAbilityConnection> GetParamIAbilityConnection();
138 
139 std::shared_ptr<OHOS::AppExecFwk::ProcessInfo> GetParamProcessInfo();
140 std::shared_ptr<OHOS::AppExecFwk::DataUriUtils> GetParamDataUriUtils();
141 std::shared_ptr<OHOS::AppExecFwk::DataAbilityHelper> GetParamDataAbilityHelper();
142 std::shared_ptr<OHOS::AppExecFwk::LifeCycle> GetParamLifeCycle();
143 OHOS::AppExecFwk::LifeCycle::Event GetParamLifeCycleEvent();
144 std::shared_ptr<OHOS::AppExecFwk::ElementName> GetParamElementName();
145 std::shared_ptr<OHOS::AAFwk::WantParams> GetParamWantParams();
146 std::shared_ptr<OHOS::AppExecFwk::AbilityManager> GetParamAbilityManager();
147 OHOS::AAFwk::PatternsMatcher GetParamPatternsMatcher();
148 OHOS::AAFwk::MatchType GetParamMatchType();
149 std::shared_ptr<OHOS::AppExecFwk::Context> GetParamContext();
150 
151 std::shared_ptr<OHOS::AppExecFwk::BundleMgrProxy> GetParamBundleMgrProxy();
152 OHOS::AppExecFwk::ApplicationFlag GetParamApplicationFlag();
153 OHOS::AppExecFwk::ApplicationInfo GetParamApplicationInfo();
154 std::vector<OHOS::AppExecFwk::ApplicationInfo> GetParamApplicationInfoVector();
155 OHOS::AppExecFwk::BundleFlag GetParamBundleFlag();
156 OHOS::AppExecFwk::BundleInfo GetParamBundleInfo();
157 std::vector<OHOS::AppExecFwk::BundleInfo> GetParamBundleInfoVector();
158 OHOS::AppExecFwk::HapModuleInfo GetParamHapModuleInfo();
159 OHOS::AppExecFwk::PermissionDef GetParamPermissionDef();
160 std::vector<OHOS::AppExecFwk::PermissionDef> GetParamPermissionDefVector();
161 OHOS::AppExecFwk::IBundleMgr::Message GetParamIBundleMgrMessage();
162 OHOS::MessageParcel GetParamMessageParcel();
163 OHOS::AppExecFwk::DumpFlag GetParamDumpFlag();
164 sptr<OHOS::AppExecFwk::ICleanCacheCallback> GetParamICleanCacheCallback();
165 sptr<OHOS::AppExecFwk::IBundleStatusCallback> GetParamIBundleStatusCallback();
166 
167 class TestRemoteObject : public IRemoteObject {
168 public:
169     /**
170      * Default constructor used to construct.
171      */
172     TestRemoteObject();
173 
174     /**
175      * Default deconstructor used to deconstruct.
176      */
177     ~TestRemoteObject();
178 
179     /**
180      * Override GetObjectRefCount
181      */
GetObjectRefCount()182     int32_t GetObjectRefCount() override
183     {
184         return 0;
185     }
186 
187     /**
188      * Override SendRequest
189      */
SendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)190     int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override
191     {
192         return 0;
193     }
194 
195     /**
196      * Override IsProxyObject
197      */
IsProxyObject()198     bool IsProxyObject() const override
199     {
200         return true;
201     }
202 
203     /**
204      * Override CheckObjectLegality
205      */
CheckObjectLegality()206     bool CheckObjectLegality() const override
207     {
208         return true;
209     }
210 
211     /**
212      * Override AddDeathRecipient
213      */
AddDeathRecipient(const sptr<DeathRecipient> & recipient)214     bool AddDeathRecipient(const sptr<DeathRecipient> &recipient) override
215     {
216         return true;
217     }
218 
219     /**
220      * Override RemoveDeathRecipient
221      */
RemoveDeathRecipient(const sptr<DeathRecipient> & recipient)222     bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient) override
223     {
224         return true;
225     }
226 
227     /**
228      * Override Marshalling
229      */
Marshalling(Parcel & parcel)230     bool Marshalling(Parcel &parcel) const override
231     {
232         return true;
233     }
234 
235     /**
236      * Override AsInterface
237      */
AsInterface()238     sptr<IRemoteBroker> AsInterface() override
239     {
240         return nullptr;
241     }
242 
243     /**
244      * Override Dump
245      */
Dump(int fd,const std::vector<std::u16string> & args)246     int Dump(int fd, const std::vector<std::u16string> &args) override
247     {
248         return 0;
249     }
250 
251     /**
252      * Override GetObjectDescriptor
253      */
GetObjectDescriptor()254     std::u16string GetObjectDescriptor() const
255     {
256         std::u16string descriptor = std::u16string();
257         return descriptor;
258     }
259 };
260 
261 class TestCommonEventSubscriber : public CommonEventSubscriber {
262 public:
263     /**
264     * Default constructor used to create subscriber.
265     */
TestCommonEventSubscriber()266     TestCommonEventSubscriber() {};
267 
268     /**
269      * Default deconstructor used to deconstruct.
270      */
~TestCommonEventSubscriber()271     ~TestCommonEventSubscriber() {};
272 
273     /**
274      * Override OnReceiveEvent.
275      */
OnReceiveEvent(const CommonEventData & data)276     virtual void OnReceiveEvent(const CommonEventData &data)
277     {
278         printf("Fuzz Test Receive Event\n");
279     }
280 };
281 
282 class TestDumper : public OHOS::AppExecFwk::Dumper {
283 public:
284     /**
285      * Override Dump.
286      */
Dump(const std::string & message)287     void Dump(const std::string &message)
288     {
289         return;
290     }
291 
292     /**
293      * Override GetTag.
294      */
GetTag()295     std::string GetTag()
296     {
297         return GetStringParam();
298     }
299 };
300 
301 class TestFileDescriptorListener : public OHOS::AppExecFwk::FileDescriptorListener {
302 public:
303     /**
304      * Default constructor used to construct.
305      */
TestFileDescriptorListener()306     TestFileDescriptorListener()
307     {}
308 
309     /**
310      * Default deconstructor used to deconstruct.
311      */
~TestFileDescriptorListener()312     ~TestFileDescriptorListener()
313     {}
314 };
315 
316 class TestIAbilityConnection : public OHOS::AAFwk::IAbilityConnection {
317 public:
318     /**
319      * Override OnAbilityConnectDone.
320      */
OnAbilityConnectDone(const OHOS::AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int resultCode)321     void OnAbilityConnectDone(
322         const OHOS::AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode) override
323     {}
324 
325     /**
326      * Override OnAbilityDisconnectDone.
327      */
OnAbilityDisconnectDone(const OHOS::AppExecFwk::ElementName & element,int resultCode)328     void OnAbilityDisconnectDone(const OHOS::AppExecFwk::ElementName &element, int resultCode) override
329     {}
330 
331     /**
332      * Default deconstructor used to deconstruct.
333      */
~TestIAbilityConnection()334     virtual ~TestIAbilityConnection()
335     {}
336 };
337 
338 class TestAbilityEvent : public OHOS::AppExecFwk::IAbilityEvent {
339 public:
340     /**
341      * Override OnBackPressed.
342      */
OnBackPressed()343     virtual void OnBackPressed()
344     {
345         printf("Fuzz Test Back Pressed.");
346     }
347 };
348 
349 class TestLogger : public OHOS::AppExecFwk::Logger {
350 public:
351     /**
352      * Override Log.
353      */
Log(const std::string & line)354     void Log(const std::string &line)
355     {}
356 
357     /**
358      * Default deconstructor used to deconstruct.
359      */
~TestLogger()360     virtual ~TestLogger()
361     {}
362 };
363 
364 class TestICleanCacheCallback : public OHOS::AppExecFwk::ICleanCacheCallback {
365 public:
366     /**
367      * Default constructor used to construct.
368      */
TestICleanCacheCallback()369     TestICleanCacheCallback()
370     {}
371 
372     /**
373      * Override OnCleanCacheFinished.
374      */
OnCleanCacheFinished(bool succeeded)375     void OnCleanCacheFinished(bool succeeded) override
376     {}
377 
378     /**
379      * Default deconstructor used to deconstruct.
380      */
~TestICleanCacheCallback()381     virtual ~TestICleanCacheCallback()
382     {}
383 };
384 
385 class TestIBundleStatusCallback : public OHOS::AppExecFwk::IBundleStatusCallback {
386 public:
387     /**
388      * Default constructor used to construct.
389      */
TestIBundleStatusCallback()390     TestIBundleStatusCallback()
391     {}
392 
393     /**
394      * Override OnBundleStateChanged.
395      */
OnBundleStateChanged(const uint8_t installType,const int32_t resultCode,const std::string & resultMsg,const std::string & bundleName)396     void OnBundleStateChanged(const uint8_t installType, const int32_t resultCode, const std::string &resultMsg,
397         const std::string &bundleName) override
398     {}
399 
400     /**
401      * Default deconstructor used to deconstruct.
402      */
~TestIBundleStatusCallback()403     virtual ~TestIBundleStatusCallback()
404     {}
405 };
406 }  // namespace EventFwk
407 }  // namespace OHOS
408 #endif