BBinder -> BHwBinder.
Test: mma
Test: croot && make
Bug: 33554989
Change-Id: Ia1356012d0cc1aef56884bfbd1a6af2a2504ab23
diff --git a/IPCThreadState.cpp b/IPCThreadState.cpp
index d3bc70d..4477298 100644
--- a/IPCThreadState.cpp
+++ b/IPCThreadState.cpp
@@ -45,10 +45,10 @@
#define IF_LOG_TRANSACTIONS() if (false)
#define IF_LOG_COMMANDS() if (false)
-#define LOG_REMOTEREFS(...)
+#define LOG_REMOTEREFS(...)
#define IF_LOG_REMOTEREFS() if (false)
-#define LOG_THREADPOOL(...)
-#define LOG_ONEWAY(...)
+#define LOG_THREADPOOL(...)
+#define LOG_ONEWAY(...)
#else
@@ -150,7 +150,7 @@
return cmd;
}
out << kReturnStrings[cmdIndex];
-
+
switch (code) {
case BR_TRANSACTION:
case BR_REPLY: {
@@ -158,12 +158,12 @@
cmd = (const int32_t *)printBinderTransactionData(out, cmd);
out << dedent;
} break;
-
+
case BR_ACQUIRE_RESULT: {
const int32_t res = *cmd++;
out << ": " << res << (res ? " (SUCCESS)" : " (FAILURE)");
} break;
-
+
case BR_INCREFS:
case BR_ACQUIRE:
case BR_RELEASE:
@@ -172,7 +172,7 @@
const int32_t c = *cmd++;
out << ": target=" << (void*)(long)b << " (cookie " << (void*)(long)c << ")";
} break;
-
+
case BR_ATTEMPT_ACQUIRE: {
const int32_t p = *cmd++;
const int32_t b = *cmd++;
@@ -192,7 +192,7 @@
// BR_TRANSACTION_COMPLETE, BR_FINISHED
break;
}
-
+
out << endl;
return cmd;
}
@@ -217,17 +217,17 @@
cmd = (const int32_t *)printBinderTransactionData(out, cmd);
out << dedent;
} break;
-
+
case BC_ACQUIRE_RESULT: {
const int32_t res = *cmd++;
out << ": " << res << (res ? " (SUCCESS)" : " (FAILURE)");
} break;
-
+
case BC_FREE_BUFFER: {
const int32_t buf = *cmd++;
out << ": buffer=" << (void*)(long)buf;
} break;
-
+
case BC_INCREFS:
case BC_ACQUIRE:
case BC_RELEASE:
@@ -235,20 +235,20 @@
const int32_t d = *cmd++;
out << ": desc=" << d;
} break;
-
+
case BC_INCREFS_DONE:
case BC_ACQUIRE_DONE: {
const int32_t b = *cmd++;
const int32_t c = *cmd++;
out << ": target=" << (void*)(long)b << " (cookie " << (void*)(long)c << ")";
} break;
-
+
case BC_ATTEMPT_ACQUIRE: {
const int32_t p = *cmd++;
const int32_t d = *cmd++;
out << ": desc=" << d << ", pri=" << p;
} break;
-
+
case BC_REQUEST_DEATH_NOTIFICATION:
case BC_CLEAR_DEATH_NOTIFICATION: {
const int32_t h = *cmd++;
@@ -266,7 +266,7 @@
// BC_EXIT_LOOPER
break;
}
-
+
out << endl;
return cmd;
}
@@ -286,12 +286,12 @@
if (st) return st;
return new IPCThreadState;
}
-
+
if (gShutdown) {
ALOGW("Calling IPCThreadState::self() during shutdown is dangerous, expect a crash.\n");
return NULL;
}
-
+
pthread_mutex_lock(&gTLSMutex);
if (!gHaveTLS) {
int key_create_value = pthread_key_create(&gTLS, threadDestructor);
@@ -320,7 +320,7 @@
void IPCThreadState::shutdown()
{
gShutdown = true;
-
+
if (gHaveTLS) {
// XXX Need to wait for all thread pool threads to exit!
IPCThreadState* st = (IPCThreadState*)pthread_getspecific(gTLS);
@@ -486,7 +486,7 @@
numPending = mPendingStrongDerefs.size();
if (numPending > 0) {
for (size_t i = 0; i < numPending; i++) {
- BBinder* obj = mPendingStrongDerefs[i];
+ BHwBinder* obj = mPendingStrongDerefs[i];
obj->decStrong(mProcess.get());
}
mPendingStrongDerefs.clear();
@@ -499,12 +499,12 @@
LOG_THREADPOOL("**** THREAD %p (PID %d) IS JOINING THE THREAD POOL\n", (void*)pthread_self(), getpid());
mOut.writeInt32(isMain ? BC_ENTER_LOOPER : BC_REGISTER_LOOPER);
-
+
// This thread may have been spawned by a thread that was in the background
// scheduling group, so first we will make sure it is in the foreground
// one to avoid performing an initial transaction in the background.
set_sched_policy(mMyThreadId, SP_FOREGROUND);
-
+
status_t result;
do {
processPendingDerefs();
@@ -516,7 +516,7 @@
mProcess->mDriverFD, result);
abort();
}
-
+
// Let this thread exit the thread pool if it is no longer
// needed and it is not the main process thread.
if(result == TIMED_OUT && !isMain) {
@@ -526,7 +526,7 @@
LOG_THREADPOOL("**** THREAD %p (PID %d) IS LEAVING THE THREAD POOL err=%d\n",
(void*)pthread_self(), getpid(), result);
-
+
mOut.writeInt32(BC_EXIT_LOOPER);
talkWithDriver(false);
}
@@ -578,18 +578,18 @@
<< handle << " / code " << TypeCode(code) << ": "
<< indent << data << dedent << endl;
}
-
+
if (err == NO_ERROR) {
LOG_ONEWAY(">>>> SEND from pid %d uid %d %s", getpid(), getuid(),
(flags & TF_ONE_WAY) == 0 ? "READ REPLY" : "ONE WAY");
err = writeTransactionData(BC_TRANSACTION_SG, flags, handle, code, data, NULL);
}
-
+
if (err != NO_ERROR) {
if (reply) reply->setError(err);
return (mLastError = err);
}
-
+
if ((flags & TF_ONE_WAY) == 0) {
#if 0
if (code == 4) { // relayout
@@ -611,7 +611,7 @@
ALOGI("<<<<<< RETURNING transaction %d", code);
}
#endif
-
+
IF_LOG_TRANSACTIONS() {
alog << "BR_REPLY thr " << (void*)pthread_self() << " / hand "
<< handle << ": ";
@@ -621,7 +621,7 @@
} else {
err = waitForResponse(NULL, NULL);
}
-
+
return err;
}
@@ -661,14 +661,14 @@
mOut.writeInt32(0); // xxx was thread priority
mOut.writeInt32(handle);
status_t result = UNKNOWN_ERROR;
-
+
waitForResponse(NULL, &result);
-
+
#if LOG_REFCOUNTS
printf("IPCThreadState::attemptIncStrongHandle(%ld) = %s\n",
handle, result == NO_ERROR ? "SUCCESS" : "FAILURE");
#endif
-
+
return result;
#else
(void)handle;
@@ -723,7 +723,7 @@
status_t statusBuffer;
err = writeTransactionData(BC_REPLY_SG, flags, -1, 0, reply, &statusBuffer);
if (err < NO_ERROR) return err;
-
+
return waitForResponse(NULL, NULL);
}
@@ -737,9 +737,9 @@
err = mIn.errorCheck();
if (err < NO_ERROR) break;
if (mIn.dataAvail() == 0) continue;
-
+
cmd = (uint32_t)mIn.readInt32();
-
+
IF_LOG_COMMANDS() {
alog << "Processing waitForResponse Command: "
<< getReturnString(cmd) << endl;
@@ -749,7 +749,7 @@
case BR_TRANSACTION_COMPLETE:
if (!reply && !acquireResult) goto finish;
break;
-
+
case BR_DEAD_REPLY:
err = DEAD_OBJECT;
goto finish;
@@ -757,7 +757,7 @@
case BR_FAILED_REPLY:
err = FAILED_TRANSACTION;
goto finish;
-
+
case BR_ACQUIRE_RESULT:
{
ALOG_ASSERT(acquireResult != NULL, "Unexpected brACQUIRE_RESULT");
@@ -766,7 +766,7 @@
*acquireResult = result ? NO_ERROR : INVALID_OPERATION;
}
goto finish;
-
+
case BR_REPLY:
{
binder_transaction_data tr;
@@ -814,7 +814,7 @@
if (reply) reply->setError(err);
mLastError = err;
}
-
+
return err;
}
@@ -823,17 +823,17 @@
if (mProcess->mDriverFD <= 0) {
return -EBADF;
}
-
+
binder_write_read bwr;
-
+
// Is the read buffer empty?
const bool needRead = mIn.dataPosition() >= mIn.dataSize();
-
+
// We don't want to write anything if we are still reading
// from data left in the input buffer and the caller
// has requested to read the next data.
const size_t outAvail = (!doReceive || needRead) ? mOut.dataSize() : 0;
-
+
bwr.write_size = outAvail;
bwr.write_buffer = (uintptr_t)mOut.data();
@@ -858,7 +858,7 @@
alog << "Size of receive buffer: " << bwr.read_size
<< ", needRead: " << needRead << ", doReceive: " << doReceive << endl;
}
-
+
// Return immediately if there is nothing to do.
if ((bwr.write_size == 0) && (bwr.read_size == 0)) return NO_ERROR;
@@ -913,7 +913,7 @@
}
return NO_ERROR;
}
-
+
return err;
}
@@ -928,7 +928,7 @@
tr_sg.tr.cookie = 0;
tr_sg.tr.sender_pid = 0;
tr_sg.tr.sender_euid = 0;
-
+
const status_t err = data.errorCheck();
if (err == NO_ERROR) {
tr_sg.tr.data_size = data.ipcDataSize();
@@ -947,34 +947,34 @@
} else {
return (mLastError = err);
}
-
+
mOut.writeInt32(cmd);
mOut.write(&tr_sg, sizeof(tr_sg));
-
+
return NO_ERROR;
}
-void IPCThreadState::setTheContextObject(sp<BBinder> obj)
+void IPCThreadState::setTheContextObject(sp<BHwBinder> obj)
{
mContextObject = obj;
}
status_t IPCThreadState::executeCommand(int32_t cmd)
{
- BBinder* obj;
+ BHwBinder* obj;
RefBase::weakref_type* refs;
status_t result = NO_ERROR;
switch ((uint32_t)cmd) {
case BR_ERROR:
result = mIn.readInt32();
break;
-
+
case BR_OK:
break;
-
+
case BR_ACQUIRE:
refs = (RefBase::weakref_type*)mIn.readPointer();
- obj = (BBinder*)mIn.readPointer();
+ obj = (BHwBinder*)mIn.readPointer();
ALOG_ASSERT(refs->refBase() == obj,
"BR_ACQUIRE: object %p does not match cookie %p (expected %p)",
refs, obj, refs->refBase());
@@ -987,10 +987,10 @@
mOut.writePointer((uintptr_t)refs);
mOut.writePointer((uintptr_t)obj);
break;
-
+
case BR_RELEASE:
refs = (RefBase::weakref_type*)mIn.readPointer();
- obj = (BBinder*)mIn.readPointer();
+ obj = (BHwBinder*)mIn.readPointer();
ALOG_ASSERT(refs->refBase() == obj,
"BR_RELEASE: object %p does not match cookie %p (expected %p)",
refs, obj, refs->refBase());
@@ -1000,43 +1000,43 @@
}
mPendingStrongDerefs.push(obj);
break;
-
+
case BR_INCREFS:
refs = (RefBase::weakref_type*)mIn.readPointer();
- obj = (BBinder*)mIn.readPointer();
+ obj = (BHwBinder*)mIn.readPointer();
refs->incWeak(mProcess.get());
mOut.writeInt32(BC_INCREFS_DONE);
mOut.writePointer((uintptr_t)refs);
mOut.writePointer((uintptr_t)obj);
break;
-
+
case BR_DECREFS:
refs = (RefBase::weakref_type*)mIn.readPointer();
- obj = (BBinder*)mIn.readPointer();
+ obj = (BHwBinder*)mIn.readPointer();
// NOTE: This assertion is not valid, because the object may no
- // longer exist (thus the (BBinder*)cast above resulting in a different
+ // longer exist (thus the (BHwBinder*)cast above resulting in a different
// memory address).
//ALOG_ASSERT(refs->refBase() == obj,
// "BR_DECREFS: object %p does not match cookie %p (expected %p)",
// refs, obj, refs->refBase());
mPendingWeakDerefs.push(refs);
break;
-
+
case BR_ATTEMPT_ACQUIRE:
refs = (RefBase::weakref_type*)mIn.readPointer();
- obj = (BBinder*)mIn.readPointer();
-
+ obj = (BHwBinder*)mIn.readPointer();
+
{
const bool success = refs->attemptIncStrong(mProcess.get());
ALOG_ASSERT(success && refs->refBase() == obj,
"BR_ATTEMPT_ACQUIRE: object %p does not match cookie %p (expected %p)",
refs, obj, refs->refBase());
-
+
mOut.writeInt32(BC_ACQUIRE_RESULT);
mOut.writeInt32((int32_t)success);
}
break;
-
+
case BR_TRANSACTION:
{
binder_transaction_data tr;
@@ -1044,14 +1044,14 @@
ALOG_ASSERT(result == NO_ERROR,
"Not enough command data for brTRANSACTION");
if (result != NO_ERROR) break;
-
+
Parcel buffer;
buffer.ipcSetDataReference(
reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
tr.data_size,
reinterpret_cast<const binder_size_t*>(tr.data.ptr.offsets),
tr.offsets_size/sizeof(binder_size_t), freeBuffer, this);
-
+
const pid_t origPid = mCallingPid;
const uid_t origUid = mCallingUid;
const int32_t origStrictModePolicy = mStrictModePolicy;
@@ -1117,9 +1117,9 @@
// safely acquire a strong reference before doing anything else with it.
if (reinterpret_cast<RefBase::weakref_type*>(
tr.target.ptr)->attemptIncStrong(this)) {
- error = reinterpret_cast<BBinder*>(tr.cookie)->transact(tr.code, buffer,
+ error = reinterpret_cast<BHwBinder*>(tr.cookie)->transact(tr.code, buffer,
&reply, tr.flags, reply_callback);
- reinterpret_cast<BBinder*>(tr.cookie)->decStrong(this);
+ reinterpret_cast<BHwBinder*>(tr.cookie)->decStrong(this);
} else {
error = UNKNOWN_TRANSACTION;
}
@@ -1148,7 +1148,7 @@
//ALOGI("<<<< TRANSACT from pid %d restore pid %d uid %d\n",
// mCallingPid, origPid, origUid);
-
+
mCallingPid = origPid;
mCallingUid = origUid;
mStrictModePolicy = origStrictModePolicy;
@@ -1158,10 +1158,10 @@
alog << "BC_REPLY thr " << (void*)pthread_self() << " / obj "
<< tr.target.ptr << ": " << indent << reply << dedent << endl;
}
-
+
}
break;
-
+
case BR_DEAD_BINDER:
{
BpBinder *proxy = (BpBinder*)mIn.readPointer();
@@ -1169,24 +1169,24 @@
mOut.writeInt32(BC_DEAD_BINDER_DONE);
mOut.writePointer((uintptr_t)proxy);
} break;
-
+
case BR_CLEAR_DEATH_NOTIFICATION_DONE:
{
BpBinder *proxy = (BpBinder*)mIn.readPointer();
proxy->getWeakRefs()->decWeak(proxy);
} break;
-
+
case BR_FINISHED:
result = TIMED_OUT;
break;
-
+
case BR_NOOP:
break;
-
+
case BR_SPAWN_LOOPER:
mProcess->spawnPooledThread(false);
break;
-
+
default:
printf("*** BAD COMMAND %d received from Binder driver\n", cmd);
result = UNKNOWN_ERROR;
@@ -1196,7 +1196,7 @@
if (result != NO_ERROR) {
mLastError = result;
}
-
+
return result;
}