1 /*
2  * Copyright 2020 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 #define LOG_TAG "VtsHalEvsTest"
18 #define UNUSED(x) (void)(x)
19 
20 const static char kEnumeratorName[] = "EvsEnumeratorHw";
21 
22 #include <android/hardware/automotive/evs/1.1/IEvsEnumerator.h>
23 #include <fuzzer/FuzzedDataProvider.h>
24 #include <hidl/HidlTransportSupport.h>
25 #include <utils/StrongPointer.h>
26 
27 using namespace ::android::hardware::automotive::evs::V1_1;
28 
29 using ::android::sp;
30 using ::android::hardware::hidl_death_recipient;
31 using ::android::hardware::hidl_vec;
32 
33 static sp<IEvsEnumerator> pEnumerator;
34 static std::vector<CameraDesc> cameraInfo;
35 
36 class EvsDeathRecipient : public hidl_death_recipient {
37   public:
serviceDied(uint64_t,const android::wp<::android::hidl::base::V1_0::IBase> &)38     void serviceDied(uint64_t /*cookie*/,
39                      const android::wp<::android::hidl::base::V1_0::IBase>& /*who*/) override {
40         abort();
41     }
42 };
43 
loadCameraList()44 void loadCameraList() {
45     // SetUp() must run first!
46     assert(pEnumerator != nullptr);
47 
48     // Get the camera list
49     pEnumerator->getCameraList_1_1([](hidl_vec<CameraDesc> cameraList) {
50         ALOGI("Camera list callback received %zu cameras", cameraList.size());
51         cameraInfo.reserve(cameraList.size());
52         for (auto&& cam : cameraList) {
53             ALOGI("Found camera %s", cam.v1.cameraId.c_str());
54             cameraInfo.push_back(cam);
55         }
56     });
57 }
58