mirror of
https://github.com/revanced/Apktool.git
synced 2025-02-14 04:46:50 +01:00
MNC, noticed recently in API 23, is no longer 0 padded. So mnc001 is now mnc1
- Frameworks between froyo and honeycomb have mnc001, etc - A size check of ResConfig header for less than 32 (honeycomb) uses old decode method - Greater than 32 bytes moves to new decode method of mnc# vs mnc###
This commit is contained in:
parent
0649d5a638
commit
8374839427
@ -57,6 +57,8 @@ public class ResConfigFlags {
|
||||
|
||||
private final String mQualifiers;
|
||||
|
||||
private final int size;
|
||||
|
||||
public ResConfigFlags() {
|
||||
mcc = 0;
|
||||
mnc = 0;
|
||||
@ -81,6 +83,7 @@ public class ResConfigFlags {
|
||||
screenLayout2 = 0;
|
||||
isInvalid = false;
|
||||
mQualifiers = "";
|
||||
size = 0;
|
||||
}
|
||||
|
||||
public ResConfigFlags(short mcc, short mnc, char[] language,
|
||||
@ -90,7 +93,7 @@ public class ResConfigFlags {
|
||||
short sdkVersion, byte screenLayout, byte uiMode,
|
||||
short smallestScreenWidthDp, short screenWidthDp,
|
||||
short screenHeightDp, char[] localeScript, char[] localeVariant,
|
||||
byte screenLayout2, boolean isInvalid) {
|
||||
byte screenLayout2, boolean isInvalid, int size) {
|
||||
if (orientation < 0 || orientation > 3) {
|
||||
LOGGER.warning("Invalid orientation value: " + orientation);
|
||||
orientation = 0;
|
||||
@ -155,6 +158,7 @@ public class ResConfigFlags {
|
||||
this.localeVariant = localeVariant;
|
||||
this.screenLayout2 = screenLayout2;
|
||||
this.isInvalid = isInvalid;
|
||||
this.size = size;
|
||||
mQualifiers = generateQualifiers();
|
||||
}
|
||||
|
||||
@ -169,10 +173,14 @@ public class ResConfigFlags {
|
||||
if (mnc != MNC_ZERO) {
|
||||
if (mnc != 0) {
|
||||
ret.append("-mnc");
|
||||
if (mnc > 0 && mnc < 10) {
|
||||
ret.append(String.format("%02d", mnc));
|
||||
if (size <= 32) {
|
||||
if (mnc > 0 && mnc < 10) {
|
||||
ret.append(String.format("%02d", mnc));
|
||||
} else {
|
||||
ret.append(String.format("%03d", mnc));
|
||||
}
|
||||
} else {
|
||||
ret.append(String.format("%03d", mnc));
|
||||
ret.append(mnc);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -354,7 +354,7 @@ public class ARSCDecoder {
|
||||
orientation, touchscreen, density, keyboard, navigation,
|
||||
inputFlags, screenWidth, screenHeight, sdkVersion,
|
||||
screenLayout, uiMode, smallestScreenWidthDp, screenWidthDp,
|
||||
screenHeightDp, localeScript, localeVariant, screenLayout2, isInvalid);
|
||||
screenHeightDp, localeScript, localeVariant, screenLayout2, isInvalid, size);
|
||||
}
|
||||
|
||||
private char[] unpackLanguageOrRegion(byte in0, byte in1, char base) throws AndrolibException {
|
||||
|
@ -177,14 +177,14 @@ public class BuildAndDecodeTest {
|
||||
|
||||
@Test
|
||||
public void qualifiersTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc004-mnc04-en-rUS-ldrtl-sw100dp-w200dp-h300dp"
|
||||
compareValuesFiles("values-mcc004-mnc4-en-rUS-ldrtl-sw100dp-w200dp-h300dp"
|
||||
+ "-xlarge-long-round-land-desk-night-xhdpi-finger-keyssoft-12key"
|
||||
+ "-navhidden-dpad/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shortendedMncTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001-mnc01/strings.xml");
|
||||
compareValuesFiles("values-mcc001-mnc1/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -192,6 +192,16 @@ public class BuildAndDecodeTest {
|
||||
compareValuesFiles("values-mnc1/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shortMncv2Test() throws BrutException {
|
||||
compareValuesFiles("values-mcc238-mnc6/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void longMncTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc238-mnc870/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anyDpiTest() throws BrutException, IOException {
|
||||
compareValuesFiles("values-watch/strings.xml");
|
||||
|
@ -16,11 +16,13 @@
|
||||
|
||||
package brut.androlib;
|
||||
|
||||
import brut.androlib.res.AndrolibResources;
|
||||
import brut.common.BrutException;
|
||||
import brut.directory.*;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.file.Files;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.custommonkey.xmlunit.ElementQualifier;
|
||||
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="test1">test1</string>
|
||||
</resources>
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="test1">test1</string>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user