blob: ca8ad9382f4d66e149ce81e9b47d5b80a8b458a3 [file] [log] [blame]
Mathias Agopian7922fa22009-05-18 15:08:03 -07001/*
2 * Copyright (C) 2005 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
Steven Morelandc4dd2102017-02-23 13:57:21 -080017#define LOG_TAG "hw-IInterface"
Marco Nelissen38b9c522014-11-17 15:24:21 -080018#include <utils/Log.h>
Martijn Coenen4080edc2016-05-04 14:17:02 +020019#include <hwbinder/IInterface.h>
Mathias Agopian7922fa22009-05-18 15:08:03 -070020
21namespace android {
Martijn Coenenf75a23d2016-08-01 11:55:17 +020022namespace hardware {
Mathias Agopian7922fa22009-05-18 15:08:03 -070023
24// ---------------------------------------------------------------------------
25
Mathias Agopiana6286c32009-05-22 19:00:22 -070026IInterface::IInterface()
27 : RefBase() {
28}
29
30IInterface::~IInterface() {
31}
32
Marco Nelissen461a6722014-11-14 08:01:01 -080033// static
34sp<IBinder> IInterface::asBinder(const IInterface* iface)
Mathias Agopian7922fa22009-05-18 15:08:03 -070035{
Yi Kong55d41072018-07-23 14:55:39 -070036 if (iface == nullptr) return nullptr;
Marco Nelissen461a6722014-11-14 08:01:01 -080037 return const_cast<IInterface*>(iface)->onAsBinder();
Mathias Agopian7922fa22009-05-18 15:08:03 -070038}
39
Marco Nelissen461a6722014-11-14 08:01:01 -080040// static
41sp<IBinder> IInterface::asBinder(const sp<IInterface>& iface)
Mathias Agopian7922fa22009-05-18 15:08:03 -070042{
Yi Kong55d41072018-07-23 14:55:39 -070043 if (iface == nullptr) return nullptr;
Marco Nelissen461a6722014-11-14 08:01:01 -080044 return iface->onAsBinder();
Mathias Agopian7922fa22009-05-18 15:08:03 -070045}
46
Marco Nelissen38b9c522014-11-17 15:24:21 -080047
Mathias Agopian7922fa22009-05-18 15:08:03 -070048// ---------------------------------------------------------------------------
49
Steven Moreland7173a4c2019-09-26 15:55:02 -070050} // namespace hardware
51} // namespace android