The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | |
| 17 | #ifndef ANDROID_BINDER_H |
| 18 | #define ANDROID_BINDER_H |
| 19 | |
| 20 | #include <utils/IBinder.h> |
| 21 | |
| 22 | // --------------------------------------------------------------------------- |
| 23 | namespace android { |
| 24 | |
| 25 | class BBinder : public IBinder |
| 26 | { |
| 27 | public: |
| 28 | BBinder(); |
| 29 | |
| 30 | virtual String16 getInterfaceDescriptor() const; |
| 31 | virtual bool isBinderAlive() const; |
| 32 | virtual status_t pingBinder(); |
| 33 | virtual status_t dump(int fd, const Vector<String16>& args); |
| 34 | |
| 35 | virtual status_t transact( uint32_t code, |
| 36 | const Parcel& data, |
| 37 | Parcel* reply, |
| 38 | uint32_t flags = 0); |
| 39 | |
| 40 | virtual status_t linkToDeath(const sp<DeathRecipient>& recipient, |
| 41 | void* cookie = NULL, |
| 42 | uint32_t flags = 0); |
| 43 | |
| 44 | virtual status_t unlinkToDeath( const wp<DeathRecipient>& recipient, |
| 45 | void* cookie = NULL, |
| 46 | uint32_t flags = 0, |
| 47 | wp<DeathRecipient>* outRecipient = NULL); |
| 48 | |
| 49 | virtual void attachObject( const void* objectID, |
| 50 | void* object, |
| 51 | void* cleanupCookie, |
| 52 | object_cleanup_func func); |
| 53 | virtual void* findObject(const void* objectID) const; |
| 54 | virtual void detachObject(const void* objectID); |
| 55 | |
| 56 | virtual BBinder* localBinder(); |
| 57 | |
| 58 | protected: |
| 59 | virtual ~BBinder(); |
| 60 | |
| 61 | virtual status_t onTransact( uint32_t code, |
| 62 | const Parcel& data, |
| 63 | Parcel* reply, |
| 64 | uint32_t flags = 0); |
| 65 | |
| 66 | private: |
| 67 | BBinder(const BBinder& o); |
| 68 | BBinder& operator=(const BBinder& o); |
| 69 | |
| 70 | class Extras; |
| 71 | |
| 72 | Extras* mExtras; |
| 73 | void* mReserved0; |
| 74 | }; |
| 75 | |
| 76 | // --------------------------------------------------------------------------- |
| 77 | |
| 78 | class BpRefBase : public virtual RefBase |
| 79 | { |
| 80 | protected: |
| 81 | BpRefBase(const sp<IBinder>& o); |
| 82 | virtual ~BpRefBase(); |
| 83 | virtual void onFirstRef(); |
| 84 | virtual void onLastStrongRef(const void* id); |
| 85 | virtual bool onIncStrongAttempted(uint32_t flags, const void* id); |
| 86 | |
| 87 | inline IBinder* remote() { return mRemote; } |
| 88 | inline IBinder* remote() const { return mRemote; } |
| 89 | |
| 90 | private: |
| 91 | BpRefBase(const BpRefBase& o); |
| 92 | BpRefBase& operator=(const BpRefBase& o); |
| 93 | |
| 94 | IBinder* const mRemote; |
| 95 | RefBase::weakref_type* mRefs; |
| 96 | volatile int32_t mState; |
| 97 | }; |
| 98 | |
| 99 | }; // namespace android |
| 100 | |
| 101 | // --------------------------------------------------------------------------- |
| 102 | |
| 103 | #endif // ANDROID_BINDER_H |