1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at: 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 #pragma once 18 #include <SurroundViewService.h> 19 #include <android/hidl/memory/1.0/IMemory.h> 20 #include <fuzzer/FuzzedDataProvider.h> 21 22 namespace android::hardware::automotive::sv::V1_0::implementation::fuzzer { 23 24 using ::android::sp; 25 using ::android::hidl::memory::V1_0::IMemory; 26 27 constexpr size_t kMinOverlays = 2; 28 29 class SurroundViewFuzzer { 30 public: SurroundViewFuzzer(const uint8_t * data,size_t size)31 SurroundViewFuzzer(const uint8_t* data, size_t size) : mFuzzedDataProvider(data, size) { 32 mSurroundViewService = sp<SurroundViewService>::make(); 33 } 34 ~SurroundViewFuzzer() = default; 35 void process(); 36 37 private: 38 void invoke2dSessionAPI(); 39 void invoke3dSessionAPI(); 40 std::pair<hidl_memory, sp<IMemory>> getMappedSharedMemory(int32_t bytesSize); 41 void initSampleOverlaysData(); 42 void setIndexOfOverlaysMemory(const std::vector<OverlayMemoryDesc>& overlaysMemDesc, 43 sp<IMemory> pIMemory, int32_t indexPosition, uint16_t indexValue); 44 OverlaysData mOverlaysdata = {}; 45 size_t mNumOverlays = kMinOverlays; 46 sp<IMemory> mMemory = nullptr; 47 FuzzedDataProvider mFuzzedDataProvider; 48 sp<SurroundViewService> mSurroundViewService = nullptr; 49 bool mIs2dStreamStarted = false; 50 bool mIs3dStreamStarted = false; 51 }; 52 } // namespace android::hardware::automotive::sv::V1_0::implementation::fuzzer 53