1e1c44949Sopenharmony_ci/* 2e1c44949Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 3e1c44949Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4e1c44949Sopenharmony_ci * you may not use this file except in compliance with the License. 5e1c44949Sopenharmony_ci * You may obtain a copy of the License at 6e1c44949Sopenharmony_ci * 7e1c44949Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8e1c44949Sopenharmony_ci * 9e1c44949Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10e1c44949Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11e1c44949Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e1c44949Sopenharmony_ci * See the License for the specific language governing permissions and 13e1c44949Sopenharmony_ci * limitations under the License. 14e1c44949Sopenharmony_ci */ 15e1c44949Sopenharmony_ci 16e1c44949Sopenharmony_ci#include "call_fuzzer.h" 17e1c44949Sopenharmony_ci 18e1c44949Sopenharmony_ci#include <cstddef> 19e1c44949Sopenharmony_ci#include <cstdint> 20e1c44949Sopenharmony_ci#define private public 21e1c44949Sopenharmony_ci#define protected public 22e1c44949Sopenharmony_ci#include "addcalltoken_fuzzer.h" 23e1c44949Sopenharmony_ci#include "cs_call.h" 24e1c44949Sopenharmony_ci#include "ims_call.h" 25e1c44949Sopenharmony_ci#include "ott_call.h" 26e1c44949Sopenharmony_ci#include "satellite_call.h" 27e1c44949Sopenharmony_ci#include "surface_utils.h" 28e1c44949Sopenharmony_ci#include "voip_call.h" 29e1c44949Sopenharmony_ci 30e1c44949Sopenharmony_ciusing namespace OHOS::Telephony; 31e1c44949Sopenharmony_cinamespace OHOS { 32e1c44949Sopenharmony_ciconstexpr int32_t SLOT_NUM = 2; 33e1c44949Sopenharmony_ciconstexpr int32_t BOOL_NUM = 2; 34e1c44949Sopenharmony_ciconstexpr int32_t DIAL_TYPE = 3; 35e1c44949Sopenharmony_ciconstexpr int32_t CALL_TYPE_NUM = 4; 36e1c44949Sopenharmony_ciconstexpr int32_t VIDIO_TYPE_NUM = 2; 37e1c44949Sopenharmony_ciconstexpr int32_t TEL_CALL_STATE_NUM = 9; 38e1c44949Sopenharmony_ciconstexpr int32_t TEL_CONFERENCE_STATE_NUM = 4; 39e1c44949Sopenharmony_ciconstexpr int32_t CALL_RUNNING_STATE_NUM = 8; 40e1c44949Sopenharmony_ciconstexpr int32_t CALL_ENDED_TYPE_NUM = 4; 41e1c44949Sopenharmony_ciconstexpr int32_t CALL_ANSWER_TYPE_NUM = 3; 42e1c44949Sopenharmony_ciconstexpr int32_t INVALID_CALL_ID = -1; 43e1c44949Sopenharmony_ciconstexpr int32_t IMS_CALL_MODE_NUM = 5; 44e1c44949Sopenharmony_ciconstexpr int32_t CALL_INDEX_MAX_NUM = 8; 45e1c44949Sopenharmony_ciconstexpr int32_t VIDEO_REQUEST_RESULT_TYPE_NUM = 102; 46e1c44949Sopenharmony_ci 47e1c44949Sopenharmony_civoid CSCallFunc(const uint8_t *data, size_t size) 48e1c44949Sopenharmony_ci{ 49e1c44949Sopenharmony_ci if (!IsServiceInited()) { 50e1c44949Sopenharmony_ci return; 51e1c44949Sopenharmony_ci } 52e1c44949Sopenharmony_ci 53e1c44949Sopenharmony_ci DialParaInfo dialParaInfo; 54e1c44949Sopenharmony_ci dialParaInfo.dialType = static_cast<DialType>(size % DIAL_TYPE); 55e1c44949Sopenharmony_ci dialParaInfo.callType = static_cast<CallType>(size % CALL_TYPE_NUM); 56e1c44949Sopenharmony_ci dialParaInfo.videoState = static_cast<VideoStateType>(size % VIDIO_TYPE_NUM); 57e1c44949Sopenharmony_ci dialParaInfo.callState = static_cast<TelCallState>(size % TEL_CALL_STATE_NUM); 58e1c44949Sopenharmony_ci sptr<CallBase> callObjectPtr = std::make_unique<CSCall>(dialParaInfo).release(); 59e1c44949Sopenharmony_ci int32_t videoState = static_cast<int32_t>(size % VIDIO_TYPE_NUM); 60e1c44949Sopenharmony_ci int32_t mute = static_cast<int32_t>(size % BOOL_NUM); 61e1c44949Sopenharmony_ci int32_t slotId = static_cast<int32_t>(size % SLOT_NUM); 62e1c44949Sopenharmony_ci TelCallState nextState = static_cast<TelCallState>(size % TEL_CALL_STATE_NUM); 63e1c44949Sopenharmony_ci TelConferenceState telConferenceState = static_cast<TelConferenceState>(size % TEL_CONFERENCE_STATE_NUM); 64e1c44949Sopenharmony_ci VideoStateType mediaType = static_cast<VideoStateType>(size % VIDIO_TYPE_NUM); 65e1c44949Sopenharmony_ci PolicyFlag flag = static_cast<PolicyFlag>(size); 66e1c44949Sopenharmony_ci bool needAutoAnswer = static_cast<bool>(size); 67e1c44949Sopenharmony_ci bool canUnHoldState = static_cast<bool>(size); 68e1c44949Sopenharmony_ci 69e1c44949Sopenharmony_ci callObjectPtr->AnswerCall(videoState); 70e1c44949Sopenharmony_ci callObjectPtr->SetMute(mute, slotId); 71e1c44949Sopenharmony_ci callObjectPtr->StartDtmf(static_cast<char>(*data)); 72e1c44949Sopenharmony_ci callObjectPtr->StopDtmf(); 73e1c44949Sopenharmony_ci callObjectPtr->GetSlotId(); 74e1c44949Sopenharmony_ci callObjectPtr->DialCallBase(); 75e1c44949Sopenharmony_ci callObjectPtr->IncomingCallBase(); 76e1c44949Sopenharmony_ci callObjectPtr->AnswerCallBase(); 77e1c44949Sopenharmony_ci callObjectPtr->RejectCallBase(); 78e1c44949Sopenharmony_ci callObjectPtr->GetCallID(); 79e1c44949Sopenharmony_ci callObjectPtr->GetCallType(); 80e1c44949Sopenharmony_ci callObjectPtr->GetCallRunningState(); 81e1c44949Sopenharmony_ci callObjectPtr->SetTelCallState(nextState); 82e1c44949Sopenharmony_ci callObjectPtr->GetTelCallState(); 83e1c44949Sopenharmony_ci callObjectPtr->SetTelConferenceState(telConferenceState); 84e1c44949Sopenharmony_ci callObjectPtr->GetTelConferenceState(); 85e1c44949Sopenharmony_ci callObjectPtr->GetVideoStateType(); 86e1c44949Sopenharmony_ci callObjectPtr->SetVideoStateType(mediaType); 87e1c44949Sopenharmony_ci callObjectPtr->SetPolicyFlag(flag); 88e1c44949Sopenharmony_ci callObjectPtr->GetPolicyFlag(); 89e1c44949Sopenharmony_ci callObjectPtr->SetAutoAnswerState(needAutoAnswer); 90e1c44949Sopenharmony_ci callObjectPtr->GetAutoAnswerState(); 91e1c44949Sopenharmony_ci callObjectPtr->SetCanUnHoldState(canUnHoldState); 92e1c44949Sopenharmony_ci callObjectPtr->GetCanUnHoldState(); 93e1c44949Sopenharmony_ci} 94e1c44949Sopenharmony_ci 95e1c44949Sopenharmony_civoid DialingProcess(const uint8_t *data, size_t size) 96e1c44949Sopenharmony_ci{ 97e1c44949Sopenharmony_ci if (!IsServiceInited()) { 98e1c44949Sopenharmony_ci return; 99e1c44949Sopenharmony_ci } 100e1c44949Sopenharmony_ci 101e1c44949Sopenharmony_ci DialParaInfo paraInfo; 102e1c44949Sopenharmony_ci paraInfo.dialType = static_cast<DialType>(size % DIAL_TYPE); 103e1c44949Sopenharmony_ci paraInfo.callType = static_cast<CallType>(size % CALL_TYPE_NUM); 104e1c44949Sopenharmony_ci paraInfo.videoState = static_cast<VideoStateType>(size % VIDIO_TYPE_NUM); 105e1c44949Sopenharmony_ci paraInfo.callState = static_cast<TelCallState>(size % TEL_CALL_STATE_NUM); 106e1c44949Sopenharmony_ci sptr<CallBase> callObjectPtr = std::make_unique<CSCall>(paraInfo).release(); 107e1c44949Sopenharmony_ci 108e1c44949Sopenharmony_ci callObjectPtr->StartDtmf(static_cast<char>(*data)); 109e1c44949Sopenharmony_ci callObjectPtr->RejectCall(); 110e1c44949Sopenharmony_ci callObjectPtr->HangUpCall(); 111e1c44949Sopenharmony_ci callObjectPtr->HoldCall(); 112e1c44949Sopenharmony_ci callObjectPtr->UnHoldCall(); 113e1c44949Sopenharmony_ci callObjectPtr->SwitchCall(); 114e1c44949Sopenharmony_ci callObjectPtr->DialingProcess(); 115e1c44949Sopenharmony_ci callObjectPtr->CombineConference(); // merge calls 116e1c44949Sopenharmony_ci callObjectPtr->SeparateConference(); 117e1c44949Sopenharmony_ci callObjectPtr->KickOutFromConference(); 118e1c44949Sopenharmony_ci callObjectPtr->CanSeparateConference(); 119e1c44949Sopenharmony_ci callObjectPtr->CanCombineConference(); 120e1c44949Sopenharmony_ci callObjectPtr->CanKickOutFromConference(); 121e1c44949Sopenharmony_ci callObjectPtr->LaunchConference(); 122e1c44949Sopenharmony_ci callObjectPtr->ExitConference(); 123e1c44949Sopenharmony_ci callObjectPtr->HoldConference(); 124e1c44949Sopenharmony_ci int32_t mainCallId = INVALID_CALL_ID; 125e1c44949Sopenharmony_ci callObjectPtr->GetMainCallId(mainCallId); 126e1c44949Sopenharmony_ci std::vector<std::u16string> subCallIdList; 127e1c44949Sopenharmony_ci callObjectPtr->GetSubCallIdList(subCallIdList); 128e1c44949Sopenharmony_ci std::vector<std::u16string> callIdList; 129e1c44949Sopenharmony_ci callObjectPtr->GetCallIdListForConference(callIdList); 130e1c44949Sopenharmony_ci callObjectPtr->IsSupportConferenceable(); 131e1c44949Sopenharmony_ci callObjectPtr->GetEmergencyState(); 132e1c44949Sopenharmony_ci} 133e1c44949Sopenharmony_ci 134e1c44949Sopenharmony_civoid GetCallerInfo(const uint8_t *data, size_t size) 135e1c44949Sopenharmony_ci{ 136e1c44949Sopenharmony_ci if (!IsServiceInited()) { 137e1c44949Sopenharmony_ci return; 138e1c44949Sopenharmony_ci } 139e1c44949Sopenharmony_ci 140e1c44949Sopenharmony_ci DialParaInfo info; 141e1c44949Sopenharmony_ci info.dialType = static_cast<DialType>(size % DIAL_TYPE); 142e1c44949Sopenharmony_ci info.callType = static_cast<CallType>(size % CALL_TYPE_NUM); 143e1c44949Sopenharmony_ci info.videoState = static_cast<VideoStateType>(size % VIDIO_TYPE_NUM); 144e1c44949Sopenharmony_ci info.callState = static_cast<TelCallState>(size % TEL_CALL_STATE_NUM); 145e1c44949Sopenharmony_ci sptr<CallBase> callObjectPtr = std::make_unique<CSCall>(info).release(); 146e1c44949Sopenharmony_ci ContactInfo contactInfo; 147e1c44949Sopenharmony_ci CallRunningState callRunningState = static_cast<CallRunningState>(size % CALL_RUNNING_STATE_NUM); 148e1c44949Sopenharmony_ci bool speakerphoneOn = static_cast<bool>(size % BOOL_NUM); 149e1c44949Sopenharmony_ci std::string phoneNumber(reinterpret_cast<const char *>(data), size); 150e1c44949Sopenharmony_ci int32_t callId = static_cast<int32_t>(size); 151e1c44949Sopenharmony_ci CallEndedType callEndedType = static_cast<CallEndedType>(size % CALL_ENDED_TYPE_NUM); 152e1c44949Sopenharmony_ci CallAnswerType answerType = static_cast<CallAnswerType>(size % CALL_ANSWER_TYPE_NUM); 153e1c44949Sopenharmony_ci int64_t startTime = static_cast<int64_t>(size); 154e1c44949Sopenharmony_ci time_t callBeginTime = static_cast<time_t>(size); 155e1c44949Sopenharmony_ci time_t callCreateTime = static_cast<time_t>(size); 156e1c44949Sopenharmony_ci time_t callEndTime = static_cast<time_t>(size); 157e1c44949Sopenharmony_ci time_t ringBeginTime = static_cast<time_t>(size); 158e1c44949Sopenharmony_ci time_t ringEndTime = static_cast<time_t>(size); 159e1c44949Sopenharmony_ci callObjectPtr->GetCallerInfo(); 160e1c44949Sopenharmony_ci callObjectPtr->SetCallerInfo(contactInfo); 161e1c44949Sopenharmony_ci callObjectPtr->SetCallRunningState(callRunningState); 162e1c44949Sopenharmony_ci callObjectPtr->SetStartTime(startTime); 163e1c44949Sopenharmony_ci callObjectPtr->SetCallBeginTime(callBeginTime); 164e1c44949Sopenharmony_ci callObjectPtr->SetCallBeginTime(callCreateTime); 165e1c44949Sopenharmony_ci callObjectPtr->SetCallEndTime(callEndTime); 166e1c44949Sopenharmony_ci callObjectPtr->SetRingBeginTime(ringBeginTime); 167e1c44949Sopenharmony_ci callObjectPtr->SetRingEndTime(ringEndTime); 168e1c44949Sopenharmony_ci callObjectPtr->SetAnswerType(answerType); 169e1c44949Sopenharmony_ci callObjectPtr->GetCallEndedType(); 170e1c44949Sopenharmony_ci callObjectPtr->SetCallEndedType(callEndedType); 171e1c44949Sopenharmony_ci callObjectPtr->SetCallId(callId); 172e1c44949Sopenharmony_ci callObjectPtr->IsSpeakerphoneEnabled(); 173e1c44949Sopenharmony_ci callObjectPtr->IsCurrentRinging(); 174e1c44949Sopenharmony_ci callObjectPtr->GetAccountNumber(); 175e1c44949Sopenharmony_ci callObjectPtr->SetSpeakerphoneOn(speakerphoneOn); 176e1c44949Sopenharmony_ci callObjectPtr->IsSpeakerphoneOn(); 177e1c44949Sopenharmony_ci callObjectPtr->CheckVoicemailNumber(phoneNumber); 178e1c44949Sopenharmony_ci callObjectPtr->IsAliveState(); 179e1c44949Sopenharmony_ci} 180e1c44949Sopenharmony_ci 181e1c44949Sopenharmony_civoid IMSCallFunc(const uint8_t *data, size_t size) 182e1c44949Sopenharmony_ci{ 183e1c44949Sopenharmony_ci if (!IsServiceInited()) { 184e1c44949Sopenharmony_ci return; 185e1c44949Sopenharmony_ci } 186e1c44949Sopenharmony_ci 187e1c44949Sopenharmony_ci DialParaInfo paraInfo; 188e1c44949Sopenharmony_ci paraInfo.dialType = static_cast<DialType>(size % DIAL_TYPE); 189e1c44949Sopenharmony_ci paraInfo.callType = static_cast<CallType>(size % CALL_TYPE_NUM); 190e1c44949Sopenharmony_ci paraInfo.videoState = static_cast<VideoStateType>(size % VIDIO_TYPE_NUM); 191e1c44949Sopenharmony_ci paraInfo.callState = static_cast<TelCallState>(size % TEL_CALL_STATE_NUM); 192e1c44949Sopenharmony_ci sptr<IMSCall> callObjectPtr = std::make_unique<IMSCall>(paraInfo).release(); 193e1c44949Sopenharmony_ci int32_t videoState = static_cast<int32_t>(size % VIDIO_TYPE_NUM); 194e1c44949Sopenharmony_ci int32_t mute = static_cast<int32_t>(size % BOOL_NUM); 195e1c44949Sopenharmony_ci int32_t slotId = static_cast<int32_t>(size % SLOT_NUM); 196e1c44949Sopenharmony_ci std::string msg(reinterpret_cast<const char *>(data), size); 197e1c44949Sopenharmony_ci std::u16string msgU16 = Str8ToStr16(msg); 198e1c44949Sopenharmony_ci 199e1c44949Sopenharmony_ci callObjectPtr->InitVideoCall(); 200e1c44949Sopenharmony_ci callObjectPtr->DialingProcess(); 201e1c44949Sopenharmony_ci callObjectPtr->AnswerCall(videoState); 202e1c44949Sopenharmony_ci callObjectPtr->RejectCall(); 203e1c44949Sopenharmony_ci callObjectPtr->HangUpCall(); 204e1c44949Sopenharmony_ci callObjectPtr->UnHoldCall(); 205e1c44949Sopenharmony_ci callObjectPtr->HoldCall(); 206e1c44949Sopenharmony_ci callObjectPtr->SwitchCall(); 207e1c44949Sopenharmony_ci callObjectPtr->CombineConference(); 208e1c44949Sopenharmony_ci callObjectPtr->SeparateConference(); 209e1c44949Sopenharmony_ci callObjectPtr->KickOutFromConference(); 210e1c44949Sopenharmony_ci callObjectPtr->CanKickOutFromConference(); 211e1c44949Sopenharmony_ci callObjectPtr->CanCombineConference(); 212e1c44949Sopenharmony_ci callObjectPtr->CanSeparateConference(); 213e1c44949Sopenharmony_ci callObjectPtr->LaunchConference(); 214e1c44949Sopenharmony_ci callObjectPtr->ExitConference(); 215e1c44949Sopenharmony_ci callObjectPtr->HoldConference(); 216e1c44949Sopenharmony_ci int32_t mainCallId = INVALID_CALL_ID; 217e1c44949Sopenharmony_ci callObjectPtr->GetMainCallId(mainCallId); 218e1c44949Sopenharmony_ci std::vector<std::u16string> subCallIdList; 219e1c44949Sopenharmony_ci callObjectPtr->GetSubCallIdList(subCallIdList); 220e1c44949Sopenharmony_ci std::vector<std::u16string> callIdList; 221e1c44949Sopenharmony_ci callObjectPtr->GetCallIdListForConference(callIdList); 222e1c44949Sopenharmony_ci callObjectPtr->IsSupportConferenceable(); 223e1c44949Sopenharmony_ci callObjectPtr->StartRtt(msgU16); 224e1c44949Sopenharmony_ci callObjectPtr->StopRtt(); 225e1c44949Sopenharmony_ci callObjectPtr->SetMute(mute, slotId); 226e1c44949Sopenharmony_ci} 227e1c44949Sopenharmony_ci 228e1c44949Sopenharmony_civoid VoIPCallFunc(const uint8_t *data, size_t size) 229e1c44949Sopenharmony_ci{ 230e1c44949Sopenharmony_ci if (!IsServiceInited()) { 231e1c44949Sopenharmony_ci return; 232e1c44949Sopenharmony_ci } 233e1c44949Sopenharmony_ci CallAttributeInfo info; 234e1c44949Sopenharmony_ci DialParaInfo dialParaInfo; 235e1c44949Sopenharmony_ci int32_t mainCallId = 0; 236e1c44949Sopenharmony_ci VoipCallEventInfo voipcallInfo; 237e1c44949Sopenharmony_ci std::vector<std::u16string> callIdList; 238e1c44949Sopenharmony_ci int32_t videoState = static_cast<int32_t>(size % VIDIO_TYPE_NUM); 239e1c44949Sopenharmony_ci sptr<VoIPCall> voipCall = std::make_unique<VoIPCall>(dialParaInfo).release(); 240e1c44949Sopenharmony_ci 241e1c44949Sopenharmony_ci voipCall->DialingProcess(); 242e1c44949Sopenharmony_ci voipCall->AnswerCall(videoState); 243e1c44949Sopenharmony_ci voipCall->PackVoipCallInfo(voipcallInfo); 244e1c44949Sopenharmony_ci voipCall->RejectCall(); 245e1c44949Sopenharmony_ci voipCall->HangUpCall(); 246e1c44949Sopenharmony_ci voipCall->HoldCall(); 247e1c44949Sopenharmony_ci voipCall->UnHoldCall(); 248e1c44949Sopenharmony_ci voipCall->SwitchCall(); 249e1c44949Sopenharmony_ci voipCall->SetMute(0, 0); 250e1c44949Sopenharmony_ci voipCall->GetCallAttributeInfo(info); 251e1c44949Sopenharmony_ci voipCall->CombineConference(); 252e1c44949Sopenharmony_ci voipCall->HandleCombineConferenceFailEvent(); 253e1c44949Sopenharmony_ci voipCall->SeparateConference(); 254e1c44949Sopenharmony_ci voipCall->KickOutFromConference(); 255e1c44949Sopenharmony_ci voipCall->CanCombineConference(); 256e1c44949Sopenharmony_ci voipCall->CanSeparateConference(); 257e1c44949Sopenharmony_ci voipCall->CanKickOutFromConference(); 258e1c44949Sopenharmony_ci voipCall->GetMainCallId(mainCallId); 259e1c44949Sopenharmony_ci voipCall->GetSubCallIdList(callIdList); 260e1c44949Sopenharmony_ci voipCall->GetCallIdListForConference(callIdList); 261e1c44949Sopenharmony_ci voipCall->IsSupportConferenceable(); 262e1c44949Sopenharmony_ci voipCall->LaunchConference(); 263e1c44949Sopenharmony_ci voipCall->ExitConference(); 264e1c44949Sopenharmony_ci voipCall->HoldConference(); 265e1c44949Sopenharmony_ci} 266e1c44949Sopenharmony_ci 267e1c44949Sopenharmony_civoid IMSVideoCallFunc(const uint8_t *data, size_t size) 268e1c44949Sopenharmony_ci{ 269e1c44949Sopenharmony_ci if (!IsServiceInited()) { 270e1c44949Sopenharmony_ci return; 271e1c44949Sopenharmony_ci } 272e1c44949Sopenharmony_ci 273e1c44949Sopenharmony_ci DialParaInfo paraInfo; 274e1c44949Sopenharmony_ci paraInfo.dialType = static_cast<DialType>(size % DIAL_TYPE); 275e1c44949Sopenharmony_ci paraInfo.callType = static_cast<CallType>(size % CALL_TYPE_NUM); 276e1c44949Sopenharmony_ci paraInfo.videoState = static_cast<VideoStateType>(size % VIDIO_TYPE_NUM); 277e1c44949Sopenharmony_ci paraInfo.callState = static_cast<TelCallState>(size % TEL_CALL_STATE_NUM); 278e1c44949Sopenharmony_ci sptr<IMSCall> callObjectPtr = std::make_unique<IMSCall>(paraInfo).release(); 279e1c44949Sopenharmony_ci std::string msg(reinterpret_cast<const char *>(data), size); 280e1c44949Sopenharmony_ci int32_t callingUid = static_cast<int32_t>(size); 281e1c44949Sopenharmony_ci int32_t callingPid = static_cast<int32_t>(size); 282e1c44949Sopenharmony_ci int32_t rotation = static_cast<int32_t>(size); 283e1c44949Sopenharmony_ci ImsCallMode mode = static_cast<ImsCallMode>(size % IMS_CALL_MODE_NUM); 284e1c44949Sopenharmony_ci CallModeReportInfo callModeReportInfo; 285e1c44949Sopenharmony_ci callModeReportInfo.callIndex = static_cast<int32_t>(size % CALL_INDEX_MAX_NUM); 286e1c44949Sopenharmony_ci callModeReportInfo.callMode = static_cast<ImsCallMode>(size % IMS_CALL_MODE_NUM); 287e1c44949Sopenharmony_ci callModeReportInfo.result = static_cast<VideoRequestResultType>(size % VIDEO_REQUEST_RESULT_TYPE_NUM); 288e1c44949Sopenharmony_ci callObjectPtr->UpdateImsCallMode(mode); 289e1c44949Sopenharmony_ci callObjectPtr->SendUpdateCallMediaModeRequest(mode); 290e1c44949Sopenharmony_ci callObjectPtr->RecieveUpdateCallMediaModeRequest(callModeReportInfo); 291e1c44949Sopenharmony_ci callObjectPtr->SendUpdateCallMediaModeResponse(mode); 292e1c44949Sopenharmony_ci callObjectPtr->ReceiveUpdateCallMediaModeResponse(callModeReportInfo); 293e1c44949Sopenharmony_ci CallMediaModeInfo callMediaModeInfo; 294e1c44949Sopenharmony_ci callMediaModeInfo.callId = static_cast<int32_t>(size); 295e1c44949Sopenharmony_ci callMediaModeInfo.isRequestInfo = static_cast<bool>(size % BOOL_NUM); 296e1c44949Sopenharmony_ci callMediaModeInfo.result = static_cast<VideoRequestResultType>(size % VIDEO_REQUEST_RESULT_TYPE_NUM); 297e1c44949Sopenharmony_ci callMediaModeInfo.callMode = static_cast<ImsCallMode>(size % IMS_CALL_MODE_NUM); 298e1c44949Sopenharmony_ci callObjectPtr->ReportImsCallModeInfo(callMediaModeInfo); 299e1c44949Sopenharmony_ci callObjectPtr->SwitchVideoState(mode); 300e1c44949Sopenharmony_ci callObjectPtr->IsSupportVideoCall(); 301e1c44949Sopenharmony_ci callObjectPtr->GetCallVideoState(mode); 302e1c44949Sopenharmony_ci callObjectPtr->ControlCamera(msg, callingUid, callingPid); 303e1c44949Sopenharmony_ci callObjectPtr->SetPausePicture(msg); 304e1c44949Sopenharmony_ci callObjectPtr->SetDeviceDirection(rotation); 305e1c44949Sopenharmony_ci callObjectPtr->CancelCallUpgrade(); 306e1c44949Sopenharmony_ci callObjectPtr->RequestCameraCapabilities(); 307e1c44949Sopenharmony_ci} 308e1c44949Sopenharmony_ci 309e1c44949Sopenharmony_civoid IMSVideoCallWindowFunc(const uint8_t *data, size_t size) 310e1c44949Sopenharmony_ci{ 311e1c44949Sopenharmony_ci if (!IsServiceInited()) { 312e1c44949Sopenharmony_ci return; 313e1c44949Sopenharmony_ci } 314e1c44949Sopenharmony_ci 315e1c44949Sopenharmony_ci DialParaInfo paraInfo; 316e1c44949Sopenharmony_ci paraInfo.dialType = static_cast<DialType>(size % DIAL_TYPE); 317e1c44949Sopenharmony_ci paraInfo.callType = static_cast<CallType>(size % CALL_TYPE_NUM); 318e1c44949Sopenharmony_ci paraInfo.videoState = static_cast<VideoStateType>(size % VIDIO_TYPE_NUM); 319e1c44949Sopenharmony_ci paraInfo.callState = static_cast<TelCallState>(size % TEL_CALL_STATE_NUM); 320e1c44949Sopenharmony_ci sptr<IMSCall> callObjectPtr = std::make_unique<IMSCall>(paraInfo).release(); 321e1c44949Sopenharmony_ci std::string msg(reinterpret_cast<const char *>(data), size); 322e1c44949Sopenharmony_ci int len = static_cast<int>(msg.length()); 323e1c44949Sopenharmony_ci std::string subSurfaceId = msg; 324e1c44949Sopenharmony_ci if (len >= 1) { 325e1c44949Sopenharmony_ci subSurfaceId = msg.substr(0, 1); 326e1c44949Sopenharmony_ci } 327e1c44949Sopenharmony_ci if (subSurfaceId.empty() || subSurfaceId[0] < '0' || subSurfaceId[0] > '9') { 328e1c44949Sopenharmony_ci subSurfaceId = ""; 329e1c44949Sopenharmony_ci callObjectPtr->SetPreviewWindow(subSurfaceId, nullptr); 330e1c44949Sopenharmony_ci callObjectPtr->SetDisplayWindow(subSurfaceId, nullptr); 331e1c44949Sopenharmony_ci } else { 332e1c44949Sopenharmony_ci uint64_t tmpSurfaceId = std::stoull(subSurfaceId); 333e1c44949Sopenharmony_ci auto surface = SurfaceUtils::GetInstance()->GetSurface(tmpSurfaceId); 334e1c44949Sopenharmony_ci callObjectPtr->SetPreviewWindow(subSurfaceId, surface); 335e1c44949Sopenharmony_ci callObjectPtr->SetDisplayWindow(subSurfaceId, surface); 336e1c44949Sopenharmony_ci } 337e1c44949Sopenharmony_ci} 338e1c44949Sopenharmony_ci 339e1c44949Sopenharmony_civoid OttCallFunc(const uint8_t *data, size_t size) 340e1c44949Sopenharmony_ci{ 341e1c44949Sopenharmony_ci if (!IsServiceInited()) { 342e1c44949Sopenharmony_ci return; 343e1c44949Sopenharmony_ci } 344e1c44949Sopenharmony_ci 345e1c44949Sopenharmony_ci DialParaInfo paraInfo; 346e1c44949Sopenharmony_ci paraInfo.dialType = static_cast<DialType>(size % DIAL_TYPE); 347e1c44949Sopenharmony_ci paraInfo.callType = static_cast<CallType>(size % CALL_TYPE_NUM); 348e1c44949Sopenharmony_ci paraInfo.videoState = static_cast<VideoStateType>(size % VIDIO_TYPE_NUM); 349e1c44949Sopenharmony_ci paraInfo.callState = static_cast<TelCallState>(size % TEL_CALL_STATE_NUM); 350e1c44949Sopenharmony_ci sptr<OTTCall> callObjectPtr = std::make_unique<OTTCall>(paraInfo).release(); 351e1c44949Sopenharmony_ci int32_t videoState = static_cast<int32_t>(size % VIDIO_TYPE_NUM); 352e1c44949Sopenharmony_ci int32_t mute = static_cast<int32_t>(size % BOOL_NUM); 353e1c44949Sopenharmony_ci int32_t slotId = static_cast<int32_t>(size % SLOT_NUM); 354e1c44949Sopenharmony_ci 355e1c44949Sopenharmony_ci callObjectPtr->DialingProcess(); 356e1c44949Sopenharmony_ci callObjectPtr->AnswerCall(videoState); 357e1c44949Sopenharmony_ci callObjectPtr->RejectCall(); 358e1c44949Sopenharmony_ci callObjectPtr->HangUpCall(); 359e1c44949Sopenharmony_ci callObjectPtr->HoldCall(); 360e1c44949Sopenharmony_ci callObjectPtr->UnHoldCall(); 361e1c44949Sopenharmony_ci callObjectPtr->SwitchCall(); 362e1c44949Sopenharmony_ci callObjectPtr->GetEmergencyState(); 363e1c44949Sopenharmony_ci callObjectPtr->StopDtmf(); 364e1c44949Sopenharmony_ci callObjectPtr->GetSlotId(); 365e1c44949Sopenharmony_ci callObjectPtr->CombineConference(); 366e1c44949Sopenharmony_ci callObjectPtr->SeparateConference(); 367e1c44949Sopenharmony_ci callObjectPtr->KickOutFromConference(); 368e1c44949Sopenharmony_ci callObjectPtr->CanCombineConference(); 369e1c44949Sopenharmony_ci callObjectPtr->CanSeparateConference(); 370e1c44949Sopenharmony_ci callObjectPtr->CanKickOutFromConference(); 371e1c44949Sopenharmony_ci callObjectPtr->LaunchConference(); 372e1c44949Sopenharmony_ci callObjectPtr->ExitConference(); 373e1c44949Sopenharmony_ci callObjectPtr->HoldConference(); 374e1c44949Sopenharmony_ci int32_t mainCallId = INVALID_CALL_ID; 375e1c44949Sopenharmony_ci callObjectPtr->GetMainCallId(mainCallId); 376e1c44949Sopenharmony_ci std::vector<std::u16string> subCallIdList; 377e1c44949Sopenharmony_ci callObjectPtr->GetSubCallIdList(subCallIdList); 378e1c44949Sopenharmony_ci std::vector<std::u16string> callIdList; 379e1c44949Sopenharmony_ci callObjectPtr->GetCallIdListForConference(callIdList); 380e1c44949Sopenharmony_ci callObjectPtr->IsSupportConferenceable(); 381e1c44949Sopenharmony_ci callObjectPtr->SetMute(mute, slotId); 382e1c44949Sopenharmony_ci} 383e1c44949Sopenharmony_ci 384e1c44949Sopenharmony_civoid OttVideoCallFunc(const uint8_t *data, size_t size) 385e1c44949Sopenharmony_ci{ 386e1c44949Sopenharmony_ci if (!IsServiceInited()) { 387e1c44949Sopenharmony_ci return; 388e1c44949Sopenharmony_ci } 389e1c44949Sopenharmony_ci DialParaInfo paraInfo; 390e1c44949Sopenharmony_ci paraInfo.dialType = static_cast<DialType>(size % DIAL_TYPE); 391e1c44949Sopenharmony_ci paraInfo.callType = static_cast<CallType>(size % CALL_TYPE_NUM); 392e1c44949Sopenharmony_ci paraInfo.videoState = static_cast<VideoStateType>(size % VIDIO_TYPE_NUM); 393e1c44949Sopenharmony_ci paraInfo.callState = static_cast<TelCallState>(size % TEL_CALL_STATE_NUM); 394e1c44949Sopenharmony_ci sptr<OTTCall> callObjectPtr = std::make_unique<OTTCall>(paraInfo).release(); 395e1c44949Sopenharmony_ci std::string msg(reinterpret_cast<const char *>(data), size); 396e1c44949Sopenharmony_ci int32_t callingUid = static_cast<int32_t>(size); 397e1c44949Sopenharmony_ci int32_t callingPid = static_cast<int32_t>(size); 398e1c44949Sopenharmony_ci int32_t rotation = static_cast<int32_t>(size); 399e1c44949Sopenharmony_ci callObjectPtr->InitVideoCall(); 400e1c44949Sopenharmony_ci ImsCallMode mode = static_cast<ImsCallMode>(size % IMS_CALL_MODE_NUM); 401e1c44949Sopenharmony_ci CallModeReportInfo callModeReportInfo; 402e1c44949Sopenharmony_ci callModeReportInfo.callIndex = static_cast<int32_t>(size % CALL_INDEX_MAX_NUM); 403e1c44949Sopenharmony_ci callModeReportInfo.callMode = static_cast<ImsCallMode>(size % IMS_CALL_MODE_NUM); 404e1c44949Sopenharmony_ci callModeReportInfo.result = static_cast<VideoRequestResultType>(size % VIDEO_REQUEST_RESULT_TYPE_NUM); 405e1c44949Sopenharmony_ci callObjectPtr->UpdateImsCallMode(mode); 406e1c44949Sopenharmony_ci callObjectPtr->SendUpdateCallMediaModeRequest(mode); 407e1c44949Sopenharmony_ci callObjectPtr->RecieveUpdateCallMediaModeRequest(callModeReportInfo); 408e1c44949Sopenharmony_ci callObjectPtr->SendUpdateCallMediaModeResponse(mode); 409e1c44949Sopenharmony_ci callObjectPtr->ReceiveUpdateCallMediaModeResponse(callModeReportInfo); 410e1c44949Sopenharmony_ci CallMediaModeInfo callMediaModeInfo; 411e1c44949Sopenharmony_ci callMediaModeInfo.callId = static_cast<int32_t>(size); 412e1c44949Sopenharmony_ci callMediaModeInfo.isRequestInfo = static_cast<bool>(size % BOOL_NUM); 413e1c44949Sopenharmony_ci callMediaModeInfo.result = static_cast<VideoRequestResultType>(size % VIDEO_REQUEST_RESULT_TYPE_NUM); 414e1c44949Sopenharmony_ci callMediaModeInfo.callMode = static_cast<ImsCallMode>(size % IMS_CALL_MODE_NUM); 415e1c44949Sopenharmony_ci callObjectPtr->ReportImsCallModeInfo(callMediaModeInfo); 416e1c44949Sopenharmony_ci callObjectPtr->ControlCamera(msg, callingUid, callingPid); 417e1c44949Sopenharmony_ci callObjectPtr->SetPausePicture(msg); 418e1c44949Sopenharmony_ci callObjectPtr->SetDeviceDirection(rotation); 419e1c44949Sopenharmony_ci callObjectPtr->CancelCallUpgrade(); 420e1c44949Sopenharmony_ci callObjectPtr->RequestCameraCapabilities(); 421e1c44949Sopenharmony_ci} 422e1c44949Sopenharmony_ci 423e1c44949Sopenharmony_civoid OttVideoCallWindowFunc(const uint8_t *data, size_t size) 424e1c44949Sopenharmony_ci{ 425e1c44949Sopenharmony_ci if (!IsServiceInited()) { 426e1c44949Sopenharmony_ci return; 427e1c44949Sopenharmony_ci } 428e1c44949Sopenharmony_ci DialParaInfo paraInfo; 429e1c44949Sopenharmony_ci paraInfo.dialType = static_cast<DialType>(size % DIAL_TYPE); 430e1c44949Sopenharmony_ci paraInfo.callType = static_cast<CallType>(size % CALL_TYPE_NUM); 431e1c44949Sopenharmony_ci paraInfo.videoState = static_cast<VideoStateType>(size % VIDIO_TYPE_NUM); 432e1c44949Sopenharmony_ci paraInfo.callState = static_cast<TelCallState>(size % TEL_CALL_STATE_NUM); 433e1c44949Sopenharmony_ci sptr<OTTCall> callObjectPtr = std::make_unique<OTTCall>(paraInfo).release(); 434e1c44949Sopenharmony_ci std::string msg(reinterpret_cast<const char *>(data), size); 435e1c44949Sopenharmony_ci int len = static_cast<int>(msg.length()); 436e1c44949Sopenharmony_ci std::string subSurfaceId = msg; 437e1c44949Sopenharmony_ci if (len >= 1) { 438e1c44949Sopenharmony_ci subSurfaceId = msg.substr(0, 1); 439e1c44949Sopenharmony_ci } 440e1c44949Sopenharmony_ci if (subSurfaceId.empty() || subSurfaceId[0] < '0' || subSurfaceId[0] > '9') { 441e1c44949Sopenharmony_ci subSurfaceId = ""; 442e1c44949Sopenharmony_ci callObjectPtr->SetPreviewWindow(subSurfaceId, nullptr); 443e1c44949Sopenharmony_ci callObjectPtr->SetDisplayWindow(subSurfaceId, nullptr); 444e1c44949Sopenharmony_ci } else { 445e1c44949Sopenharmony_ci uint64_t tmpSurfaceId = std::stoull(subSurfaceId); 446e1c44949Sopenharmony_ci auto surface = SurfaceUtils::GetInstance()->GetSurface(tmpSurfaceId); 447e1c44949Sopenharmony_ci callObjectPtr->SetPreviewWindow(subSurfaceId, surface); 448e1c44949Sopenharmony_ci callObjectPtr->SetDisplayWindow(subSurfaceId, surface); 449e1c44949Sopenharmony_ci } 450e1c44949Sopenharmony_ci} 451e1c44949Sopenharmony_ci 452e1c44949Sopenharmony_civoid SatelliteCallFunc(const uint8_t *data, size_t size) 453e1c44949Sopenharmony_ci{ 454e1c44949Sopenharmony_ci if (!IsServiceInited()) { 455e1c44949Sopenharmony_ci return; 456e1c44949Sopenharmony_ci } 457e1c44949Sopenharmony_ci 458e1c44949Sopenharmony_ci DialParaInfo paraInfo; 459e1c44949Sopenharmony_ci paraInfo.dialType = static_cast<DialType>(size % DIAL_TYPE); 460e1c44949Sopenharmony_ci paraInfo.callType = static_cast<CallType>(size % CALL_TYPE_NUM); 461e1c44949Sopenharmony_ci paraInfo.videoState = static_cast<VideoStateType>(size % VIDIO_TYPE_NUM); 462e1c44949Sopenharmony_ci paraInfo.callState = static_cast<TelCallState>(size % TEL_CALL_STATE_NUM); 463e1c44949Sopenharmony_ci sptr<SatelliteCall> callObjectPtr = std::make_unique<SatelliteCall>(paraInfo).release(); 464e1c44949Sopenharmony_ci int32_t videoState = static_cast<int32_t>(size % VIDIO_TYPE_NUM); 465e1c44949Sopenharmony_ci CallAttributeInfo info; 466e1c44949Sopenharmony_ci 467e1c44949Sopenharmony_ci callObjectPtr->DialingProcess(); 468e1c44949Sopenharmony_ci callObjectPtr->AnswerCall(videoState); 469e1c44949Sopenharmony_ci callObjectPtr->RejectCall(); 470e1c44949Sopenharmony_ci callObjectPtr->HangUpCall(); 471e1c44949Sopenharmony_ci callObjectPtr->GetCallAttributeInfo(info); 472e1c44949Sopenharmony_ci} 473e1c44949Sopenharmony_ci 474e1c44949Sopenharmony_civoid DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) 475e1c44949Sopenharmony_ci{ 476e1c44949Sopenharmony_ci if (data == nullptr || size == 0) { 477e1c44949Sopenharmony_ci return; 478e1c44949Sopenharmony_ci } 479e1c44949Sopenharmony_ci 480e1c44949Sopenharmony_ci CSCallFunc(data, size); 481e1c44949Sopenharmony_ci DialingProcess(data, size); 482e1c44949Sopenharmony_ci GetCallerInfo(data, size); 483e1c44949Sopenharmony_ci IMSCallFunc(data, size); 484e1c44949Sopenharmony_ci IMSVideoCallFunc(data, size); 485e1c44949Sopenharmony_ci IMSVideoCallWindowFunc(data, size); 486e1c44949Sopenharmony_ci OttCallFunc(data, size); 487e1c44949Sopenharmony_ci VoIPCallFunc(data, size); 488e1c44949Sopenharmony_ci OttVideoCallFunc(data, size); 489e1c44949Sopenharmony_ci OttVideoCallWindowFunc(data, size); 490e1c44949Sopenharmony_ci SatelliteCallFunc(data, size); 491e1c44949Sopenharmony_ci} 492e1c44949Sopenharmony_ci} // namespace OHOS 493e1c44949Sopenharmony_ci 494e1c44949Sopenharmony_ci/* Fuzzer entry point */ 495e1c44949Sopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) 496e1c44949Sopenharmony_ci{ 497e1c44949Sopenharmony_ci OHOS::AddCallTokenFuzzer token; 498e1c44949Sopenharmony_ci /* Run your code on data */ 499e1c44949Sopenharmony_ci OHOS::DoSomethingInterestingWithMyAPI(data, size); 500e1c44949Sopenharmony_ci return 0; 501e1c44949Sopenharmony_ci} 502