mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-05 02:22:55 +01:00
cleanup of various functions
Removed attr sorting that was never enabled and never worked, added @todo elements for unknown file handling, updated usage output
This commit is contained in:
parent
0ca74eca67
commit
a48c11dc1c
@ -487,9 +487,9 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isAdvanceMode() {
|
||||
return advanceMode;
|
||||
}
|
||||
public static boolean isAdvanceMode() {
|
||||
return advanceMode;
|
||||
}
|
||||
|
||||
public static void setAdvanceMode(boolean advanceMode) {
|
||||
Main.advanceMode = advanceMode;
|
||||
|
@ -546,7 +546,9 @@ public class Androlib {
|
||||
|
||||
// check if file exists
|
||||
if (new File(appDir,entry.getKey()).isFile()) {
|
||||
// apkZipFile.
|
||||
|
||||
// @todo read ZipFile and inject file into
|
||||
// might need to use Zip4j
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
|
@ -283,7 +283,7 @@ public class AXmlResourceParser implements XmlResourceParser {
|
||||
if (m_event != START_TAG) {
|
||||
return -1;
|
||||
}
|
||||
return m_attributes.length / ATTRIBUTE_LENGHT;
|
||||
return m_attributes.length / ATTRIBUTE_LENGTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -362,13 +362,7 @@ public class AXmlResourceParser implements XmlResourceParser {
|
||||
getAttributePrefix(index), getAttributeName(index),
|
||||
valueData), ex);
|
||||
}
|
||||
} else {
|
||||
if (valueType == TypedValue.TYPE_STRING) {
|
||||
return ResXmlEncoders.escapeXmlChars(m_strings
|
||||
.getString(valueRaw));
|
||||
}
|
||||
}
|
||||
|
||||
return TypedValue.coerceToString(valueType, valueData);
|
||||
}
|
||||
|
||||
@ -830,7 +824,7 @@ public class AXmlResourceParser implements XmlResourceParser {
|
||||
throw new IndexOutOfBoundsException(
|
||||
"Current event is not START_TAG.");
|
||||
}
|
||||
int offset = index * ATTRIBUTE_LENGHT;
|
||||
int offset = index * ATTRIBUTE_LENGTH;
|
||||
if (offset >= m_attributes.length) {
|
||||
throw new IndexOutOfBoundsException("Invalid attribute index ("
|
||||
+ index + ").");
|
||||
@ -847,11 +841,11 @@ public class AXmlResourceParser implements XmlResourceParser {
|
||||
return -1;
|
||||
}
|
||||
int uri = (namespace != null) ? m_strings.find(namespace) : -1;
|
||||
for (int o = 0; o != m_attributes.length; o += ATTRIBUTE_LENGHT) {
|
||||
for (int o = 0; o != m_attributes.length; o += ATTRIBUTE_LENGTH) {
|
||||
if (name == m_attributes[o + ATTRIBUTE_IX_NAME]
|
||||
&& (uri == -1 || uri == m_attributes[o
|
||||
+ ATTRIBUTE_IX_NAMESPACE_URI])) {
|
||||
return o / ATTRIBUTE_LENGHT;
|
||||
return o / ATTRIBUTE_LENGTH;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@ -874,7 +868,8 @@ public class AXmlResourceParser implements XmlResourceParser {
|
||||
m_reader.skipCheckInt(CHUNK_AXML_FILE);
|
||||
/*
|
||||
* chunkSize
|
||||
*/m_reader.skipInt();
|
||||
*/
|
||||
m_reader.skipInt();
|
||||
m_strings = StringBlock.read(m_reader);
|
||||
m_namespaces.increaseDepth();
|
||||
m_operational = true;
|
||||
@ -960,10 +955,10 @@ public class AXmlResourceParser implements XmlResourceParser {
|
||||
m_styleAttribute = (m_classAttribute >>> 16) - 1;
|
||||
m_classAttribute = (m_classAttribute & 0xFFFF) - 1;
|
||||
m_attributes = m_reader.readIntArray(attributeCount
|
||||
* ATTRIBUTE_LENGHT);
|
||||
* ATTRIBUTE_LENGTH);
|
||||
for (int i = ATTRIBUTE_IX_VALUE_TYPE; i < m_attributes.length;) {
|
||||
m_attributes[i] = (m_attributes[i] >>> 24);
|
||||
i += ATTRIBUTE_LENGHT;
|
||||
i += ATTRIBUTE_LENGTH;
|
||||
}
|
||||
m_namespaces.increaseDepth();
|
||||
m_event = START_TAG;
|
||||
@ -988,62 +983,6 @@ public class AXmlResourceParser implements XmlResourceParser {
|
||||
}
|
||||
}
|
||||
|
||||
private static String formatArray(int[] array, int min, int max) {
|
||||
if (max > array.length) {
|
||||
max = array.length;
|
||||
}
|
||||
if (min < 0) {
|
||||
min = 0;
|
||||
}
|
||||
StringBuffer sb = new StringBuffer("[");
|
||||
int i = min;
|
||||
while (true) {
|
||||
sb.append(array[i]);
|
||||
i++;
|
||||
if (i < max) {
|
||||
sb.append(", ");
|
||||
} else {
|
||||
sb.append("]");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private boolean compareAttr(int[] attr1, int[] attr2) {
|
||||
// TODO: sort Attrs
|
||||
/*
|
||||
* ATTRIBUTE_IX_VALUE_TYPE == TYPE_STRING : ATTRIBUTE_IX_VALUE_STRING :
|
||||
* ATTRIBUTE_IX_NAMESPACE_URI ATTRIBUTE_IX_NAMESPACE_URI :
|
||||
* ATTRIBUTE_IX_NAME id
|
||||
*/
|
||||
if (attr1[ATTRIBUTE_IX_VALUE_TYPE] == TypedValue.TYPE_STRING
|
||||
&& attr1[ATTRIBUTE_IX_VALUE_TYPE] == attr2[ATTRIBUTE_IX_VALUE_TYPE]
|
||||
&& // (m_strings.touch(attr1[ATTRIBUTE_IX_VALUE_STRING], m_name)
|
||||
// ||
|
||||
// m_strings.touch(attr2[ATTRIBUTE_IX_VALUE_STRING],
|
||||
// m_name)) &&
|
||||
// m_strings.touch(attr1[ATTRIBUTE_IX_VALUE_STRING], m_name)
|
||||
// &&
|
||||
attr1[ATTRIBUTE_IX_VALUE_STRING] != attr2[ATTRIBUTE_IX_VALUE_STRING]) {
|
||||
return (attr1[ATTRIBUTE_IX_VALUE_STRING] < attr2[ATTRIBUTE_IX_VALUE_STRING]);
|
||||
} else if ((attr1[ATTRIBUTE_IX_NAMESPACE_URI] == attr2[ATTRIBUTE_IX_NAMESPACE_URI])
|
||||
&& (attr1[ATTRIBUTE_IX_NAMESPACE_URI] != -1) && // (m_strings.touch(attr1[ATTRIBUTE_IX_NAME],
|
||||
// m_name) ||
|
||||
// m_strings.touch(attr2[ATTRIBUTE_IX_NAME],
|
||||
// m_name)) &&
|
||||
// m_strings.touch(attr1[ATTRIBUTE_IX_NAME],
|
||||
// m_name) &&
|
||||
(attr1[ATTRIBUTE_IX_NAME] != attr2[ATTRIBUTE_IX_NAME])) {
|
||||
return (attr1[ATTRIBUTE_IX_NAME] < attr2[ATTRIBUTE_IX_NAME]);
|
||||
// } else if (attr1[ATTRIBUTE_IX_NAMESPACE_URI] <
|
||||
// attr2[ATTRIBUTE_IX_NAMESPACE_URI]) {
|
||||
// return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void setFirstError(AndrolibException error) {
|
||||
if (mFirstError == null) {
|
||||
mFirstError = error;
|
||||
@ -1079,7 +1018,7 @@ public class AXmlResourceParser implements XmlResourceParser {
|
||||
private static final int ATTRIBUTE_IX_NAMESPACE_URI = 0,
|
||||
ATTRIBUTE_IX_NAME = 1, ATTRIBUTE_IX_VALUE_STRING = 2,
|
||||
ATTRIBUTE_IX_VALUE_TYPE = 3, ATTRIBUTE_IX_VALUE_DATA = 4,
|
||||
ATTRIBUTE_LENGHT = 5;
|
||||
ATTRIBUTE_LENGTH = 5;
|
||||
|
||||
private static final int CHUNK_AXML_FILE = 0x00080003,
|
||||
CHUNK_RESOURCEIDS = 0x00080180, CHUNK_XML_FIRST = 0x00100100,
|
||||
|
@ -309,20 +309,6 @@ public class StringBlock {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean touch(int index, int own) {
|
||||
if (index < 0 || m_stringOwns == null || index >= m_stringOwns.length) {
|
||||
return false;
|
||||
}
|
||||
if (m_stringOwns[index] == -1) {
|
||||
m_stringOwns[index] = own;
|
||||
return true;
|
||||
} else if (m_stringOwns[index] == own) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private int[] m_stringOffsets;
|
||||
private byte[] m_strings;
|
||||
private int[] m_styleOffsets;
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
|
||||
dependencies {
|
||||
compile project(':brut.j.common'), "commons-io:commons-io:2.4"
|
||||
compile project(':brut.j.common')
|
||||
compile "commons-io:commons-io:2.4",
|
||||
"org.apache.commons:commons-compress:1.4.1"
|
||||
testCompile "junit:junit:3.8.1"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user