diff options
author | Sudheer Shanka <sudheersai@google.com> | 2020-06-21 22:31:26 -0700 |
---|---|---|
committer | Sudheer Shanka <sudheersai@google.com> | 2020-06-21 22:47:50 -0700 |
commit | a2c2087f941013cb47a757206320dfed1dd8f88e (patch) | |
tree | b1017ab5783507dc00efb59a4c83ba10b5a77796 | |
parent | c8f4a8a5e98832e2764a09e23f480779a0a312ce (diff) |
Correct the blobstore Session.openWrite() API usage in tests.
Fixes: 157204810
Test: atest --test-mapping apex/blobstore
Change-Id: Ic587da72c4018b15902b2b65307b112edc1c119e
-rw-r--r-- | tests/BlobStoreTestUtils/src/com/android/utils/blob/DummyBlobData.java | 9 | ||||
-rw-r--r-- | tests/BlobStoreTestUtils/src/com/android/utils/blob/Utils.java | 6 |
2 files changed, 11 insertions, 4 deletions
diff --git a/tests/BlobStoreTestUtils/src/com/android/utils/blob/DummyBlobData.java b/tests/BlobStoreTestUtils/src/com/android/utils/blob/DummyBlobData.java index 4a0ca664049a..2df0024bdea9 100644 --- a/tests/BlobStoreTestUtils/src/com/android/utils/blob/DummyBlobData.java +++ b/tests/BlobStoreTestUtils/src/com/android/utils/blob/DummyBlobData.java @@ -153,7 +153,14 @@ public class DummyBlobData { public void writeToSession(BlobStoreManager.Session session, long offsetBytes, long lengthBytes) throws Exception { try (FileInputStream in = new FileInputStream(mFile)) { - Utils.writeToSession(session, in, offsetBytes, lengthBytes); + Utils.writeToSession(session, in, offsetBytes, lengthBytes, lengthBytes); + } + } + + public void writeToSession(BlobStoreManager.Session session, + long offsetBytes, long lengthBytes, long allocateBytes) throws Exception { + try (FileInputStream in = new FileInputStream(mFile)) { + Utils.writeToSession(session, in, offsetBytes, lengthBytes, allocateBytes); } } diff --git a/tests/BlobStoreTestUtils/src/com/android/utils/blob/Utils.java b/tests/BlobStoreTestUtils/src/com/android/utils/blob/Utils.java index b9bd661dfd67..ec859955694c 100644 --- a/tests/BlobStoreTestUtils/src/com/android/utils/blob/Utils.java +++ b/tests/BlobStoreTestUtils/src/com/android/utils/blob/Utils.java @@ -59,15 +59,15 @@ public class Utils { public static void writeToSession(BlobStoreManager.Session session, ParcelFileDescriptor input, long lengthBytes) throws IOException { try (FileInputStream in = new ParcelFileDescriptor.AutoCloseInputStream(input)) { - writeToSession(session, in, 0, lengthBytes); + writeToSession(session, in, 0, lengthBytes, lengthBytes); } } public static void writeToSession(BlobStoreManager.Session session, FileInputStream in, - long offsetBytes, long lengthBytes) throws IOException { + long offsetBytes, long lengthBytes, long allocateBytes) throws IOException { in.getChannel().position(offsetBytes); try (FileOutputStream out = new ParcelFileDescriptor.AutoCloseOutputStream( - session.openWrite(offsetBytes, lengthBytes))) { + session.openWrite(offsetBytes, allocateBytes))) { copy(in, out, lengthBytes); } } |