Memory: add ability to update memory range.

This will allow memory to be used in a way that is efficiently
remotable.

Test: hidl_test
Change-Id: I553a6293a6378fb1a1be8930ac4cb62662cbdcc5
Fixes: 35328065
diff --git a/transport/memory/1.0/IMemory.hal b/transport/memory/1.0/IMemory.hal
index 404675a..66f37b3 100644
--- a/transport/memory/1.0/IMemory.hal
+++ b/transport/memory/1.0/IMemory.hal
@@ -19,12 +19,24 @@
 interface IMemory {
 
     /**
-     * Notify that you are about to use this memory.
+     * Notify that you are about to use all of this memory.
      */
     update();
 
     /**
+     * Notify that you are about to use the specific range.
+     *
+     * start + length must be < size
+     *
+     * @param start Offset from start of buffer about to be updated.
+     * @param length Number of bytes to be updated.
+     */
+    updateRange(uint64_t start, uint64_t length);
+
+    /**
      * Notify that you are done modifying this memory.
+     *
+     * Must commit all previous update's and updateAll's.
      */
     commit();
 
diff --git a/transport/memory/1.0/default/AshmemMemory.cpp b/transport/memory/1.0/default/AshmemMemory.cpp
index 31626ea..b954bad 100644
--- a/transport/memory/1.0/default/AshmemMemory.cpp
+++ b/transport/memory/1.0/default/AshmemMemory.cpp
@@ -37,12 +37,17 @@
 
 // Methods from ::android::hidl::memory::V1_0::IMemory follow.
 Return<void> AshmemMemory::update() {
-    // NOOP
+    // NOOP (since non-remoted memory)
+    return Void();
+}
+
+Return<void> AshmemMemory::updateRange(uint64_t start, uint64_t length) {
+    // NOOP (since non-remoted memory)
     return Void();
 }
 
 Return<void> AshmemMemory::commit() {
-    // NOOP
+    // 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 9dbe1fe..825d74e 100644
--- a/transport/memory/1.0/default/AshmemMemory.h
+++ b/transport/memory/1.0/default/AshmemMemory.h
@@ -43,6 +43,7 @@
 
     // 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> commit() override;
     Return<void*> getPointer() override;
     Return<uint64_t> getSize() override;