blob: 43724f9cbca471648960c0e21c054551a4a6219e [file] [log] [blame]
Yifan Hong6bf733e2016-12-07 14:42:02 -08001/*
2 * Copyright (C) 2016 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 <hidl/HidlPassthroughSupport.h>
17
18#include <hidl/HidlSupport.h>
19#include <hidl/Static.h>
20#include <hidl/HidlTransportUtils.h>
21
22namespace android {
23namespace hardware {
24
25sp<::android::hidl::base::V1_0::IBase> wrapPassthrough(
26 sp<::android::hidl::base::V1_0::IBase> iface) {
27 if (iface.get() == nullptr || iface->isRemote()) {
28 // doesn't know how to handle it.
29 return iface;
30 }
Yifan Hong2ac326f2017-02-22 18:13:06 -080031 std::string myDescriptor = details::getDescriptor(iface.get());
Yifan Hong6bf733e2016-12-07 14:42:02 -080032 if (myDescriptor.empty()) {
Yifan Hong2ac326f2017-02-22 18:13:06 -080033 // interfaceDescriptor fails
Yifan Hong6bf733e2016-12-07 14:42:02 -080034 return nullptr;
35 }
Yifan Hong84888d32017-02-06 15:32:41 -080036 auto func = gBsConstructorMap.get(myDescriptor, nullptr);
37 if (!func) {
Yifan Hong6bf733e2016-12-07 14:42:02 -080038 return nullptr;
39 }
Yifan Hong84888d32017-02-06 15:32:41 -080040 return func(reinterpret_cast<void *>(iface.get()));
Yifan Hong6bf733e2016-12-07 14:42:02 -080041}
42
43
44} // namespace hardware
45} // namespace android