mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-12 05:47:46 +01:00
Merge pull request #991 from mmastrac/master
Propagate the raw int values to callers
This commit is contained in:
commit
59c5316d94
@ -22,8 +22,8 @@ package brut.androlib.res.data.value;
|
||||
public class ResBoolValue extends ResScalarValue {
|
||||
private final boolean mValue;
|
||||
|
||||
public ResBoolValue(boolean value, String rawValue) {
|
||||
super("bool", rawValue);
|
||||
public ResBoolValue(boolean value, int rawIntValue, String rawValue) {
|
||||
super("bool", rawIntValue, rawValue);
|
||||
this.mValue = value;
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,11 @@ import brut.androlib.AndrolibException;
|
||||
/**
|
||||
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
*/
|
||||
public class ResFileValue extends ResValue {
|
||||
public class ResFileValue extends ResIntBasedValue {
|
||||
private final String mPath;
|
||||
|
||||
public ResFileValue(String path) {
|
||||
public ResFileValue(String path, int rawIntValue) {
|
||||
super(rawIntValue);
|
||||
this.mPath = path;
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,8 @@ package brut.androlib.res.data.value;
|
||||
public class ResFloatValue extends ResScalarValue {
|
||||
private final float mValue;
|
||||
|
||||
public ResFloatValue(float value, String rawValue) {
|
||||
super("float", rawValue);
|
||||
public ResFloatValue(float value, int rawIntValue, String rawValue) {
|
||||
super("float", rawIntValue, rawValue);
|
||||
this.mValue = value;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package brut.androlib.res.data.value;
|
||||
|
||||
/**
|
||||
* @author Matt Mastracci <matthew@mastracci.com>
|
||||
*/
|
||||
public class ResIntBasedValue extends ResValue {
|
||||
private int mRawIntValue;
|
||||
|
||||
protected ResIntBasedValue(int rawIntValue) {
|
||||
mRawIntValue = rawIntValue;
|
||||
}
|
||||
|
||||
public int getRawIntValue() {
|
||||
return mRawIntValue;
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ public class ResIntValue extends ResScalarValue {
|
||||
}
|
||||
|
||||
public ResIntValue(int value, String rawValue, String type) {
|
||||
super(type, rawValue);
|
||||
super(type, value, rawValue);
|
||||
this.mValue = value;
|
||||
}
|
||||
|
||||
|
@ -27,12 +27,13 @@ import org.xmlpull.v1.XmlSerializer;
|
||||
/**
|
||||
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
*/
|
||||
public abstract class ResScalarValue extends ResValue implements
|
||||
public abstract class ResScalarValue extends ResIntBasedValue implements
|
||||
ResXmlEncodable, ResValuesXmlSerializable {
|
||||
protected final String mType;
|
||||
protected final String mRawValue;
|
||||
|
||||
protected ResScalarValue(String type, String rawValue) {
|
||||
protected ResScalarValue(String type, int rawIntValue, String rawValue) {
|
||||
super(rawIntValue);
|
||||
mType = type;
|
||||
mRawValue = rawValue;
|
||||
}
|
||||
|
@ -27,12 +27,12 @@ import org.xmlpull.v1.XmlSerializer;
|
||||
*/
|
||||
public class ResStringValue extends ResScalarValue {
|
||||
|
||||
public ResStringValue(String value) {
|
||||
this(value, "string");
|
||||
public ResStringValue(String value, int rawValue) {
|
||||
this(value, rawValue, "string");
|
||||
}
|
||||
|
||||
public ResStringValue(String value, String type) {
|
||||
super(type, value);
|
||||
public ResStringValue(String value, int rawValue, String type) {
|
||||
super(type, rawValue, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,15 +41,15 @@ public class ResValueFactory {
|
||||
case TypedValue.TYPE_ATTRIBUTE:
|
||||
return newReference(value, rawValue, true);
|
||||
case TypedValue.TYPE_STRING:
|
||||
return new ResStringValue(rawValue);
|
||||
return new ResStringValue(rawValue, value);
|
||||
case TypedValue.TYPE_FLOAT:
|
||||
return new ResFloatValue(Float.intBitsToFloat(value), rawValue);
|
||||
return new ResFloatValue(Float.intBitsToFloat(value), value, rawValue);
|
||||
case TypedValue.TYPE_DIMENSION:
|
||||
return new ResDimenValue(value, rawValue);
|
||||
case TypedValue.TYPE_FRACTION:
|
||||
return new ResFractionValue(value, rawValue);
|
||||
case TypedValue.TYPE_INT_BOOLEAN:
|
||||
return new ResBoolValue(value != 0, rawValue);
|
||||
return new ResBoolValue(value != 0, value, rawValue);
|
||||
case TypedValue.TYPE_DYNAMIC_REFERENCE:
|
||||
return newReference(value, rawValue);
|
||||
}
|
||||
@ -66,11 +66,11 @@ public class ResValueFactory {
|
||||
throw new AndrolibException("Invalid value type: " + type);
|
||||
}
|
||||
|
||||
public ResValue factory(String value) {
|
||||
public ResIntBasedValue factory(String value, int rawValue) {
|
||||
if (value.startsWith("res/")) {
|
||||
return new ResFileValue(value);
|
||||
return new ResFileValue(value, rawValue);
|
||||
}
|
||||
return new ResStringValue(value);
|
||||
return new ResStringValue(value, rawValue);
|
||||
}
|
||||
|
||||
public ResBagValue bagFactory(int parent,
|
||||
|
@ -203,7 +203,7 @@ public class ARSCDecoder {
|
||||
ResValue value = (flags & ENTRY_FLAG_COMPLEX) == 0 ? readValue() : readComplexEntry();
|
||||
|
||||
if (mType.isString() && value instanceof ResFileValue) {
|
||||
value = new ResStringValue(value.toString());
|
||||
value = new ResStringValue(value.toString(), ((ResFileValue) value).getRawIntValue());
|
||||
}
|
||||
if (mConfig == null) {
|
||||
return;
|
||||
@ -232,17 +232,17 @@ public class ARSCDecoder {
|
||||
|
||||
ResValueFactory factory = mPkg.getValueFactory();
|
||||
Duo<Integer, ResScalarValue>[] items = new Duo[count];
|
||||
ResValue resValue;
|
||||
ResIntBasedValue resValue;
|
||||
int resId;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
resId = mIn.readInt();
|
||||
resValue = readValue();
|
||||
|
||||
try {
|
||||
if (resValue instanceof ResScalarValue) {
|
||||
items[i] = new Duo<Integer, ResScalarValue>(resId, (ResScalarValue) resValue);
|
||||
} catch (ClassCastException ex) {
|
||||
resValue = new ResStringValue(resValue.toString());
|
||||
} else {
|
||||
resValue = new ResStringValue(resValue.toString(), resValue.getRawIntValue());
|
||||
items[i] = new Duo<Integer, ResScalarValue>(resId, (ResScalarValue) resValue);
|
||||
}
|
||||
}
|
||||
@ -250,14 +250,14 @@ public class ARSCDecoder {
|
||||
return factory.bagFactory(parent, items);
|
||||
}
|
||||
|
||||
private ResValue readValue() throws IOException, AndrolibException {
|
||||
private ResIntBasedValue readValue() throws IOException, AndrolibException {
|
||||
/* size */mIn.skipCheckShort((short) 8);
|
||||
/* zero */mIn.skipCheckByte((byte) 0);
|
||||
byte type = mIn.readByte();
|
||||
int data = mIn.readInt();
|
||||
|
||||
return type == TypedValue.TYPE_STRING
|
||||
? mPkg.getValueFactory().factory(mTableStrings.getHTML(data))
|
||||
? mPkg.getValueFactory().factory(mTableStrings.getHTML(data), data)
|
||||
: mPkg.getValueFactory().factory(type, data, null);
|
||||
}
|
||||
|
||||
@ -395,7 +395,7 @@ public class ARSCDecoder {
|
||||
mConfig = mPkg.getOrCreateConfig(new ResConfigFlags());
|
||||
}
|
||||
|
||||
ResValue value = new ResBoolValue(false, null);
|
||||
ResValue value = new ResBoolValue(false, 0, null);
|
||||
ResResource res = new ResResource(mConfig, spec, value);
|
||||
|
||||
mPkg.addResource(res);
|
||||
|
@ -101,7 +101,7 @@ public class ResFileDecoder {
|
||||
LOGGER.log(Level.SEVERE, String.format(
|
||||
"Could not decode file, replacing by FALSE value: %s",
|
||||
inFileName, outFileName), ex);
|
||||
res.replace(new ResBoolValue(false, null));
|
||||
res.replace(new ResBoolValue(false, 0, null));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user