summaryrefslogtreecommitdiffstats
path: root/include/binder/Parcel.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/binder/Parcel.h')
-rw-r--r--include/binder/Parcel.h35
1 files changed, 26 insertions, 9 deletions
diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h
index 98f20de..2ee99f8 100644
--- a/include/binder/Parcel.h
+++ b/include/binder/Parcel.h
@@ -23,6 +23,7 @@
#include <utils/String16.h>
#include <utils/Vector.h>
#include <utils/Flattenable.h>
+#include <linux/binder.h>
// ---------------------------------------------------------------------------
namespace android {
@@ -35,9 +36,8 @@ class ProcessState;
class String8;
class TextOutput;
-struct flat_binder_object; // defined in support_p/binder_module.h
-
class Parcel {
+ friend class IPCThreadState;
public:
class ReadableBlob;
class WritableBlob;
@@ -81,7 +81,10 @@ public:
void freeData();
- const size_t* objects() const;
+private:
+ const binder_size_t* objects() const;
+
+public:
size_t objectsCount() const;
status_t errorCheck() const;
@@ -94,7 +97,6 @@ public:
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);
@@ -126,6 +128,11 @@ public:
// will be closed once the parcel is destroyed.
status_t writeDupFileDescriptor(int fd);
+ // Writes a raw fd and optional comm channel fd to the parcel as a ParcelFileDescriptor.
+ // A dup's of the fds are made, which will be closed once the parcel is destroyed.
+ // Null values are passed as -1.
+ status_t writeParcelFileDescriptor(int fd, int commChannel = -1);
+
// 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.
@@ -185,6 +192,11 @@ public:
// in the parcel, which you do not own -- use dup() to get your own copy.
int readFileDescriptor() const;
+ // Reads a ParcelFileDescriptor from the parcel. Returns the raw fd as
+ // the result, and the optional comm channel fd in outCommChannel.
+ // Null values are returned as -1.
+ int readParcelFileDescriptor(int& outCommChannel) 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;
@@ -194,19 +206,21 @@ public:
// Explicitly close all file descriptors in the parcel.
void closeFileDescriptors();
+private:
typedef void (*release_func)(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);
- const uint8_t* ipcData() const;
+ uintptr_t ipcData() const;
size_t ipcDataSize() const;
- const size_t* ipcObjects() const;
+ uintptr_t ipcObjects() const;
size_t ipcObjectsCount() const;
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);
+public:
void print(TextOutput& to, uint32_t flags = 0) const;
private:
@@ -219,6 +233,9 @@ private:
status_t growData(size_t len);
status_t restartWrite(size_t desired);
status_t continueWrite(size_t desired);
+ status_t writePointer(uintptr_t val);
+ status_t readPointer(uintptr_t *pArg) const;
+ uintptr_t readPointer() const;
void freeDataNoInit();
void initState();
void scanForFds() const;
@@ -236,7 +253,7 @@ private:
size_t mDataSize;
size_t mDataCapacity;
mutable size_t mDataPos;
- size_t* mObjects;
+ binder_size_t* mObjects;
size_t mObjectsSize;
size_t mObjectsCapacity;
mutable size_t mNextObjectHint;