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 "answerrequest_fuzzer.h"
17d95e75fdSopenharmony_ci
18d95e75fdSopenharmony_ci#include <cstddef>
19d95e75fdSopenharmony_ci#include <cstdint>
20d95e75fdSopenharmony_ci
21d95e75fdSopenharmony_ci#include "addcellularcalltoken_fuzzer.h"
22d95e75fdSopenharmony_ci#include "cellular_call_connection_ims.h"
23d95e75fdSopenharmony_ci#include "system_ability_definition.h"
24d95e75fdSopenharmony_ci
25d95e75fdSopenharmony_ciusing namespace OHOS::Telephony;
26d95e75fdSopenharmony_cinamespace OHOS {
27d95e75fdSopenharmony_ciconstexpr int32_t SLOT_NUM = 2;
28d95e75fdSopenharmony_ciconstexpr int32_t VEDIO_STATE_NUM = 2;
29d95e75fdSopenharmony_ci
30d95e75fdSopenharmony_civoid DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size)
31d95e75fdSopenharmony_ci{
32d95e75fdSopenharmony_ci    if (data == nullptr || size == 0) {
33d95e75fdSopenharmony_ci        return;
34d95e75fdSopenharmony_ci    }
35d95e75fdSopenharmony_ci
36d95e75fdSopenharmony_ci    auto cellularCallConnectionIMS = std::shared_ptr<CellularCallConnectionIMS>();
37d95e75fdSopenharmony_ci    std::string phoneNum(reinterpret_cast<const char *>(data), size);
38d95e75fdSopenharmony_ci    std::string msg(reinterpret_cast<const char *>(data), size);
39d95e75fdSopenharmony_ci    int32_t slotId = static_cast<int32_t>(size % SLOT_NUM);
40d95e75fdSopenharmony_ci    int32_t videoState = static_cast<int32_t>(size % VEDIO_STATE_NUM);
41d95e75fdSopenharmony_ci    int32_t index = static_cast<int32_t>(size);
42d95e75fdSopenharmony_ci    std::vector<std::string> numberList;
43d95e75fdSopenharmony_ci    numberList.push_back(phoneNum);
44d95e75fdSopenharmony_ci    cellularCallConnectionIMS->HangUpRequest(slotId, phoneNum, index);
45d95e75fdSopenharmony_ci    cellularCallConnectionIMS->AnswerRequest(slotId, phoneNum, videoState, index);
46d95e75fdSopenharmony_ci    cellularCallConnectionIMS->RejectRequest(slotId, phoneNum, index);
47d95e75fdSopenharmony_ci    cellularCallConnectionIMS->HoldCallRequest(slotId);
48d95e75fdSopenharmony_ci    cellularCallConnectionIMS->UnHoldCallRequest(slotId);
49d95e75fdSopenharmony_ci    cellularCallConnectionIMS->InviteToConferenceRequest(slotId, numberList);
50d95e75fdSopenharmony_ci    cellularCallConnectionIMS->KickOutFromConferenceRequest(slotId, index);
51d95e75fdSopenharmony_ci    cellularCallConnectionIMS->StartRttRequest(slotId, msg);
52d95e75fdSopenharmony_ci    cellularCallConnectionIMS->StopRttRequest(slotId);
53d95e75fdSopenharmony_ci    return;
54d95e75fdSopenharmony_ci}
55d95e75fdSopenharmony_ci} // namespace OHOS
56d95e75fdSopenharmony_ci
57d95e75fdSopenharmony_ci/* Fuzzer entry point */
58d95e75fdSopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
59d95e75fdSopenharmony_ci{
60d95e75fdSopenharmony_ci    OHOS::AddCellularCallTokenFuzzer token;
61d95e75fdSopenharmony_ci    /* Run your code on data */
62d95e75fdSopenharmony_ci    OHOS::DoSomethingInterestingWithMyAPI(data, size);
63d95e75fdSopenharmony_ci    return 0;
64d95e75fdSopenharmony_ci}
65