const sp<IBinder>& binder, Parcel* out)
{
flat_binder_object obj;
-
+
obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
if (binder != NULL) {
IBinder *local = binder->localBinder();
obj.binder = 0;
obj.cookie = 0;
}
-
+
return finish_flatten_binder(binder, obj, out);
}
const wp<IBinder>& binder, Parcel* out)
{
flat_binder_object obj;
-
+
obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
if (binder != NULL) {
sp<IBinder> real = binder.promote();
}
return finish_flatten_binder(real, obj, out);
}
-
+
// XXX How to deal? In order to flatten the given binder,
// we need to probe it for information, which requires a primary
// reference... but we don't have one.
obj.binder = 0;
obj.cookie = 0;
return finish_flatten_binder(NULL, obj, out);
-
+
} else {
obj.type = BINDER_TYPE_BINDER;
obj.binder = 0;
{
return NO_ERROR;
}
-
+
status_t unflatten_binder(const sp<ProcessState>& proc,
const Parcel& in, sp<IBinder>* out)
{
const flat_binder_object* flat = in.readObject(false);
-
+
if (flat) {
switch (flat->type) {
case BINDER_TYPE_BINDER:
*out = proc->getStrongProxyForHandle(flat->handle);
return finish_unflatten_binder(
static_cast<BpBinder*>(out->get()), *flat, in);
- }
+ }
}
return BAD_TYPE;
}
const Parcel& in, wp<IBinder>* out)
{
const flat_binder_object* flat = in.readObject(false);
-
+
if (flat) {
switch (flat->type) {
case BINDER_TYPE_BINDER:
err = continueWrite(size);
if (err == NO_ERROR) {
mDataSize = size;
- ALOGV("setDataSize Setting data size of %p to %d\n", this, mDataSize);
+ ALOGV("setDataSize Setting data size of %p to %zu", this, mDataSize);
}
return err;
}
mObjects = objects;
mObjectsCapacity = newSize;
}
-
+
// append and acquire objects
int idx = mObjectsSize;
for (int i = firstIndex; i <= lastIndex; i++) {
if (str == interface) {
return true;
} else {
- ALOGW("**** enforceInterface() expected '%s' but read '%s'\n",
+ ALOGW("**** enforceInterface() expected '%s' but read '%s'",
String8(interface).string(), String8(str).string());
return false;
}
{
//printf("Finish write of %d\n", len);
mDataPos += len;
- ALOGV("finishWrite Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("finishWrite Setting data pos of %p to %zu", this, mDataPos);
if (mDataPos > mDataSize) {
mDataSize = mDataPos;
- ALOGV("finishWrite Setting data size of %p to %d\n", this, mDataSize);
+ ALOGV("finishWrite Setting data size of %p to %zu", this, mDataSize);
}
//printf("New pos=%d, size=%d\n", mDataPos, mDataSize);
return NO_ERROR;
status_t Parcel::writeString16(const char16_t* str, size_t len)
{
if (str == NULL) return writeInt32(-1);
-
+
status_t err = writeInt32(len);
if (err == NO_ERROR) {
len *= sizeof(char16_t);
if (enoughData && enoughObjects) {
restart_write:
*reinterpret_cast<flat_binder_object*>(mData+mDataPos) = val;
-
+
// Need to write meta-data?
if (nullMetaData || val.binder != 0) {
mObjects[mObjectsSize] = mDataPos;
acquire_object(ProcessState::self(), val, this);
mObjectsSize++;
}
-
+
// remember if it's a file descriptor
if (val.type == BINDER_TYPE_FD) {
if (!mAllowFds) {
mObjects = objects;
mObjectsCapacity = newSize;
}
-
+
goto restart_write;
}
&& len <= PAD_SIZE(len)) {
memcpy(outData, mData+mDataPos, len);
mDataPos += PAD_SIZE(len);
- ALOGV("read Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("read Setting data pos of %p to %zu", this, mDataPos);
return NO_ERROR;
}
return NOT_ENOUGH_DATA;
&& len <= PAD_SIZE(len)) {
const void* data = mData+mDataPos;
mDataPos += PAD_SIZE(len);
- ALOGV("readInplace Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("readInplace Setting data pos of %p to %zu", this, mDataPos);
return data;
}
return NULL;
if (eos) {
const size_t len = eos - str;
mDataPos += PAD_SIZE(len+1);
- ALOGV("readCString Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("readCString Setting data pos of %p to %zu", this, mDataPos);
return str;
}
}
if (flat) {
switch (flat->type) {
case BINDER_TYPE_FD:
- //ALOGI("Returning file descriptor %ld from parcel %p\n", flat->handle, this);
+ //ALOGI("Returning file descriptor %ld from parcel %p", flat->handle, this);
return flat->handle;
- }
+ }
}
return BAD_TYPE;
}
fds[i] = dup(this->readFileDescriptor());
if (fds[i] < 0) {
err = BAD_VALUE;
- ALOGE("dup() failed in Parcel::read, i is %d, fds[i] is %d, fd_count is %d, error: %s",
+ ALOGE("dup() failed in Parcel::read, i is %zu, fds[i] is %d, fd_count is %zu, error: %s",
i, fds[i], fd_count, strerror(errno));
}
}
// When transferring a NULL object, we don't write it into
// the object list, so we don't want to check for it when
// reading.
- ALOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("readObject Setting data pos of %p to %zu", this, mDataPos);
return obj;
}
-
+
// Ensure that this object is valid...
binder_size_t* const OBJS = mObjects;
const size_t N = mObjectsSize;
size_t opos = mNextObjectHint;
-
+
if (N > 0) {
- ALOGV("Parcel %p looking for obj at %d, hint=%d\n",
+ ALOGV("Parcel %p looking for obj at %zu, hint=%zu",
this, DPOS, opos);
-
+
// Start at the current hint position, looking for an object at
// the current data position.
if (opos < N) {
}
if (OBJS[opos] == DPOS) {
// Found it!
- ALOGV("Parcel found obj %d at index %d with forward search",
+ ALOGV("Parcel %p found obj %zu at index %zu with forward search",
this, DPOS, opos);
mNextObjectHint = opos+1;
- ALOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("readObject Setting data pos of %p to %zu", this, mDataPos);
return obj;
}
-
+
// Look backwards for it...
while (opos > 0 && OBJS[opos] > DPOS) {
opos--;
}
if (OBJS[opos] == DPOS) {
// Found it!
- ALOGV("Parcel found obj %d at index %d with backward search",
+ ALOGV("Parcel %p found obj %zu at index %zu with backward search",
this, DPOS, opos);
mNextObjectHint = opos+1;
- ALOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("readObject Setting data pos of %p to %zu", this, mDataPos);
return obj;
}
}
{
size_t i = mObjectsSize;
if (i > 0) {
- //ALOGI("Closing file descriptors for %d objects...", mObjectsSize);
+ //ALOGI("Closing file descriptors for %zu objects...", i);
}
while (i > 0) {
i--;
const flat_binder_object* flat
= reinterpret_cast<flat_binder_object*>(mData+mObjects[i]);
if (flat->type == BINDER_TYPE_FD) {
- //ALOGI("Closing fd: %ld\n", flat->handle);
+ //ALOGI("Closing fd: %ld", flat->handle);
close(flat->handle);
}
}
mError = NO_ERROR;
mData = const_cast<uint8_t*>(data);
mDataSize = mDataCapacity = dataSize;
- //ALOGI("setDataReference Setting data size of %p to %lu (pid=%d)\n", this, mDataSize, getpid());
+ //ALOGI("setDataReference Setting data size of %p to %lu (pid=%d)", this, mDataSize, getpid());
mDataPos = 0;
- ALOGV("setDataReference Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("setDataReference Setting data pos of %p to %zu", this, mDataPos);
mObjects = const_cast<binder_size_t*>(objects);
mObjectsSize = mObjectsCapacity = objectsCount;
mNextObjectHint = 0;
void Parcel::print(TextOutput& to, uint32_t /*flags*/) const
{
to << "Parcel(";
-
+
if (errorCheck() != NO_ERROR) {
const status_t err = errorCheck();
to << "Error: " << (void*)(intptr_t)err << " \"" << strerror(-err) << "\"";
} else {
to << "NULL";
}
-
+
to << ")";
}
void Parcel::freeDataNoInit()
{
if (mOwner) {
- //ALOGI("Freeing data ref of %p (pid=%d)\n", this, getpid());
+ //ALOGI("Freeing data ref of %p (pid=%d)", this, getpid());
mOwner(this, mData, mDataSize, mObjects, mObjectsSize, mOwnerCookie);
} else {
releaseObjects();
freeData();
return continueWrite(desired);
}
-
+
uint8_t* data = (uint8_t*)realloc(mData, desired);
if (!data && desired > mDataCapacity) {
mError = NO_MEMORY;
return NO_MEMORY;
}
-
+
releaseObjects();
-
+
if (data) {
mData = data;
mDataCapacity = desired;
}
-
+
mDataSize = mDataPos = 0;
- ALOGV("restartWrite Setting data size of %p to %d\n", this, mDataSize);
- ALOGV("restartWrite Setting data pos of %p to %d\n", this, mDataPos);
-
+ ALOGV("restartWrite Setting data size of %p to %zu", this, mDataSize);
+ ALOGV("restartWrite Setting data pos of %p to %zu", this, mDataPos);
+
free(mObjects);
mObjects = NULL;
mObjectsSize = mObjectsCapacity = 0;
mHasFds = false;
mFdsKnown = true;
mAllowFds = true;
-
+
return NO_ERROR;
}
}
}
}
-
+
if (mOwner) {
// If the size is going to zero, just release the owner's data.
if (desired == 0) {
return NO_MEMORY;
}
binder_size_t* objects = NULL;
-
+
if (objectsSize) {
objects = (binder_size_t*)malloc(objectsSize*sizeof(binder_size_t));
if (!objects) {
acquireObjects();
mObjectsSize = oldObjectsSize;
}
-
+
if (mData) {
memcpy(data, mData, mDataSize < desired ? mDataSize : desired);
}
if (objects && mObjects) {
memcpy(objects, mObjects, objectsSize*sizeof(binder_size_t));
}
- //ALOGI("Freeing data ref of %p (pid=%d)\n", this, getpid());
+ //ALOGI("Freeing data ref of %p (pid=%d)", this, getpid());
mOwner(this, mData, mDataSize, mObjects, mObjectsSize, mOwnerCookie);
mOwner = NULL;
mData = data;
mObjects = objects;
mDataSize = (mDataSize < desired) ? mDataSize : desired;
- ALOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
+ ALOGV("continueWrite Setting data size of %p to %zu", this, mDataSize);
mDataCapacity = desired;
mObjectsSize = mObjectsCapacity = objectsSize;
mNextObjectHint = 0;
} else {
if (mDataSize > desired) {
mDataSize = desired;
- ALOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
+ ALOGV("continueWrite Setting data size of %p to %zu", this, mDataSize);
}
if (mDataPos > desired) {
mDataPos = desired;
- ALOGV("continueWrite Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("continueWrite Setting data pos of %p to %zu", this, mDataPos);
}
}
-
+
} else {
// This is the first data. Easy!
uint8_t* data = (uint8_t*)malloc(desired);
&& mObjectsCapacity == 0)) {
ALOGE("continueWrite: %zu/%p/%zu/%zu", mDataCapacity, mObjects, mObjectsCapacity, desired);
}
-
+
mData = data;
mDataSize = mDataPos = 0;
- ALOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
- ALOGV("continueWrite Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("continueWrite Setting data size of %p to %zu", this, mDataSize);
+ ALOGV("continueWrite Setting data pos of %p to %zu", this, mDataPos);
mDataCapacity = desired;
}
mDataSize = 0;
mDataCapacity = 0;
mDataPos = 0;
- ALOGV("initState Setting data size of %p to %d\n", this, mDataSize);
- ALOGV("initState Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("initState Setting data size of %p to %zu", this, mDataSize);
+ ALOGV("initState Setting data pos of %p to %zu", this, mDataPos);
mObjects = NULL;
mObjectsSize = 0;
mObjectsCapacity = 0;