Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e0b767a authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Automerger Merge Worker
Browse files

Merge "Correct the blobstore Session.openWrite() API usage in tests." into...

Merge "Correct the blobstore Session.openWrite() API usage in tests." into rvc-dev am: 74e4018f am: f98a78d4 am: a9e536ef

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11948400

Change-Id: I8195350e9e2f8aa674d17b68dd55eea4748c175c
parents 4cc94f91 a9e536ef
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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);
        }
    }

+3 −3
Original line number Diff line number Diff line
@@ -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);
        }
    }