diff options
author | Mathias Agopian <mathias@google.com> | 2012-03-07 19:36:08 -0800 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2012-03-07 19:36:08 -0800 |
commit | 8c79817dc6459baa2c79db88e3c3e4d5c07d6a61 (patch) | |
tree | d7e4dfcc8a7851d5851750989664ec81ca620d6d /include/binder | |
parent | 08965ec67ada98f63f8ac879cc44c8b0e7ff046d (diff) | |
download | frameworks_base-8c79817dc6459baa2c79db88e3c3e4d5c07d6a61.zip frameworks_base-8c79817dc6459baa2c79db88e3c3e4d5c07d6a61.tar.gz frameworks_base-8c79817dc6459baa2c79db88e3c3e4d5c07d6a61.tar.bz2 |
remove files that moved to frameworks/native
Change-Id: I140d291e520097b1148930f736823650e08488f7
Diffstat (limited to 'include/binder')
-rw-r--r-- | include/binder/Binder.h | 103 | ||||
-rw-r--r-- | include/binder/BinderService.h | 60 | ||||
-rw-r--r-- | include/binder/BpBinder.h | 124 | ||||
-rw-r--r-- | include/binder/IBinder.h | 159 | ||||
-rw-r--r-- | include/binder/IInterface.h | 150 | ||||
-rw-r--r-- | include/binder/IMemory.h | 102 | ||||
-rw-r--r-- | include/binder/IPCThreadState.h | 129 | ||||
-rw-r--r-- | include/binder/IPermissionController.h | 56 | ||||
-rw-r--r-- | include/binder/IServiceManager.h | 101 | ||||
-rw-r--r-- | include/binder/MemoryBase.h | 51 | ||||
-rw-r--r-- | include/binder/MemoryDealer.h | 60 | ||||
-rw-r--r-- | include/binder/MemoryHeapBase.h | 100 | ||||
-rw-r--r-- | include/binder/Parcel.h | 297 | ||||
-rw-r--r-- | include/binder/PermissionCache.h | 79 | ||||
-rw-r--r-- | include/binder/ProcessState.h | 113 |
15 files changed, 0 insertions, 1684 deletions
diff --git a/include/binder/Binder.h b/include/binder/Binder.h deleted file mode 100644 index ba3ac4b..0000000 --- a/include/binder/Binder.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_BINDER_H -#define ANDROID_BINDER_H - -#include <binder/IBinder.h> - -// --------------------------------------------------------------------------- -namespace android { - -class BBinder : public IBinder -{ -public: - BBinder(); - - virtual const String16& getInterfaceDescriptor() const; - virtual bool isBinderAlive() const; - virtual status_t pingBinder(); - virtual status_t dump(int fd, const Vector<String16>& args); - - virtual status_t transact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); - - virtual status_t linkToDeath(const sp<DeathRecipient>& recipient, - void* cookie = NULL, - uint32_t flags = 0); - - virtual status_t unlinkToDeath( const wp<DeathRecipient>& recipient, - void* cookie = NULL, - uint32_t flags = 0, - wp<DeathRecipient>* outRecipient = NULL); - - virtual void attachObject( const void* objectID, - void* object, - void* cleanupCookie, - object_cleanup_func func); - virtual void* findObject(const void* objectID) const; - virtual void detachObject(const void* objectID); - - virtual BBinder* localBinder(); - -protected: - virtual ~BBinder(); - - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); - -private: - BBinder(const BBinder& o); - BBinder& operator=(const BBinder& o); - - class Extras; - - Extras* mExtras; - void* mReserved0; -}; - -// --------------------------------------------------------------------------- - -class BpRefBase : public virtual RefBase -{ -protected: - BpRefBase(const sp<IBinder>& o); - virtual ~BpRefBase(); - virtual void onFirstRef(); - virtual void onLastStrongRef(const void* id); - virtual bool onIncStrongAttempted(uint32_t flags, const void* id); - - inline IBinder* remote() { return mRemote; } - inline IBinder* remote() const { return mRemote; } - -private: - BpRefBase(const BpRefBase& o); - BpRefBase& operator=(const BpRefBase& o); - - IBinder* const mRemote; - RefBase::weakref_type* mRefs; - volatile int32_t mState; -}; - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_BINDER_H diff --git a/include/binder/BinderService.h b/include/binder/BinderService.h deleted file mode 100644 index ca594d3..0000000 --- a/include/binder/BinderService.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_BINDER_SERVICE_H -#define ANDROID_BINDER_SERVICE_H - -#include <stdint.h> - -#include <utils/Errors.h> -#include <utils/String16.h> - -#include <binder/IServiceManager.h> -#include <binder/IPCThreadState.h> -#include <binder/ProcessState.h> -#include <binder/IServiceManager.h> - -// --------------------------------------------------------------------------- -namespace android { - -template<typename SERVICE> -class BinderService -{ -public: - static status_t publish(bool allowIsolated = false) { - sp<IServiceManager> sm(defaultServiceManager()); - return sm->addService(String16(SERVICE::getServiceName()), new SERVICE(), allowIsolated); - } - - static void publishAndJoinThreadPool(bool allowIsolated = false) { - sp<ProcessState> proc(ProcessState::self()); - sp<IServiceManager> sm(defaultServiceManager()); - sm->addService(String16(SERVICE::getServiceName()), new SERVICE(), allowIsolated); - ProcessState::self()->startThreadPool(); - IPCThreadState::self()->joinThreadPool(); - } - - static void instantiate() { publish(); } - - static status_t shutdown() { - return NO_ERROR; - } -}; - - -}; // namespace android -// --------------------------------------------------------------------------- -#endif // ANDROID_BINDER_SERVICE_H diff --git a/include/binder/BpBinder.h b/include/binder/BpBinder.h deleted file mode 100644 index 7ef93aa..0000000 --- a/include/binder/BpBinder.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_BPBINDER_H -#define ANDROID_BPBINDER_H - -#include <binder/IBinder.h> -#include <utils/KeyedVector.h> -#include <utils/threads.h> - -// --------------------------------------------------------------------------- -namespace android { - -class BpBinder : public IBinder -{ -public: - BpBinder(int32_t handle); - - inline int32_t handle() const { return mHandle; } - - virtual const String16& getInterfaceDescriptor() const; - virtual bool isBinderAlive() const; - virtual status_t pingBinder(); - virtual status_t dump(int fd, const Vector<String16>& args); - - virtual status_t transact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); - - virtual status_t linkToDeath(const sp<DeathRecipient>& recipient, - void* cookie = NULL, - uint32_t flags = 0); - virtual status_t unlinkToDeath( const wp<DeathRecipient>& recipient, - void* cookie = NULL, - uint32_t flags = 0, - wp<DeathRecipient>* outRecipient = NULL); - - virtual void attachObject( const void* objectID, - void* object, - void* cleanupCookie, - object_cleanup_func func); - virtual void* findObject(const void* objectID) const; - virtual void detachObject(const void* objectID); - - virtual BpBinder* remoteBinder(); - - status_t setConstantData(const void* data, size_t size); - void sendObituary(); - - class ObjectManager - { - public: - ObjectManager(); - ~ObjectManager(); - - void attach( const void* objectID, - void* object, - void* cleanupCookie, - IBinder::object_cleanup_func func); - void* find(const void* objectID) const; - void detach(const void* objectID); - - void kill(); - - private: - ObjectManager(const ObjectManager&); - ObjectManager& operator=(const ObjectManager&); - - struct entry_t - { - void* object; - void* cleanupCookie; - IBinder::object_cleanup_func func; - }; - - KeyedVector<const void*, entry_t> mObjects; - }; - -protected: - virtual ~BpBinder(); - virtual void onFirstRef(); - virtual void onLastStrongRef(const void* id); - virtual bool onIncStrongAttempted(uint32_t flags, const void* id); - -private: - const int32_t mHandle; - - struct Obituary { - wp<DeathRecipient> recipient; - void* cookie; - uint32_t flags; - }; - - void reportOneDeath(const Obituary& obit); - bool isDescriptorCached() const; - - mutable Mutex mLock; - volatile int32_t mAlive; - volatile int32_t mObitsSent; - Vector<Obituary>* mObituaries; - ObjectManager mObjects; - Parcel* mConstantData; - mutable String16 mDescriptorCache; -}; - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_BPBINDER_H diff --git a/include/binder/IBinder.h b/include/binder/IBinder.h deleted file mode 100644 index 81b56c2..0000000 --- a/include/binder/IBinder.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_IBINDER_H -#define ANDROID_IBINDER_H - -#include <utils/Errors.h> -#include <utils/RefBase.h> -#include <utils/String16.h> -#include <utils/Vector.h> - - -#define B_PACK_CHARS(c1, c2, c3, c4) \ - ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4)) - -// --------------------------------------------------------------------------- -namespace android { - -class BBinder; -class BpBinder; -class IInterface; -class Parcel; - -/** - * Base class and low-level protocol for a remotable object. - * You can derive from this class to create an object for which other - * processes can hold references to it. Communication between processes - * (method calls, property get and set) is down through a low-level - * protocol implemented on top of the transact() API. - */ -class IBinder : public virtual RefBase -{ -public: - enum { - FIRST_CALL_TRANSACTION = 0x00000001, - LAST_CALL_TRANSACTION = 0x00ffffff, - - PING_TRANSACTION = B_PACK_CHARS('_','P','N','G'), - DUMP_TRANSACTION = B_PACK_CHARS('_','D','M','P'), - INTERFACE_TRANSACTION = B_PACK_CHARS('_', 'N', 'T', 'F'), - - // Corresponds to TF_ONE_WAY -- an asynchronous call. - FLAG_ONEWAY = 0x00000001 - }; - - IBinder(); - - /** - * Check if this IBinder implements the interface named by - * @a descriptor. If it does, the base pointer to it is returned, - * which you can safely static_cast<> to the concrete C++ interface. - */ - virtual sp<IInterface> queryLocalInterface(const String16& descriptor); - - /** - * Return the canonical name of the interface provided by this IBinder - * object. - */ - virtual const String16& getInterfaceDescriptor() const = 0; - - virtual bool isBinderAlive() const = 0; - virtual status_t pingBinder() = 0; - virtual status_t dump(int fd, const Vector<String16>& args) = 0; - - virtual status_t transact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0) = 0; - - /** - * This method allows you to add data that is transported through - * IPC along with your IBinder pointer. When implementing a Binder - * object, override it to write your desired data in to @a outData. - * You can then call getConstantData() on your IBinder to retrieve - * that data, from any process. You MUST return the number of bytes - * written in to the parcel (including padding). - */ - class DeathRecipient : public virtual RefBase - { - public: - virtual void binderDied(const wp<IBinder>& who) = 0; - }; - - /** - * Register the @a recipient for a notification if this binder - * goes away. If this binder object unexpectedly goes away - * (typically because its hosting process has been killed), - * then DeathRecipient::binderDied() will be called with a reference - * to this. - * - * The @a cookie is optional -- if non-NULL, it should be a - * memory address that you own (that is, you know it is unique). - * - * @note You will only receive death notifications for remote binders, - * as local binders by definition can't die without you dying as well. - * Trying to use this function on a local binder will result in an - * INVALID_OPERATION code being returned and nothing happening. - * - * @note This link always holds a weak reference to its recipient. - * - * @note You will only receive a weak reference to the dead - * binder. You should not try to promote this to a strong reference. - * (Nor should you need to, as there is nothing useful you can - * directly do with it now that it has passed on.) - */ - virtual status_t linkToDeath(const sp<DeathRecipient>& recipient, - void* cookie = NULL, - uint32_t flags = 0) = 0; - - /** - * Remove a previously registered death notification. - * The @a recipient will no longer be called if this object - * dies. The @a cookie is optional. If non-NULL, you can - * supply a NULL @a recipient, and the recipient previously - * added with that cookie will be unlinked. - */ - virtual status_t unlinkToDeath( const wp<DeathRecipient>& recipient, - void* cookie = NULL, - uint32_t flags = 0, - wp<DeathRecipient>* outRecipient = NULL) = 0; - - virtual bool checkSubclass(const void* subclassID) const; - - typedef void (*object_cleanup_func)(const void* id, void* obj, void* cleanupCookie); - - virtual void attachObject( const void* objectID, - void* object, - void* cleanupCookie, - object_cleanup_func func) = 0; - virtual void* findObject(const void* objectID) const = 0; - virtual void detachObject(const void* objectID) = 0; - - virtual BBinder* localBinder(); - virtual BpBinder* remoteBinder(); - -protected: - virtual ~IBinder(); - -private: -}; - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_IBINDER_H diff --git a/include/binder/IInterface.h b/include/binder/IInterface.h deleted file mode 100644 index 5f9f69c..0000000 --- a/include/binder/IInterface.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// -#ifndef ANDROID_IINTERFACE_H -#define ANDROID_IINTERFACE_H - -#include <binder/Binder.h> - -namespace android { - -// ---------------------------------------------------------------------- - -class IInterface : public virtual RefBase -{ -public: - IInterface(); - sp<IBinder> asBinder(); - sp<const IBinder> asBinder() const; - -protected: - virtual ~IInterface(); - virtual IBinder* onAsBinder() = 0; -}; - -// ---------------------------------------------------------------------- - -template<typename INTERFACE> -inline sp<INTERFACE> interface_cast(const sp<IBinder>& obj) -{ - return INTERFACE::asInterface(obj); -} - -// ---------------------------------------------------------------------- - -template<typename INTERFACE> -class BnInterface : public INTERFACE, public BBinder -{ -public: - virtual sp<IInterface> queryLocalInterface(const String16& _descriptor); - virtual const String16& getInterfaceDescriptor() const; - -protected: - virtual IBinder* onAsBinder(); -}; - -// ---------------------------------------------------------------------- - -template<typename INTERFACE> -class BpInterface : public INTERFACE, public BpRefBase -{ -public: - BpInterface(const sp<IBinder>& remote); - -protected: - virtual IBinder* onAsBinder(); -}; - -// ---------------------------------------------------------------------- - -#define DECLARE_META_INTERFACE(INTERFACE) \ - static const android::String16 descriptor; \ - static android::sp<I##INTERFACE> asInterface( \ - const android::sp<android::IBinder>& obj); \ - virtual const android::String16& getInterfaceDescriptor() const; \ - I##INTERFACE(); \ - virtual ~I##INTERFACE(); \ - - -#define IMPLEMENT_META_INTERFACE(INTERFACE, NAME) \ - const android::String16 I##INTERFACE::descriptor(NAME); \ - const android::String16& \ - I##INTERFACE::getInterfaceDescriptor() const { \ - return I##INTERFACE::descriptor; \ - } \ - android::sp<I##INTERFACE> I##INTERFACE::asInterface( \ - const android::sp<android::IBinder>& obj) \ - { \ - android::sp<I##INTERFACE> intr; \ - if (obj != NULL) { \ - intr = static_cast<I##INTERFACE*>( \ - obj->queryLocalInterface( \ - I##INTERFACE::descriptor).get()); \ - if (intr == NULL) { \ - intr = new Bp##INTERFACE(obj); \ - } \ - } \ - 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-serviceable parts after this... - -template<typename INTERFACE> -inline sp<IInterface> BnInterface<INTERFACE>::queryLocalInterface( - const String16& _descriptor) -{ - if (_descriptor == INTERFACE::descriptor) return this; - return NULL; -} - -template<typename INTERFACE> -inline const String16& BnInterface<INTERFACE>::getInterfaceDescriptor() const -{ - return INTERFACE::getInterfaceDescriptor(); -} - -template<typename INTERFACE> -IBinder* BnInterface<INTERFACE>::onAsBinder() -{ - return this; -} - -template<typename INTERFACE> -inline BpInterface<INTERFACE>::BpInterface(const sp<IBinder>& remote) - : BpRefBase(remote) -{ -} - -template<typename INTERFACE> -inline IBinder* BpInterface<INTERFACE>::onAsBinder() -{ - return remote(); -} - -// ---------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_IINTERFACE_H diff --git a/include/binder/IMemory.h b/include/binder/IMemory.h deleted file mode 100644 index 2d0db00..0000000 --- a/include/binder/IMemory.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_IMEMORY_H -#define ANDROID_IMEMORY_H - -#include <stdint.h> -#include <sys/types.h> -#include <sys/mman.h> - -#include <utils/RefBase.h> -#include <utils/Errors.h> -#include <binder/IInterface.h> - -namespace android { - -// ---------------------------------------------------------------------------- - -class IMemoryHeap : public IInterface -{ -public: - DECLARE_META_INTERFACE(MemoryHeap); - - // flags returned by getFlags() - enum { - READ_ONLY = 0x00000001 - }; - - virtual int getHeapID() const = 0; - virtual void* getBase() const = 0; - virtual size_t getSize() const = 0; - virtual uint32_t getFlags() const = 0; - virtual uint32_t getOffset() const = 0; - - // these are there just for backward source compatibility - int32_t heapID() const { return getHeapID(); } - void* base() const { return getBase(); } - size_t virtualSize() const { return getSize(); } -}; - -class BnMemoryHeap : public BnInterface<IMemoryHeap> -{ -public: - virtual status_t onTransact( - uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); - - BnMemoryHeap(); -protected: - virtual ~BnMemoryHeap(); -}; - -// ---------------------------------------------------------------------------- - -class IMemory : public IInterface -{ -public: - DECLARE_META_INTERFACE(Memory); - - virtual sp<IMemoryHeap> getMemory(ssize_t* offset=0, size_t* size=0) const = 0; - - // helpers - void* fastPointer(const sp<IBinder>& heap, ssize_t offset) const; - void* pointer() const; - size_t size() const; - ssize_t offset() const; -}; - -class BnMemory : public BnInterface<IMemory> -{ -public: - virtual status_t onTransact( - uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); - - BnMemory(); -protected: - virtual ~BnMemory(); -}; - -// ---------------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_IMEMORY_H diff --git a/include/binder/IPCThreadState.h b/include/binder/IPCThreadState.h deleted file mode 100644 index 691ba2f..0000000 --- a/include/binder/IPCThreadState.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_IPC_THREAD_STATE_H -#define ANDROID_IPC_THREAD_STATE_H - -#include <utils/Errors.h> -#include <binder/Parcel.h> -#include <binder/ProcessState.h> -#include <utils/Vector.h> - -#ifdef HAVE_WIN32_PROC -typedef int uid_t; -#endif - -// --------------------------------------------------------------------------- -namespace android { - -class IPCThreadState -{ -public: - static IPCThreadState* self(); - static IPCThreadState* selfOrNull(); // self(), but won't instantiate - - sp<ProcessState> process(); - - status_t clearLastError(); - - int getCallingPid(); - int getCallingUid(); - int getOrigCallingUid(); - - void setStrictModePolicy(int32_t policy); - int32_t getStrictModePolicy() const; - - void setLastTransactionBinderFlags(int32_t flags); - int32_t getLastTransactionBinderFlags() const; - - int64_t clearCallingIdentity(); - void restoreCallingIdentity(int64_t token); - - void flushCommands(); - - void joinThreadPool(bool isMain = true); - - // Stop the local process. - void stopProcess(bool immediate = true); - - status_t transact(int32_t handle, - uint32_t code, const Parcel& data, - Parcel* reply, uint32_t flags); - - void incStrongHandle(int32_t handle); - void decStrongHandle(int32_t handle); - void incWeakHandle(int32_t handle); - void decWeakHandle(int32_t handle); - status_t attemptIncStrongHandle(int32_t handle); - static void expungeHandle(int32_t handle, IBinder* binder); - status_t requestDeathNotification( int32_t handle, - BpBinder* proxy); - status_t clearDeathNotification( int32_t handle, - BpBinder* proxy); - - static void shutdown(); - - // Call this to disable switching threads to background scheduling when - // receiving incoming IPC calls. This is specifically here for the - // Android system process, since it expects to have background apps calling - // in to it but doesn't want to acquire locks in its services while in - // the background. - static void disableBackgroundScheduling(bool disable); - -private: - IPCThreadState(); - ~IPCThreadState(); - - status_t sendReply(const Parcel& reply, uint32_t flags); - status_t waitForResponse(Parcel *reply, - status_t *acquireResult=NULL); - status_t talkWithDriver(bool doReceive=true); - status_t writeTransactionData(int32_t cmd, - uint32_t binderFlags, - int32_t handle, - uint32_t code, - const Parcel& data, - status_t* statusBuffer); - status_t executeCommand(int32_t command); - - void clearCaller(); - - static void threadDestructor(void *st); - static void freeBuffer(Parcel* parcel, - const uint8_t* data, size_t dataSize, - const size_t* objects, size_t objectsSize, - void* cookie); - - const sp<ProcessState> mProcess; - const pid_t mMyThreadId; - Vector<BBinder*> mPendingStrongDerefs; - Vector<RefBase::weakref_type*> mPendingWeakDerefs; - - Parcel mIn; - Parcel mOut; - status_t mLastError; - pid_t mCallingPid; - uid_t mCallingUid; - uid_t mOrigCallingUid; - int32_t mStrictModePolicy; - int32_t mLastTransactionBinderFlags; -}; - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_IPC_THREAD_STATE_H diff --git a/include/binder/IPermissionController.h b/include/binder/IPermissionController.h deleted file mode 100644 index f9d371b..0000000 --- a/include/binder/IPermissionController.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// -#ifndef ANDROID_IPERMISSION_CONTROLLER_H -#define ANDROID_IPERMISSION_CONTROLLER_H - -#include <binder/IInterface.h> - -namespace android { - -// ---------------------------------------------------------------------- - -class IPermissionController : public IInterface -{ -public: - DECLARE_META_INTERFACE(PermissionController); - - virtual bool checkPermission(const String16& permission, - int32_t pid, int32_t uid) = 0; - - enum { - CHECK_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION - }; -}; - -// ---------------------------------------------------------------------- - -class BnPermissionController : public BnInterface<IPermissionController> -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_IPERMISSION_CONTROLLER_H - diff --git a/include/binder/IServiceManager.h b/include/binder/IServiceManager.h deleted file mode 100644 index 2c297d6..0000000 --- a/include/binder/IServiceManager.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// -#ifndef ANDROID_ISERVICE_MANAGER_H -#define ANDROID_ISERVICE_MANAGER_H - -#include <binder/IInterface.h> -#include <binder/IPermissionController.h> -#include <utils/Vector.h> -#include <utils/String16.h> - -namespace android { - -// ---------------------------------------------------------------------- - -class IServiceManager : public IInterface -{ -public: - DECLARE_META_INTERFACE(ServiceManager); - - /** - * Retrieve an existing service, blocking for a few seconds - * if it doesn't yet exist. - */ - virtual sp<IBinder> getService( const String16& name) const = 0; - - /** - * Retrieve an existing service, non-blocking. - */ - virtual sp<IBinder> checkService( const String16& name) const = 0; - - /** - * Register a service. - */ - virtual status_t addService( const String16& name, - const sp<IBinder>& service, - bool allowIsolated = false) = 0; - - /** - * Return list of all existing services. - */ - virtual Vector<String16> listServices() = 0; - - enum { - GET_SERVICE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, - CHECK_SERVICE_TRANSACTION, - ADD_SERVICE_TRANSACTION, - LIST_SERVICES_TRANSACTION, - }; -}; - -sp<IServiceManager> defaultServiceManager(); - -template<typename INTERFACE> -status_t getService(const String16& name, sp<INTERFACE>* outService) -{ - const sp<IServiceManager> sm = defaultServiceManager(); - if (sm != NULL) { - *outService = interface_cast<INTERFACE>(sm->getService(name)); - if ((*outService) != NULL) return NO_ERROR; - } - return NAME_NOT_FOUND; -} - -bool checkCallingPermission(const String16& permission); -bool checkCallingPermission(const String16& permission, - int32_t* outPid, int32_t* outUid); -bool checkPermission(const String16& permission, pid_t pid, uid_t uid); - - -// ---------------------------------------------------------------------- - -class BnServiceManager : public BnInterface<IServiceManager> -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_ISERVICE_MANAGER_H - diff --git a/include/binder/MemoryBase.h b/include/binder/MemoryBase.h deleted file mode 100644 index 463e26d..0000000 --- a/include/binder/MemoryBase.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_MEMORY_BASE_H -#define ANDROID_MEMORY_BASE_H - -#include <stdlib.h> -#include <stdint.h> - -#include <binder/IMemory.h> - - -namespace android { - -// --------------------------------------------------------------------------- - -class MemoryBase : public BnMemory -{ -public: - MemoryBase(const sp<IMemoryHeap>& heap, ssize_t offset, size_t size); - virtual ~MemoryBase(); - virtual sp<IMemoryHeap> getMemory(ssize_t* offset, size_t* size) const; - -protected: - size_t getSize() const { return mSize; } - ssize_t getOffset() const { return mOffset; } - const sp<IMemoryHeap>& getHeap() const { return mHeap; } - -private: - size_t mSize; - ssize_t mOffset; - sp<IMemoryHeap> mHeap; -}; - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_MEMORY_BASE_H diff --git a/include/binder/MemoryDealer.h b/include/binder/MemoryDealer.h deleted file mode 100644 index 170f20d..0000000 --- a/include/binder/MemoryDealer.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_MEMORY_DEALER_H -#define ANDROID_MEMORY_DEALER_H - - -#include <stdint.h> -#include <sys/types.h> - -#include <binder/IMemory.h> -#include <binder/MemoryHeapBase.h> - -namespace android { -// ---------------------------------------------------------------------------- - -class SimpleBestFitAllocator; - -// ---------------------------------------------------------------------------- - -class MemoryDealer : public RefBase -{ -public: - MemoryDealer(size_t size, const char* name = 0); - - virtual sp<IMemory> allocate(size_t size); - virtual void deallocate(size_t offset); - virtual void dump(const char* what) const; - - sp<IMemoryHeap> getMemoryHeap() const { return heap(); } - -protected: - virtual ~MemoryDealer(); - -private: - const sp<IMemoryHeap>& heap() const; - SimpleBestFitAllocator* allocator() const; - - sp<IMemoryHeap> mHeap; - SimpleBestFitAllocator* mAllocator; -}; - - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_MEMORY_DEALER_H diff --git a/include/binder/MemoryHeapBase.h b/include/binder/MemoryHeapBase.h deleted file mode 100644 index bbbda9c..0000000 --- a/include/binder/MemoryHeapBase.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_MEMORY_HEAP_BASE_H -#define ANDROID_MEMORY_HEAP_BASE_H - -#include <stdlib.h> -#include <stdint.h> - -#include <binder/IMemory.h> - - -namespace android { - -// --------------------------------------------------------------------------- - -class MemoryHeapBase : public virtual BnMemoryHeap -{ -public: - enum { - READ_ONLY = IMemoryHeap::READ_ONLY, - // memory won't be mapped locally, but will be mapped in the remote - // process. - DONT_MAP_LOCALLY = 0x00000100, - NO_CACHING = 0x00000200 - }; - - /* - * maps the memory referenced by fd. but DOESN'T take ownership - * of the filedescriptor (it makes a copy with dup() - */ - MemoryHeapBase(int fd, size_t size, uint32_t flags = 0, uint32_t offset = 0); - - /* - * maps memory from the given device - */ - MemoryHeapBase(const char* device, size_t size = 0, uint32_t flags = 0); - - /* - * maps memory from ashmem, with the given name for debugging - */ - MemoryHeapBase(size_t size, uint32_t flags = 0, char const* name = NULL); - - virtual ~MemoryHeapBase(); - - /* implement IMemoryHeap interface */ - virtual int getHeapID() const; - virtual void* getBase() const; - virtual size_t getSize() const; - virtual uint32_t getFlags() const; - virtual uint32_t getOffset() const; - - const char* getDevice() const; - - /* this closes this heap -- use carefully */ - void dispose(); - - /* this is only needed as a workaround, use only if you know - * what you are doing */ - status_t setDevice(const char* device) { - if (mDevice == 0) - mDevice = device; - return mDevice ? NO_ERROR : ALREADY_EXISTS; - } - -protected: - MemoryHeapBase(); - // init() takes ownership of fd - status_t init(int fd, void *base, int size, - int flags = 0, const char* device = NULL); - -private: - status_t mapfd(int fd, size_t size, uint32_t offset = 0); - - int mFD; - size_t mSize; - void* mBase; - uint32_t mFlags; - const char* mDevice; - bool mNeedUnmap; - uint32_t mOffset; -}; - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_MEMORY_HEAP_BASE_H diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h deleted file mode 100644 index 33b2f00..0000000 --- a/include/binder/Parcel.h +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_PARCEL_H -#define ANDROID_PARCEL_H - -#include <cutils/native_handle.h> -#include <utils/Errors.h> -#include <utils/RefBase.h> -#include <utils/String16.h> -#include <utils/Vector.h> - -// --------------------------------------------------------------------------- -namespace android { - -class Flattenable; -class IBinder; -class IPCThreadState; -class ProcessState; -class String8; -class TextOutput; - -struct flat_binder_object; // defined in support_p/binder_module.h - -class Parcel -{ -public: - class ReadableBlob; - class WritableBlob; - - Parcel(); - ~Parcel(); - - const uint8_t* data() const; - size_t dataSize() const; - size_t dataAvail() const; - size_t dataPosition() const; - size_t dataCapacity() const; - - status_t setDataSize(size_t size); - void setDataPosition(size_t pos) const; - status_t setDataCapacity(size_t size); - - status_t setData(const uint8_t* buffer, size_t len); - - status_t appendFrom(const Parcel *parcel, - size_t start, size_t len); - - bool pushAllowFds(bool allowFds); - void restoreAllowFds(bool lastValue); - - bool hasFileDescriptors() const; - - // Writes the RPC header. - status_t writeInterfaceToken(const String16& interface); - - // Parses the RPC header, returning true if the interface name - // in the header matches the expected interface from the caller. - // - // Additionally, enforceInterface does part of the work of - // propagating the StrictMode policy mask, populating the current - // IPCThreadState, which as an optimization may optionally be - // passed in. - bool enforceInterface(const String16& interface, - IPCThreadState* threadState = NULL) const; - bool checkInterface(IBinder*) const; - - void freeData(); - - const size_t* objects() const; - size_t objectsCount() const; - - status_t errorCheck() const; - void setError(status_t err); - - status_t write(const void* data, size_t len); - void* writeInplace(size_t len); - status_t writeUnpadded(const void* data, size_t len); - status_t writeInt32(int32_t val); - status_t writeInt64(int64_t val); - status_t writeFloat(float val); - status_t writeDouble(double val); - status_t writeIntPtr(intptr_t val); - status_t writeCString(const char* str); - status_t writeString8(const String8& str); - status_t writeString16(const String16& str); - status_t writeString16(const char16_t* str, size_t len); - status_t writeStrongBinder(const sp<IBinder>& val); - status_t writeWeakBinder(const wp<IBinder>& val); - status_t write(const Flattenable& val); - - // Place a native_handle into the parcel (the native_handle's file- - // descriptors are dup'ed, so it is safe to delete the native_handle - // when this function returns). - // Doesn't take ownership of the native_handle. - status_t writeNativeHandle(const native_handle* handle); - - // Place a file descriptor into the parcel. The given fd must remain - // valid for the lifetime of the parcel. - // The Parcel does not take ownership of the given fd unless you ask it to. - status_t writeFileDescriptor(int fd, bool takeOwnership = false); - - // Place a file descriptor into the parcel. A dup of the fd is made, which - // will be closed once the parcel is destroyed. - status_t writeDupFileDescriptor(int fd); - - // Writes a blob to the parcel. - // If the blob is small, then it is stored in-place, otherwise it is - // transferred by way of an anonymous shared memory region. - // The caller should call release() on the blob after writing its contents. - status_t writeBlob(size_t len, WritableBlob* outBlob); - - status_t writeObject(const flat_binder_object& val, bool nullMetaData); - - // Like Parcel.java's writeNoException(). Just writes a zero int32. - // Currently the native implementation doesn't do any of the StrictMode - // stack gathering and serialization that the Java implementation does. - status_t writeNoException(); - - void remove(size_t start, size_t amt); - - status_t read(void* outData, size_t len) const; - const void* readInplace(size_t len) const; - int32_t readInt32() const; - status_t readInt32(int32_t *pArg) const; - int64_t readInt64() const; - status_t readInt64(int64_t *pArg) const; - float readFloat() const; - status_t readFloat(float *pArg) const; - double readDouble() const; - status_t readDouble(double *pArg) const; - intptr_t readIntPtr() const; - status_t readIntPtr(intptr_t *pArg) const; - - const char* readCString() const; - String8 readString8() const; - String16 readString16() const; - const char16_t* readString16Inplace(size_t* outLen) const; - sp<IBinder> readStrongBinder() const; - wp<IBinder> readWeakBinder() const; - status_t read(Flattenable& val) const; - - // Like Parcel.java's readExceptionCode(). Reads the first int32 - // off of a Parcel's header, returning 0 or the negative error - // code on exceptions, but also deals with skipping over rich - // response headers. Callers should use this to read & parse the - // response headers rather than doing it by hand. - int32_t readExceptionCode() const; - - // Retrieve native_handle from the parcel. This returns a copy of the - // parcel's native_handle (the caller takes ownership). The caller - // must free the native_handle with native_handle_close() and - // native_handle_delete(). - native_handle* readNativeHandle() const; - - - // Retrieve a file descriptor from the parcel. This returns the raw fd - // in the parcel, which you do not own -- use dup() to get your own copy. - int readFileDescriptor() const; - - // Reads a blob from the parcel. - // The caller should call release() on the blob after reading its contents. - status_t readBlob(size_t len, ReadableBlob* outBlob) const; - - const flat_binder_object* readObject(bool nullMetaData) const; - - // Explicitly close all file descriptors in the parcel. - void closeFileDescriptors(); - - typedef void (*release_func)(Parcel* parcel, - const uint8_t* data, size_t dataSize, - const size_t* objects, size_t objectsSize, - void* cookie); - - const uint8_t* ipcData() const; - size_t ipcDataSize() const; - const size_t* ipcObjects() const; - size_t ipcObjectsCount() const; - void ipcSetDataReference(const uint8_t* data, size_t dataSize, - const size_t* objects, size_t objectsCount, - release_func relFunc, void* relCookie); - - void print(TextOutput& to, uint32_t flags = 0) const; - -private: - Parcel(const Parcel& o); - Parcel& operator=(const Parcel& o); - - status_t finishWrite(size_t len); - void releaseObjects(); - void acquireObjects(); - status_t growData(size_t len); - status_t restartWrite(size_t desired); - status_t continueWrite(size_t desired); - void freeDataNoInit(); - void initState(); - void scanForFds() const; - - template<class T> - status_t readAligned(T *pArg) const; - - template<class T> T readAligned() const; - - template<class T> - status_t writeAligned(T val); - - status_t mError; - uint8_t* mData; - size_t mDataSize; - size_t mDataCapacity; - mutable size_t mDataPos; - size_t* mObjects; - size_t mObjectsSize; - size_t mObjectsCapacity; - mutable size_t mNextObjectHint; - - mutable bool mFdsKnown; - mutable bool mHasFds; - bool mAllowFds; - - release_func mOwner; - void* mOwnerCookie; - - class Blob { - public: - Blob(); - ~Blob(); - - void release(); - inline size_t size() const { return mSize; } - - protected: - void init(bool mapped, void* data, size_t size); - void clear(); - - bool mMapped; - void* mData; - size_t mSize; - }; - -public: - class ReadableBlob : public Blob { - friend class Parcel; - public: - inline const void* data() const { return mData; } - }; - - class WritableBlob : public Blob { - friend class Parcel; - public: - inline void* data() { return mData; } - }; -}; - -// --------------------------------------------------------------------------- - -inline TextOutput& operator<<(TextOutput& to, const Parcel& parcel) -{ - parcel.print(to); - return to; -} - -// --------------------------------------------------------------------------- - -// Generic acquire and release of objects. -void acquire_object(const sp<ProcessState>& proc, - const flat_binder_object& obj, const void* who); -void release_object(const sp<ProcessState>& proc, - const flat_binder_object& obj, const void* who); - -void flatten_binder(const sp<ProcessState>& proc, - const sp<IBinder>& binder, flat_binder_object* out); -void flatten_binder(const sp<ProcessState>& proc, - const wp<IBinder>& binder, flat_binder_object* out); -status_t unflatten_binder(const sp<ProcessState>& proc, - const flat_binder_object& flat, sp<IBinder>* out); -status_t unflatten_binder(const sp<ProcessState>& proc, - const flat_binder_object& flat, wp<IBinder>* out); - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_PARCEL_H diff --git a/include/binder/PermissionCache.h b/include/binder/PermissionCache.h deleted file mode 100644 index 1171d48..0000000 --- a/include/binder/PermissionCache.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef BINDER_PERMISSION_H -#define BINDER_PERMISSION_H - -#include <stdint.h> -#include <unistd.h> - -#include <utils/String16.h> -#include <utils/Singleton.h> - -namespace android { -// --------------------------------------------------------------------------- - -/* - * PermissionCache caches permission checks for a given uid. - * - * Currently the cache is not updated when there is a permission change, - * for instance when an application is uninstalled. - * - * IMPORTANT: for the reason stated above, only system permissions are safe - * to cache. This restriction may be lifted at a later time. - * - */ - -class PermissionCache : Singleton<PermissionCache> { - struct Entry { - String16 name; - uid_t uid; - bool granted; - inline bool operator < (const Entry& e) const { - return (uid == e.uid) ? (name < e.name) : (uid < e.uid); - } - }; - mutable Mutex mLock; - // we pool all the permission names we see, as many permissions checks - // will have identical names - SortedVector< String16 > mPermissionNamesPool; - // this is our cache per say. it stores pooled names. - SortedVector< Entry > mCache; - - // free the whole cache, but keep the permission name pool - void purge(); - - status_t check(bool* granted, - const String16& permission, uid_t uid) const; - - void cache(const String16& permission, uid_t uid, bool granted); - -public: - PermissionCache(); - - static bool checkCallingPermission(const String16& permission); - - static bool checkCallingPermission(const String16& permission, - int32_t* outPid, int32_t* outUid); - - static bool checkPermission(const String16& permission, - pid_t pid, uid_t uid); -}; - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif /* BINDER_PERMISSION_H */ diff --git a/include/binder/ProcessState.h b/include/binder/ProcessState.h deleted file mode 100644 index 9725822..0000000 --- a/include/binder/ProcessState.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_PROCESS_STATE_H -#define ANDROID_PROCESS_STATE_H - -#include <binder/IBinder.h> -#include <utils/KeyedVector.h> -#include <utils/String8.h> -#include <utils/String16.h> - -#include <utils/threads.h> - -// --------------------------------------------------------------------------- -namespace android { - -// Global variables -extern int mArgC; -extern const char* const* mArgV; -extern int mArgLen; - -class IPCThreadState; - -class ProcessState : public virtual RefBase -{ -public: - static sp<ProcessState> self(); - - void setContextObject(const sp<IBinder>& object); - sp<IBinder> getContextObject(const sp<IBinder>& caller); - - void setContextObject(const sp<IBinder>& object, - const String16& name); - sp<IBinder> getContextObject(const String16& name, - const sp<IBinder>& caller); - - void startThreadPool(); - - typedef bool (*context_check_func)(const String16& name, - const sp<IBinder>& caller, - void* userData); - - bool isContextManager(void) const; - bool becomeContextManager( - context_check_func checkFunc, - void* userData); - - sp<IBinder> getStrongProxyForHandle(int32_t handle); - wp<IBinder> getWeakProxyForHandle(int32_t handle); - void expungeHandle(int32_t handle, IBinder* binder); - - void setArgs(int argc, const char* const argv[]); - int getArgC() const; - const char* const* getArgV() const; - - void setArgV0(const char* txt); - - void spawnPooledThread(bool isMain); - -private: - friend class IPCThreadState; - - ProcessState(); - ~ProcessState(); - - ProcessState(const ProcessState& o); - ProcessState& operator=(const ProcessState& o); - - struct handle_entry { - IBinder* binder; - RefBase::weakref_type* refs; - }; - - handle_entry* lookupHandleLocked(int32_t handle); - - int mDriverFD; - void* mVMStart; - - mutable Mutex mLock; // protects everything below. - - Vector<handle_entry>mHandleToObject; - - bool mManagesContexts; - context_check_func mBinderContextCheckFunc; - void* mBinderContextUserData; - - KeyedVector<String16, sp<IBinder> > - mContexts; - - - String8 mRootDir; - bool mThreadPoolStarted; - volatile int32_t mThreadPoolSeq; -}; - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_PROCESS_STATE_H |