• 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_handler.h"
28 #include "ability_manager.h"
29 #include "ability_manager_interface.h"
30 #include "async_common_event_result.h"
31 #include "bundle_info.h"
32 #include "common_event_manager.h"
33 #include "common_event_data.h"
34 #include "common_event_publish_info.h"
35 #include "common_event_subscribe_info.h"
36 #include "common_event_subscriber.h"
37 #include "common_event_support.h"
38 #include "data_uri_utils.h"
39 #include "dummy_component_container.h"
40 #include "dumper.h"
41 #include "element_name.h"
42 #include "event_handler.h"
43 #include "event_runner.h"
44 #include "inner_event.h"
45 #include "iremote_broker.h"
46 #include "iremote_object.h"
47 #include "key_event.h"
48 #include "logger.h"
49 #include "matching_skills.h"
50 #include "module_info.h"
51 #include "native_implement_eventhandler.h"
52 #include "pac_map.h"
53 #include "parcel.h"
54 #include "patterns_matcher.h"
55 #include "uri.h"
56 #include "want.h"
57 #include "bundle_mgr_proxy.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 sptr<OHOS::AppExecFwk::AbilityThread> GetParamAbilityThread();
126 std::shared_ptr<OHOS::AppExecFwk::AbilityHandler> GetParamAbilityHandler();
127 std::shared_ptr<OHOS::AppExecFwk::AbilityStartSetting> GetParamAbilityStartSetting();
128 std::shared_ptr<OHOS::AppExecFwk::Ability> GetParamAbility();
129 std::shared_ptr<OHOS::AppExecFwk::OHOSApplication> GetParamOHOSApplication();
130 OHOS::Uri GetParamUri();
131 
132 NativeRdb::ValuesBucket GetParamValuesBucket();
133 OHOS::AppExecFwk::Configuration GetParamConfiguration();
134 NativeRdb::DataAbilityPredicates GetParamDataAbilityPredicates();
135 OHOS::AppExecFwk::PacMap GetParamPacMap();
136 OHOS::AppExecFwk::NotificationRequest GetParamNotificationRequest();
137 std::shared_ptr<OHOS::AppExecFwk::ComponentContainer> GetParamComponentContainer();
138 sptr<OHOS::AAFwk::IAbilityConnection> GetParamIAbilityConnection();
139 
140 std::shared_ptr<OHOS::AppExecFwk::ProcessInfo> GetParamProcessInfo();
141 std::shared_ptr<OHOS::AppExecFwk::DataUriUtils> GetParamDataUriUtils();
142 std::shared_ptr<OHOS::AppExecFwk::DataAbilityHelper> GetParamDataAbilityHelper();
143 std::shared_ptr<OHOS::AppExecFwk::LifeCycle> GetParamLifeCycle();
144 OHOS::AppExecFwk::LifeCycle::Event GetParamLifeCycleEvent();
145 std::shared_ptr<OHOS::AppExecFwk::ElementName> GetParamElementName();
146 std::shared_ptr<OHOS::AAFwk::WantParams> GetParamWantParams();
147 std::shared_ptr<OHOS::AppExecFwk::AbilityManager> GetParamAbilityManager();
148 OHOS::AAFwk::PatternsMatcher GetParamPatternsMatcher();
149 OHOS::AAFwk::MatchType GetParamMatchType();
150 std::shared_ptr<OHOS::AppExecFwk::Context> GetParamContext();
151 
152 std::shared_ptr<OHOS::AppExecFwk::BundleMgrProxy> GetParamBundleMgrProxy();
153 OHOS::AppExecFwk::ApplicationFlag GetParamApplicationFlag();
154 OHOS::AppExecFwk::ApplicationInfo GetParamApplicationInfo();
155 std::vector<OHOS::AppExecFwk::ApplicationInfo> GetParamApplicationInfoVector();
156 OHOS::AppExecFwk::BundleFlag GetParamBundleFlag();
157 OHOS::AppExecFwk::BundleInfo GetParamBundleInfo();
158 std::vector<OHOS::AppExecFwk::BundleInfo> GetParamBundleInfoVector();
159 OHOS::AppExecFwk::HapModuleInfo GetParamHapModuleInfo();
160 OHOS::AppExecFwk::PermissionDef GetParamPermissionDef();
161 std::vector<OHOS::AppExecFwk::PermissionDef> GetParamPermissionDefVector();
162 OHOS::AppExecFwk::IBundleMgr::Message GetParamIBundleMgrMessage();
163 OHOS::MessageParcel GetParamMessageParcel();
164 OHOS::AppExecFwk::DumpFlag GetParamDumpFlag();
165 sptr<OHOS::AppExecFwk::ICleanCacheCallback> GetParamICleanCacheCallback();
166 sptr<OHOS::AppExecFwk::IBundleStatusCallback> GetParamIBundleStatusCallback();
167 
168 class TestRemoteObject : public IRemoteObject {
169 public:
170     TestRemoteObject();
171     ~TestRemoteObject();
172 
GetObjectRefCount()173     int32_t GetObjectRefCount() override
174     {
175         return 0;
176     }
177 
SendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)178     int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override
179     {
180         return 0;
181     }
182 
IsProxyObject()183     bool IsProxyObject() const override
184     {
185         return true;
186     }
187 
CheckObjectLegality()188     bool CheckObjectLegality() const override
189     {
190         return true;
191     }
192 
AddDeathRecipient(const sptr<DeathRecipient> & recipient)193     bool AddDeathRecipient(const sptr<DeathRecipient> &recipient) override
194     {
195         return true;
196     }
197 
RemoveDeathRecipient(const sptr<DeathRecipient> & recipient)198     bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient) override
199     {
200         return true;
201     }
202 
Marshalling(Parcel & parcel)203     bool Marshalling(Parcel &parcel) const override
204     {
205         return true;
206     }
207 
AsInterface()208     sptr<IRemoteBroker> AsInterface() override
209     {
210         return nullptr;
211     }
212 
Dump(int fd,const std::vector<std::u16string> & args)213     int Dump(int fd, const std::vector<std::u16string> &args) override
214     {
215         return 0;
216     }
217 
GetObjectDescriptor()218     std::u16string GetObjectDescriptor() const
219     {
220         std::u16string descriptor = std::u16string();
221         return descriptor;
222     }
223 };
224 
225 class TestCommonEventSubscriber : public CommonEventSubscriber {
226 public:
TestCommonEventSubscriber()227     TestCommonEventSubscriber() {};
~TestCommonEventSubscriber()228     ~TestCommonEventSubscriber() {};
OnReceiveEvent(const CommonEventData & data)229     virtual void OnReceiveEvent(const CommonEventData &data)
230     {
231         printf("Fuzz Test Receive Event\n");
232     }
233 };
234 
235 class TestDumper : public OHOS::AppExecFwk::Dumper {
236 public:
Dump(const std::string & message)237     void Dump(const std::string &message)
238     {
239         return;
240     }
GetTag()241     std::string GetTag()
242     {
243         return GetStringParam();
244     }
245 };
246 
247 class TestFileDescriptorListener : public OHOS::AppExecFwk::FileDescriptorListener {
248 public:
TestFileDescriptorListener()249     TestFileDescriptorListener()
250     {}
~TestFileDescriptorListener()251     ~TestFileDescriptorListener()
252     {}
253 };
254 
255 class TestIAbilityConnection : public OHOS::AAFwk::IAbilityConnection {
256 public:
OnAbilityConnectDone(const OHOS::AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int resultCode)257     void OnAbilityConnectDone(
258         const OHOS::AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode) override
259     {}
OnAbilityDisconnectDone(const OHOS::AppExecFwk::ElementName & element,int resultCode)260     void OnAbilityDisconnectDone(const OHOS::AppExecFwk::ElementName &element, int resultCode) override
261     {}
~TestIAbilityConnection()262     virtual ~TestIAbilityConnection()
263     {}
264 };
265 
266 class TestAbilityEvent : public OHOS::AppExecFwk::IAbilityEvent {
267 public:
OnBackPressed()268     virtual void OnBackPressed()
269     {
270         printf("Fuzz Test Back Pressed.");
271     }
272 };
273 
274 class TestLogger : public OHOS::AppExecFwk::Logger {
275 public:
Log(const std::string & line)276     void Log(const std::string &line)
277     {}
~TestLogger()278     virtual ~TestLogger()
279     {}
280 };
281 
282 class TestICleanCacheCallback : public OHOS::AppExecFwk::ICleanCacheCallback {
283 public:
TestICleanCacheCallback()284     TestICleanCacheCallback()
285     {}
OnCleanCacheFinished(bool succeeded)286     void OnCleanCacheFinished(bool succeeded) override
287     {}
~TestICleanCacheCallback()288     virtual ~TestICleanCacheCallback()
289     {}
290 };
291 
292 class TestIBundleStatusCallback : public OHOS::AppExecFwk::IBundleStatusCallback {
293 public:
TestIBundleStatusCallback()294     TestIBundleStatusCallback()
295     {}
OnBundleStateChanged(const uint8_t installType,const int32_t resultCode,const std::string & resultMsg,const std::string & bundleName)296     void OnBundleStateChanged(const uint8_t installType, const int32_t resultCode, const std::string &resultMsg,
297         const std::string &bundleName) override
298     {}
~TestIBundleStatusCallback()299     virtual ~TestIBundleStatusCallback()
300     {}
301 };
302 }  // namespace EventFwk
303 }  // namespace OHOS
304 #endif