mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-20 16:57:34 +01:00
Initial support for BCP47 tags
- needs script/variant support - currently only region(s) supported
This commit is contained in:
parent
1788ca061b
commit
af65dea319
@ -256,8 +256,8 @@ public class ARSCDecoder {
|
||||
short mcc = mIn.readShort();
|
||||
short mnc = mIn.readShort();
|
||||
|
||||
char[] language = new char[] { (char) mIn.readByte(), (char) mIn.readByte() };
|
||||
char[] country = new char[] { (char) mIn.readByte(), (char) mIn.readByte() };
|
||||
char[] language = this.unpackLanguageOrRegion(mIn.readByte(), mIn.readByte(), 'a');
|
||||
char[] country = this.unpackLanguageOrRegion(mIn.readByte(), mIn.readByte(), '0');
|
||||
|
||||
byte orientation = mIn.readByte();
|
||||
byte touchscreen = mIn.readByte();
|
||||
@ -320,6 +320,24 @@ public class ARSCDecoder {
|
||||
screenHeightDp, isInvalid);
|
||||
}
|
||||
|
||||
private char[] unpackLanguageOrRegion(byte in0, byte in1, char base) throws AndrolibException {
|
||||
if (in0 == 0 && in1 == 0) {
|
||||
return new char[] {(char) in0, (char) in1};
|
||||
} else {
|
||||
// check high bit, if so we have a packed 3 letter code
|
||||
if (((in0 >> 7) & 1) == 1) {
|
||||
int first = in1 & 0x1F;
|
||||
int second = ((in1 & 0xE0) >> 5) + ((in0 & 0x03) << 3);
|
||||
int third = (in0 & 0x7C) >> 2;
|
||||
|
||||
// since this function handles languages & regions, we add the value(s) to the base char
|
||||
// which is usually 'a' or '0' depending on language or region.
|
||||
return new char[] { (char) (first + base), (char) (second + base), (char) (third + base) };
|
||||
}
|
||||
return new char[] { (char) in0, (char) in1 };
|
||||
}
|
||||
}
|
||||
|
||||
private void addMissingResSpecs() throws AndrolibException {
|
||||
int resId = mResId & 0xffff0000;
|
||||
|
||||
|
@ -182,6 +182,11 @@ public class BuildAndDecodeTest {
|
||||
compareValuesFiles("values-watch/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bcp47tagTest() throws BrutException, IOException {
|
||||
compareValuesFiles("values-ast-rES/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawableNoDpiTest() throws BrutException, IOException {
|
||||
compareResFolder("drawable-nodpi");
|
||||
|
@ -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