diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/binder/Binder.h | 3 | ||||
-rw-r--r-- | include/binder/BpBinder.h | 4 | ||||
-rw-r--r-- | include/binder/IBinder.h | 6 | ||||
-rw-r--r-- | include/binder/IInterface.h | 24 | ||||
-rw-r--r-- | include/binder/IMemory.h | 8 | ||||
-rw-r--r-- | include/binder/MemoryDealer.h | 9 | ||||
-rw-r--r-- | include/binder/Parcel.h | 5 | ||||
-rw-r--r-- | include/utils/TextOutput.h | 4 | ||||
-rw-r--r-- | include/utils/Timers.h | 10 | ||||
-rw-r--r-- | include/utils/threads.h | 10 |
10 files changed, 58 insertions, 25 deletions
diff --git a/include/binder/Binder.h b/include/binder/Binder.h index c9b71fd..47b2bb9 100644 --- a/include/binder/Binder.h +++ b/include/binder/Binder.h @@ -27,7 +27,7 @@ class BBinder : public IBinder public: BBinder(); - virtual String16 getInterfaceDescriptor() const; + virtual const String16& getInterfaceDescriptor() const; virtual bool isBinderAlive() const; virtual status_t pingBinder(); virtual status_t dump(int fd, const Vector<String16>& args); @@ -71,6 +71,7 @@ private: Extras* mExtras; void* mReserved0; + static String16 sEmptyDescriptor; }; // --------------------------------------------------------------------------- diff --git a/include/binder/BpBinder.h b/include/binder/BpBinder.h index 067637e..7ef93aa 100644 --- a/include/binder/BpBinder.h +++ b/include/binder/BpBinder.h @@ -31,7 +31,7 @@ public: inline int32_t handle() const { return mHandle; } - virtual String16 getInterfaceDescriptor() const; + virtual const String16& getInterfaceDescriptor() const; virtual bool isBinderAlive() const; virtual status_t pingBinder(); virtual status_t dump(int fd, const Vector<String16>& args); @@ -106,6 +106,7 @@ private: }; void reportOneDeath(const Obituary& obit); + bool isDescriptorCached() const; mutable Mutex mLock; volatile int32_t mAlive; @@ -113,6 +114,7 @@ private: Vector<Obituary>* mObituaries; ObjectManager mObjects; Parcel* mConstantData; + mutable String16 mDescriptorCache; }; }; // namespace android diff --git a/include/binder/IBinder.h b/include/binder/IBinder.h index 7370330..884b5c1 100644 --- a/include/binder/IBinder.h +++ b/include/binder/IBinder.h @@ -56,7 +56,7 @@ public: FLAG_ONEWAY = 0x00000001 }; - inline IBinder() { } + IBinder(); /** * Check if this IBinder implements the interface named by @@ -69,7 +69,7 @@ public: * Return the canonical name of the interface provided by this IBinder * object. */ - virtual String16 getInterfaceDescriptor() const = 0; + virtual const String16& getInterfaceDescriptor() const = 0; virtual bool isBinderAlive() const = 0; virtual status_t pingBinder() = 0; @@ -147,7 +147,7 @@ public: virtual BpBinder* remoteBinder(); protected: - inline virtual ~IBinder() { } + virtual ~IBinder(); private: }; diff --git a/include/binder/IInterface.h b/include/binder/IInterface.h index 3b1e33b..273d922 100644 --- a/include/binder/IInterface.h +++ b/include/binder/IInterface.h @@ -27,10 +27,12 @@ namespace android { class IInterface : public virtual RefBase { public: + IInterface(); sp<IBinder> asBinder(); sp<const IBinder> asBinder() const; - + protected: + virtual ~IInterface(); virtual IBinder* onAsBinder() = 0; }; @@ -49,7 +51,7 @@ class BnInterface : public INTERFACE, public BBinder { public: virtual sp<IInterface> queryLocalInterface(const String16& _descriptor); - virtual String16 getInterfaceDescriptor() const; + virtual const String16& getInterfaceDescriptor() const; protected: virtual IBinder* onAsBinder(); @@ -72,11 +74,14 @@ protected: #define DECLARE_META_INTERFACE(INTERFACE) \ static const String16 descriptor; \ static sp<I##INTERFACE> asInterface(const sp<IBinder>& obj); \ - virtual String16 getInterfaceDescriptor() const; \ + virtual const String16& getInterfaceDescriptor() const; \ + I##INTERFACE(); \ + virtual ~I##INTERFACE(); \ + #define IMPLEMENT_META_INTERFACE(INTERFACE, NAME) \ const String16 I##INTERFACE::descriptor(NAME); \ - String16 I##INTERFACE::getInterfaceDescriptor() const { \ + const String16& I##INTERFACE::getInterfaceDescriptor() const { \ return I##INTERFACE::descriptor; \ } \ sp<I##INTERFACE> I##INTERFACE::asInterface(const sp<IBinder>& obj) \ @@ -92,9 +97,16 @@ protected: } \ return intr; \ } \ + I##INTERFACE::I##INTERFACE() { } \ + I##INTERFACE::~I##INTERFACE() { } \ + + +#define CHECK_INTERFACE(interface, data, reply) \ + if (!data.checkInterface(this)) { return PERMISSION_DENIED; } \ + // ---------------------------------------------------------------------- -// No user-servicable parts after this... +// No user-serviceable parts after this... template<typename INTERFACE> inline sp<IInterface> BnInterface<INTERFACE>::queryLocalInterface( @@ -105,7 +117,7 @@ inline sp<IInterface> BnInterface<INTERFACE>::queryLocalInterface( } template<typename INTERFACE> -inline String16 BnInterface<INTERFACE>::getInterfaceDescriptor() const +inline const String16& BnInterface<INTERFACE>::getInterfaceDescriptor() const { return INTERFACE::getInterfaceDescriptor(); } diff --git a/include/binder/IMemory.h b/include/binder/IMemory.h index 182792c..ae042cb 100644 --- a/include/binder/IMemory.h +++ b/include/binder/IMemory.h @@ -59,6 +59,10 @@ public: const Parcel& data, Parcel* reply, uint32_t flags = 0); + + BnMemoryHeap(); +protected: + virtual ~BnMemoryHeap(); }; // ---------------------------------------------------------------------------- @@ -85,6 +89,10 @@ public: const Parcel& data, Parcel* reply, uint32_t flags = 0); + + BnMemory(); +protected: + virtual ~BnMemory(); }; // ---------------------------------------------------------------------------- diff --git a/include/binder/MemoryDealer.h b/include/binder/MemoryDealer.h index 097767f..d057556 100644 --- a/include/binder/MemoryDealer.h +++ b/include/binder/MemoryDealer.h @@ -39,6 +39,10 @@ class HeapInterface : public virtual BnMemoryHeap public: // all values must be page-aligned virtual sp<IMemory> mapMemory(size_t offset, size_t size) = 0; + + HeapInterface(); +protected: + virtual ~HeapInterface(); }; // ---------------------------------------------------------------------------- @@ -61,6 +65,10 @@ public: virtual void dump(const char* what, uint32_t flags = 0) const = 0; virtual void dump(String8& res, const char* what, uint32_t flags = 0) const = 0; + + AllocatorInterface(); +protected: + virtual ~AllocatorInterface(); }; // ---------------------------------------------------------------------------- @@ -71,6 +79,7 @@ public: class SharedHeap : public HeapInterface, public MemoryHeapBase { public: + SharedHeap(); SharedHeap(size_t size, uint32_t flags = 0, char const * name = NULL); virtual ~SharedHeap(); virtual sp<IMemory> mapMemory(size_t offset, size_t size); diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h index af1490a..58c2d9a 100644 --- a/include/binder/Parcel.h +++ b/include/binder/Parcel.h @@ -57,7 +57,8 @@ public: status_t writeInterfaceToken(const String16& interface); bool enforceInterface(const String16& interface) const; - + bool checkInterface(IBinder*) const; + void freeData(); const size_t* objects() const; @@ -147,7 +148,7 @@ public: release_func relFunc, void* relCookie); void print(TextOutput& to, uint32_t flags = 0) const; - + private: Parcel(const Parcel& o); Parcel& operator=(const Parcel& o); diff --git a/include/utils/TextOutput.h b/include/utils/TextOutput.h index d8d86ba..de2fbbe 100644 --- a/include/utils/TextOutput.h +++ b/include/utils/TextOutput.h @@ -28,8 +28,8 @@ namespace android { class TextOutput { public: - TextOutput() { } - virtual ~TextOutput() { } + TextOutput(); + virtual ~TextOutput(); virtual status_t print(const char* txt, size_t len) = 0; virtual void moveIndent(int delta) = 0; diff --git a/include/utils/Timers.h b/include/utils/Timers.h index 9610399..577325f 100644 --- a/include/utils/Timers.h +++ b/include/utils/Timers.h @@ -108,15 +108,15 @@ namespace android { */ class DurationTimer { public: - DurationTimer(void) {} - ~DurationTimer(void) {} + DurationTimer() {} + ~DurationTimer() {} // Start the timer. - void start(void); + void start(); // Stop the timer. - void stop(void); + void stop(); // Get the duration in microseconds. - long long durationUsecs(void) const; + long long durationUsecs() const; // Subtract two timevals. Returns the difference (ptv1-ptv2) in // microseconds. diff --git a/include/utils/threads.h b/include/utils/threads.h index b320915..e0cb664 100644 --- a/include/utils/threads.h +++ b/include/utils/threads.h @@ -199,11 +199,11 @@ public: // constructed and released when Autolock goes out of scope. class Autolock { public: - inline Autolock(Mutex& mutex) : mpMutex(&mutex) { mutex.lock(); } - inline Autolock(Mutex* mutex) : mpMutex(mutex) { mutex->lock(); } - inline ~Autolock() { mpMutex->unlock(); } + inline Autolock(Mutex& mutex) : mLock(mutex) { mLock.lock(); } + inline Autolock(Mutex* mutex) : mLock(*mutex) { mLock.lock(); } + inline ~Autolock() { mLock.unlock(); } private: - Mutex* mpMutex; + Mutex& mLock; }; private: @@ -291,7 +291,7 @@ protected: bool exitPending() const; private: - // Derived class must implemtent threadLoop(). The thread starts its life + // Derived class must implement threadLoop(). The thread starts its life // here. There are two ways of using the Thread object: // 1) loop: if threadLoop() returns true, it will be called again if // requestExit() wasn't called. |