diff --git a/src/brut/androlib/res/data/ResConfigFlags.java b/src/brut/androlib/res/data/ResConfigFlags.java index 2fc1975f..2c481f87 100644 --- a/src/brut/androlib/res/data/ResConfigFlags.java +++ b/src/brut/androlib/res/data/ResConfigFlags.java @@ -43,6 +43,8 @@ public class ResConfigFlags { public final byte screenLayout; public final byte uiMode; + public final boolean isInvalid; + private final String mQualifiers; public ResConfigFlags() { @@ -61,6 +63,7 @@ public class ResConfigFlags { sdkVersion = 0; screenLayout = SCREENLONG_ANY | SCREENSIZE_ANY; uiMode = UI_MODE_TYPE_ANY | UI_MODE_NIGHT_ANY; + isInvalid = false; mQualifiers = ""; } @@ -68,7 +71,7 @@ public class ResConfigFlags { byte orientation, byte touchscreen, short density, byte keyboard, byte navigation, byte inputFlags, short screenWidth, short screenHeight, short sdkVersion, byte screenLayout, - byte uiMode) { + byte uiMode, boolean isInvalid) { this.mcc = mcc; this.mnc = mnc; this.language = language; @@ -84,6 +87,7 @@ public class ResConfigFlags { this.sdkVersion = sdkVersion; this.screenLayout = screenLayout; this.uiMode = uiMode; + this.isInvalid = isInvalid; mQualifiers = generateQualifiers(); } @@ -234,6 +238,9 @@ public class ResConfigFlags { if (sdkVersion > getNaturalSdkVersionRequirement()) { ret.append("-v").append(sdkVersion); } + if (isInvalid) { + ret.append("-[ERR]"); + } return ret.toString(); } diff --git a/src/brut/androlib/res/decoder/ARSCDecoder.java b/src/brut/androlib/res/decoder/ARSCDecoder.java index b1e4d4c2..6229bd06 100644 --- a/src/brut/androlib/res/decoder/ARSCDecoder.java +++ b/src/brut/androlib/res/decoder/ARSCDecoder.java @@ -143,7 +143,11 @@ public class ARSCDecoder { int[] entryOffsets = mIn.readIntArray(entryCount); ResConfig config; - if (mPkg.hasConfig(flags)) { + if (flags.isInvalid) { + config = null; + LOGGER.warning( + "Invalid config flags detected. Dropping resources: " + mType.getName() + flags.getQualifiers()); + } else if (mPkg.hasConfig(flags)) { config = mPkg.getConfig(flags); } else { config = new ResConfig(flags); @@ -167,6 +171,13 @@ public class ARSCDecoder { short flags = mIn.readShort(); int specNamesId = mIn.readInt(); + ResValue value = (flags & ENTRY_FLAG_COMPLEX) == 0 ? + readValue() : readComplexEntry(); + + if (mConfig == null) { + return; + } + ResID resId = new ResID(mResId); ResResSpec spec; if (mPkg.hasResSpec(resId)) { @@ -177,9 +188,6 @@ public class ARSCDecoder { mPkg.addResSpec(spec); mType.addResSpec(spec); } - - ResValue value = (flags & ENTRY_FLAG_COMPLEX) == 0 ? - readValue() : readComplexEntry(); ResResource res = new ResResource(mConfig, spec, value); mConfig.addResource(res); @@ -219,6 +227,8 @@ public class ARSCDecoder { throw new AndrolibException("Config size < 28"); } + boolean isInvalid = false; + short mcc = mIn.readShort(); short mnc = mIn.readShort(); @@ -262,7 +272,8 @@ public class ARSCDecoder { return new ResConfigFlags(mcc, mnc, language, country, orientation, touchscreen, density, keyboard, navigation, inputFlags, - screenWidth, screenHeight, sdkVersion, screenLayout, uiMode); + screenWidth, screenHeight, sdkVersion, screenLayout, uiMode, + isInvalid); } private void addMissingResSpecs() throws AndrolibException {