From 013a2e1336693f44db82fbede928d348571cb868 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 31 Aug 2020 04:02:47 -0700 Subject: [PATCH] Minor code changes --- app/src/main/java/com/topjohnwu/magisk/core/utils/AXML.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/core/utils/AXML.kt b/app/src/main/java/com/topjohnwu/magisk/core/utils/AXML.kt index 39469c332..0775e81ac 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/utils/AXML.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/utils/AXML.kt @@ -81,6 +81,7 @@ class AXML(b: ByteArray) { val baos = RawByteStream() baos.write(bytes, 0, dataOff) + // Write string data val strList = IntArray(count) for (i in 0 until count) { strList[i] = baos.size() - dataOff @@ -102,9 +103,8 @@ class AXML(b: ByteArray) { newBuffer.putInt(start + CHUNK_SIZE_OFF, size + sizeDiff) // Patch index table newBuffer.position(start + STRING_INDICES_OFF) - val newStrList = newBuffer.asIntBuffer() - for (idx in strList) - newStrList.put(idx) + val newIntBuf = newBuffer.asIntBuffer() + strList.forEach { newIntBuf.put(it) } // Write the rest of the chunks val nextOff = start + size @@ -121,7 +121,7 @@ class AXML(b: ByteArray) { } private class RawByteStream : ByteArrayOutputStream() { - val buf get() = buf + val buf: ByteArray get() = buf fun align(alignment: Int = 4) { val newCount = (count + alignment - 1) / alignment * alignment