1d95e75fdSopenharmony_ci/*
2d95e75fdSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
3d95e75fdSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4d95e75fdSopenharmony_ci * you may not use this file except in compliance with the License.
5d95e75fdSopenharmony_ci * You may obtain a copy of the License at
6d95e75fdSopenharmony_ci *
7d95e75fdSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8d95e75fdSopenharmony_ci *
9d95e75fdSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10d95e75fdSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11d95e75fdSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12d95e75fdSopenharmony_ci * See the License for the specific language governing permissions and
13d95e75fdSopenharmony_ci * limitations under the License.
14d95e75fdSopenharmony_ci */
15d95e75fdSopenharmony_ci
16d95e75fdSopenharmony_ci#include "setpreviewwindow_fuzzer.h"
17d95e75fdSopenharmony_ci
18d95e75fdSopenharmony_ci#include <cstddef>
19d95e75fdSopenharmony_ci#include <cstdint>
20d95e75fdSopenharmony_ci#include <string_ex.h>
21d95e75fdSopenharmony_ci#define private public
22d95e75fdSopenharmony_ci
23d95e75fdSopenharmony_ci#include "addcellularcalltoken_fuzzer.h"
24d95e75fdSopenharmony_ci#include "cellular_call_service.h"
25d95e75fdSopenharmony_ci#include "securec.h"
26d95e75fdSopenharmony_ci#include "surface_utils.h"
27d95e75fdSopenharmony_ci#include "system_ability_definition.h"
28d95e75fdSopenharmony_ci
29d95e75fdSopenharmony_ciusing namespace OHOS::Telephony;
30d95e75fdSopenharmony_cinamespace OHOS {
31d95e75fdSopenharmony_cistatic bool g_isInited = false;
32d95e75fdSopenharmony_ciconstexpr int32_t BOOL_NUM = 2;
33d95e75fdSopenharmony_ciconstexpr int32_t VEDIO_STATE_NUM = 2;
34d95e75fdSopenharmony_ciconstexpr int32_t OFFSET_SIZE = 11;
35d95e75fdSopenharmony_ciconstexpr size_t MAX_NUMBER_LEN = 99;
36d95e75fdSopenharmony_ci
37d95e75fdSopenharmony_cibool IsServiceInited()
38d95e75fdSopenharmony_ci{
39d95e75fdSopenharmony_ci    if (!g_isInited) {
40d95e75fdSopenharmony_ci        DelayedSingleton<CellularCallService>::GetInstance()->OnStart();
41d95e75fdSopenharmony_ci    }
42d95e75fdSopenharmony_ci    if (!g_isInited && (static_cast<int32_t>(DelayedSingleton<CellularCallService>::GetInstance()->state_) ==
43d95e75fdSopenharmony_ci                           static_cast<int32_t>(ServiceRunningState::STATE_RUNNING))) {
44d95e75fdSopenharmony_ci        g_isInited = true;
45d95e75fdSopenharmony_ci    }
46d95e75fdSopenharmony_ci    return g_isInited;
47d95e75fdSopenharmony_ci}
48d95e75fdSopenharmony_ci
49d95e75fdSopenharmony_civoid OnRemoteRequest(const uint8_t *data, size_t size)
50d95e75fdSopenharmony_ci{
51d95e75fdSopenharmony_ci    if (!IsServiceInited()) {
52d95e75fdSopenharmony_ci        return;
53d95e75fdSopenharmony_ci    }
54d95e75fdSopenharmony_ci
55d95e75fdSopenharmony_ci    MessageParcel dataMessageParcel;
56d95e75fdSopenharmony_ci    if (!dataMessageParcel.WriteInterfaceToken(CellularCallStub::GetDescriptor())) {
57d95e75fdSopenharmony_ci        return;
58d95e75fdSopenharmony_ci    }
59d95e75fdSopenharmony_ci    int32_t maxSize = static_cast<int32_t>(size) + OFFSET_SIZE;
60d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(maxSize);
61d95e75fdSopenharmony_ci    dataMessageParcel.WriteBuffer(data, size);
62d95e75fdSopenharmony_ci    dataMessageParcel.RewindRead(0);
63d95e75fdSopenharmony_ci    uint32_t code = static_cast<uint32_t>(size);
64d95e75fdSopenharmony_ci    MessageParcel reply;
65d95e75fdSopenharmony_ci    MessageOption option;
66d95e75fdSopenharmony_ci    DelayedSingleton<CellularCallService>::GetInstance()->OnRemoteRequest(code, dataMessageParcel, reply, option);
67d95e75fdSopenharmony_ci}
68d95e75fdSopenharmony_ci
69d95e75fdSopenharmony_civoid SetPreviewWindow(const uint8_t *data, size_t size)
70d95e75fdSopenharmony_ci{
71d95e75fdSopenharmony_ci    if (!IsServiceInited()) {
72d95e75fdSopenharmony_ci        return;
73d95e75fdSopenharmony_ci    }
74d95e75fdSopenharmony_ci
75d95e75fdSopenharmony_ci    int32_t maxSize = static_cast<int32_t>(size);
76d95e75fdSopenharmony_ci    int32_t slotId = static_cast<int32_t>(size % BOOL_NUM);
77d95e75fdSopenharmony_ci    int32_t index = static_cast<int32_t>(size);
78d95e75fdSopenharmony_ci    std::string surfaceId(reinterpret_cast<const char *>(data), size);
79d95e75fdSopenharmony_ci    MessageParcel dataMessageParcel;
80d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(maxSize);
81d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(slotId);
82d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(index);
83d95e75fdSopenharmony_ci    int len = static_cast<int>(surfaceId.length());
84d95e75fdSopenharmony_ci    std::string subSurfaceId = surfaceId;
85d95e75fdSopenharmony_ci    if (len >= 1) {
86d95e75fdSopenharmony_ci        subSurfaceId = surfaceId.substr(0, 1);
87d95e75fdSopenharmony_ci    }
88d95e75fdSopenharmony_ci    if (subSurfaceId.empty() || subSurfaceId[0] < '0' || subSurfaceId[0] > '9') {
89d95e75fdSopenharmony_ci        subSurfaceId = "";
90d95e75fdSopenharmony_ci        dataMessageParcel.WriteString(subSurfaceId);
91d95e75fdSopenharmony_ci    } else {
92d95e75fdSopenharmony_ci        dataMessageParcel.WriteString(subSurfaceId);
93d95e75fdSopenharmony_ci        uint64_t tmpSurfaceId = std::stoull(subSurfaceId);
94d95e75fdSopenharmony_ci        auto surface = SurfaceUtils::GetInstance()->GetSurface(tmpSurfaceId);
95d95e75fdSopenharmony_ci        if (surface != nullptr) {
96d95e75fdSopenharmony_ci            sptr<IBufferProducer> producer = surface->GetProducer();
97d95e75fdSopenharmony_ci            if (producer != nullptr) {
98d95e75fdSopenharmony_ci                dataMessageParcel.WriteRemoteObject(producer->AsObject());
99d95e75fdSopenharmony_ci            }
100d95e75fdSopenharmony_ci        }
101d95e75fdSopenharmony_ci    }
102d95e75fdSopenharmony_ci    dataMessageParcel.RewindRead(0);
103d95e75fdSopenharmony_ci    MessageParcel reply;
104d95e75fdSopenharmony_ci    DelayedSingleton<CellularCallService>::GetInstance()->OnSetPreviewWindowInner(dataMessageParcel, reply);
105d95e75fdSopenharmony_ci}
106d95e75fdSopenharmony_ci
107d95e75fdSopenharmony_civoid SetDisplayWindow(const uint8_t *data, size_t size)
108d95e75fdSopenharmony_ci{
109d95e75fdSopenharmony_ci    if (!IsServiceInited()) {
110d95e75fdSopenharmony_ci        return;
111d95e75fdSopenharmony_ci    }
112d95e75fdSopenharmony_ci
113d95e75fdSopenharmony_ci    int32_t maxSize = static_cast<int32_t>(size);
114d95e75fdSopenharmony_ci    int32_t slotId = static_cast<int32_t>(size % BOOL_NUM);
115d95e75fdSopenharmony_ci    int32_t index = static_cast<int32_t>(size);
116d95e75fdSopenharmony_ci    std::string surfaceId(reinterpret_cast<const char *>(data), size);
117d95e75fdSopenharmony_ci    MessageParcel dataMessageParcel;
118d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(maxSize);
119d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(slotId);
120d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(index);
121d95e75fdSopenharmony_ci    int len = static_cast<int>(surfaceId.length());
122d95e75fdSopenharmony_ci    std::string subSurfaceId = surfaceId;
123d95e75fdSopenharmony_ci    if (len >= 1) {
124d95e75fdSopenharmony_ci        subSurfaceId = surfaceId.substr(0, 1);
125d95e75fdSopenharmony_ci    }
126d95e75fdSopenharmony_ci    if (subSurfaceId.empty() || subSurfaceId[0] < '0' || subSurfaceId[0] > '9') {
127d95e75fdSopenharmony_ci        subSurfaceId = "";
128d95e75fdSopenharmony_ci        dataMessageParcel.WriteString(subSurfaceId);
129d95e75fdSopenharmony_ci    } else {
130d95e75fdSopenharmony_ci        dataMessageParcel.WriteString(subSurfaceId);
131d95e75fdSopenharmony_ci        uint64_t tmpSurfaceId = std::stoull(subSurfaceId);
132d95e75fdSopenharmony_ci        auto surface = SurfaceUtils::GetInstance()->GetSurface(tmpSurfaceId);
133d95e75fdSopenharmony_ci        if (surface != nullptr) {
134d95e75fdSopenharmony_ci            sptr<IBufferProducer> producer = surface->GetProducer();
135d95e75fdSopenharmony_ci            if (producer != nullptr) {
136d95e75fdSopenharmony_ci                dataMessageParcel.WriteRemoteObject(producer->AsObject());
137d95e75fdSopenharmony_ci            }
138d95e75fdSopenharmony_ci        }
139d95e75fdSopenharmony_ci    }
140d95e75fdSopenharmony_ci    dataMessageParcel.RewindRead(0);
141d95e75fdSopenharmony_ci    MessageParcel reply;
142d95e75fdSopenharmony_ci    DelayedSingleton<CellularCallService>::GetInstance()->OnSetDisplayWindowInner(dataMessageParcel, reply);
143d95e75fdSopenharmony_ci}
144d95e75fdSopenharmony_ci
145d95e75fdSopenharmony_civoid SetCameraZoom(const uint8_t *data, size_t size)
146d95e75fdSopenharmony_ci{
147d95e75fdSopenharmony_ci    if (!IsServiceInited()) {
148d95e75fdSopenharmony_ci        return;
149d95e75fdSopenharmony_ci    }
150d95e75fdSopenharmony_ci
151d95e75fdSopenharmony_ci    int32_t maxSize = static_cast<int32_t>(size);
152d95e75fdSopenharmony_ci    float zoomRatio = static_cast<float>(size);
153d95e75fdSopenharmony_ci    MessageParcel dataMessageParcel;
154d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(maxSize);
155d95e75fdSopenharmony_ci    dataMessageParcel.WriteFloat(zoomRatio);
156d95e75fdSopenharmony_ci    dataMessageParcel.RewindRead(0);
157d95e75fdSopenharmony_ci    MessageParcel reply;
158d95e75fdSopenharmony_ci    DelayedSingleton<CellularCallService>::GetInstance()->OnSetCameraZoomInner(dataMessageParcel, reply);
159d95e75fdSopenharmony_ci}
160d95e75fdSopenharmony_ci
161d95e75fdSopenharmony_civoid ControlCamera(const uint8_t *data, size_t size)
162d95e75fdSopenharmony_ci{
163d95e75fdSopenharmony_ci    if (!IsServiceInited()) {
164d95e75fdSopenharmony_ci        return;
165d95e75fdSopenharmony_ci    }
166d95e75fdSopenharmony_ci
167d95e75fdSopenharmony_ci    int32_t maxSize = static_cast<int32_t>(size);
168d95e75fdSopenharmony_ci    int32_t slotId = static_cast<int32_t>(size % BOOL_NUM);
169d95e75fdSopenharmony_ci    int32_t index = static_cast<int32_t>(size);
170d95e75fdSopenharmony_ci    std::string cameraId(reinterpret_cast<const char *>(data), size);
171d95e75fdSopenharmony_ci    MessageParcel dataMessageParcel;
172d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(maxSize);
173d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(slotId);
174d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(index);
175d95e75fdSopenharmony_ci    dataMessageParcel.WriteString(cameraId);
176d95e75fdSopenharmony_ci    dataMessageParcel.RewindRead(0);
177d95e75fdSopenharmony_ci    MessageParcel reply;
178d95e75fdSopenharmony_ci    DelayedSingleton<CellularCallService>::GetInstance()->OnControlCameraInner(dataMessageParcel, reply);
179d95e75fdSopenharmony_ci}
180d95e75fdSopenharmony_ci
181d95e75fdSopenharmony_civoid SetPausePicture(const uint8_t *data, size_t size)
182d95e75fdSopenharmony_ci{
183d95e75fdSopenharmony_ci    if (!IsServiceInited()) {
184d95e75fdSopenharmony_ci        return;
185d95e75fdSopenharmony_ci    }
186d95e75fdSopenharmony_ci
187d95e75fdSopenharmony_ci    int32_t maxSize = static_cast<int32_t>(size);
188d95e75fdSopenharmony_ci    int32_t slotId = static_cast<int32_t>(size % BOOL_NUM);
189d95e75fdSopenharmony_ci    int32_t index = static_cast<int32_t>(size);
190d95e75fdSopenharmony_ci    std::string path(reinterpret_cast<const char *>(data), size);
191d95e75fdSopenharmony_ci    MessageParcel dataMessageParcel;
192d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(maxSize);
193d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(slotId);
194d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(index);
195d95e75fdSopenharmony_ci    dataMessageParcel.WriteString(path);
196d95e75fdSopenharmony_ci    dataMessageParcel.RewindRead(0);
197d95e75fdSopenharmony_ci    MessageParcel reply;
198d95e75fdSopenharmony_ci    DelayedSingleton<CellularCallService>::GetInstance()->OnSetPausePictureInner(dataMessageParcel, reply);
199d95e75fdSopenharmony_ci}
200d95e75fdSopenharmony_ci
201d95e75fdSopenharmony_civoid SetDeviceDirection(const uint8_t *data, size_t size)
202d95e75fdSopenharmony_ci{
203d95e75fdSopenharmony_ci    if (!IsServiceInited()) {
204d95e75fdSopenharmony_ci        return;
205d95e75fdSopenharmony_ci    }
206d95e75fdSopenharmony_ci
207d95e75fdSopenharmony_ci    int32_t maxSize = static_cast<int32_t>(size);
208d95e75fdSopenharmony_ci    int32_t slotId = static_cast<int32_t>(size % BOOL_NUM);
209d95e75fdSopenharmony_ci    int32_t index = static_cast<int32_t>(size);
210d95e75fdSopenharmony_ci    int32_t rotation = static_cast<int32_t>(size);
211d95e75fdSopenharmony_ci    MessageParcel dataMessageParcel;
212d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(maxSize);
213d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(slotId);
214d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(index);
215d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(rotation);
216d95e75fdSopenharmony_ci    dataMessageParcel.RewindRead(0);
217d95e75fdSopenharmony_ci    MessageParcel reply;
218d95e75fdSopenharmony_ci    DelayedSingleton<CellularCallService>::GetInstance()->OnSetDeviceDirectionInner(dataMessageParcel, reply);
219d95e75fdSopenharmony_ci}
220d95e75fdSopenharmony_ci
221d95e75fdSopenharmony_civoid SendUpdateCallMediaModeRequest(const uint8_t *data, size_t size)
222d95e75fdSopenharmony_ci{
223d95e75fdSopenharmony_ci    if (!IsServiceInited()) {
224d95e75fdSopenharmony_ci        return;
225d95e75fdSopenharmony_ci    }
226d95e75fdSopenharmony_ci
227d95e75fdSopenharmony_ci    int32_t maxSize = static_cast<int32_t>(size);
228d95e75fdSopenharmony_ci    CellularCallInfo callInfo;
229d95e75fdSopenharmony_ci    callInfo.callId = static_cast<int32_t>(size);
230d95e75fdSopenharmony_ci    callInfo.slotId = static_cast<int32_t>(size % BOOL_NUM);
231d95e75fdSopenharmony_ci    callInfo.accountId = static_cast<int32_t>(size % BOOL_NUM);
232d95e75fdSopenharmony_ci    callInfo.callType = static_cast<CallType>(static_cast<int32_t>(size));
233d95e75fdSopenharmony_ci    callInfo.videoState = static_cast<int32_t>(size % VEDIO_STATE_NUM);
234d95e75fdSopenharmony_ci    callInfo.index = static_cast<int32_t>(size);
235d95e75fdSopenharmony_ci    std::string telNum = "000000000";
236d95e75fdSopenharmony_ci    std::string tempNum(reinterpret_cast<const char *>(data), size);
237d95e75fdSopenharmony_ci    if (strlen(tempNum.c_str()) <= MAX_NUMBER_LEN) {
238d95e75fdSopenharmony_ci        telNum = tempNum;
239d95e75fdSopenharmony_ci    }
240d95e75fdSopenharmony_ci    size_t length = strlen(telNum.c_str()) + 1;
241d95e75fdSopenharmony_ci    if (strcpy_s(callInfo.phoneNum, length, telNum.c_str()) != EOK) {
242d95e75fdSopenharmony_ci        return;
243d95e75fdSopenharmony_ci    }
244d95e75fdSopenharmony_ci    int32_t mode = static_cast<int32_t>(size);
245d95e75fdSopenharmony_ci    MessageParcel dataMessageParcel;
246d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(maxSize);
247d95e75fdSopenharmony_ci    dataMessageParcel.WriteRawData(static_cast<const void *>(&callInfo), sizeof(CellularCallInfo));
248d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(mode);
249d95e75fdSopenharmony_ci    dataMessageParcel.RewindRead(0);
250d95e75fdSopenharmony_ci    MessageParcel reply;
251d95e75fdSopenharmony_ci    DelayedSingleton<CellularCallService>::GetInstance()->OnSendUpdateCallMediaModeRequestInner(
252d95e75fdSopenharmony_ci        dataMessageParcel, reply);
253d95e75fdSopenharmony_ci}
254d95e75fdSopenharmony_ci
255d95e75fdSopenharmony_civoid SendUpdateCallMediaModeResponse(const uint8_t *data, size_t size)
256d95e75fdSopenharmony_ci{
257d95e75fdSopenharmony_ci    if (!IsServiceInited()) {
258d95e75fdSopenharmony_ci        return;
259d95e75fdSopenharmony_ci    }
260d95e75fdSopenharmony_ci
261d95e75fdSopenharmony_ci    int32_t maxSize = static_cast<int32_t>(size);
262d95e75fdSopenharmony_ci    CellularCallInfo callInfo;
263d95e75fdSopenharmony_ci    callInfo.callId = static_cast<int32_t>(size);
264d95e75fdSopenharmony_ci    callInfo.slotId = static_cast<int32_t>(size % BOOL_NUM);
265d95e75fdSopenharmony_ci    callInfo.accountId = static_cast<int32_t>(size % BOOL_NUM);
266d95e75fdSopenharmony_ci    callInfo.callType = static_cast<CallType>(static_cast<int32_t>(size));
267d95e75fdSopenharmony_ci    callInfo.videoState = static_cast<int32_t>(size % VEDIO_STATE_NUM);
268d95e75fdSopenharmony_ci    callInfo.index = static_cast<int32_t>(size);
269d95e75fdSopenharmony_ci    std::string telNum = "000000000";
270d95e75fdSopenharmony_ci    std::string tempNum(reinterpret_cast<const char *>(data), size);
271d95e75fdSopenharmony_ci    if (strlen(tempNum.c_str()) <= MAX_NUMBER_LEN) {
272d95e75fdSopenharmony_ci        telNum = tempNum;
273d95e75fdSopenharmony_ci    }
274d95e75fdSopenharmony_ci    size_t length = strlen(telNum.c_str()) + 1;
275d95e75fdSopenharmony_ci    if (strcpy_s(callInfo.phoneNum, length, telNum.c_str()) != EOK) {
276d95e75fdSopenharmony_ci        return;
277d95e75fdSopenharmony_ci    }
278d95e75fdSopenharmony_ci    int32_t mode = static_cast<int32_t>(size);
279d95e75fdSopenharmony_ci    MessageParcel dataMessageParcel;
280d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(maxSize);
281d95e75fdSopenharmony_ci    dataMessageParcel.WriteRawData(static_cast<const void *>(&callInfo), sizeof(CellularCallInfo));
282d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(mode);
283d95e75fdSopenharmony_ci    dataMessageParcel.RewindRead(0);
284d95e75fdSopenharmony_ci    MessageParcel reply;
285d95e75fdSopenharmony_ci    DelayedSingleton<CellularCallService>::GetInstance()->OnSendUpdateCallMediaModeResponseInner(
286d95e75fdSopenharmony_ci        dataMessageParcel, reply);
287d95e75fdSopenharmony_ci}
288d95e75fdSopenharmony_ci
289d95e75fdSopenharmony_civoid SetMute(const uint8_t *data, size_t size)
290d95e75fdSopenharmony_ci{
291d95e75fdSopenharmony_ci    if (!IsServiceInited()) {
292d95e75fdSopenharmony_ci        return;
293d95e75fdSopenharmony_ci    }
294d95e75fdSopenharmony_ci
295d95e75fdSopenharmony_ci    int32_t mute = static_cast<int32_t>(size);
296d95e75fdSopenharmony_ci    MessageParcel dataMessageParcel;
297d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(mute);
298d95e75fdSopenharmony_ci    dataMessageParcel.WriteBuffer(data, size);
299d95e75fdSopenharmony_ci    dataMessageParcel.RewindRead(0);
300d95e75fdSopenharmony_ci    MessageParcel reply;
301d95e75fdSopenharmony_ci    DelayedSingleton<CellularCallService>::GetInstance()->OnSetMuteInner(dataMessageParcel, reply);
302d95e75fdSopenharmony_ci}
303d95e75fdSopenharmony_ci
304d95e75fdSopenharmony_civoid GetMute(const uint8_t *data, size_t size)
305d95e75fdSopenharmony_ci{
306d95e75fdSopenharmony_ci    if (!IsServiceInited()) {
307d95e75fdSopenharmony_ci        return;
308d95e75fdSopenharmony_ci    }
309d95e75fdSopenharmony_ci
310d95e75fdSopenharmony_ci    MessageParcel dataMessageParcel;
311d95e75fdSopenharmony_ci    dataMessageParcel.WriteBuffer(data, size);
312d95e75fdSopenharmony_ci    dataMessageParcel.RewindRead(0);
313d95e75fdSopenharmony_ci    MessageParcel reply;
314d95e75fdSopenharmony_ci    DelayedSingleton<CellularCallService>::GetInstance()->OnGetMuteInner(dataMessageParcel, reply);
315d95e75fdSopenharmony_ci}
316d95e75fdSopenharmony_ci
317d95e75fdSopenharmony_civoid StartDtmf(const uint8_t *data, size_t size)
318d95e75fdSopenharmony_ci{
319d95e75fdSopenharmony_ci    if (!IsServiceInited()) {
320d95e75fdSopenharmony_ci        return;
321d95e75fdSopenharmony_ci    }
322d95e75fdSopenharmony_ci
323d95e75fdSopenharmony_ci    int32_t maxSize = static_cast<int32_t>(size);
324d95e75fdSopenharmony_ci    int32_t slotId = static_cast<int32_t>(size % BOOL_NUM);
325d95e75fdSopenharmony_ci    int32_t callId = static_cast<int32_t>(size);
326d95e75fdSopenharmony_ci    int32_t accountId = static_cast<int32_t>(size);
327d95e75fdSopenharmony_ci    int32_t videoState = static_cast<int32_t>(size % VEDIO_STATE_NUM);
328d95e75fdSopenharmony_ci    int32_t index = static_cast<int32_t>(size);
329d95e75fdSopenharmony_ci    char cDtmfCode = static_cast<char>(size);
330d95e75fdSopenharmony_ci    std::string telNum = "000000000";
331d95e75fdSopenharmony_ci    std::string tempNum(reinterpret_cast<const char *>(data), size);
332d95e75fdSopenharmony_ci    if (strlen(tempNum.c_str()) <= MAX_NUMBER_LEN) {
333d95e75fdSopenharmony_ci        telNum = tempNum;
334d95e75fdSopenharmony_ci    }
335d95e75fdSopenharmony_ci    size_t length = strlen(telNum.c_str()) + 1;
336d95e75fdSopenharmony_ci    CellularCallInfo callInfo;
337d95e75fdSopenharmony_ci    callInfo.slotId = slotId;
338d95e75fdSopenharmony_ci    callInfo.callId = callId;
339d95e75fdSopenharmony_ci    callInfo.accountId = accountId;
340d95e75fdSopenharmony_ci    callInfo.videoState = videoState;
341d95e75fdSopenharmony_ci    callInfo.index = index;
342d95e75fdSopenharmony_ci    if (strcpy_s(callInfo.phoneNum, length, telNum.c_str()) != EOK) {
343d95e75fdSopenharmony_ci        return;
344d95e75fdSopenharmony_ci    }
345d95e75fdSopenharmony_ci    MessageParcel dataMessageParcel;
346d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(maxSize);
347d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt8(cDtmfCode);
348d95e75fdSopenharmony_ci    dataMessageParcel.WriteRawData(static_cast<const void *>(&callInfo), sizeof(CellularCallInfo));
349d95e75fdSopenharmony_ci    dataMessageParcel.RewindRead(0);
350d95e75fdSopenharmony_ci    MessageParcel reply;
351d95e75fdSopenharmony_ci    DelayedSingleton<CellularCallService>::GetInstance()->OnStartDtmfInner(dataMessageParcel, reply);
352d95e75fdSopenharmony_ci}
353d95e75fdSopenharmony_ci
354d95e75fdSopenharmony_civoid CancelCallUpgrade(const uint8_t *data, size_t size)
355d95e75fdSopenharmony_ci{
356d95e75fdSopenharmony_ci    if (!IsServiceInited()) {
357d95e75fdSopenharmony_ci        return;
358d95e75fdSopenharmony_ci    }
359d95e75fdSopenharmony_ci
360d95e75fdSopenharmony_ci    int32_t maxSize = static_cast<int32_t>(size);
361d95e75fdSopenharmony_ci    int32_t slotId = static_cast<int32_t>(size % BOOL_NUM);
362d95e75fdSopenharmony_ci    int32_t index = static_cast<int32_t>(size);
363d95e75fdSopenharmony_ci    MessageParcel dataMessageParcel;
364d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(maxSize);
365d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(slotId);
366d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(index);
367d95e75fdSopenharmony_ci    dataMessageParcel.RewindRead(0);
368d95e75fdSopenharmony_ci    MessageParcel reply;
369d95e75fdSopenharmony_ci    DelayedSingleton<CellularCallService>::GetInstance()->OnCancelCallUpgradeInner(dataMessageParcel, reply);
370d95e75fdSopenharmony_ci}
371d95e75fdSopenharmony_ci
372d95e75fdSopenharmony_civoid RequestCameraCapabilities(const uint8_t *data, size_t size)
373d95e75fdSopenharmony_ci{
374d95e75fdSopenharmony_ci    if (!IsServiceInited()) {
375d95e75fdSopenharmony_ci        return;
376d95e75fdSopenharmony_ci    }
377d95e75fdSopenharmony_ci
378d95e75fdSopenharmony_ci    int32_t maxSize = static_cast<int32_t>(size);
379d95e75fdSopenharmony_ci    int32_t slotId = static_cast<int32_t>(size % BOOL_NUM);
380d95e75fdSopenharmony_ci    int32_t index = static_cast<int32_t>(size);
381d95e75fdSopenharmony_ci    MessageParcel dataMessageParcel;
382d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(maxSize);
383d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(slotId);
384d95e75fdSopenharmony_ci    dataMessageParcel.WriteInt32(index);
385d95e75fdSopenharmony_ci    dataMessageParcel.RewindRead(0);
386d95e75fdSopenharmony_ci    MessageParcel reply;
387d95e75fdSopenharmony_ci    DelayedSingleton<CellularCallService>::GetInstance()->OnRequestCameraCapabilitiesInner(dataMessageParcel, reply);
388d95e75fdSopenharmony_ci}
389d95e75fdSopenharmony_ci
390d95e75fdSopenharmony_civoid DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size)
391d95e75fdSopenharmony_ci{
392d95e75fdSopenharmony_ci    if (data == nullptr || size == 0) {
393d95e75fdSopenharmony_ci        return;
394d95e75fdSopenharmony_ci    }
395d95e75fdSopenharmony_ci
396d95e75fdSopenharmony_ci    OnRemoteRequest(data, size);
397d95e75fdSopenharmony_ci    SetPreviewWindow(data, size);
398d95e75fdSopenharmony_ci    SetDisplayWindow(data, size);
399d95e75fdSopenharmony_ci    SetCameraZoom(data, size);
400d95e75fdSopenharmony_ci    ControlCamera(data, size);
401d95e75fdSopenharmony_ci    SetPausePicture(data, size);
402d95e75fdSopenharmony_ci    SetDeviceDirection(data, size);
403d95e75fdSopenharmony_ci    SetMute(data, size);
404d95e75fdSopenharmony_ci    GetMute(data, size);
405d95e75fdSopenharmony_ci    StartDtmf(data, size);
406d95e75fdSopenharmony_ci    SendUpdateCallMediaModeRequest(data, size);
407d95e75fdSopenharmony_ci    SendUpdateCallMediaModeResponse(data, size);
408d95e75fdSopenharmony_ci    CancelCallUpgrade(data, size);
409d95e75fdSopenharmony_ci    RequestCameraCapabilities(data, size);
410d95e75fdSopenharmony_ci}
411d95e75fdSopenharmony_ci} // namespace OHOS
412d95e75fdSopenharmony_ci
413d95e75fdSopenharmony_ci/* Fuzzer entry point */
414d95e75fdSopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
415d95e75fdSopenharmony_ci{
416d95e75fdSopenharmony_ci    OHOS::AddCellularCallTokenFuzzer token;
417d95e75fdSopenharmony_ci    /* Run your code on data */
418d95e75fdSopenharmony_ci    OHOS::DoSomethingInterestingWithMyAPI(data, size);
419d95e75fdSopenharmony_ci    return 0;
420d95e75fdSopenharmony_ci}
421