1 /*
2 * Copyright (c) 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 #include "distributedschedstub_fuzzer.h"
17
18 #include <cstddef>
19 #include <cstdint>
20 #include <singleton.h>
21
22 #include "distributed_sched_interface.h"
23 #include "distributed_sched_service.h"
24 #include "distributed_sched_stub.h"
25 #include "distributedWant/distributed_want.h"
26 #include "mock_fuzz_util.h"
27 #include "mock_distributed_sched.h"
28 #include "parcel_helper.h"
29 #include "dms_continue_time_dumper.h"
30
31 using namespace OHOS::AAFwk;
32 using namespace OHOS::AppExecFwk;
33
34 namespace OHOS {
35 namespace DistributedSchedule {
36 const std::string TAG = "DistributedSchedFuzzTest";
37 namespace {
38 const std::u16string DMS_STUB_INTERFACE_TOKEN = u"ohos.distributedschedule.accessToken";
39 const uint32_t ONE = 1;
40 constexpr size_t FOO_MAX_LEN = 1024;
41 constexpr size_t U32_AT_SIZE = 4;
42 }
43
GetU32Data(const uint8_t * ptr,size_t size)44 uint32_t GetU32Data(const uint8_t* ptr, size_t size)
45 {
46 if (size > FOO_MAX_LEN || size < U32_AT_SIZE) {
47 return 0;
48 }
49 char *ch = static_cast<char*>(malloc(size + 1));
50 if (ch == nullptr) {
51 std::cout << "malloc failed." << std::endl;
52 return 0;
53 }
54 (void)memset_s(ch, size + 1, 0x00, size + 1);
55 if (memcpy_s(ch, size + 1, ptr, size) != EOK) {
56 std::cout << "copy failed." << std::endl;
57 free(ch);
58 ch = nullptr;
59 return 0;
60 }
61 uint32_t data = (ch[0] << 24) | (ch[1] << 16) | (ch[2] << 8) | ch[3];
62 free(ch);
63 ch = nullptr;
64 return data;
65 }
66
StartRemoteAbilityInnerFuzzTest(const uint8_t * data,size_t size)67 bool StartRemoteAbilityInnerFuzzTest(const uint8_t* data, size_t size)
68 {
69 if ((data == nullptr) || (size < sizeof(int32_t))) {
70 return false;
71 }
72 MessageParcel dataParcel;
73 MessageParcel reply;
74 Want want;
75 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
76 uint32_t uint32Data = *(reinterpret_cast<const uint32_t*>(data));
77
78 PARCEL_WRITE_HELPER(dataParcel, Parcelable, &want);
79 PARCEL_WRITE_HELPER(dataParcel, Int32, int32Data);
80 PARCEL_WRITE_HELPER(dataParcel, Int32, int32Data);
81 PARCEL_WRITE_HELPER(dataParcel, Uint32, uint32Data);
82 DistributedSchedService::GetInstance().StartRemoteAbilityInner(dataParcel, reply);
83 FuzzUtil::MockPermission();
84 DistributedSchedService::GetInstance().StartRemoteAbilityInner(dataParcel, reply);
85 return true;
86 }
87
ConnectRemoteAbilityInnerFuzzTest(const uint8_t * data,size_t size)88 void ConnectRemoteAbilityInnerFuzzTest(const uint8_t* data, size_t size)
89 {
90 if ((data == nullptr) || (size < sizeof(int32_t))) {
91 return;
92 }
93 FuzzUtil::MockPermission();
94 MessageParcel dataParcel;
95 MessageParcel reply;
96 MessageOption option;
97 Want want;
98 sptr<IRemoteObject> connect(new MockDistributedSched());
99 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
100 uint32_t uint32Data = *(reinterpret_cast<const uint32_t*>(data));
101
102 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &want);
103 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, connect);
104 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
105 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
106 PARCEL_WRITE_HELPER_NORET(dataParcel, Uint32, uint32Data);
107 DistributedSchedService::GetInstance().ConnectRemoteAbilityInner(dataParcel, reply);
108 std::string devId(reinterpret_cast<const char*>(data), size);
109 DistributedSchedService::GetInstance().InitDataShareManager();
110 DistributedSchedService::GetInstance().InitCommonEventListener();
111 DistributedSchedService::GetInstance().InitWifiStateListener();
112 DistributedSchedService::GetInstance().GetFormMgrProxy();
113 DistributedSchedService::GetInstance().ProcessFreeInstallOffline(devId);
114 DistributedSchedService::GetInstance().ProcessCalleeOffline(devId);
115 }
116
DisconnectRemoteAbilityInnerFuzzTest(const uint8_t * data,size_t size)117 void DisconnectRemoteAbilityInnerFuzzTest(const uint8_t* data, size_t size)
118 {
119 if ((data == nullptr) || (size < sizeof(int32_t))) {
120 return;
121 }
122 FuzzUtil::MockPermission();
123 MessageParcel dataParcel;
124 MessageParcel reply;
125 MessageOption option;
126 sptr<IRemoteObject> connect(new MockDistributedSched());
127 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
128 uint32_t uint32Data = *(reinterpret_cast<const uint32_t*>(data));
129
130 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, connect);
131 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
132 PARCEL_WRITE_HELPER_NORET(dataParcel, Uint32, uint32Data);
133 DistributedSchedService::GetInstance().DisconnectRemoteAbilityInner(dataParcel, reply);
134
135 std::string networkId(reinterpret_cast<const char*>(data), size);
136 std::string bundleName(reinterpret_cast<const char*>(data), size);
137 DistributedSchedService::GetInstance().IsRemoteInstall(networkId, bundleName);
138 DistributedSchedService::GetInstance().GetContinueInfo(networkId, networkId);
139 }
140
StartContinuationInnerFuzzTest(const uint8_t * data,size_t size)141 void StartContinuationInnerFuzzTest(const uint8_t* data, size_t size)
142 {
143 if ((data == nullptr) || (size < sizeof(int32_t))) {
144 return;
145 }
146 FuzzUtil::MockPermission();
147 MessageParcel dataParcel;
148 MessageParcel reply;
149 MessageOption option;
150 Want want;
151 int32_t missionId = *(reinterpret_cast<const int32_t*>(data));
152 int32_t callerUid = *(reinterpret_cast<const int32_t*>(data));
153 int32_t status = *(reinterpret_cast<const int32_t*>(data));
154 uint32_t accessToken = *(reinterpret_cast<const int32_t*>(data));
155
156 dataParcel.WriteParcelable(&want);
157 dataParcel.WriteInt32(missionId);
158 dataParcel.WriteInt32(callerUid);
159 dataParcel.WriteInt32(status);
160 dataParcel.WriteUint32(accessToken);
161 DistributedSchedService::GetInstance().StartContinuationInner(dataParcel, reply);
162 DistributedSchedService::GetInstance().StartAbility(want, callerUid);
163 DistributedSchedService::GetInstance().GetAppManager();
164 }
165
NotifyCompleteContinuationInnerFuzzTest(const uint8_t * data,size_t size)166 void NotifyCompleteContinuationInnerFuzzTest(const uint8_t* data, size_t size)
167 {
168 if ((data == nullptr) || (size < sizeof(int32_t))) {
169 return;
170 }
171 FuzzUtil::MockPermission();
172 std::string devId(reinterpret_cast<const char*>(data), size);
173 bool isSuccess = *(reinterpret_cast<const bool*>(data));
174 MessageParcel dataParcel;
175 MessageParcel reply;
176 MessageOption option;
177 int32_t sessionId = *(reinterpret_cast<const int32_t*>(data));
178
179 dataParcel.WriteString16(Str8ToStr16(devId));
180 dataParcel.WriteInt32(sessionId);
181 dataParcel.WriteBool(isSuccess);
182 DistributedSchedService::GetInstance().NotifyCompleteContinuationInner(dataParcel, reply);
183 }
184
ContinueMissionInnerFuzzTest(const uint8_t * data,size_t size)185 void ContinueMissionInnerFuzzTest(const uint8_t* data, size_t size)
186 {
187 if ((data == nullptr) || (size < sizeof(int32_t))) {
188 return;
189 }
190 FuzzUtil::MockPermission();
191 MessageParcel dataParcel;
192 MessageParcel reply;
193 MessageOption option;
194 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
195 std::string str(reinterpret_cast<const char*>(data), size);
196 std::string deviceId(reinterpret_cast<const char*>(data), size);
197 std::string bundleName(reinterpret_cast<const char*>(data), size);
198 sptr<IRemoteObject> callback(new MockDistributedSched());
199 WantParams wantParams;
200
201 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
202 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
203 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
204 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, callback);
205 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &wantParams);
206 DistributedSchedService::GetInstance().ContinueMissionInner(dataParcel, reply);
207 DistributedSchedService::GetInstance().ContinueLocalMission(deviceId, int32Data, callback, wantParams);
208 DistributedSchedService::GetInstance().ContinueRemoteMission(deviceId, deviceId, int32Data, callback, wantParams);
209 DistributedSchedService::GetInstance().ContinueMission(deviceId, deviceId, int32Data, callback, wantParams);
210 }
211
ContinueMissionOfBundleNameInnerFuzzTest(const uint8_t * data,size_t size)212 void ContinueMissionOfBundleNameInnerFuzzTest(const uint8_t* data, size_t size)
213 {
214 if ((data == nullptr) || (size < sizeof(int32_t))) {
215 return;
216 }
217 FuzzUtil::MockPermission();
218 MessageParcel dataParcel;
219 MessageParcel reply;
220 MessageOption option;
221 std::string str(reinterpret_cast<const char*>(data), size);
222 std::string deviceId(reinterpret_cast<const char*>(data), size);
223 std::string bundleName(reinterpret_cast<const char*>(data), size);
224 sptr<IRemoteObject> callback(new MockDistributedSched());
225 WantParams wantParams;
226
227 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
228 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
229 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
230 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, callback);
231 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &wantParams);
232 DistributedSchedService::GetInstance().ContinueMissionOfBundleNameInner(dataParcel, reply);
233 DistributedSchedService::GetInstance().ContinueRemoteMission(deviceId, deviceId, bundleName,
234 callback, wantParams);
235 DistributedSchedService::GetInstance().ProcessContinueLocalMission(deviceId, deviceId, bundleName,
236 callback, wantParams);
237 DistributedSchedService::GetInstance().ProcessContinueRemoteMission(deviceId, deviceId, bundleName,
238 callback, wantParams);
239 }
240
GetMissionInfosInnerFuzzTest(const uint8_t * data,size_t size)241 void GetMissionInfosInnerFuzzTest(const uint8_t* data, size_t size)
242 {
243 if ((data == nullptr) || (size < sizeof(int32_t))) {
244 return;
245 }
246 FuzzUtil::MockPermission();
247 MessageParcel dataParcel;
248 MessageParcel reply;
249 MessageOption option;
250 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
251 std::string str(reinterpret_cast<const char*>(data), size);
252
253 PARCEL_WRITE_HELPER_NORET(dataParcel, String16, Str8ToStr16(str));
254 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
255 DistributedSchedService::GetInstance().GetMissionInfosInner(dataParcel, reply);
256 }
257
RegisterMissionListenerInnerFuzzTest(const uint8_t * data,size_t size)258 void RegisterMissionListenerInnerFuzzTest(const uint8_t* data, size_t size)
259 {
260 if ((data == nullptr) || (size < sizeof(int32_t))) {
261 return;
262 }
263 FuzzUtil::MockPermission();
264 MessageParcel dataParcel;
265 MessageParcel reply;
266 MessageOption option;
267 Want want;
268 int32_t missionId = *(reinterpret_cast<const int32_t*>(data));
269 uint32_t uint32Data = *(reinterpret_cast<const uint32_t*>(data));
270 std::string str(reinterpret_cast<const char*>(data), size);
271 sptr<IRemoteObject> obj(new MockDistributedSched());
272
273 PARCEL_WRITE_HELPER_NORET(dataParcel, String16, Str8ToStr16(str));
274 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj);
275 DistributedSchedService::GetInstance().RegisterMissionListenerInner(dataParcel, reply);
276 DistributedSchedService::GetInstance().ContinueLocalMissionDealFreeInstall(want, missionId, str, obj);
277 DistributedSchedService::GetInstance().ContinueAbilityWithTimeout(str, missionId, obj, uint32Data);
278 }
279
UnRegisterMissionListenerInnerFuzzTest(const uint8_t * data,size_t size)280 void UnRegisterMissionListenerInnerFuzzTest(const uint8_t* data, size_t size)
281 {
282 if ((data == nullptr) || (size < sizeof(int32_t))) {
283 return;
284 }
285 FuzzUtil::MockPermission();
286 MessageParcel dataParcel;
287 MessageParcel reply;
288 MessageOption option;
289 std::string str(reinterpret_cast<const char*>(data), size);
290 sptr<IRemoteObject> obj(new MockDistributedSched());
291
292 PARCEL_WRITE_HELPER_NORET(dataParcel, String16, Str8ToStr16(str));
293 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj);
294 DistributedSchedService::GetInstance().UnRegisterMissionListenerInner(dataParcel, reply);
295 }
296
StartSyncRemoteMissionsInnerFuzzTest(const uint8_t * data,size_t size)297 void StartSyncRemoteMissionsInnerFuzzTest(const uint8_t* data, size_t size)
298 {
299 if ((data == nullptr) || (size < sizeof(int32_t))) {
300 return;
301 }
302 FuzzUtil::MockPermission();
303 MessageParcel dataParcel;
304 MessageParcel reply;
305 MessageOption option;
306 bool boolData = *(reinterpret_cast<const bool*>(data));
307 int64_t int64Data = static_cast<int64_t>(GetU32Data(data, size));
308 std::string str(reinterpret_cast<const char*>(data), size);
309
310 PARCEL_WRITE_HELPER_NORET(dataParcel, String16, Str8ToStr16(str));
311 PARCEL_WRITE_HELPER_NORET(dataParcel, Bool, boolData);
312 PARCEL_WRITE_HELPER_NORET(dataParcel, Int64, int64Data);
313 DistributedSchedService::GetInstance().StartSyncRemoteMissionsInner(dataParcel, reply);
314 }
315
StopSyncRemoteMissionsInnerFuzzTest(const uint8_t * data,size_t size)316 void StopSyncRemoteMissionsInnerFuzzTest(const uint8_t* data, size_t size)
317 {
318 if ((data == nullptr) || (size < sizeof(int32_t))) {
319 return;
320 }
321 FuzzUtil::MockPermission();
322 MessageParcel dataParcel;
323 MessageParcel reply;
324 MessageOption option;
325 std::string str(reinterpret_cast<const char*>(data), size);
326
327 PARCEL_WRITE_HELPER_NORET(dataParcel, String16, Str8ToStr16(str));
328 DistributedSchedService::GetInstance().StopSyncRemoteMissionsInner(dataParcel, reply);
329
330 Want want;
331 CallerInfo callerInfo;
332 IDistributedSched::AccountInfo accountInfo;
333 int32_t flag = *(reinterpret_cast<const int32_t*>(data));
334 DistributedSchedService::GetInstance().CheckTargetPermission(want, callerInfo, accountInfo, flag, true);
335 }
336
GetRemoteMissionSnapshotInfoInnerFuzzTest(const uint8_t * data,size_t size)337 void GetRemoteMissionSnapshotInfoInnerFuzzTest(const uint8_t* data, size_t size)
338 {
339 if ((data == nullptr) || (size < sizeof(int32_t))) {
340 return;
341 }
342 FuzzUtil::MockPermission();
343 MessageParcel dataParcel;
344 MessageParcel reply;
345 MessageOption option;
346 std::string networkId(reinterpret_cast<const char*>(data), size);
347 int32_t missionId = *(reinterpret_cast<const int32_t*>(data));
348
349 dataParcel.WriteString(networkId);
350 dataParcel.WriteInt32(missionId);
351 DistributedSchedService::GetInstance().GetRemoteMissionSnapshotInfoInner(dataParcel, reply);
352 DistributedSchedService::GetInstance().DurationStart(networkId, networkId);
353 }
354
StartRemoteAbilityByCallInnerFuzzTest(const uint8_t * data,size_t size)355 void StartRemoteAbilityByCallInnerFuzzTest(const uint8_t* data, size_t size)
356 {
357 if ((data == nullptr) || (size < sizeof(int32_t))) {
358 return;
359 }
360 FuzzUtil::MockPermission();
361 MessageParcel dataParcel;
362 MessageParcel reply;
363 MessageOption option;
364 Want want;
365 sptr<IRemoteObject> obj(new MockDistributedSched());
366 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
367 uint32_t uint32Data = *(reinterpret_cast<const uint32_t*>(data));
368
369 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &want);
370 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj);
371 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
372 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
373 PARCEL_WRITE_HELPER_NORET(dataParcel, Uint32, uint32Data);
374 DistributedSchedService::GetInstance().StartRemoteAbilityByCallInner(dataParcel, reply);
375 DistributedSchedService::GetInstance().SetWantForContinuation(want, int32Data);
376 }
377
ReleaseRemoteAbilityInnerFuzzTest(const uint8_t * data,size_t size)378 void ReleaseRemoteAbilityInnerFuzzTest(const uint8_t* data, size_t size)
379 {
380 if ((data == nullptr) || (size < sizeof(int32_t))) {
381 return;
382 }
383 FuzzUtil::MockPermission();
384 MessageParcel dataParcel;
385 MessageParcel reply;
386 MessageOption option;
387 sptr<IRemoteObject> connect(new MockDistributedSched());
388 Want want;
389 AppExecFwk::ElementName element;
390 CallerInfo callerInfo;
391 std::string deviceId(reinterpret_cast<const char*>(data), size);
392
393 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, connect);
394 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &element);
395 DistributedSchedService::GetInstance().ReleaseRemoteAbilityInner(dataParcel, reply);
396 callerInfo.uid = ONE;
397 DistributedSchedService::GetInstance().CheckDistributedConnectLocked(callerInfo);
398 DistributedSchedService::GetInstance().DecreaseConnectLocked(ONE);
399 DistributedSchedService::GetInstance().RemoteConnectAbilityMappingLocked(connect, deviceId,
400 deviceId, element, callerInfo, TargetComponent::HARMONY_COMPONENT);
401 DistributedSchedService::GetInstance().NotifyProcessDied(deviceId, callerInfo, TargetComponent::HARMONY_COMPONENT);
402 DistributedSchedService::GetInstance().ProcessDeviceOffline(deviceId);
403 }
404
GetDistributedComponentListInnerFuzzTest(const uint8_t * data,size_t size)405 void GetDistributedComponentListInnerFuzzTest(const uint8_t* data, size_t size)
406 {
407 if ((data == nullptr) || (size < sizeof(int32_t))) {
408 return;
409 }
410 FuzzUtil::MockPermission();
411 MessageParcel dataParcel;
412 MessageParcel reply;
413 MessageOption option;
414
415 DistributedSchedService::GetInstance().GetDistributedComponentListInner(dataParcel, reply);
416 }
417
StartRemoteFreeInstallInnerFuzzTest(const uint8_t * data,size_t size)418 void StartRemoteFreeInstallInnerFuzzTest(const uint8_t* data, size_t size)
419 {
420 if ((data == nullptr) || (size < sizeof(int32_t))) {
421 return;
422 }
423 FuzzUtil::MockPermission();
424 MessageParcel dataParcel;
425 MessageParcel reply;
426 MessageOption option;
427 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
428 uint32_t uint32Data = *(reinterpret_cast<const uint32_t*>(data));
429 sptr<IRemoteObject> obj(new MockDistributedSched());
430 Want want;
431
432 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &want);
433 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
434 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
435 PARCEL_WRITE_HELPER_NORET(dataParcel, Uint32, uint32Data);
436 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj);
437 DistributedSchedService::GetInstance().StartRemoteFreeInstallInner(dataParcel, reply);
438 DistributedSchedService::GetInstance().ProcessCallResult(obj, obj);
439 }
440
StartRemoteShareFormInnerFuzzTest(const uint8_t * data,size_t size)441 void StartRemoteShareFormInnerFuzzTest(const uint8_t* data, size_t size)
442 {
443 if ((data == nullptr) || (size < sizeof(int32_t))) {
444 return;
445 }
446 FuzzUtil::MockPermission();
447 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_SHARE_FORM);
448 MessageParcel dataParcel;
449 MessageParcel reply;
450 MessageOption option;
451 std::string str(reinterpret_cast<const char*>(data), size);
452 Want want;
453 dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
454 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
455 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &want);
456 DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option);
457 }
458
StopRemoteExtensionAbilityInnerFuzzTest(const uint8_t * data,size_t size)459 void StopRemoteExtensionAbilityInnerFuzzTest(const uint8_t* data, size_t size)
460 {
461 if ((data == nullptr) || (size < sizeof(int32_t))) {
462 return;
463 }
464 FuzzUtil::MockPermission();
465 MessageParcel dataParcel;
466 MessageParcel reply;
467 MessageOption option;
468 Want want;
469 int32_t callerUid = *(reinterpret_cast<const int32_t*>(data));
470 int32_t serviceType = *(reinterpret_cast<const int32_t*>(data));
471 uint32_t accessToken = *(reinterpret_cast<const int32_t*>(data));
472 dataParcel.WriteParcelable(&want);
473 dataParcel.WriteInt32(callerUid);
474 dataParcel.WriteUint32(accessToken);
475 dataParcel.WriteInt32(serviceType);
476 DistributedSchedService::GetInstance().StopRemoteExtensionAbilityInner(dataParcel, reply);
477
478 CallerInfo callerInfo;
479 std::string localDeviceId(reinterpret_cast<const char*>(data), size);
480 DistributedSchedService::GetInstance().GetCallerInfo(localDeviceId, callerUid, accessToken, callerInfo);
481 DistributedSchedService::GetInstance().CheckDeviceIdFromRemote(localDeviceId, localDeviceId, localDeviceId);
482 }
483
RegisterOnListenerInnerFuzzTest(const uint8_t * data,size_t size)484 void RegisterOnListenerInnerFuzzTest(const uint8_t* data, size_t size)
485 {
486 if ((data == nullptr) || (size < sizeof(int32_t))) {
487 return;
488 }
489 FuzzUtil::MockPermission();
490 MessageParcel dataParcel;
491 MessageParcel reply;
492 MessageOption option;
493 std::string str(reinterpret_cast<const char*>(data), size);
494 sptr<IRemoteObject> obj(new MockDistributedSched());
495
496 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
497 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj);
498 DistributedSchedService::GetInstance().RegisterOnListenerInner(dataParcel, reply);
499 DistributedSchedService::GetInstance().HandleLocalCallerDied(obj);
500 DistributedSchedService::GetInstance().RemoveCallerComponent(obj);
501 DistributedSchedService::GetInstance().RemoveConnectAbilityInfo(str);
502 DistributedSchedService::GetInstance().DumpConnectInfo(str);
503 }
504
RegisterOffListenerInnerFuzzTest(const uint8_t * data,size_t size)505 void RegisterOffListenerInnerFuzzTest(const uint8_t* data, size_t size)
506 {
507 if ((data == nullptr) || (size < sizeof(int32_t))) {
508 return;
509 }
510 FuzzUtil::MockPermission();
511 MessageParcel dataParcel;
512 MessageParcel reply;
513 MessageOption option;
514 std::string str(reinterpret_cast<const char*>(data), size);
515 sptr<IRemoteObject> obj(new MockDistributedSched());
516
517 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
518 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj);
519 DistributedSchedService::GetInstance().RegisterOffListenerInner(dataParcel, reply);
520 }
521
RegisterDSchedEventListenerInnerFuzzTest(const uint8_t * data,size_t size)522 void RegisterDSchedEventListenerInnerFuzzTest(const uint8_t* data, size_t size)
523 {
524 if ((data == nullptr) || (size < sizeof(int32_t))) {
525 return;
526 }
527 FuzzUtil::MockPermission();
528 MessageParcel dataParcel;
529 MessageParcel reply;
530 MessageOption option;
531 uint8_t uint8Data = *(reinterpret_cast<const uint8_t*>(data));
532 sptr<IRemoteObject> obj(new MockDistributedSched());
533
534 PARCEL_WRITE_HELPER_NORET(dataParcel, Uint8, uint8Data);
535 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj);
536 DistributedSchedService::GetInstance().RegisterDSchedEventListenerInner(dataParcel, reply);
537 }
538
UnRegisterDSchedEventListenerInnerFuzzTest(const uint8_t * data,size_t size)539 void UnRegisterDSchedEventListenerInnerFuzzTest(const uint8_t* data, size_t size)
540 {
541 if ((data == nullptr) || (size < sizeof(int32_t))) {
542 return;
543 }
544 FuzzUtil::MockPermission();
545 MessageParcel dataParcel;
546 MessageParcel reply;
547 MessageOption option;
548 uint8_t uint8Data = *(reinterpret_cast<const uint8_t*>(data));
549 sptr<IRemoteObject> obj(new MockDistributedSched());
550
551 PARCEL_WRITE_HELPER_NORET(dataParcel, Uint8, uint8Data);
552 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj);
553 DistributedSchedService::GetInstance().UnRegisterDSchedEventListenerInner(dataParcel, reply);
554 }
555
SetMissionContinueStateInnerFuzzTest(const uint8_t * data,size_t size)556 void SetMissionContinueStateInnerFuzzTest(const uint8_t* data, size_t size)
557 {
558 if ((data == nullptr) || (size < sizeof(int32_t))) {
559 return;
560 }
561 FuzzUtil::MockPermission();
562 MessageParcel dataParcel;
563 MessageParcel reply;
564 MessageOption option;
565 int32_t missionId = *(reinterpret_cast<const int32_t*>(data));
566 int32_t state = *(reinterpret_cast<const int32_t*>(data));
567 int32_t timeout = *(reinterpret_cast<const int32_t*>(data));
568
569 dataParcel.WriteInt32(missionId);
570 dataParcel.WriteInt32(state);
571 DistributedSchedService::GetInstance().SetMissionContinueStateInner(dataParcel, reply);
572 DistributedSchedService::GetInstance().RemoveContinuationTimeout(missionId);
573 DistributedSchedService::GetInstance().SetContinuationTimeout(missionId, timeout);
574 DistributedSchedService::GetInstance().GetContinuaitonDevice(missionId);
575 }
576
StartAbilityFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)577 void StartAbilityFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
578 {
579 if ((data == nullptr) || (size < sizeof(int32_t))) {
580 return;
581 }
582 FuzzUtil::MockPermission();
583 MessageParcel dataParcel;
584 MessageParcel reply;
585 MessageOption option;
586 DistributedWant dstbWant;
587 AppExecFwk::CompatibleAbilityInfo compatibleAbilityInfo;
588 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
589 std::string str(reinterpret_cast<const char*>(data), size);
590 std::vector<std::string> strVector = {str};
591
592 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &dstbWant);
593 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &compatibleAbilityInfo);
594 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
595 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
596 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
597 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
598 PARCEL_WRITE_HELPER_NORET(dataParcel, StringVector, strVector);
599 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
600 DistributedSchedService::GetInstance().StartAbilityFromRemoteInner(dataParcel, reply);
601 }
602
SendResultFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)603 void SendResultFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
604 {
605 if ((data == nullptr) || (size < sizeof(int32_t))) {
606 return;
607 }
608 FuzzUtil::MockPermission();
609 MessageParcel dataParcel;
610 MessageParcel reply;
611 MessageOption option;
612 AppExecFwk::CompatibleAbilityInfo compatibleAbilityInfo;
613 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
614 std::string str(reinterpret_cast<const char*>(data), size);
615 std::vector<std::string> strVector = {str};
616 DistributedWant dstbWant;
617
618 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &dstbWant);
619 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
620 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
621 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
622 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
623 PARCEL_WRITE_HELPER_NORET(dataParcel, StringVector, strVector);
624 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
625 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
626 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
627 DistributedSchedService::GetInstance().SendResultFromRemoteInner(dataParcel, reply);
628 }
629
NotifyDSchedEventResultFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)630 void NotifyDSchedEventResultFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
631 {
632 if ((data == nullptr) || (size < sizeof(int32_t))) {
633 return;
634 }
635 FuzzUtil::MockPermission();
636 MessageParcel dataParcel;
637 MessageParcel reply;
638 MessageOption option;
639 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
640 std::string str(reinterpret_cast<const char*>(data), size);
641
642 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
643 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
644 DistributedSchedService::GetInstance().NotifyDSchedEventResultFromRemoteInner(dataParcel, reply);
645 }
646
NotifyContinuationResultFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)647 void NotifyContinuationResultFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
648 {
649 if ((data == nullptr) || (size < sizeof(int32_t))) {
650 return;
651 }
652 FuzzUtil::MockPermission();
653 DmsContinueTime::GetInstance().Init();
654 MessageParcel dataParcel;
655 MessageParcel reply;
656 MessageOption option;
657 AppExecFwk::CompatibleAbilityInfo compatibleAbilityInfo;
658 bool boolData = *(reinterpret_cast<const bool*>(data));
659 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
660 std::string str(reinterpret_cast<const char*>(data), size);
661
662 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
663 PARCEL_WRITE_HELPER_NORET(dataParcel, Bool, boolData);
664 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
665 DistributedSchedService::GetInstance().NotifyContinuationResultFromRemoteInner(dataParcel, reply);
666 }
667
ConnectAbilityFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)668 void ConnectAbilityFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
669 {
670 if ((data == nullptr) || (size < sizeof(int32_t))) {
671 return;
672 }
673 FuzzUtil::MockPermission();
674 MessageParcel dataParcel;
675 MessageParcel reply;
676 MessageOption option;
677 AppExecFwk::CompatibleAbilityInfo compatibleAbilityInfo;
678 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
679 std::string str(reinterpret_cast<const char*>(data), size);
680 std::vector<std::string> strVector = {str};
681 DistributedWant dstbWant;
682 const sptr<IRemoteObject> connect(new MockDistributedSched());
683
684 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &dstbWant);
685 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &compatibleAbilityInfo);
686 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, connect);
687 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
688 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
689 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
690 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
691 PARCEL_WRITE_HELPER_NORET(dataParcel, StringVector, strVector);
692 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
693 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
694 DistributedSchedService::GetInstance().ConnectAbilityFromRemoteInner(dataParcel, reply);
695 }
696
DisconnectAbilityFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)697 void DisconnectAbilityFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
698 {
699 if ((data == nullptr) || (size < sizeof(int32_t))) {
700 return;
701 }
702 FuzzUtil::MockPermission();
703 MessageParcel dataParcel;
704 MessageParcel reply;
705 MessageOption option;
706 AppExecFwk::CompatibleAbilityInfo compatibleAbilityInfo;
707 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
708 std::string str(reinterpret_cast<const char*>(data), size);
709
710 sptr<IRemoteObject> connect(new MockDistributedSched());
711 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, connect);
712 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
713 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
714 DistributedSchedService::GetInstance().DisconnectAbilityFromRemoteInner(dataParcel, reply);
715 DistributedSchedService::GetInstance().ProcessCallerDied(connect, int32Data);
716 DistributedSchedService::GetInstance().ProcessCalleeDied(connect);
717 }
718
NotifyProcessDiedFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)719 void NotifyProcessDiedFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
720 {
721 if ((data == nullptr) || (size < sizeof(int32_t))) {
722 return;
723 }
724 FuzzUtil::MockPermission();
725 MessageParcel dataParcel;
726 MessageParcel reply;
727 MessageOption option;
728 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
729 std::string str(reinterpret_cast<const char*>(data), size);
730
731 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
732 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
733 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
734 DistributedSchedService::GetInstance().NotifyProcessDiedFromRemoteInner(dataParcel, reply);
735 }
736
GetContinueInfoInnerFuzzTest(const uint8_t * data,size_t size)737 void GetContinueInfoInnerFuzzTest(const uint8_t* data, size_t size)
738 {
739 if ((data == nullptr) || (size < sizeof(int32_t))) {
740 return;
741 }
742 FuzzUtil::MockPermission();
743 MessageParcel dataParcel;
744 MessageParcel reply;
745 MessageOption option;
746 std::string str(reinterpret_cast<const char*>(data), size);
747
748 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
749 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
750 DistributedSchedService::GetInstance().GetContinueInfoInner(dataParcel, reply);
751 }
752
NotifyMissionsChangedFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)753 void NotifyMissionsChangedFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
754 {
755 if ((data == nullptr) || (size < sizeof(int32_t))) {
756 return;
757 }
758 FuzzUtil::MockPermission();
759 MessageParcel dataParcel;
760 MessageParcel reply;
761 MessageOption option;
762 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
763 std::string str(reinterpret_cast<const char*>(data), size);
764 std::vector<DstbMissionInfo> missionInfos;
765 CallerInfo callerInfo;
766 DistributedWant dstbWant;
767
768 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &dstbWant);
769 if (!DstbMissionInfo::WriteDstbMissionInfosToParcel(dataParcel, missionInfos)) {
770 return;
771 }
772 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
773 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
774 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
775 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
776 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
777 DistributedSchedService::GetInstance().NotifyMissionsChangedFromRemoteInner(dataParcel, reply);
778 }
779
ReleaseAbilityFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)780 void ReleaseAbilityFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
781 {
782 if ((data == nullptr) || (size < sizeof(int32_t))) {
783 return;
784 }
785 FuzzUtil::MockPermission();
786 MessageParcel dataParcel;
787 MessageParcel reply;
788 MessageOption option;
789 sptr<IRemoteObject> connect(new MockDistributedSched());
790 AppExecFwk::ElementName element;
791 Want want;
792 const CallerInfo callerInfo;
793 std::string str(reinterpret_cast<const char*>(data), size);
794 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
795
796 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, connect);
797 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &element);
798 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
799 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
800 DistributedSchedService::GetInstance().ReleaseAbilityFromRemoteInner(dataParcel, reply);
801 DistributedSchedService::GetInstance().TryStartRemoteAbilityByCall(want, connect, callerInfo);
802 DistributedSchedService::GetInstance().SaveCallerComponent(want, connect, callerInfo);
803 DistributedSchedService::GetInstance().SaveConnectToken(want, connect);
804 DistributedSchedService::GetInstance().NotifyStateChanged(int32Data, element, connect);
805 DistributedSchedService::GetInstance().SetCleanMissionFlag(want, int32Data);
806 }
807
NotifyStateChangedFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)808 void NotifyStateChangedFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
809 {
810 if ((data == nullptr) || (size < sizeof(int32_t))) {
811 return;
812 }
813 FuzzUtil::MockPermission();
814 MessageParcel dataParcel;
815 MessageParcel reply;
816 MessageOption option;
817 const AppExecFwk::ElementName element;
818 sptr<IRemoteObject> connect(new MockDistributedSched());
819 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
820 std::string str(reinterpret_cast<const char*>(data), size);
821
822 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
823 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
824 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &element);
825 DistributedSchedService::GetInstance().NotifyStateChangedFromRemoteInner(dataParcel, reply);
826 DistributedSchedService::GetInstance().NotifyApp(connect, element, int32Data);
827 }
828
StartFreeInstallFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)829 void StartFreeInstallFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
830 {
831 if ((data == nullptr) || (size < sizeof(int32_t))) {
832 return;
833 }
834 FuzzUtil::MockPermission();
835 MessageParcel dataParcel;
836 MessageParcel reply;
837 MessageOption option;
838 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
839 int64_t int64Data = static_cast<int64_t>(GetU32Data(data, size));
840 std::string str(reinterpret_cast<const char*>(data), size);
841 std::vector<std::string> strVector = {str};
842 DistributedWant dstbWant;
843
844 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &dstbWant);
845 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
846 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
847 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
848 PARCEL_WRITE_HELPER_NORET(dataParcel, StringVector, strVector);
849 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
850 PARCEL_WRITE_HELPER_NORET(dataParcel, Int64, int64Data);
851 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &dstbWant);
852 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
853 DistributedSchedService::GetInstance().StartFreeInstallFromRemoteInner(dataParcel, reply);
854 }
855
NotifyCompleteFreeInstallFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)856 void NotifyCompleteFreeInstallFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
857 {
858 if ((data == nullptr) || (size < sizeof(int32_t))) {
859 return;
860 }
861 FuzzUtil::MockPermission();
862 MessageParcel dataParcel;
863 MessageParcel reply;
864 MessageOption option;
865 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
866 int64_t int64Data = static_cast<int64_t>(GetU32Data(data, size));
867
868 PARCEL_WRITE_HELPER_NORET(dataParcel, Int64, int64Data);
869 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
870 DistributedSchedService::GetInstance().NotifyCompleteFreeInstallFromRemoteInner(dataParcel, reply);
871 }
872
GetDSchedEventInfoInnerFuzzTest(const uint8_t * data,size_t size)873 void GetDSchedEventInfoInnerFuzzTest(const uint8_t* data, size_t size)
874 {
875 if ((data == nullptr) || (size < sizeof(int32_t))) {
876 return;
877 }
878 FuzzUtil::MockPermission();
879 MessageParcel dataParcel;
880 MessageParcel reply;
881 MessageOption option;
882 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data)) % DMS_ALL;
883
884 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
885 DistributedSchedService::GetInstance().GetDSchedEventInfoInner(dataParcel, reply);
886 }
887
StartAbilityByCallFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)888 void StartAbilityByCallFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
889 {
890 if ((data == nullptr) || (size < sizeof(int32_t))) {
891 return;
892 }
893 FuzzUtil::MockPermission();
894 MessageParcel dataParcel;
895 MessageParcel reply;
896 MessageOption option;
897 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
898 std::string str(reinterpret_cast<const char*>(data), size);
899 std::vector<std::string> strVector = {str};
900 DistributedWant dstbWant;
901 sptr<IRemoteObject> connect(new MockDistributedSched());
902
903 PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, connect);
904 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
905 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
906 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
907 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
908 PARCEL_WRITE_HELPER_NORET(dataParcel, StringVector, strVector);
909 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
910 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
911 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &dstbWant);
912 DistributedSchedService::GetInstance().StartAbilityByCallFromRemoteInner(dataParcel, reply);
913 DistributedSchedService::GetInstance().ProcessConnectDied(connect);
914 DistributedSchedService::GetInstance().DisconnectEachRemoteAbilityLocked(str, str, connect);
915 }
916
StartSyncMissionsFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)917 void StartSyncMissionsFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
918 {
919 if ((data == nullptr) || (size < sizeof(int32_t))) {
920 return;
921 }
922 FuzzUtil::MockPermission();
923 MessageParcel dataParcel;
924 MessageParcel reply;
925 MessageOption option;
926 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
927 std::string str(reinterpret_cast<const char*>(data), size);
928
929 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
930 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
931 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
932 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
933 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
934 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
935 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
936 DistributedSchedService::GetInstance().StartSyncMissionsFromRemoteInner(dataParcel, reply);
937 }
938
StopSyncMissionsFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)939 void StopSyncMissionsFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
940 {
941 if ((data == nullptr) || (size < sizeof(int32_t))) {
942 return;
943 }
944 FuzzUtil::MockPermission();
945 MessageParcel dataParcel;
946 MessageParcel reply;
947 MessageOption option;
948 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
949 std::string str(reinterpret_cast<const char*>(data), size);
950
951 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
952 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
953 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
954 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
955 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
956 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
957 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
958
959 DistributedSchedService::GetInstance().StopSyncMissionsFromRemoteInner(dataParcel, reply);
960 }
961
StartShareFormFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)962 void StartShareFormFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
963 {
964 if ((data == nullptr) || (size < sizeof(int32_t))) {
965 return;
966 }
967 FuzzUtil::MockPermission();
968 MessageParcel dataParcel;
969 MessageParcel reply;
970 std::string str(reinterpret_cast<const char*>(data), size);
971 DistributedWant dstbWant;
972 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
973 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &dstbWant);
974 DistributedSchedService::GetInstance().StartShareFormFromRemoteInner(dataParcel, reply);
975 }
976
StopExtensionAbilityFromRemoteInnerFuzzTest(const uint8_t * data,size_t size)977 void StopExtensionAbilityFromRemoteInnerFuzzTest(const uint8_t* data, size_t size)
978 {
979 if ((data == nullptr) || (size < sizeof(int32_t))) {
980 return;
981 }
982 FuzzUtil::MockPermission();
983 MessageParcel dataParcel;
984 MessageParcel reply;
985 MessageOption option;
986 int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
987 std::string str(reinterpret_cast<const char*>(data), size);
988 std::vector<std::string> strVector = {str};
989 DistributedWant dstbWant;
990
991 PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &dstbWant);
992 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
993 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
994 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
995 PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data);
996 PARCEL_WRITE_HELPER_NORET(dataParcel, StringVector, strVector);
997 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
998 PARCEL_WRITE_HELPER_NORET(dataParcel, String, str);
999 DistributedSchedService::GetInstance().StopExtensionAbilityFromRemoteInner(dataParcel, reply);
1000 }
1001 }
1002 }
1003
1004 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)1005 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
1006 {
1007 OHOS::DistributedSchedule::StartRemoteAbilityInnerFuzzTest(data, size);
1008 OHOS::DistributedSchedule::ConnectRemoteAbilityInnerFuzzTest(data, size);
1009 OHOS::DistributedSchedule::DisconnectRemoteAbilityInnerFuzzTest(data, size);
1010 OHOS::DistributedSchedule::StartContinuationInnerFuzzTest(data, size);
1011 OHOS::DistributedSchedule::NotifyCompleteContinuationInnerFuzzTest(data, size);
1012 OHOS::DistributedSchedule::ContinueMissionInnerFuzzTest(data, size);
1013 OHOS::DistributedSchedule::ContinueMissionOfBundleNameInnerFuzzTest(data, size);
1014 OHOS::DistributedSchedule::GetMissionInfosInnerFuzzTest(data, size);
1015 OHOS::DistributedSchedule::RegisterMissionListenerInnerFuzzTest(data, size);
1016 OHOS::DistributedSchedule::UnRegisterMissionListenerInnerFuzzTest(data, size);
1017 OHOS::DistributedSchedule::StartSyncRemoteMissionsInnerFuzzTest(data, size);
1018 OHOS::DistributedSchedule::StopSyncRemoteMissionsInnerFuzzTest(data, size);
1019 OHOS::DistributedSchedule::GetRemoteMissionSnapshotInfoInnerFuzzTest(data, size);
1020 OHOS::DistributedSchedule::StartRemoteAbilityByCallInnerFuzzTest(data, size);
1021 OHOS::DistributedSchedule::ReleaseRemoteAbilityInnerFuzzTest(data, size);
1022 OHOS::DistributedSchedule::GetDistributedComponentListInnerFuzzTest(data, size);
1023 OHOS::DistributedSchedule::StartRemoteFreeInstallInnerFuzzTest(data, size);
1024 OHOS::DistributedSchedule::StartRemoteShareFormInnerFuzzTest(data, size);
1025 OHOS::DistributedSchedule::StopRemoteExtensionAbilityInnerFuzzTest(data, size);
1026 OHOS::DistributedSchedule::RegisterOnListenerInnerFuzzTest(data, size);
1027 OHOS::DistributedSchedule::RegisterOffListenerInnerFuzzTest(data, size);
1028 OHOS::DistributedSchedule::RegisterDSchedEventListenerInnerFuzzTest(data, size);
1029 OHOS::DistributedSchedule::UnRegisterDSchedEventListenerInnerFuzzTest(data, size);
1030 OHOS::DistributedSchedule::SetMissionContinueStateInnerFuzzTest(data, size);
1031 OHOS::DistributedSchedule::StartAbilityFromRemoteInnerFuzzTest(data, size);
1032 OHOS::DistributedSchedule::SendResultFromRemoteInnerFuzzTest(data, size);
1033 OHOS::DistributedSchedule::NotifyDSchedEventResultFromRemoteInnerFuzzTest(data, size);
1034 OHOS::DistributedSchedule::NotifyContinuationResultFromRemoteInnerFuzzTest(data, size);
1035 OHOS::DistributedSchedule::ConnectAbilityFromRemoteInnerFuzzTest(data, size);
1036 OHOS::DistributedSchedule::DisconnectAbilityFromRemoteInnerFuzzTest(data, size);
1037 OHOS::DistributedSchedule::NotifyProcessDiedFromRemoteInnerFuzzTest(data, size);
1038 OHOS::DistributedSchedule::GetContinueInfoInnerFuzzTest(data, size);
1039 OHOS::DistributedSchedule::NotifyMissionsChangedFromRemoteInnerFuzzTest(data, size);
1040 OHOS::DistributedSchedule::ReleaseAbilityFromRemoteInnerFuzzTest(data, size);
1041 OHOS::DistributedSchedule::NotifyStateChangedFromRemoteInnerFuzzTest(data, size);
1042 OHOS::DistributedSchedule::StartFreeInstallFromRemoteInnerFuzzTest(data, size);
1043 OHOS::DistributedSchedule::NotifyCompleteFreeInstallFromRemoteInnerFuzzTest(data, size);
1044 OHOS::DistributedSchedule::GetDSchedEventInfoInnerFuzzTest(data, size);
1045 OHOS::DistributedSchedule::StartAbilityByCallFromRemoteInnerFuzzTest(data, size);
1046 OHOS::DistributedSchedule::StartSyncMissionsFromRemoteInnerFuzzTest(data, size);
1047 OHOS::DistributedSchedule::StopSyncMissionsFromRemoteInnerFuzzTest(data, size);
1048 OHOS::DistributedSchedule::StartShareFormFromRemoteInnerFuzzTest(data, size);
1049 OHOS::DistributedSchedule::StopExtensionAbilityFromRemoteInnerFuzzTest(data, size);
1050 return 0;
1051 }