Binder: Use 64 bit pointers in 32 processes if selected by the target
Uses new kernel header where void * has been replaced by binder_uintptr_t Change-Id: Icfc67c2a279269f700343bd9246fd7cb94efe2c1
This commit is contained in:
parent
e91fff0a2d
commit
84e625ac1e
@ -107,7 +107,7 @@ private:
|
|||||||
static void threadDestructor(void *st);
|
static void threadDestructor(void *st);
|
||||||
static void freeBuffer(Parcel* parcel,
|
static void freeBuffer(Parcel* parcel,
|
||||||
const uint8_t* data, size_t dataSize,
|
const uint8_t* data, size_t dataSize,
|
||||||
const size_t* objects, size_t objectsSize,
|
const binder_size_t* objects, size_t objectsSize,
|
||||||
void* cookie);
|
void* cookie);
|
||||||
|
|
||||||
const sp<ProcessState> mProcess;
|
const sp<ProcessState> mProcess;
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <utils/String16.h>
|
#include <utils/String16.h>
|
||||||
#include <utils/Vector.h>
|
#include <utils/Vector.h>
|
||||||
#include <utils/Flattenable.h>
|
#include <utils/Flattenable.h>
|
||||||
|
#include <linux/binder.h>
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
namespace android {
|
namespace android {
|
||||||
@ -35,8 +36,6 @@ class ProcessState;
|
|||||||
class String8;
|
class String8;
|
||||||
class TextOutput;
|
class TextOutput;
|
||||||
|
|
||||||
struct flat_binder_object; // defined in support_p/binder_module.h
|
|
||||||
|
|
||||||
class Parcel {
|
class Parcel {
|
||||||
friend class IPCThreadState;
|
friend class IPCThreadState;
|
||||||
public:
|
public:
|
||||||
@ -82,7 +81,10 @@ public:
|
|||||||
|
|
||||||
void freeData();
|
void freeData();
|
||||||
|
|
||||||
const size_t* objects() const;
|
private:
|
||||||
|
const binder_size_t* objects() const;
|
||||||
|
|
||||||
|
public:
|
||||||
size_t objectsCount() const;
|
size_t objectsCount() const;
|
||||||
|
|
||||||
status_t errorCheck() const;
|
status_t errorCheck() const;
|
||||||
@ -194,19 +196,21 @@ public:
|
|||||||
// Explicitly close all file descriptors in the parcel.
|
// Explicitly close all file descriptors in the parcel.
|
||||||
void closeFileDescriptors();
|
void closeFileDescriptors();
|
||||||
|
|
||||||
|
private:
|
||||||
typedef void (*release_func)(Parcel* parcel,
|
typedef void (*release_func)(Parcel* parcel,
|
||||||
const uint8_t* data, size_t dataSize,
|
const uint8_t* data, size_t dataSize,
|
||||||
const size_t* objects, size_t objectsSize,
|
const binder_size_t* objects, size_t objectsSize,
|
||||||
void* cookie);
|
void* cookie);
|
||||||
|
|
||||||
const uint8_t* ipcData() const;
|
uintptr_t ipcData() const;
|
||||||
size_t ipcDataSize() const;
|
size_t ipcDataSize() const;
|
||||||
const size_t* ipcObjects() const;
|
uintptr_t ipcObjects() const;
|
||||||
size_t ipcObjectsCount() const;
|
size_t ipcObjectsCount() const;
|
||||||
void ipcSetDataReference(const uint8_t* data, size_t dataSize,
|
void ipcSetDataReference(const uint8_t* data, size_t dataSize,
|
||||||
const size_t* objects, size_t objectsCount,
|
const binder_size_t* objects, size_t objectsCount,
|
||||||
release_func relFunc, void* relCookie);
|
release_func relFunc, void* relCookie);
|
||||||
|
|
||||||
|
public:
|
||||||
void print(TextOutput& to, uint32_t flags = 0) const;
|
void print(TextOutput& to, uint32_t flags = 0) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -239,7 +243,7 @@ private:
|
|||||||
size_t mDataSize;
|
size_t mDataSize;
|
||||||
size_t mDataCapacity;
|
size_t mDataCapacity;
|
||||||
mutable size_t mDataPos;
|
mutable size_t mDataPos;
|
||||||
size_t* mObjects;
|
binder_size_t* mObjects;
|
||||||
size_t mObjectsSize;
|
size_t mObjectsSize;
|
||||||
size_t mObjectsCapacity;
|
size_t mObjectsCapacity;
|
||||||
mutable size_t mNextObjectHint;
|
mutable size_t mNextObjectHint;
|
||||||
|
@ -753,23 +753,23 @@ status_t IPCThreadState::waitForResponse(Parcel *reply, status_t *acquireResult)
|
|||||||
reply->ipcSetDataReference(
|
reply->ipcSetDataReference(
|
||||||
reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
|
reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
|
||||||
tr.data_size,
|
tr.data_size,
|
||||||
reinterpret_cast<const size_t*>(tr.data.ptr.offsets),
|
reinterpret_cast<const binder_size_t*>(tr.data.ptr.offsets),
|
||||||
tr.offsets_size/sizeof(size_t),
|
tr.offsets_size/sizeof(binder_size_t),
|
||||||
freeBuffer, this);
|
freeBuffer, this);
|
||||||
} else {
|
} else {
|
||||||
err = *static_cast<const status_t*>(tr.data.ptr.buffer);
|
err = *reinterpret_cast<const status_t*>(tr.data.ptr.buffer);
|
||||||
freeBuffer(NULL,
|
freeBuffer(NULL,
|
||||||
reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
|
reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
|
||||||
tr.data_size,
|
tr.data_size,
|
||||||
reinterpret_cast<const size_t*>(tr.data.ptr.offsets),
|
reinterpret_cast<const binder_size_t*>(tr.data.ptr.offsets),
|
||||||
tr.offsets_size/sizeof(size_t), this);
|
tr.offsets_size/sizeof(binder_size_t), this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
freeBuffer(NULL,
|
freeBuffer(NULL,
|
||||||
reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
|
reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
|
||||||
tr.data_size,
|
tr.data_size,
|
||||||
reinterpret_cast<const size_t*>(tr.data.ptr.offsets),
|
reinterpret_cast<const binder_size_t*>(tr.data.ptr.offsets),
|
||||||
tr.offsets_size/sizeof(size_t), this);
|
tr.offsets_size/sizeof(binder_size_t), this);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -809,12 +809,12 @@ status_t IPCThreadState::talkWithDriver(bool doReceive)
|
|||||||
const size_t outAvail = (!doReceive || needRead) ? mOut.dataSize() : 0;
|
const size_t outAvail = (!doReceive || needRead) ? mOut.dataSize() : 0;
|
||||||
|
|
||||||
bwr.write_size = outAvail;
|
bwr.write_size = outAvail;
|
||||||
bwr.write_buffer = (long unsigned int)mOut.data();
|
bwr.write_buffer = (uintptr_t)mOut.data();
|
||||||
|
|
||||||
// This is what we'll read.
|
// This is what we'll read.
|
||||||
if (doReceive && needRead) {
|
if (doReceive && needRead) {
|
||||||
bwr.read_size = mIn.dataCapacity();
|
bwr.read_size = mIn.dataCapacity();
|
||||||
bwr.read_buffer = (long unsigned int)mIn.data();
|
bwr.read_buffer = (uintptr_t)mIn.data();
|
||||||
} else {
|
} else {
|
||||||
bwr.read_size = 0;
|
bwr.read_size = 0;
|
||||||
bwr.read_buffer = 0;
|
bwr.read_buffer = 0;
|
||||||
@ -868,7 +868,7 @@ status_t IPCThreadState::talkWithDriver(bool doReceive)
|
|||||||
|
|
||||||
if (err >= NO_ERROR) {
|
if (err >= NO_ERROR) {
|
||||||
if (bwr.write_consumed > 0) {
|
if (bwr.write_consumed > 0) {
|
||||||
if (bwr.write_consumed < (ssize_t)mOut.dataSize())
|
if (bwr.write_consumed < mOut.dataSize())
|
||||||
mOut.remove(0, bwr.write_consumed);
|
mOut.remove(0, bwr.write_consumed);
|
||||||
else
|
else
|
||||||
mOut.setDataSize(0);
|
mOut.setDataSize(0);
|
||||||
@ -909,15 +909,15 @@ status_t IPCThreadState::writeTransactionData(int32_t cmd, uint32_t binderFlags,
|
|||||||
if (err == NO_ERROR) {
|
if (err == NO_ERROR) {
|
||||||
tr.data_size = data.ipcDataSize();
|
tr.data_size = data.ipcDataSize();
|
||||||
tr.data.ptr.buffer = data.ipcData();
|
tr.data.ptr.buffer = data.ipcData();
|
||||||
tr.offsets_size = data.ipcObjectsCount()*sizeof(size_t);
|
tr.offsets_size = data.ipcObjectsCount()*sizeof(binder_size_t);
|
||||||
tr.data.ptr.offsets = data.ipcObjects();
|
tr.data.ptr.offsets = data.ipcObjects();
|
||||||
} else if (statusBuffer) {
|
} else if (statusBuffer) {
|
||||||
tr.flags |= TF_STATUS_CODE;
|
tr.flags |= TF_STATUS_CODE;
|
||||||
*statusBuffer = err;
|
*statusBuffer = err;
|
||||||
tr.data_size = sizeof(status_t);
|
tr.data_size = sizeof(status_t);
|
||||||
tr.data.ptr.buffer = statusBuffer;
|
tr.data.ptr.buffer = reinterpret_cast<binder_uintptr_t>(statusBuffer);
|
||||||
tr.offsets_size = 0;
|
tr.offsets_size = 0;
|
||||||
tr.data.ptr.offsets = NULL;
|
tr.data.ptr.offsets = 0;
|
||||||
} else {
|
} else {
|
||||||
return (mLastError = err);
|
return (mLastError = err);
|
||||||
}
|
}
|
||||||
@ -1026,8 +1026,8 @@ status_t IPCThreadState::executeCommand(int32_t cmd)
|
|||||||
buffer.ipcSetDataReference(
|
buffer.ipcSetDataReference(
|
||||||
reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
|
reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
|
||||||
tr.data_size,
|
tr.data_size,
|
||||||
reinterpret_cast<const size_t*>(tr.data.ptr.offsets),
|
reinterpret_cast<const binder_size_t*>(tr.data.ptr.offsets),
|
||||||
tr.offsets_size/sizeof(size_t), freeBuffer, this);
|
tr.offsets_size/sizeof(binder_size_t), freeBuffer, this);
|
||||||
|
|
||||||
const pid_t origPid = mCallingPid;
|
const pid_t origPid = mCallingPid;
|
||||||
const uid_t origUid = mCallingUid;
|
const uid_t origUid = mCallingUid;
|
||||||
@ -1155,7 +1155,7 @@ void IPCThreadState::threadDestructor(void *st)
|
|||||||
|
|
||||||
|
|
||||||
void IPCThreadState::freeBuffer(Parcel* parcel, const uint8_t* data, size_t dataSize,
|
void IPCThreadState::freeBuffer(Parcel* parcel, const uint8_t* data, size_t dataSize,
|
||||||
const size_t* objects, size_t objectsSize,
|
const binder_size_t* objects, size_t objectsSize,
|
||||||
void* cookie)
|
void* cookie)
|
||||||
{
|
{
|
||||||
//ALOGI("Freeing parcel %p", &parcel);
|
//ALOGI("Freeing parcel %p", &parcel);
|
||||||
|
@ -77,12 +77,12 @@ void acquire_object(const sp<ProcessState>& proc,
|
|||||||
case BINDER_TYPE_BINDER:
|
case BINDER_TYPE_BINDER:
|
||||||
if (obj.binder) {
|
if (obj.binder) {
|
||||||
LOG_REFS("Parcel %p acquiring reference on local %p", who, obj.cookie);
|
LOG_REFS("Parcel %p acquiring reference on local %p", who, obj.cookie);
|
||||||
static_cast<IBinder*>(obj.cookie)->incStrong(who);
|
reinterpret_cast<IBinder*>(obj.cookie)->incStrong(who);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case BINDER_TYPE_WEAK_BINDER:
|
case BINDER_TYPE_WEAK_BINDER:
|
||||||
if (obj.binder)
|
if (obj.binder)
|
||||||
static_cast<RefBase::weakref_type*>(obj.binder)->incWeak(who);
|
reinterpret_cast<RefBase::weakref_type*>(obj.binder)->incWeak(who);
|
||||||
return;
|
return;
|
||||||
case BINDER_TYPE_HANDLE: {
|
case BINDER_TYPE_HANDLE: {
|
||||||
const sp<IBinder> b = proc->getStrongProxyForHandle(obj.handle);
|
const sp<IBinder> b = proc->getStrongProxyForHandle(obj.handle);
|
||||||
@ -114,12 +114,12 @@ void release_object(const sp<ProcessState>& proc,
|
|||||||
case BINDER_TYPE_BINDER:
|
case BINDER_TYPE_BINDER:
|
||||||
if (obj.binder) {
|
if (obj.binder) {
|
||||||
LOG_REFS("Parcel %p releasing reference on local %p", who, obj.cookie);
|
LOG_REFS("Parcel %p releasing reference on local %p", who, obj.cookie);
|
||||||
static_cast<IBinder*>(obj.cookie)->decStrong(who);
|
reinterpret_cast<IBinder*>(obj.cookie)->decStrong(who);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case BINDER_TYPE_WEAK_BINDER:
|
case BINDER_TYPE_WEAK_BINDER:
|
||||||
if (obj.binder)
|
if (obj.binder)
|
||||||
static_cast<RefBase::weakref_type*>(obj.binder)->decWeak(who);
|
reinterpret_cast<RefBase::weakref_type*>(obj.binder)->decWeak(who);
|
||||||
return;
|
return;
|
||||||
case BINDER_TYPE_HANDLE: {
|
case BINDER_TYPE_HANDLE: {
|
||||||
const sp<IBinder> b = proc->getStrongProxyForHandle(obj.handle);
|
const sp<IBinder> b = proc->getStrongProxyForHandle(obj.handle);
|
||||||
@ -135,7 +135,7 @@ void release_object(const sp<ProcessState>& proc,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case BINDER_TYPE_FD: {
|
case BINDER_TYPE_FD: {
|
||||||
if (obj.cookie != (void*)0) close(obj.handle);
|
if (obj.cookie != 0) close(obj.handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,16 +165,16 @@ status_t flatten_binder(const sp<ProcessState>& proc,
|
|||||||
const int32_t handle = proxy ? proxy->handle() : 0;
|
const int32_t handle = proxy ? proxy->handle() : 0;
|
||||||
obj.type = BINDER_TYPE_HANDLE;
|
obj.type = BINDER_TYPE_HANDLE;
|
||||||
obj.handle = handle;
|
obj.handle = handle;
|
||||||
obj.cookie = NULL;
|
obj.cookie = 0;
|
||||||
} else {
|
} else {
|
||||||
obj.type = BINDER_TYPE_BINDER;
|
obj.type = BINDER_TYPE_BINDER;
|
||||||
obj.binder = local->getWeakRefs();
|
obj.binder = reinterpret_cast<uintptr_t>(local->getWeakRefs());
|
||||||
obj.cookie = local;
|
obj.cookie = reinterpret_cast<uintptr_t>(local);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
obj.type = BINDER_TYPE_BINDER;
|
obj.type = BINDER_TYPE_BINDER;
|
||||||
obj.binder = NULL;
|
obj.binder = 0;
|
||||||
obj.cookie = NULL;
|
obj.cookie = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return finish_flatten_binder(binder, obj, out);
|
return finish_flatten_binder(binder, obj, out);
|
||||||
@ -198,11 +198,11 @@ status_t flatten_binder(const sp<ProcessState>& proc,
|
|||||||
const int32_t handle = proxy ? proxy->handle() : 0;
|
const int32_t handle = proxy ? proxy->handle() : 0;
|
||||||
obj.type = BINDER_TYPE_WEAK_HANDLE;
|
obj.type = BINDER_TYPE_WEAK_HANDLE;
|
||||||
obj.handle = handle;
|
obj.handle = handle;
|
||||||
obj.cookie = NULL;
|
obj.cookie = 0;
|
||||||
} else {
|
} else {
|
||||||
obj.type = BINDER_TYPE_WEAK_BINDER;
|
obj.type = BINDER_TYPE_WEAK_BINDER;
|
||||||
obj.binder = binder.get_refs();
|
obj.binder = reinterpret_cast<uintptr_t>(binder.get_refs());
|
||||||
obj.cookie = binder.unsafe_get();
|
obj.cookie = reinterpret_cast<uintptr_t>(binder.unsafe_get());
|
||||||
}
|
}
|
||||||
return finish_flatten_binder(real, obj, out);
|
return finish_flatten_binder(real, obj, out);
|
||||||
}
|
}
|
||||||
@ -216,14 +216,14 @@ status_t flatten_binder(const sp<ProcessState>& proc,
|
|||||||
// implementation we are using.
|
// implementation we are using.
|
||||||
ALOGE("Unable to unflatten Binder weak reference!");
|
ALOGE("Unable to unflatten Binder weak reference!");
|
||||||
obj.type = BINDER_TYPE_BINDER;
|
obj.type = BINDER_TYPE_BINDER;
|
||||||
obj.binder = NULL;
|
obj.binder = 0;
|
||||||
obj.cookie = NULL;
|
obj.cookie = 0;
|
||||||
return finish_flatten_binder(NULL, obj, out);
|
return finish_flatten_binder(NULL, obj, out);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
obj.type = BINDER_TYPE_BINDER;
|
obj.type = BINDER_TYPE_BINDER;
|
||||||
obj.binder = NULL;
|
obj.binder = 0;
|
||||||
obj.cookie = NULL;
|
obj.cookie = 0;
|
||||||
return finish_flatten_binder(NULL, obj, out);
|
return finish_flatten_binder(NULL, obj, out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -242,7 +242,7 @@ status_t unflatten_binder(const sp<ProcessState>& proc,
|
|||||||
if (flat) {
|
if (flat) {
|
||||||
switch (flat->type) {
|
switch (flat->type) {
|
||||||
case BINDER_TYPE_BINDER:
|
case BINDER_TYPE_BINDER:
|
||||||
*out = static_cast<IBinder*>(flat->cookie);
|
*out = reinterpret_cast<IBinder*>(flat->cookie);
|
||||||
return finish_unflatten_binder(NULL, *flat, in);
|
return finish_unflatten_binder(NULL, *flat, in);
|
||||||
case BINDER_TYPE_HANDLE:
|
case BINDER_TYPE_HANDLE:
|
||||||
*out = proc->getStrongProxyForHandle(flat->handle);
|
*out = proc->getStrongProxyForHandle(flat->handle);
|
||||||
@ -261,13 +261,13 @@ status_t unflatten_binder(const sp<ProcessState>& proc,
|
|||||||
if (flat) {
|
if (flat) {
|
||||||
switch (flat->type) {
|
switch (flat->type) {
|
||||||
case BINDER_TYPE_BINDER:
|
case BINDER_TYPE_BINDER:
|
||||||
*out = static_cast<IBinder*>(flat->cookie);
|
*out = reinterpret_cast<IBinder*>(flat->cookie);
|
||||||
return finish_unflatten_binder(NULL, *flat, in);
|
return finish_unflatten_binder(NULL, *flat, in);
|
||||||
case BINDER_TYPE_WEAK_BINDER:
|
case BINDER_TYPE_WEAK_BINDER:
|
||||||
if (flat->binder != NULL) {
|
if (flat->binder != 0) {
|
||||||
out->set_object_and_refs(
|
out->set_object_and_refs(
|
||||||
static_cast<IBinder*>(flat->cookie),
|
reinterpret_cast<IBinder*>(flat->cookie),
|
||||||
static_cast<RefBase::weakref_type*>(flat->binder));
|
reinterpret_cast<RefBase::weakref_type*>(flat->binder));
|
||||||
} else {
|
} else {
|
||||||
*out = NULL;
|
*out = NULL;
|
||||||
}
|
}
|
||||||
@ -364,7 +364,7 @@ status_t Parcel::appendFrom(const Parcel *parcel, size_t offset, size_t len)
|
|||||||
const sp<ProcessState> proc(ProcessState::self());
|
const sp<ProcessState> proc(ProcessState::self());
|
||||||
status_t err;
|
status_t err;
|
||||||
const uint8_t *data = parcel->mData;
|
const uint8_t *data = parcel->mData;
|
||||||
const size_t *objects = parcel->mObjects;
|
const binder_size_t *objects = parcel->mObjects;
|
||||||
size_t size = parcel->mObjectsSize;
|
size_t size = parcel->mObjectsSize;
|
||||||
int startPos = mDataPos;
|
int startPos = mDataPos;
|
||||||
int firstIndex = -1, lastIndex = -2;
|
int firstIndex = -1, lastIndex = -2;
|
||||||
@ -411,9 +411,9 @@ status_t Parcel::appendFrom(const Parcel *parcel, size_t offset, size_t len)
|
|||||||
// grow objects
|
// grow objects
|
||||||
if (mObjectsCapacity < mObjectsSize + numObjects) {
|
if (mObjectsCapacity < mObjectsSize + numObjects) {
|
||||||
int newSize = ((mObjectsSize + numObjects)*3)/2;
|
int newSize = ((mObjectsSize + numObjects)*3)/2;
|
||||||
size_t *objects =
|
binder_size_t *objects =
|
||||||
(size_t*)realloc(mObjects, newSize*sizeof(size_t));
|
(binder_size_t*)realloc(mObjects, newSize*sizeof(binder_size_t));
|
||||||
if (objects == (size_t*)0) {
|
if (objects == (binder_size_t*)0) {
|
||||||
return NO_MEMORY;
|
return NO_MEMORY;
|
||||||
}
|
}
|
||||||
mObjects = objects;
|
mObjects = objects;
|
||||||
@ -436,7 +436,7 @@ status_t Parcel::appendFrom(const Parcel *parcel, size_t offset, size_t len)
|
|||||||
// new Parcel now owns its own fd, and can declare that we
|
// new Parcel now owns its own fd, and can declare that we
|
||||||
// officially know we have fds.
|
// officially know we have fds.
|
||||||
flat->handle = dup(flat->handle);
|
flat->handle = dup(flat->handle);
|
||||||
flat->cookie = (void*)1;
|
flat->cookie = 1;
|
||||||
mHasFds = mFdsKnown = true;
|
mHasFds = mFdsKnown = true;
|
||||||
if (!mAllowFds) {
|
if (!mAllowFds) {
|
||||||
err = FDS_NOT_ALLOWED;
|
err = FDS_NOT_ALLOWED;
|
||||||
@ -511,7 +511,7 @@ bool Parcel::enforceInterface(const String16& interface,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t* Parcel::objects() const
|
const binder_size_t* Parcel::objects() const
|
||||||
{
|
{
|
||||||
return mObjects;
|
return mObjects;
|
||||||
}
|
}
|
||||||
@ -635,7 +635,7 @@ status_t Parcel::writeInt64(int64_t val)
|
|||||||
|
|
||||||
status_t Parcel::writePointer(uintptr_t val)
|
status_t Parcel::writePointer(uintptr_t val)
|
||||||
{
|
{
|
||||||
return writeAligned(val);
|
return writeAligned<binder_uintptr_t>(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t Parcel::writeFloat(float val)
|
status_t Parcel::writeFloat(float val)
|
||||||
@ -748,7 +748,7 @@ status_t Parcel::writeFileDescriptor(int fd, bool takeOwnership)
|
|||||||
obj.type = BINDER_TYPE_FD;
|
obj.type = BINDER_TYPE_FD;
|
||||||
obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
|
obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
|
||||||
obj.handle = fd;
|
obj.handle = fd;
|
||||||
obj.cookie = (void*) (takeOwnership ? 1 : 0);
|
obj.cookie = takeOwnership ? 1 : 0;
|
||||||
return writeObject(obj, true);
|
return writeObject(obj, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -858,7 +858,7 @@ restart_write:
|
|||||||
*reinterpret_cast<flat_binder_object*>(mData+mDataPos) = val;
|
*reinterpret_cast<flat_binder_object*>(mData+mDataPos) = val;
|
||||||
|
|
||||||
// Need to write meta-data?
|
// Need to write meta-data?
|
||||||
if (nullMetaData || val.binder != NULL) {
|
if (nullMetaData || val.binder != 0) {
|
||||||
mObjects[mObjectsSize] = mDataPos;
|
mObjects[mObjectsSize] = mDataPos;
|
||||||
acquire_object(ProcessState::self(), val, this);
|
acquire_object(ProcessState::self(), val, this);
|
||||||
mObjectsSize++;
|
mObjectsSize++;
|
||||||
@ -881,7 +881,7 @@ restart_write:
|
|||||||
}
|
}
|
||||||
if (!enoughObjects) {
|
if (!enoughObjects) {
|
||||||
size_t newSize = ((mObjectsSize+2)*3)/2;
|
size_t newSize = ((mObjectsSize+2)*3)/2;
|
||||||
size_t* objects = (size_t*)realloc(mObjects, newSize*sizeof(size_t));
|
binder_size_t* objects = (binder_size_t*)realloc(mObjects, newSize*sizeof(binder_size_t));
|
||||||
if (objects == NULL) return NO_MEMORY;
|
if (objects == NULL) return NO_MEMORY;
|
||||||
mObjects = objects;
|
mObjects = objects;
|
||||||
mObjectsCapacity = newSize;
|
mObjectsCapacity = newSize;
|
||||||
@ -985,12 +985,17 @@ int64_t Parcel::readInt64() const
|
|||||||
|
|
||||||
status_t Parcel::readPointer(uintptr_t *pArg) const
|
status_t Parcel::readPointer(uintptr_t *pArg) const
|
||||||
{
|
{
|
||||||
return readAligned(pArg);
|
status_t ret;
|
||||||
|
binder_uintptr_t ptr;
|
||||||
|
ret = readAligned(&ptr);
|
||||||
|
if (!ret)
|
||||||
|
*pArg = ptr;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uintptr_t Parcel::readPointer() const
|
uintptr_t Parcel::readPointer() const
|
||||||
{
|
{
|
||||||
return readAligned<uintptr_t>();
|
return readAligned<binder_uintptr_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1239,7 +1244,7 @@ const flat_binder_object* Parcel::readObject(bool nullMetaData) const
|
|||||||
const flat_binder_object* obj
|
const flat_binder_object* obj
|
||||||
= reinterpret_cast<const flat_binder_object*>(mData+DPOS);
|
= reinterpret_cast<const flat_binder_object*>(mData+DPOS);
|
||||||
mDataPos = DPOS + sizeof(flat_binder_object);
|
mDataPos = DPOS + sizeof(flat_binder_object);
|
||||||
if (!nullMetaData && (obj->cookie == NULL && obj->binder == NULL)) {
|
if (!nullMetaData && (obj->cookie == 0 && obj->binder == 0)) {
|
||||||
// When transferring a NULL object, we don't write it into
|
// When transferring a NULL object, we don't write it into
|
||||||
// the object list, so we don't want to check for it when
|
// the object list, so we don't want to check for it when
|
||||||
// reading.
|
// reading.
|
||||||
@ -1248,7 +1253,7 @@ const flat_binder_object* Parcel::readObject(bool nullMetaData) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that this object is valid...
|
// Ensure that this object is valid...
|
||||||
size_t* const OBJS = mObjects;
|
binder_size_t* const OBJS = mObjects;
|
||||||
const size_t N = mObjectsSize;
|
const size_t N = mObjectsSize;
|
||||||
size_t opos = mNextObjectHint;
|
size_t opos = mNextObjectHint;
|
||||||
|
|
||||||
@ -1310,9 +1315,9 @@ void Parcel::closeFileDescriptors()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t* Parcel::ipcData() const
|
uintptr_t Parcel::ipcData() const
|
||||||
{
|
{
|
||||||
return mData;
|
return reinterpret_cast<uintptr_t>(mData);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Parcel::ipcDataSize() const
|
size_t Parcel::ipcDataSize() const
|
||||||
@ -1320,9 +1325,9 @@ size_t Parcel::ipcDataSize() const
|
|||||||
return (mDataSize > mDataPos ? mDataSize : mDataPos);
|
return (mDataSize > mDataPos ? mDataSize : mDataPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t* Parcel::ipcObjects() const
|
uintptr_t Parcel::ipcObjects() const
|
||||||
{
|
{
|
||||||
return mObjects;
|
return reinterpret_cast<uintptr_t>(mObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Parcel::ipcObjectsCount() const
|
size_t Parcel::ipcObjectsCount() const
|
||||||
@ -1331,7 +1336,7 @@ size_t Parcel::ipcObjectsCount() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Parcel::ipcSetDataReference(const uint8_t* data, size_t dataSize,
|
void Parcel::ipcSetDataReference(const uint8_t* data, size_t dataSize,
|
||||||
const size_t* objects, size_t objectsCount, release_func relFunc, void* relCookie)
|
const binder_size_t* objects, size_t objectsCount, release_func relFunc, void* relCookie)
|
||||||
{
|
{
|
||||||
freeDataNoInit();
|
freeDataNoInit();
|
||||||
mError = NO_ERROR;
|
mError = NO_ERROR;
|
||||||
@ -1340,7 +1345,7 @@ void Parcel::ipcSetDataReference(const uint8_t* data, size_t 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)\n", this, mDataSize, getpid());
|
||||||
mDataPos = 0;
|
mDataPos = 0;
|
||||||
ALOGV("setDataReference Setting data pos of %p to %d\n", this, mDataPos);
|
ALOGV("setDataReference Setting data pos of %p to %d\n", this, mDataPos);
|
||||||
mObjects = const_cast<size_t*>(objects);
|
mObjects = const_cast<binder_size_t*>(objects);
|
||||||
mObjectsSize = mObjectsCapacity = objectsCount;
|
mObjectsSize = mObjectsCapacity = objectsCount;
|
||||||
mNextObjectHint = 0;
|
mNextObjectHint = 0;
|
||||||
mOwner = relFunc;
|
mOwner = relFunc;
|
||||||
@ -1358,7 +1363,7 @@ void Parcel::print(TextOutput& to, uint32_t flags) const
|
|||||||
} else if (dataSize() > 0) {
|
} else if (dataSize() > 0) {
|
||||||
const uint8_t* DATA = data();
|
const uint8_t* DATA = data();
|
||||||
to << indent << HexDump(DATA, dataSize()) << dedent;
|
to << indent << HexDump(DATA, dataSize()) << dedent;
|
||||||
const size_t* OBJS = objects();
|
const binder_size_t* OBJS = objects();
|
||||||
const size_t N = objectsCount();
|
const size_t N = objectsCount();
|
||||||
for (size_t i=0; i<N; i++) {
|
for (size_t i=0; i<N; i++) {
|
||||||
const flat_binder_object* flat
|
const flat_binder_object* flat
|
||||||
@ -1379,7 +1384,7 @@ void Parcel::releaseObjects()
|
|||||||
const sp<ProcessState> proc(ProcessState::self());
|
const sp<ProcessState> proc(ProcessState::self());
|
||||||
size_t i = mObjectsSize;
|
size_t i = mObjectsSize;
|
||||||
uint8_t* const data = mData;
|
uint8_t* const data = mData;
|
||||||
size_t* const objects = mObjects;
|
binder_size_t* const objects = mObjects;
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
i--;
|
i--;
|
||||||
const flat_binder_object* flat
|
const flat_binder_object* flat
|
||||||
@ -1393,7 +1398,7 @@ void Parcel::acquireObjects()
|
|||||||
const sp<ProcessState> proc(ProcessState::self());
|
const sp<ProcessState> proc(ProcessState::self());
|
||||||
size_t i = mObjectsSize;
|
size_t i = mObjectsSize;
|
||||||
uint8_t* const data = mData;
|
uint8_t* const data = mData;
|
||||||
size_t* const objects = mObjects;
|
binder_size_t* const objects = mObjects;
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
i--;
|
i--;
|
||||||
const flat_binder_object* flat
|
const flat_binder_object* flat
|
||||||
@ -1494,10 +1499,10 @@ status_t Parcel::continueWrite(size_t desired)
|
|||||||
mError = NO_MEMORY;
|
mError = NO_MEMORY;
|
||||||
return NO_MEMORY;
|
return NO_MEMORY;
|
||||||
}
|
}
|
||||||
size_t* objects = NULL;
|
binder_size_t* objects = NULL;
|
||||||
|
|
||||||
if (objectsSize) {
|
if (objectsSize) {
|
||||||
objects = (size_t*)malloc(objectsSize*sizeof(size_t));
|
objects = (binder_size_t*)malloc(objectsSize*sizeof(binder_size_t));
|
||||||
if (!objects) {
|
if (!objects) {
|
||||||
free(data);
|
free(data);
|
||||||
|
|
||||||
@ -1517,7 +1522,7 @@ status_t Parcel::continueWrite(size_t desired)
|
|||||||
memcpy(data, mData, mDataSize < desired ? mDataSize : desired);
|
memcpy(data, mData, mDataSize < desired ? mDataSize : desired);
|
||||||
}
|
}
|
||||||
if (objects && mObjects) {
|
if (objects && mObjects) {
|
||||||
memcpy(objects, mObjects, objectsSize*sizeof(size_t));
|
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)\n", this, getpid());
|
||||||
mOwner(this, mData, mDataSize, mObjects, mObjectsSize, mOwnerCookie);
|
mOwner(this, mData, mDataSize, mObjects, mObjectsSize, mOwnerCookie);
|
||||||
@ -1544,8 +1549,8 @@ status_t Parcel::continueWrite(size_t desired)
|
|||||||
}
|
}
|
||||||
release_object(proc, *flat, this);
|
release_object(proc, *flat, this);
|
||||||
}
|
}
|
||||||
size_t* objects =
|
binder_size_t* objects =
|
||||||
(size_t*)realloc(mObjects, objectsSize*sizeof(size_t));
|
(binder_size_t*)realloc(mObjects, objectsSize*sizeof(binder_size_t));
|
||||||
if (objects) {
|
if (objects) {
|
||||||
mObjects = objects;
|
mObjects = objects;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user