mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-12 05:47:46 +01:00
Merge pull request #1690 from iBotPeaches/type-id-offset
We are ignoring typeIdOffset
This commit is contained in:
commit
17bad5a9bd
@ -77,6 +77,7 @@ public class ARSCDecoder {
|
||||
|
||||
nextChunk();
|
||||
for (int i = 0; i < packageCount; i++) {
|
||||
mTypeIdOffset = 0;
|
||||
packages[i] = readTablePackage();
|
||||
}
|
||||
return packages;
|
||||
@ -103,6 +104,17 @@ public class ARSCDecoder {
|
||||
/* keyStrings */mIn.skipInt();
|
||||
/* lastPublicKey */mIn.skipInt();
|
||||
|
||||
// TypeIdOffset was added platform_frameworks_base/@f90f2f8dc36e7243b85e0b6a7fd5a590893c827e
|
||||
// which is only in split/new applications.
|
||||
int splitHeaderSize = (2 + 2 + 4 + 4 + (2 * 128) + (4 * 5)); // short, short, int, int, char[128], int * 4
|
||||
if (mHeader.headerSize == splitHeaderSize) {
|
||||
mTypeIdOffset = mIn.readInt();
|
||||
}
|
||||
|
||||
if (mTypeIdOffset > 0) {
|
||||
LOGGER.warning("Please report this application to Apktool for a fix: https://github.com/iBotPeaches/Apktool/issues/1728");
|
||||
}
|
||||
|
||||
mTypeNames = StringBlock.read(mIn);
|
||||
mSpecNames = StringBlock.read(mIn);
|
||||
|
||||
@ -157,6 +169,7 @@ public class ARSCDecoder {
|
||||
|
||||
// skip "TYPE 8 chunks" and/or padding data at the end of this chunk
|
||||
if (mCountIn.getCount() < mHeader.endPosition) {
|
||||
LOGGER.warning("Unknown data detected. Skipping: " + (mHeader.endPosition - mCountIn.getCount()) + " byte(s)");
|
||||
mCountIn.skip(mHeader.endPosition - mCountIn.getCount());
|
||||
}
|
||||
|
||||
@ -186,7 +199,7 @@ public class ARSCDecoder {
|
||||
|
||||
private ResType readTableType() throws IOException, AndrolibException {
|
||||
checkChunkType(Header.TYPE_TYPE);
|
||||
int typeId = mIn.readUnsignedByte();
|
||||
int typeId = mIn.readUnsignedByte() - mTypeIdOffset;
|
||||
if (mResTypeSpecs.containsKey(typeId)) {
|
||||
mResId = (0xff000000 & mResId) | mResTypeSpecs.get(typeId).getId() << 16;
|
||||
mTypeSpec = mResTypeSpecs.get(typeId);
|
||||
@ -205,6 +218,7 @@ public class ARSCDecoder {
|
||||
// For some APKs there is a disconnect between the reported size of Configs
|
||||
// If we find a mismatch skip those bytes.
|
||||
if (position != mCountIn.getCount()) {
|
||||
LOGGER.warning("Invalid data detected. Skipping: " + (position - mCountIn.getCount()) + " byte(s)");
|
||||
mIn.skipBytes(position - mCountIn.getCount());
|
||||
}
|
||||
|
||||
@ -544,6 +558,7 @@ public class ARSCDecoder {
|
||||
private ResTypeSpec mTypeSpec;
|
||||
private ResType mType;
|
||||
private int mResId;
|
||||
private int mTypeIdOffset = 0;
|
||||
private boolean[] mMissingResSpecs;
|
||||
private HashMap<Integer, ResTypeSpec> mResTypeSpecs = new HashMap<>();
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class StringBlock {
|
||||
* be at the chunk type.
|
||||
*/
|
||||
public static StringBlock read(ExtDataInput reader) throws IOException {
|
||||
reader.skipCheckChunkTypeInt(CHUNK_STRINGPOOL_TYPE, CHUNK_NULL_TYPE);
|
||||
reader.skipCheckInt(CHUNK_STRINGPOOL_TYPE);
|
||||
int chunkSize = reader.readInt();
|
||||
|
||||
// ResStringPool_header
|
||||
|
Loading…
Reference in New Issue
Block a user