blob: 2fcd3d92fb4014c56c029b7e05f718d69b8eb646 [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
Marco Nelissen38b9c522014-11-17 15:24:21 -080017#define LOG_TAG "IInterface"
18#include <utils/Log.h>
Mathias Agopian16475702009-05-19 19:08:10 -070019#include <binder/IInterface.h>
Mathias Agopian7922fa22009-05-18 15:08:03 -070020
21namespace android {
22
23// ---------------------------------------------------------------------------
24
Mathias Agopiana6286c32009-05-22 19:00:22 -070025IInterface::IInterface()
26 : RefBase() {
27}
28
29IInterface::~IInterface() {
30}
31
Marco Nelissen461a6722014-11-14 08:01:01 -080032// static
33sp<IBinder> IInterface::asBinder(const IInterface* iface)
Mathias Agopian7922fa22009-05-18 15:08:03 -070034{
Marco Nelissen461a6722014-11-14 08:01:01 -080035 if (iface == NULL) return NULL;
36 return const_cast<IInterface*>(iface)->onAsBinder();
Mathias Agopian7922fa22009-05-18 15:08:03 -070037}
38
Marco Nelissen461a6722014-11-14 08:01:01 -080039// static
40sp<IBinder> IInterface::asBinder(const sp<IInterface>& iface)
Mathias Agopian7922fa22009-05-18 15:08:03 -070041{
Marco Nelissen461a6722014-11-14 08:01:01 -080042 if (iface == NULL) return NULL;
43 return iface->onAsBinder();
Mathias Agopian7922fa22009-05-18 15:08:03 -070044}
45
Marco Nelissen38b9c522014-11-17 15:24:21 -080046
Mathias Agopian7922fa22009-05-18 15:08:03 -070047// ---------------------------------------------------------------------------
48
49}; // namespace android
Marco Nelissen38b9c522014-11-17 15:24:21 -080050
51extern "C" {
52
53void _ZN7android10IInterface8asBinderEv(void *retval, void* self) {
54 ALOGW("deprecated asBinder call, please update your code");
55 //ALOGI("self: %p, retval: %p", self, retval);
56 android::sp<android::IBinder> *ret = new(retval) android::sp<android::IBinder>;
57 *ret = android::IInterface::asBinder((android::IInterface*)self);
58}
59
60void _ZNK7android10IInterface8asBinderEv(void *retval, void *self) {
61 ALOGW("deprecated asBinder call, please update your code");
62 //ALOGI("self: %p, retval: %p", self, retval);
63 android::sp<android::IBinder> *ret = new(retval) android::sp<android::IBinder>;
64 *ret = android::IInterface::asBinder((android::IInterface*)self);
65}
66
67} // extern "C"