• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef CPP_EVS_MANAGER_1_1_ENUMERATORPROXY_H_
17 #define CPP_EVS_MANAGER_1_1_ENUMERATORPROXY_H_
18 
19 #include "Enumerator.h"
20 #include "IEnumeratorManager.h"
21 
22 #include <android/hardware/automotive/evs/1.1/IEvsEnumerator.h>
23 #include <android/hardware/automotive/evs/1.1/IEvsUltrasonicsArray.h>
24 #include <android/hardware/camera/device/3.2/ICameraDevice.h>
25 
26 #include <memory>
27 
28 namespace android::automotive::evs::V1_1::implementation {
29 
30 // Flyweight proxy that is platform aware (i.e. handles Android symbols) and
31 // converts them to host/target (i.e. x86 non Android) friendly symbols.
32 class EnumeratorProxy : public hardware::automotive::evs::V1_1::IEvsEnumerator {
33 public:
34     // TODO(b/206829268): This constructor will eventually be deleted and
35     // replaced with the above. Enumerator is being migrated from implementing
36     // IEVSEnumerator to IEnumeratorManager.
EnumeratorProxy(std::unique_ptr<Enumerator> enumeratorManager)37     explicit EnumeratorProxy(std::unique_ptr<Enumerator> enumeratorManager) :
38           mEnumeratorManager(std::move(enumeratorManager)) {}
39 
40     // Methods from hardware::automotive::evs::V1_0::IEvsEnumerator follow.
getCameraList(getCameraList_cb getCameraCallback)41     hardware::Return<void> getCameraList(getCameraList_cb getCameraCallback) override {
42         return mEnumeratorManager->getCameraList(std::move(getCameraCallback));
43     }
openCamera(const hardware::hidl_string & cameraId)44     hardware::Return<sp<hardware::automotive::evs::V1_0::IEvsCamera>> openCamera(
45             const hardware::hidl_string& cameraId) override {
46         return mEnumeratorManager->openCamera(cameraId);
47     }
closeCamera(const::android::sp<hardware::automotive::evs::V1_0::IEvsCamera> & virtualCamera)48     hardware::Return<void> closeCamera(
49             const ::android::sp<hardware::automotive::evs::V1_0::IEvsCamera>& virtualCamera)
50             override {
51         return mEnumeratorManager->closeCamera(std::move(virtualCamera));
52     }
openDisplay()53     hardware::Return<sp<hardware::automotive::evs::V1_0::IEvsDisplay>> openDisplay() override {
54         return mEnumeratorManager->openDisplay();
55     }
56 
closeDisplay(const::android::sp<hardware::automotive::evs::V1_0::IEvsDisplay> & display)57     hardware::Return<void> closeDisplay(
58             const ::android::sp<hardware::automotive::evs::V1_0::IEvsDisplay>& display) override {
59         return mEnumeratorManager->closeDisplay(display);
60     }
getDisplayState()61     hardware::Return<hardware::automotive::evs::V1_0::DisplayState> getDisplayState() override {
62         return mEnumeratorManager->getDisplayState();
63     }
64 
65     // Methods from hardware::automotive::evs::V1_1::IEvsEnumerator follow.
getCameraList_1_1(getCameraList_1_1_cb _hidl_cb)66     hardware::Return<void> getCameraList_1_1(getCameraList_1_1_cb _hidl_cb) override {
67         return mEnumeratorManager->getCameraList_1_1(_hidl_cb);
68     };
openCamera_1_1(const hardware::hidl_string & cameraId,const hardware::camera::device::V3_2::Stream & streamCfg)69     hardware::Return<sp<hardware::automotive::evs::V1_1::IEvsCamera>> openCamera_1_1(
70             const hardware::hidl_string& cameraId,
71             const hardware::camera::device::V3_2::Stream& streamCfg) override {
72         return mEnumeratorManager->openCamera_1_1(cameraId, streamCfg);
73     }
isHardware()74     hardware::Return<bool> isHardware() override { return mEnumeratorManager->isHardware(); }
getDisplayIdList(getDisplayIdList_cb _list_cb)75     hardware::Return<void> getDisplayIdList(getDisplayIdList_cb _list_cb) override {
76         return mEnumeratorManager->getDisplayIdList(_list_cb);
77     }
openDisplay_1_1(uint8_t id)78     hardware::Return<sp<hardware::automotive::evs::V1_1::IEvsDisplay>> openDisplay_1_1(
79             uint8_t id) override {
80         return mEnumeratorManager->openDisplay_1_1(id);
81     }
getUltrasonicsArrayList(getUltrasonicsArrayList_cb _hidl_cb)82     hardware::Return<void> getUltrasonicsArrayList(getUltrasonicsArrayList_cb _hidl_cb) override {
83         return mEnumeratorManager->getUltrasonicsArrayList(_hidl_cb);
84     }
85     hardware::Return<sp<hardware::automotive::evs::V1_1::IEvsUltrasonicsArray>>
openUltrasonicsArray(const hardware::hidl_string & ultrasonicsArrayId)86     openUltrasonicsArray(const hardware::hidl_string& ultrasonicsArrayId) override {
87         return mEnumeratorManager->openUltrasonicsArray(ultrasonicsArrayId);
88     }
closeUltrasonicsArray(const::android::sp<hardware::automotive::evs::V1_1::IEvsUltrasonicsArray> & evsUltrasonicsArray)89     hardware::Return<void> closeUltrasonicsArray(
90             const ::android::sp<hardware::automotive::evs::V1_1::IEvsUltrasonicsArray>&
91                     evsUltrasonicsArray) override {
92         return mEnumeratorManager->closeUltrasonicsArray(evsUltrasonicsArray);
93     }
94 
95     // Methods from ::android.hidl.base::V1_0::IBase follow.
debug(const hardware::hidl_handle & fd,const hardware::hidl_vec<hardware::hidl_string> & options)96     hardware::Return<void> debug(
97             const hardware::hidl_handle& fd,
98             const hardware::hidl_vec<hardware::hidl_string>& options) override {
99         return mEnumeratorManager->debug(fd, options);
100     }
101 
102 private:
103     // TODO(b/206829268): This will eventually be restored (see constructor).
104     // const std::unique_ptr<IEnumeratorManager> mEnumeratorManager;
105 
106     const std::unique_ptr<Enumerator> mEnumeratorManager;
107 };
108 
109 }  // namespace android::automotive::evs::V1_1::implementation
110 
111 #endif  // CPP_EVS_MANAGER_1_1_ENUMERATORPROXY_H_
112