blob: dea26038cf3fae6887f2de62d0459cd967b44dc4 [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"
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070018#include <binder/IInterface.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080019
20namespace android {
21
22// ---------------------------------------------------------------------------
23
Mathias Agopian83c04462009-05-22 19:00:22 -070024IInterface::IInterface()
25 : RefBase() {
26}
27
28IInterface::~IInterface() {
29}
30
Marco Nelissen2ea926b2014-11-14 08:01:01 -080031// static
32sp<IBinder> IInterface::asBinder(const IInterface* iface)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080033{
Yi Kongfdd8da92018-06-07 17:52:27 -070034 if (iface == nullptr) return nullptr;
Steven Moreland1a3a8ef2021-04-02 02:52:46 +000035 return sp<IBinder>::fromExisting(const_cast<IInterface*>(iface)->onAsBinder());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080036}
37
Marco Nelissen2ea926b2014-11-14 08:01:01 -080038// static
39sp<IBinder> IInterface::asBinder(const sp<IInterface>& iface)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080040{
Yi Kongfdd8da92018-06-07 17:52:27 -070041 if (iface == nullptr) return nullptr;
Steven Moreland1a3a8ef2021-04-02 02:52:46 +000042 return sp<IBinder>::fromExisting(iface->onAsBinder());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080043}
44
Marco Nelissen5c6ec522014-11-17 15:24:21 -080045
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080046// ---------------------------------------------------------------------------
47
Steven Moreland61ff8492019-09-26 16:05:45 -070048} // namespace android