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 #ifndef CPP_EVS_MANAGER_AIDL_WRAPPERS_INCLUDE_HIDLENUMERATOR_H
18 #define CPP_EVS_MANAGER_AIDL_WRAPPERS_INCLUDE_HIDLENUMERATOR_H
19 
20 #include <aidl/android/hardware/automotive/evs/BnEvsEnumerator.h>
21 #include <aidl/android/hardware/automotive/evs/IEvsCamera.h>
22 #include <aidl/android/hardware/automotive/evs/IEvsDisplay.h>
23 #include <aidl/android/hardware/automotive/evs/IEvsEnumeratorStatusCallback.h>
24 #include <android/hardware/automotive/evs/1.1/IEvsDisplay.h>
25 #include <android/hardware/automotive/evs/1.1/IEvsEnumerator.h>
26 #include <system/camera_metadata.h>
27 
28 namespace aidl::android::automotive::evs::implementation {
29 
30 namespace aidlevs = ::aidl::android::hardware::automotive::evs;
31 namespace hidlevs = ::android::hardware::automotive::evs;
32 
33 class HidlEnumerator final : public hidlevs::V1_1::IEvsEnumerator {
34 public:
35     // Methods from ::android::hardware::automotive::evs::V1_0::IEvsEnumerator follow.
36     ::android::hardware::Return<void> getCameraList(getCameraList_cb _hidl_cb) override;
37     ::android::hardware::Return<::android::sp<hidlevs::V1_0::IEvsCamera>> openCamera(
38             const ::android::hardware::hidl_string& cameraId) override;
39     ::android::hardware::Return<void> closeCamera(
40             const ::android::sp<hidlevs::V1_0::IEvsCamera>& virtualCamera) override;
41     ::android::hardware::Return<::android::sp<hidlevs::V1_0::IEvsDisplay>> openDisplay() override;
42     ::android::hardware::Return<void> closeDisplay(
43             const ::android::sp<hidlevs::V1_0::IEvsDisplay>& display) override;
44     ::android::hardware::Return<hidlevs::V1_0::DisplayState> getDisplayState() override;
45 
46     // Methods from hardware::automotive::evs::V1_1::IEvsEnumerator follow.
47     ::android::hardware::Return<void> getCameraList_1_1(getCameraList_1_1_cb _hidl_cb) override;
48     ::android::hardware::Return<::android::sp<hidlevs::V1_1::IEvsCamera>> openCamera_1_1(
49             const ::android::hardware::hidl_string& cameraId,
50             const ::android::hardware::camera::device::V3_2::Stream& streamCfg) override;
isHardware()51     ::android::hardware::Return<bool> isHardware() override { return false; }
52     ::android::hardware::Return<void> getDisplayIdList(getDisplayIdList_cb _list_cb) override;
53     ::android::hardware::Return<::android::sp<hidlevs::V1_1::IEvsDisplay>> openDisplay_1_1(
54             uint8_t id) override;
55     ::android::hardware::Return<void> getUltrasonicsArrayList(
56             getUltrasonicsArrayList_cb _hidl_cb) override;
57     ::android::hardware::Return<::android::sp<hidlevs::V1_1::IEvsUltrasonicsArray>>
58     openUltrasonicsArray(const ::android::hardware::hidl_string& ultrasonicsArrayId) override;
59     ::android::hardware::Return<void> closeUltrasonicsArray(
60             const ::android::sp<hidlevs::V1_1::IEvsUltrasonicsArray>& evsUltrasonicsArray) override;
61 
HidlEnumerator(const std::shared_ptr<aidlevs::IEvsEnumerator> & service)62     explicit HidlEnumerator(const std::shared_ptr<aidlevs::IEvsEnumerator>& service) :
63           mEnumerator(service) {}
64     virtual ~HidlEnumerator();
65 
66     // Implementation details
67     bool init(const char* hardwareServiceName);
68 
69 private:
70     std::shared_ptr<aidlevs::IEvsEnumerator> mEnumerator;
71     std::weak_ptr<aidlevs::IEvsDisplay> mAidlDisplay;
72     std::vector<uint8_t> mAidlDisplayIds;
73     ::android::wp<hidlevs::V1_0::IEvsDisplay> mHidlDisplay;
74 };
75 
76 }  // namespace aidl::android::automotive::evs::implementation
77 
78 #endif  // CPP_EVS_MANAGER_AIDL_WRAPPERS_INCLUDE_HIDLENUMERATOR_H
79