blob: 2780bd4cd967df2ca989d45cb9f4187996d4cf6a [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
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
Marco Nelissen5c6ec522014-11-17 15:24:21 -080017#define LOG_TAG "IInterface"
18#include <utils/Log.h>
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070019#include <binder/IInterface.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080020
21namespace android {
22
23// ---------------------------------------------------------------------------
24
Mathias Agopian83c04462009-05-22 19:00:22 -070025IInterface::IInterface()
26 : RefBase() {
27}
28
29IInterface::~IInterface() {
30}
31
Marco Nelissen2ea926b2014-11-14 08:01:01 -080032// static
33sp<IBinder> IInterface::asBinder(const IInterface* iface)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080034{
Yi Kongfdd8da92018-06-07 17:52:27 -070035 if (iface == nullptr) return nullptr;
Steven Moreland1a3a8ef2021-04-02 02:52:46 +000036 return sp<IBinder>::fromExisting(const_cast<IInterface*>(iface)->onAsBinder());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080037}
38
Marco Nelissen2ea926b2014-11-14 08:01:01 -080039// static
40sp<IBinder> IInterface::asBinder(const sp<IInterface>& iface)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080041{
Yi Kongfdd8da92018-06-07 17:52:27 -070042 if (iface == nullptr) return nullptr;
Steven Moreland1a3a8ef2021-04-02 02:52:46 +000043 return sp<IBinder>::fromExisting(iface->onAsBinder());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080044}
45
Marco Nelissen5c6ec522014-11-17 15:24:21 -080046
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080047// ---------------------------------------------------------------------------
48
Steven Moreland61ff8492019-09-26 16:05:45 -070049} // namespace android