From 1037986e950958fe05883e2c1cb684221465c211 Mon Sep 17 00:00:00 2001 From: REAndroid Date: Tue, 2 May 2023 17:27:45 +0200 Subject: [PATCH] fix issue on attribute format encoding --- .../apk/xmlencoder/XMLValuesEncoderAttr.java | 3 +-- .../arsc/value/attribute/AttributeBagItem.java | 4 ++-- .../arsc/value/attribute/AttributeValueType.java | 14 +++++++------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/reandroid/apk/xmlencoder/XMLValuesEncoderAttr.java b/src/main/java/com/reandroid/apk/xmlencoder/XMLValuesEncoderAttr.java index 66b803c..03acca4 100644 --- a/src/main/java/com/reandroid/apk/xmlencoder/XMLValuesEncoderAttr.java +++ b/src/main/java/com/reandroid/apk/xmlencoder/XMLValuesEncoderAttr.java @@ -63,8 +63,7 @@ class XMLValuesEncoderAttr extends XMLValuesEncoderBag{ AttributeValueType[] valueTypes = AttributeValueType .valuesOf(parentElement.getAttributeValue("formats")); - formatItem.setDataLow((short) (0xffff & - AttributeValueType.getByte(valueTypes))); + formatItem.setDataLow((short) (0xff & AttributeValueType.sumValues(valueTypes))); bagIndex++; diff --git a/src/main/java/com/reandroid/arsc/value/attribute/AttributeBagItem.java b/src/main/java/com/reandroid/arsc/value/attribute/AttributeBagItem.java index 6c47f1e..d6c675d 100755 --- a/src/main/java/com/reandroid/arsc/value/attribute/AttributeBagItem.java +++ b/src/main/java/com/reandroid/arsc/value/attribute/AttributeBagItem.java @@ -89,7 +89,7 @@ public class AttributeBagItem { if(valueType == null || getItemType()!=AttributeItemType.FORMAT){ return false; } - int value = 0xff & valueType.getByte(); + int value = 0xff & valueType.sumValues(); int dataLow = 0xffff & getBagItem().getData(); return (dataLow & value) == value; } @@ -97,7 +97,7 @@ public class AttributeBagItem { if(valueType == null || getItemType()!=AttributeItemType.FORMAT){ return false; } - int value = 0xff & valueType.getByte(); + int value = 0xff & valueType.sumValues(); int dataLow = 0xffff & getBagItem().getData(); return (dataLow == value); } diff --git a/src/main/java/com/reandroid/arsc/value/attribute/AttributeValueType.java b/src/main/java/com/reandroid/arsc/value/attribute/AttributeValueType.java index 176f6b5..5a9feb6 100755 --- a/src/main/java/com/reandroid/arsc/value/attribute/AttributeValueType.java +++ b/src/main/java/com/reandroid/arsc/value/attribute/AttributeValueType.java @@ -1,4 +1,4 @@ - /* +/* * Copyright (C) 2022 github.com/REAndroid * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,7 +34,7 @@ import java.util.*; AttributeValueType(byte b) { this.mByte=b; } - public byte getByte(){ + public byte sumValues(){ return mByte; } @Override @@ -65,18 +65,18 @@ import java.util.*; } return builder.toString(); } - public static byte getByte(AttributeValueType[] valueTypes){ + public static int sumValues(AttributeValueType[] valueTypes){ if(valueTypes==null){ return 0; } - int i=0; + int result = 0; for(AttributeValueType vt:valueTypes){ - if(vt==null){ + if(vt == null){ continue; } - i=i|(0xff & vt.mByte); + result = result | (0xff & vt.mByte); } - return (byte) (0xff & i); + return result; } public static AttributeValueType valueOf(byte b){ AttributeValueType[] all=values();