From e873913f68cb0c655658b590dc430d60eb4a3357 Mon Sep 17 00:00:00 2001 From: REAndroid Date: Sun, 12 Mar 2023 09:42:38 -0400 Subject: [PATCH] implement unsigned byte & short value --- src/main/java/com/reandroid/arsc/item/ByteArray.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/reandroid/arsc/item/ByteArray.java b/src/main/java/com/reandroid/arsc/item/ByteArray.java index 9eb530b..86c7bcf 100755 --- a/src/main/java/com/reandroid/arsc/item/ByteArray.java +++ b/src/main/java/com/reandroid/arsc/item/ByteArray.java @@ -73,6 +73,13 @@ public class ByteArray extends BlockItem { } return getBytesInternal()[index]; } + public int getByteUnsigned(int index){ + Byte b = get(index); + if(b==null){ + return 0; + } + return 0xff & b; + } public final void put(int index, byte value){ byte[] bts = getBytesInternal(); bts[index]=value; @@ -99,6 +106,9 @@ public class ByteArray extends BlockItem { bts[offset+1]= (byte) (val >>> 8 & 0xff); bts[offset]= (byte) (val & 0xff); } + public final int getShortUnsigned(int offset){ + return 0xffff & getShort(offset); + } public final short getShort(int offset){ byte[] bts = getBytesInternal(); return (short) (bts[offset] & 0xff | (bts[offset+1] & 0xff) << 8);