BpBinder -> BpHwBinder.
Test: mma
Test: croot && make
Bug: 33554989
Change-Id: I484c9e2e30f12ac3352aabecdf5b30fcf090a191
diff --git a/Android.bp b/Android.bp
index ce86186..c893507 100644
--- a/Android.bp
+++ b/Android.bp
@@ -33,7 +33,7 @@
},
srcs: [
"Binder.cpp",
- "BpBinder.cpp",
+ "BpHwBinder.cpp",
"BufferedTextOutput.cpp",
"Debug.cpp",
"IInterface.cpp",
diff --git a/Binder.cpp b/Binder.cpp
index e7701c6..88b9544 100644
--- a/Binder.cpp
+++ b/Binder.cpp
@@ -18,7 +18,7 @@
#include <atomic>
#include <utils/misc.h>
-#include <hwbinder/BpBinder.h>
+#include <hwbinder/BpHwBinder.h>
#include <hwbinder/IInterface.h>
#include <hwbinder/Parcel.h>
@@ -50,7 +50,7 @@
return NULL;
}
-BpBinder* IBinder::remoteBinder()
+BpHwBinder* IBinder::remoteBinder()
{
return NULL;
}
@@ -66,7 +66,7 @@
{
public:
Mutex mLock;
- BpBinder::ObjectManager mObjects;
+ BpHwBinder::ObjectManager mObjects;
};
// ---------------------------------------------------------------------------
diff --git a/BpBinder.cpp b/BpHwBinder.cpp
similarity index 84%
rename from BpBinder.cpp
rename to BpHwBinder.cpp
index 25e9010..c6d6fcf 100644
--- a/BpBinder.cpp
+++ b/BpHwBinder.cpp
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-#define LOG_TAG "BpBinder"
+#define LOG_TAG "BpHwBinder"
//#define LOG_NDEBUG 0
-#include <hwbinder/BpBinder.h>
+#include <hwbinder/BpHwBinder.h>
#include <hwbinder/IPCThreadState.h>
#include <utils/Log.h>
@@ -32,16 +32,16 @@
// ---------------------------------------------------------------------------
-BpBinder::ObjectManager::ObjectManager()
+BpHwBinder::ObjectManager::ObjectManager()
{
}
-BpBinder::ObjectManager::~ObjectManager()
+BpHwBinder::ObjectManager::~ObjectManager()
{
kill();
}
-void BpBinder::ObjectManager::attach(
+void BpHwBinder::ObjectManager::attach(
const void* objectID, void* object, void* cleanupCookie,
IBinder::object_cleanup_func func)
{
@@ -59,19 +59,19 @@
mObjects.add(objectID, e);
}
-void* BpBinder::ObjectManager::find(const void* objectID) const
+void* BpHwBinder::ObjectManager::find(const void* objectID) const
{
const ssize_t i = mObjects.indexOfKey(objectID);
if (i < 0) return NULL;
return mObjects.valueAt(i).object;
}
-void BpBinder::ObjectManager::detach(const void* objectID)
+void BpHwBinder::ObjectManager::detach(const void* objectID)
{
mObjects.removeItem(objectID);
}
-void BpBinder::ObjectManager::kill()
+void BpHwBinder::ObjectManager::kill()
{
const size_t N = mObjects.size();
ALOGV("Killing %zu objects in manager %p", N, this);
@@ -87,29 +87,29 @@
// ---------------------------------------------------------------------------
-BpBinder::BpBinder(int32_t handle)
+BpHwBinder::BpHwBinder(int32_t handle)
: mHandle(handle)
, mAlive(1)
, mObitsSent(0)
, mObituaries(NULL)
{
- ALOGV("Creating BpBinder %p handle %d\n", this, mHandle);
+ ALOGV("Creating BpHwBinder %p handle %d\n", this, mHandle);
extendObjectLifetime(OBJECT_LIFETIME_WEAK);
IPCThreadState::self()->incWeakHandle(handle);
}
-bool BpBinder::isDescriptorCached() const {
+bool BpHwBinder::isDescriptorCached() const {
Mutex::Autolock _l(mLock);
return mDescriptorCache.size() ? true : false;
}
-const String16& BpBinder::getInterfaceDescriptor() const
+const String16& BpHwBinder::getInterfaceDescriptor() const
{
if (isDescriptorCached() == false) {
Parcel send, reply;
// do the IPC without a lock held.
- status_t err = const_cast<BpBinder*>(this)->transact(
+ status_t err = const_cast<BpHwBinder*>(this)->transact(
INTERFACE_TRANSACTION, send, &reply);
if (err == NO_ERROR) {
String16 res(reply.readString16());
@@ -128,12 +128,12 @@
return mDescriptorCache;
}
-bool BpBinder::isBinderAlive() const
+bool BpHwBinder::isBinderAlive() const
{
return mAlive != 0;
}
-status_t BpBinder::pingBinder()
+status_t BpHwBinder::pingBinder()
{
Parcel send;
Parcel reply;
@@ -143,7 +143,7 @@
return (status_t)reply.readInt32();
}
-status_t BpBinder::dump(int fd, const Vector<String16>& args)
+status_t BpHwBinder::dump(int fd, const Vector<String16>& args)
{
Parcel send;
Parcel reply;
@@ -157,7 +157,7 @@
return err;
}
-status_t BpBinder::transact(
+status_t BpHwBinder::transact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags, TransactCallback /*callback*/)
{
// Once a binder has died, it will never come back to life.
@@ -171,7 +171,7 @@
return DEAD_OBJECT;
}
-status_t BpBinder::linkToDeath(
+status_t BpHwBinder::linkToDeath(
const sp<DeathRecipient>& recipient, void* cookie, uint32_t flags)
{
Obituary ob;
@@ -205,7 +205,7 @@
return DEAD_OBJECT;
}
-status_t BpBinder::unlinkToDeath(
+status_t BpHwBinder::unlinkToDeath(
const wp<DeathRecipient>& recipient, void* cookie, uint32_t flags,
wp<DeathRecipient>* outRecipient)
{
@@ -240,7 +240,7 @@
return NAME_NOT_FOUND;
}
-void BpBinder::sendObituary()
+void BpHwBinder::sendObituary()
{
ALOGV("Sending obituary for proxy %p handle %d, mObitsSent=%s\n",
this, mHandle, mObitsSent ? "true" : "false");
@@ -273,7 +273,7 @@
}
}
-void BpBinder::reportOneDeath(const Obituary& obit)
+void BpHwBinder::reportOneDeath(const Obituary& obit)
{
sp<DeathRecipient> recipient = obit.recipient.promote();
ALOGV("Reporting death to recipient: %p\n", recipient.get());
@@ -283,7 +283,7 @@
}
-void BpBinder::attachObject(
+void BpHwBinder::attachObject(
const void* objectID, void* object, void* cleanupCookie,
object_cleanup_func func)
{
@@ -292,26 +292,26 @@
mObjects.attach(objectID, object, cleanupCookie, func);
}
-void* BpBinder::findObject(const void* objectID) const
+void* BpHwBinder::findObject(const void* objectID) const
{
AutoMutex _l(mLock);
return mObjects.find(objectID);
}
-void BpBinder::detachObject(const void* objectID)
+void BpHwBinder::detachObject(const void* objectID)
{
AutoMutex _l(mLock);
mObjects.detach(objectID);
}
-BpBinder* BpBinder::remoteBinder()
+BpHwBinder* BpHwBinder::remoteBinder()
{
return this;
}
-BpBinder::~BpBinder()
+BpHwBinder::~BpHwBinder()
{
- ALOGV("Destroying BpBinder %p handle %d\n", this, mHandle);
+ ALOGV("Destroying BpHwBinder %p handle %d\n", this, mHandle);
IPCThreadState* ipc = IPCThreadState::self();
@@ -336,16 +336,16 @@
}
}
-void BpBinder::onFirstRef()
+void BpHwBinder::onFirstRef()
{
- ALOGV("onFirstRef BpBinder %p handle %d\n", this, mHandle);
+ ALOGV("onFirstRef BpHwBinder %p handle %d\n", this, mHandle);
IPCThreadState* ipc = IPCThreadState::self();
if (ipc) ipc->incStrongHandle(mHandle);
}
-void BpBinder::onLastStrongRef(const void* /*id*/)
+void BpHwBinder::onLastStrongRef(const void* /*id*/)
{
- ALOGV("onLastStrongRef BpBinder %p handle %d\n", this, mHandle);
+ ALOGV("onLastStrongRef BpHwBinder %p handle %d\n", this, mHandle);
IF_ALOGV() {
printRefs();
}
@@ -353,9 +353,9 @@
if (ipc) ipc->decStrongHandle(mHandle);
}
-bool BpBinder::onIncStrongAttempted(uint32_t /*flags*/, const void* /*id*/)
+bool BpHwBinder::onIncStrongAttempted(uint32_t /*flags*/, const void* /*id*/)
{
- ALOGV("onIncStrongAttempted BpBinder %p handle %d\n", this, mHandle);
+ ALOGV("onIncStrongAttempted BpHwBinder %p handle %d\n", this, mHandle);
IPCThreadState* ipc = IPCThreadState::self();
return ipc ? ipc->attemptIncStrongHandle(mHandle) == NO_ERROR : false;
}
diff --git a/IPCThreadState.cpp b/IPCThreadState.cpp
index 4477298..c24ce21 100644
--- a/IPCThreadState.cpp
+++ b/IPCThreadState.cpp
@@ -19,7 +19,7 @@
#include <hwbinder/IPCThreadState.h>
#include <hwbinder/Binder.h>
-#include <hwbinder/BpBinder.h>
+#include <hwbinder/BpHwBinder.h>
#include <hwbinder/TextOutput.h>
#include <hwbinder/binder_kernel.h>
@@ -685,7 +685,7 @@
self()->mProcess->expungeHandle(handle, binder);
}
-status_t IPCThreadState::requestDeathNotification(int32_t handle, BpBinder* proxy)
+status_t IPCThreadState::requestDeathNotification(int32_t handle, BpHwBinder* proxy)
{
mOut.writeInt32(BC_REQUEST_DEATH_NOTIFICATION);
mOut.writeInt32((int32_t)handle);
@@ -693,7 +693,7 @@
return NO_ERROR;
}
-status_t IPCThreadState::clearDeathNotification(int32_t handle, BpBinder* proxy)
+status_t IPCThreadState::clearDeathNotification(int32_t handle, BpHwBinder* proxy)
{
mOut.writeInt32(BC_CLEAR_DEATH_NOTIFICATION);
mOut.writeInt32((int32_t)handle);
@@ -1164,7 +1164,7 @@
case BR_DEAD_BINDER:
{
- BpBinder *proxy = (BpBinder*)mIn.readPointer();
+ BpHwBinder *proxy = (BpHwBinder*)mIn.readPointer();
proxy->sendObituary();
mOut.writeInt32(BC_DEAD_BINDER_DONE);
mOut.writePointer((uintptr_t)proxy);
@@ -1172,7 +1172,7 @@
case BR_CLEAR_DEATH_NOTIFICATION_DONE:
{
- BpBinder *proxy = (BpBinder*)mIn.readPointer();
+ BpHwBinder *proxy = (BpHwBinder*)mIn.readPointer();
proxy->getWeakRefs()->decWeak(proxy);
} break;
diff --git a/Parcel.cpp b/Parcel.cpp
index e9ab05d..edfe2d9 100644
--- a/Parcel.cpp
+++ b/Parcel.cpp
@@ -31,7 +31,7 @@
#include <unistd.h>
#include <hwbinder/Binder.h>
-#include <hwbinder/BpBinder.h>
+#include <hwbinder/BpHwBinder.h>
#include <hwbinder/IPCThreadState.h>
#include <hwbinder/Parcel.h>
#include <hwbinder/ProcessState.h>
@@ -239,7 +239,7 @@
if (binder != NULL) {
IBinder *local = binder->localBinder();
if (!local) {
- BpBinder *proxy = binder->remoteBinder();
+ BpHwBinder *proxy = binder->remoteBinder();
if (proxy == NULL) {
ALOGE("null proxy");
}
@@ -273,7 +273,7 @@
if (real != NULL) {
IBinder *local = real->localBinder();
if (!local) {
- BpBinder *proxy = real->remoteBinder();
+ BpHwBinder *proxy = real->remoteBinder();
if (proxy == NULL) {
ALOGE("null proxy");
}
@@ -312,7 +312,7 @@
}
inline static status_t finish_unflatten_binder(
- BpBinder* /*proxy*/, const flat_binder_object& /*flat*/,
+ BpHwBinder* /*proxy*/, const flat_binder_object& /*flat*/,
const Parcel& /*in*/)
{
return NO_ERROR;
@@ -331,7 +331,7 @@
case BINDER_TYPE_HANDLE:
*out = proc->getStrongProxyForHandle(flat->handle);
return finish_unflatten_binder(
- static_cast<BpBinder*>(out->get()), *flat, in);
+ static_cast<BpHwBinder*>(out->get()), *flat, in);
}
}
return BAD_TYPE;
@@ -360,7 +360,7 @@
case BINDER_TYPE_WEAK_HANDLE:
*out = proc->getWeakProxyForHandle(flat->handle);
return finish_unflatten_binder(
- static_cast<BpBinder*>(out->unsafe_get()), *flat, in);
+ static_cast<BpHwBinder*>(out->unsafe_get()), *flat, in);
}
}
return BAD_TYPE;
diff --git a/ProcessState.cpp b/ProcessState.cpp
index 5b7a9ce..3c369f7 100644
--- a/ProcessState.cpp
+++ b/ProcessState.cpp
@@ -19,7 +19,7 @@
#include <hwbinder/ProcessState.h>
#include <utils/Atomic.h>
-#include <hwbinder/BpBinder.h>
+#include <hwbinder/BpHwBinder.h>
#include <hwbinder/IPCThreadState.h>
#include <utils/Log.h>
#include <utils/String8.h>
@@ -54,14 +54,14 @@
: mIsMain(isMain)
{
}
-
+
protected:
virtual bool threadLoop()
{
IPCThreadState::self()->joinThreadPool(mIsMain);
return false;
}
-
+
const bool mIsMain;
};
@@ -97,9 +97,9 @@
sp<IBinder> object(
mContexts.indexOfKey(name) >= 0 ? mContexts.valueFor(name) : NULL);
mLock.unlock();
-
+
//printf("Getting context object %s for %p\n", String8(name).string(), caller.get());
-
+
if (object != NULL) return object;
// Don't attempt to retrieve contexts if we manage them
@@ -108,7 +108,7 @@
String8(name).string());
return NULL;
}
-
+
IPCThreadState* ipc = IPCThreadState::self();
{
Parcel data, reply;
@@ -120,9 +120,9 @@
object = reply.readStrongBinder();
}
}
-
+
ipc->flushCommands();
-
+
if (object != NULL) setContextObject(object, name);
return object;
}
@@ -185,7 +185,7 @@
handle_entry* e = lookupHandleLocked(handle);
if (e != NULL) {
- // We need to create a new BpBinder if there isn't currently one, OR we
+ // We need to create a new BpHwBinder if there isn't currently one, OR we
// are unable to acquire a weak reference on this current one. See comment
// in getWeakProxyForHandle() for more info about this.
IBinder* b = e->binder;
@@ -193,11 +193,11 @@
if (handle == 0) {
// Special case for context manager...
// The context manager is the only object for which we create
- // a BpBinder proxy without already holding a reference.
+ // a BpHwBinder proxy without already holding a reference.
// Perform a dummy transaction to ensure the context manager
// is registered before we create the first local reference
- // to it (which will occur when creating the BpBinder).
- // If a local reference is created for the BpBinder when the
+ // to it (which will occur when creating the BpHwBinder).
+ // If a local reference is created for the BpHwBinder when the
// context manager is not present, the driver will fail to
// provide a reference to the context manager, but the
// driver API does not return status.
@@ -217,7 +217,7 @@
return NULL;
}
- b = new BpBinder(handle);
+ b = new BpHwBinder(handle);
e->binder = b;
if (b) e->refs = b->getWeakRefs();
result = b;
@@ -241,17 +241,17 @@
handle_entry* e = lookupHandleLocked(handle);
- if (e != NULL) {
- // We need to create a new BpBinder if there isn't currently one, OR we
+ if (e != NULL) {
+ // We need to create a new BpHwBinder if there isn't currently one, OR we
// are unable to acquire a weak reference on this current one. The
- // attemptIncWeak() is safe because we know the BpBinder destructor will always
+ // attemptIncWeak() is safe because we know the BpHwBinder destructor will always
// call expungeHandle(), which acquires the same lock we are holding now.
// We need to do this because there is a race condition between someone
- // releasing a reference on this BpBinder, and a new reference on its handle
+ // releasing a reference on this BpHwBinder, and a new reference on its handle
// arriving from the driver.
IBinder* b = e->binder;
if (b == NULL || !e->refs->attemptIncWeak(this)) {
- b = new BpBinder(handle);
+ b = new BpHwBinder(handle);
result = b;
e->binder = b;
if (b) e->refs = b->getWeakRefs();
@@ -267,10 +267,10 @@
void ProcessState::expungeHandle(int32_t handle, IBinder* binder)
{
AutoMutex _l(mLock);
-
+
handle_entry* e = lookupHandleLocked(handle);
- // This handle may have already been replaced with a new BpBinder
+ // This handle may have already been replaced with a new BpHwBinder
// (if someone failed the AttemptIncWeak() above); we don't want
// to overwrite it.
if (e && e->binder == binder) e->binder = NULL;
@@ -386,6 +386,6 @@
}
mDriverFD = -1;
}
-
+
}; // namespace hardware
}; // namespace android
diff --git a/include/hwbinder/BpBinder.h b/include/hwbinder/BpHwBinder.h
similarity index 93%
rename from include/hwbinder/BpBinder.h
rename to include/hwbinder/BpHwBinder.h
index ccd1f0d..a49f232 100644
--- a/include/hwbinder/BpBinder.h
+++ b/include/hwbinder/BpHwBinder.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef ANDROID_HARDWARE_BPBINDER_H
-#define ANDROID_HARDWARE_BPBINDER_H
+#ifndef ANDROID_HARDWARE_BPHWBINDER_H
+#define ANDROID_HARDWARE_BPHWBINDER_H
#include <hwbinder/IBinder.h>
#include <utils/KeyedVector.h>
@@ -25,10 +25,10 @@
namespace android {
namespace hardware {
-class BpBinder : public IBinder
+class BpHwBinder : public IBinder
{
public:
- BpBinder(int32_t handle);
+ BpHwBinder(int32_t handle);
inline int32_t handle() const { return mHandle; }
@@ -58,7 +58,7 @@
virtual void* findObject(const void* objectID) const;
virtual void detachObject(const void* objectID);
- virtual BpBinder* remoteBinder();
+ virtual BpHwBinder* remoteBinder();
status_t setConstantData(const void* data, size_t size);
void sendObituary();
@@ -93,7 +93,7 @@
};
protected:
- virtual ~BpBinder();
+ virtual ~BpHwBinder();
virtual void onFirstRef();
virtual void onLastStrongRef(const void* id);
virtual bool onIncStrongAttempted(uint32_t flags, const void* id);
@@ -124,4 +124,4 @@
// ---------------------------------------------------------------------------
-#endif // ANDROID_HARDWARE_BPBINDER_H
+#endif // ANDROID_HARDWARE_BPHWBINDER_H
diff --git a/include/hwbinder/IBinder.h b/include/hwbinder/IBinder.h
index dc04472..28a2b52 100644
--- a/include/hwbinder/IBinder.h
+++ b/include/hwbinder/IBinder.h
@@ -37,7 +37,7 @@
namespace hardware {
class BHwBinder;
-class BpBinder;
+class BpHwBinder;
class IInterface;
class Parcel;
@@ -154,7 +154,7 @@
virtual void detachObject(const void* objectID) = 0;
virtual BHwBinder* localBinder();
- virtual BpBinder* remoteBinder();
+ virtual BpHwBinder* remoteBinder();
protected:
virtual ~IBinder();
diff --git a/include/hwbinder/IPCThreadState.h b/include/hwbinder/IPCThreadState.h
index 3f45217..fde1562 100644
--- a/include/hwbinder/IPCThreadState.h
+++ b/include/hwbinder/IPCThreadState.h
@@ -72,9 +72,9 @@
status_t attemptIncStrongHandle(int32_t handle);
static void expungeHandle(int32_t handle, IBinder* binder);
status_t requestDeathNotification( int32_t handle,
- BpBinder* proxy);
+ BpHwBinder* proxy);
status_t clearDeathNotification( int32_t handle,
- BpBinder* proxy);
+ BpHwBinder* proxy);
static void shutdown();