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

Commit b4799807 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove workaround for the ByteBuffer#put issue"

parents 5bfddadb 2c8fbd62
Loading
Loading
Loading
Loading
+6 −14
Original line number Diff line number Diff line
@@ -308,14 +308,6 @@ abstract class ApkVerityBuilder {
        return rootHash;
    }

    private static void bufferPut(ByteBuffer buffer, byte value) {
        // FIXME(b/72459251): buffer.put(value) does NOT work surprisingly. The position() after put
        // does NOT even change. This hack workaround the problem, but the root cause remains
        // unkonwn yet.  This seems only happen when it goes through the apk install flow on my
        // setup.
        buffer.put(new byte[] { value });
    }

    private static ByteBuffer generateFsverityHeader(ByteBuffer buffer, long fileSize, int depth,
            byte[] salt) {
        if (salt.length != 8) {
@@ -325,10 +317,10 @@ abstract class ApkVerityBuilder {
        // TODO(b/30972906): update the reference when there is a better one in public.
        buffer.put("TrueBrew".getBytes());  // magic

        bufferPut(buffer, (byte) 1);        // major version
        bufferPut(buffer, (byte) 0);        // minor version
        bufferPut(buffer, (byte) 12);       // log2(block-size): log2(4096)
        bufferPut(buffer, (byte) 7);        // log2(leaves-per-node): log2(4096 / 32)
        buffer.put((byte) 1);               // major version
        buffer.put((byte) 0);               // minor version
        buffer.put((byte) 12);              // log2(block-size): log2(4096)
        buffer.put((byte) 7);               // log2(leaves-per-node): log2(4096 / 32)

        buffer.putShort((short) 1);         // meta algorithm, SHA256_MODE == 1
        buffer.putShort((short) 1);         // data algorithm, SHA256_MODE == 1
@@ -338,8 +330,8 @@ abstract class ApkVerityBuilder {

        buffer.putLong(fileSize);           // original file size

        bufferPut(buffer, (byte) 0);        // auth block offset, disabled here
        bufferPut(buffer, (byte) 2);        // extension count
        buffer.put((byte) 0);               // auth block offset, disabled here
        buffer.put((byte) 2);               // extension count
        buffer.put(salt);                   // salt (8 bytes)
        // skip(buffer, 22);                // reserved