The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 Nelissen | 5c6ec52 | 2014-11-17 15:24:21 -0800 | [diff] [blame] | 17 | #define LOG_TAG "IInterface" |
| 18 | #include <utils/Log.h> |
Mathias Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 19 | #include <binder/IInterface.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | |
| 21 | namespace android { |
| 22 | |
| 23 | // --------------------------------------------------------------------------- |
| 24 | |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 25 | IInterface::IInterface() |
| 26 | : RefBase() { |
| 27 | } |
| 28 | |
| 29 | IInterface::~IInterface() { |
| 30 | } |
| 31 | |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 32 | // static |
| 33 | sp<IBinder> IInterface::asBinder(const IInterface* iface) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | { |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 35 | if (iface == NULL) return NULL; |
| 36 | return const_cast<IInterface*>(iface)->onAsBinder(); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | } |
| 38 | |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 39 | // static |
| 40 | sp<IBinder> IInterface::asBinder(const sp<IInterface>& iface) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | { |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 42 | if (iface == NULL) return NULL; |
| 43 | return iface->onAsBinder(); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | } |
| 45 | |
Marco Nelissen | 5c6ec52 | 2014-11-17 15:24:21 -0800 | [diff] [blame] | 46 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | // --------------------------------------------------------------------------- |
| 48 | |
| 49 | }; // namespace android |
Marco Nelissen | 5c6ec52 | 2014-11-17 15:24:21 -0800 | [diff] [blame] | 50 | |
| 51 | extern "C" { |
| 52 | |
| 53 | void _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 | |
| 60 | void _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" |