blob: 9d4e2b4878269173a48b72fb57c8f749d3813179 [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 }
31 std::string myDescriptor = getDescriptor(iface.get());
32 if (myDescriptor.empty()) {
33 // interfaceChain fails
34 return nullptr;
35 }
36 auto iter = gBsConstructorMap.find(myDescriptor);
37 if (iter == gBsConstructorMap.end()) {
38 return nullptr;
39 }
40 return (iter->second)(reinterpret_cast<void *>(iface.get()));
41}
42
43
44} // namespace hardware
45} // namespace android