IMemory: add read/readRange APIs.
These are required for efficient remoting of HIDL hals. If someone on
the remote side is only reading, we no longer need to copy the entire
chunk of memory over.
Test: hidl_test
Bug: 35328065
Change-Id: I55bf3e5ef4ba2054105e4e8ce9aa2e490a8cf167
diff --git a/transport/memory/1.0/IMemory.hal b/transport/memory/1.0/IMemory.hal
index 66f37b3..14dcfb1 100644
--- a/transport/memory/1.0/IMemory.hal
+++ b/transport/memory/1.0/IMemory.hal
@@ -34,7 +34,20 @@
updateRange(uint64_t start, uint64_t length);
/**
- * Notify that you are done modifying this memory.
+ * Notify that you are about to start reading all of this memory.
+ */
+ read();
+
+ /**
+ * Notify that you are about to read the specific range.
+ *
+ * @param start Offset from start of buffer about to be read.
+ * @param length Number of bytes to be read.
+ */
+ readRange(uint64_t start, uint64_t length);
+
+ /**
+ * Notify that you are done reading and/or writing this memory.
*
* Must commit all previous update's and updateAll's.
*/
diff --git a/transport/memory/1.0/default/AshmemMemory.cpp b/transport/memory/1.0/default/AshmemMemory.cpp
index 912b724..0729608 100644
--- a/transport/memory/1.0/default/AshmemMemory.cpp
+++ b/transport/memory/1.0/default/AshmemMemory.cpp
@@ -46,6 +46,16 @@
return Void();
}
+Return<void> AshmemMemory::read() {
+ // NOOP (since non-remoted memory)
+ return Void();
+}
+
+Return<void> AshmemMemory::readRange(uint64_t /* start */, uint64_t /* length */) {
+ // NOOP (since non-remoted memory)
+ return Void();
+}
+
Return<void> AshmemMemory::commit() {
// NOOP (since non-remoted memory)
return Void();
diff --git a/transport/memory/1.0/default/AshmemMemory.h b/transport/memory/1.0/default/AshmemMemory.h
index 825d74e..cf2d543 100644
--- a/transport/memory/1.0/default/AshmemMemory.h
+++ b/transport/memory/1.0/default/AshmemMemory.h
@@ -44,6 +44,8 @@
// Methods from ::android::hidl::memory::V1_0::IMemory follow.
Return<void> update() override;
Return<void> updateRange(uint64_t start, uint64_t length) override;
+ Return<void> read() override;
+ Return<void> readRange(uint64_t start, uint64_t length) override;
Return<void> commit() override;
Return<void*> getPointer() override;
Return<uint64_t> getSize() override;