Binder.h revision edbf3b6af777b721cd2a1ef461947e51e88241e1
198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams/* 298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * Copyright (C) 2008 The Android Open Source Project 398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * 498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * Licensed under the Apache License, Version 2.0 (the "License"); 598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * you may not use this file except in compliance with the License. 698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * You may obtain a copy of the License at 798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * 898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * http://www.apache.org/licenses/LICENSE-2.0 998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * 1098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * Unless required by applicable law or agreed to in writing, software 1198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * distributed under the License is distributed on an "AS IS" BASIS, 1298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * See the License for the specific language governing permissions and 1498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * limitations under the License. 1598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams */ 1698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 1798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#ifndef ANDROID_BINDER_H 1898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#define ANDROID_BINDER_H 1998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 2098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <utils/IBinder.h> 2198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 2298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 2398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsnamespace android { 2498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 2598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsclass BBinder : public IBinder 2698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 2798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samspublic: 2898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams BBinder(); 2998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 3098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams virtual String16 getInterfaceDescriptor() const; 3198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams virtual bool isBinderAlive() const; 3298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams virtual status_t pingBinder(); 3398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams virtual status_t dump(int fd, const Vector<String16>& args); 3498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 3598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams virtual status_t transact( uint32_t code, 3698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const Parcel& data, 3798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams Parcel* reply, 3898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t flags = 0); 3998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 4098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams virtual status_t linkToDeath(const sp<DeathRecipient>& recipient, 4198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams void* cookie = NULL, 4298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t flags = 0); 4398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 4498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams virtual status_t unlinkToDeath( const wp<DeathRecipient>& recipient, 4598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 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 58protected: 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 66private: 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 78class BpRefBase : public virtual RefBase 79{ 80protected: 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 90private: 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 104