michael@0: /* michael@0: * Copyright (C) 2008 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef ANDROID_BINDER_H michael@0: #define ANDROID_BINDER_H michael@0: michael@0: #include michael@0: michael@0: // --------------------------------------------------------------------------- michael@0: namespace android { michael@0: michael@0: class BBinder : public IBinder michael@0: { michael@0: public: michael@0: BBinder(); michael@0: michael@0: virtual const String16& getInterfaceDescriptor() const; michael@0: virtual bool isBinderAlive() const; michael@0: virtual status_t pingBinder(); michael@0: virtual status_t dump(int fd, const Vector& args); michael@0: michael@0: virtual status_t transact( uint32_t code, michael@0: const Parcel& data, michael@0: Parcel* reply, michael@0: uint32_t flags = 0); michael@0: michael@0: virtual status_t linkToDeath(const sp& recipient, michael@0: void* cookie = NULL, michael@0: uint32_t flags = 0); michael@0: michael@0: virtual status_t unlinkToDeath( const wp& recipient, michael@0: void* cookie = NULL, michael@0: uint32_t flags = 0, michael@0: wp* outRecipient = NULL); michael@0: michael@0: virtual void attachObject( const void* objectID, michael@0: void* object, michael@0: void* cleanupCookie, michael@0: object_cleanup_func func); michael@0: virtual void* findObject(const void* objectID) const; michael@0: virtual void detachObject(const void* objectID); michael@0: michael@0: virtual BBinder* localBinder(); michael@0: michael@0: protected: michael@0: virtual ~BBinder(); michael@0: michael@0: virtual status_t onTransact( uint32_t code, michael@0: const Parcel& data, michael@0: Parcel* reply, michael@0: uint32_t flags = 0); michael@0: michael@0: private: michael@0: BBinder(const BBinder& o); michael@0: BBinder& operator=(const BBinder& o); michael@0: michael@0: class Extras; michael@0: michael@0: Extras* mExtras; michael@0: void* mReserved0; michael@0: }; michael@0: michael@0: // --------------------------------------------------------------------------- michael@0: michael@0: class BpRefBase : public virtual RefBase michael@0: { michael@0: protected: michael@0: BpRefBase(const sp& o); michael@0: virtual ~BpRefBase(); michael@0: virtual void onFirstRef(); michael@0: virtual void onLastStrongRef(const void* id); michael@0: virtual bool onIncStrongAttempted(uint32_t flags, const void* id); michael@0: michael@0: inline IBinder* remote() { return mRemote; } michael@0: inline IBinder* remote() const { return mRemote; } michael@0: michael@0: private: michael@0: BpRefBase(const BpRefBase& o); michael@0: BpRefBase& operator=(const BpRefBase& o); michael@0: michael@0: IBinder* const mRemote; michael@0: RefBase::weakref_type* mRefs; michael@0: volatile int32_t mState; michael@0: }; michael@0: michael@0: }; // namespace android michael@0: michael@0: // --------------------------------------------------------------------------- michael@0: michael@0: #endif // ANDROID_BINDER_H