Remove workaround for the ByteBuffer#put issue
It works on ToT now. See b/72480435 for the ART bug.
Test: install apk with verity and succeed
Bug: 72459251
Change-Id: I409b344169b3448496d26b772b520d9b148d7baf
diff --git a/core/java/android/util/apk/ApkVerityBuilder.java b/core/java/android/util/apk/ApkVerityBuilder.java
index ba21ccb..4c6e511 100644
--- a/core/java/android/util/apk/ApkVerityBuilder.java
+++ b/core/java/android/util/apk/ApkVerityBuilder.java
@@ -308,14 +308,6 @@
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 @@
// 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 @@
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