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 #include "EnumeratorProxy.h"
17
18 #include <android/hardware/automotive/evs/1.1/IEvsEnumerator.h>
19
20 #include <string>
21 #include <vector>
22
23 namespace {
24
25 using ::android::sp;
26 using ::android::hardware::hidl_string;
27 using ::android::hardware::hidl_vec;
28 using ::android::hardware::Return;
29 using ::android::hardware::Void;
30 using CameraDesc_1_0 = ::android::hardware::automotive::evs::V1_0::CameraDesc;
31 using CameraDesc_1_1 = ::android::hardware::automotive::evs::V1_1::CameraDesc;
32
33 } // namespace
34
35 namespace android::automotive::evs::V1_1::implementation {
36
37 // TODO(b/206829268): As EnumeratorProxy is introduced piece meal the proxied
38 // methods will be added here (this is being done in order to introduce tests).
39 #ifdef TEMPORARILY_DISABLE_SEE_B_206829268
getCameraList(getCameraList_cb hidlCallback)40 hardware::Return<void> EnumeratorProxy::getCameraList(getCameraList_cb hidlCallback) {
41 hidlCallback(stlToHidlVec(mEnumeratorManager->getCameraList()));
42 return Void();
43 }
44
openCamera(const hardware::hidl_string & cameraId)45 hardware::Return<sp<hardware::automotive::evs::V1_0::IEvsCamera>> EnumeratorProxy::openCamera(
46 const hardware::hidl_string& cameraId) {
47 return sp<hardware::automotive::evs::V1_0::IEvsCamera>(
48 mEnumeratorManager->openCamera(hidlToStlString(cameraId)).release());
49 }
50
closeCamera(const sp<hardware::automotive::evs::V1_0::IEvsCamera> & camera)51 hardware::Return<void> EnumeratorProxy::closeCamera(
52 const sp<hardware::automotive::evs::V1_0::IEvsCamera>& camera) {
53 mEnumeratorManager->closeCamera(*camera);
54 return Void();
55 }
56
openDisplay()57 hardware::Return<sp<hardware::automotive::evs::V1_0::IEvsDisplay>> EnumeratorProxy::openDisplay() {
58 return sp<hardware::automotive::evs::V1_0::IEvsDisplay>(
59 mEnumeratorManager->openDisplay().release());
60 }
61
closeDisplay(const sp<hardware::automotive::evs::V1_0::IEvsDisplay> & display)62 hardware::Return<void> EnumeratorProxy::closeDisplay(
63 const sp<hardware::automotive::evs::V1_0::IEvsDisplay>& display) {
64 mEnumeratorManager->closeDisplay(display.get());
65
66 return Void();
67 }
68
getDisplayState()69 hardware::Return<hardware::automotive::evs::V1_0::DisplayState> EnumeratorProxy::getDisplayState() {
70 return mEnumeratorManager->getDisplayState();
71 }
72
getCameraList_1_1(::android::hardware::automotive::evs::V1_1::IEvsEnumerator::getCameraList_1_1_cb hidlCallback)73 hardware::Return<void> EnumeratorProxy::getCameraList_1_1(
74 ::android::hardware::automotive::evs::V1_1::IEvsEnumerator::getCameraList_1_1_cb
75 hidlCallback) {
76 hidlCallback(stlToHidlVec(mEnumeratorManager->getCameraList_1_1()));
77 return Void();
78 }
79
openCamera_1_1(const hardware::hidl_string & cameraId,const hardware::camera::device::V3_2::Stream & streamCfg)80 hardware::Return<sp<hardware::automotive::evs::V1_1::IEvsCamera>> EnumeratorProxy::openCamera_1_1(
81 const hardware::hidl_string& cameraId,
82 const hardware::camera::device::V3_2::Stream& streamCfg) {
83 return sp<hardware::automotive::evs::V1_1::IEvsCamera>{
84 mEnumeratorManager->openCamera_1_1(hidlToStlString(cameraId), streamCfg).release()};
85 }
86
isHardware()87 hardware::Return<bool> EnumeratorProxy::isHardware() {
88 return mEnumeratorManager->isHardware();
89 }
90
getDisplayIdList(hardware::automotive::evs::V1_1::IEvsEnumerator::getDisplayIdList_cb list_callback)91 hardware::Return<void> EnumeratorProxy::getDisplayIdList(
92 hardware::automotive::evs::V1_1::IEvsEnumerator::getDisplayIdList_cb list_callback) {
93 list_callback(stlToHidlVec(mEnumeratorManager->getDisplayIdList()));
94
95 return Void();
96 }
97
openDisplay_1_1(uint8_t id)98 hardware::Return<sp<hardware::automotive::evs::V1_1::IEvsDisplay>> EnumeratorProxy::openDisplay_1_1(
99 uint8_t id) {
100 return sp<hardware::automotive::evs::V1_1::IEvsDisplay>{
101 mEnumeratorManager->openDisplay_1_1(id).release()};
102 }
103
getUltrasonicsArrayList(::android::hardware::automotive::evs::V1_1::IEvsEnumerator::getUltrasonicsArrayList_cb list_callback)104 hardware::Return<void> EnumeratorProxy::getUltrasonicsArrayList(
105 ::android::hardware::automotive::evs::V1_1::IEvsEnumerator::getUltrasonicsArrayList_cb
106 list_callback) {
107 list_callback(stlToHidlVec(mEnumeratorManager->getUltrasonicsArrayList()));
108
109 return Void();
110 }
111
112 hardware::Return<sp<::android::hardware::automotive::evs::V1_1::IEvsUltrasonicsArray>>
openUltrasonicsArray(const hardware::hidl_string & ultrasonicsArrayId)113 EnumeratorProxy::openUltrasonicsArray(const hardware::hidl_string& ultrasonicsArrayId) {
114 return sp<::android::hardware::automotive::evs::V1_1::IEvsUltrasonicsArray>(
115 mEnumeratorManager->openUltrasonicsArray(hidlToStlString(ultrasonicsArrayId))
116 .release());
117 }
118
closeUltrasonicsArray(const sp<::android::hardware::automotive::evs::V1_1::IEvsUltrasonicsArray> & evsUltrasonicsArray)119 hardware::Return<void> EnumeratorProxy::closeUltrasonicsArray(
120 const sp<::android::hardware::automotive::evs::V1_1::IEvsUltrasonicsArray>&
121 evsUltrasonicsArray) {
122 mEnumeratorManager->closeUltrasonicsArray(*evsUltrasonicsArray);
123
124 return Void();
125 }
126
debug(const::android::hardware::hidl_handle & fileDescriptor,const hidl_vec<hardware::hidl_string> & options)127 hardware::Return<void> EnumeratorProxy::debug(
128 const ::android::hardware::hidl_handle& fileDescriptor,
129 const hidl_vec<hardware::hidl_string>& options) {
130 mEnumeratorManager->debug(fileDescriptor, hidlToStlVecOfStrings(options));
131
132 return Void();
133 }
134
135 #endif // TEMPORARILY_DISABLE_SEE_B_206829268
136
137 } // namespace android::automotive::evs::V1_1::implementation
138