Implementing support for HIDL native handles in Java
This change implements the equivalent of the C++ native_handle_t type in
Java. Similar to the C++ type, the NativeHandle class wraps an arraylist
of FileDescriptor objects, along with a raw data stream (integer array).
Bug: 35098567
Test: Ran m, hidl_test (C++ and Java). Functionality tests are included
in a separate CL.
Change-Id: Ic53f9a49ae17ce5708577a586230126ab0e222c7
diff --git a/core/jni/android_os_HwBlob.h b/core/jni/android_os_HwBlob.h
index 6b1db63..69a1b16 100644
--- a/core/jni/android_os_HwBlob.h
+++ b/core/jni/android_os_HwBlob.h
@@ -27,6 +27,11 @@
namespace android {
struct JHwBlob : public RefBase {
+ enum class BlobType {
+ GENERIC,
+ NATIVE_HANDLE,
+ };
+
static void InitClass(JNIEnv *env);
static sp<JHwBlob> SetNativeContext(
@@ -54,6 +59,9 @@
size_t size() const;
+ void specializeBlobTo(BlobType type);
+ BlobType type() const;
+
status_t putBlob(size_t offset, const sp<JHwBlob> &blob);
status_t writeToParcel(hardware::Parcel *parcel) const;
@@ -74,12 +82,15 @@
void *mBuffer;
size_t mSize;
+ BlobType mType;
bool mOwnsBuffer;
size_t mHandle;
Vector<BlobInfo> mSubBlobs;
+ status_t writeSubBlobsToParcel(hardware::Parcel *parcel, size_t parentHandle) const;
+
DISALLOW_COPY_AND_ASSIGN(JHwBlob);
};