mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-05 02:22:55 +01:00
StringBlock, AXmlResourceParser: use ExtDataInput instead of IntReader and ChunkUtil.
This commit is contained in:
parent
819d2aa463
commit
19f06fe98d
@ -16,11 +16,14 @@
|
|||||||
*/
|
*/
|
||||||
package brut.androlib.res.decoder;
|
package brut.androlib.res.decoder;
|
||||||
|
|
||||||
|
import android.content.res.XmlResourceParser;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
import brut.util.ExtDataInput;
|
||||||
|
import com.mindprod.ledatastream.LEDataInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||||
@ -47,7 +50,8 @@ public class AXmlResourceParser implements XmlResourceParser {
|
|||||||
public void open(InputStream stream) {
|
public void open(InputStream stream) {
|
||||||
close();
|
close();
|
||||||
if (stream != null) {
|
if (stream != null) {
|
||||||
m_reader = new IntReader(stream, false);
|
m_reader = new ExtDataInput(
|
||||||
|
new LEDataInputStream(stream));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +60,7 @@ public class AXmlResourceParser implements XmlResourceParser {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_operational = false;
|
m_operational = false;
|
||||||
m_reader.close();
|
// m_reader.close();
|
||||||
m_reader = null;
|
m_reader = null;
|
||||||
m_strings = null;
|
m_strings = null;
|
||||||
m_resourceIDs = null;
|
m_resourceIDs = null;
|
||||||
@ -756,7 +760,7 @@ public class AXmlResourceParser implements XmlResourceParser {
|
|||||||
private final void doNext() throws IOException {
|
private final void doNext() throws IOException {
|
||||||
// Delayed initialization.
|
// Delayed initialization.
|
||||||
if (m_strings == null) {
|
if (m_strings == null) {
|
||||||
ChunkUtil.readCheckType(m_reader, CHUNK_AXML_FILE);
|
m_reader.skipCheckInt(CHUNK_AXML_FILE);
|
||||||
/*chunkSize*/ m_reader.skipInt();
|
/*chunkSize*/ m_reader.skipInt();
|
||||||
m_strings = StringBlock.read(m_reader);
|
m_strings = StringBlock.read(m_reader);
|
||||||
m_namespaces.increaseDepth();
|
m_namespaces.increaseDepth();
|
||||||
@ -874,7 +878,7 @@ public class AXmlResourceParser implements XmlResourceParser {
|
|||||||
* All values are essentially indices, e.g. m_name is
|
* All values are essentially indices, e.g. m_name is
|
||||||
* an index of name in m_strings.
|
* an index of name in m_strings.
|
||||||
*/
|
*/
|
||||||
private IntReader m_reader;
|
private ExtDataInput m_reader;
|
||||||
private boolean m_operational = false;
|
private boolean m_operational = false;
|
||||||
private StringBlock m_strings;
|
private StringBlock m_strings;
|
||||||
private int[] m_resourceIDs;
|
private int[] m_resourceIDs;
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package brut.androlib.res.decoder;
|
package brut.androlib.res.decoder;
|
||||||
|
|
||||||
|
import brut.util.ExtDataInput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,8 +35,8 @@ public class StringBlock {
|
|||||||
* Reads whole (including chunk type) string block from stream.
|
* Reads whole (including chunk type) string block from stream.
|
||||||
* Stream must be at the chunk type.
|
* Stream must be at the chunk type.
|
||||||
*/
|
*/
|
||||||
public static StringBlock read(IntReader reader) throws IOException {
|
public static StringBlock read(ExtDataInput reader) throws IOException {
|
||||||
ChunkUtil.readCheckType(reader, CHUNK_TYPE);
|
reader.skipCheckInt(CHUNK_TYPE);
|
||||||
int chunkSize = reader.readInt();
|
int chunkSize = reader.readInt();
|
||||||
int stringCount = reader.readInt();
|
int stringCount = reader.readInt();
|
||||||
int styleOffsetCount = reader.readInt();
|
int styleOffsetCount = reader.readInt();
|
||||||
|
Loading…
Reference in New Issue
Block a user