mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-23 10:17:33 +01:00
Merge pull request #1493 from iBotPeaches/issue-1453
Android O Preview Support
This commit is contained in:
commit
5ec25c9e37
19
INTERNAL.md
19
INTERNAL.md
@ -239,3 +239,22 @@ we lose the ability to quickly build just the aapt binary. So the Windows proced
|
||||
1. `source build/envsetup.sh`
|
||||
2. `lunch sdk-eng`
|
||||
3. `make OUT_DIR=out-x64 LOCAL_MULTILIB=64 USE_NINJA=false aapt`
|
||||
|
||||
# Gradle Tips n Tricks
|
||||
|
||||
./gradlew build shadowJar proguard -x test
|
||||
|
||||
This skips the testing suite (which currently takes 2-4 minutes). Use this when making quick builds and save the testing
|
||||
suite before pushing to GitHub.
|
||||
|
||||
./gradlew build shadowJar proguard -Dtest.debug
|
||||
|
||||
This enables debugging on the test suite. This starts the debugger on port 5005 which you can connect with IntelliJ.
|
||||
|
||||
./gradlew :brut.apktool:apktool-lib:test ---tests "*BuildAndDecodeTest"
|
||||
|
||||
This runs the library project of Apktool, selecting a specific test to run. Comes in handy when writing a new test and
|
||||
only wanting to run that one. The asterisk is used to the full path to the test can be ignored. You can additionally
|
||||
match this with the debugging parameter to debug a specific test. This command can be found below.
|
||||
|
||||
./gradlew :brut.apktool:apktool-lib:test --tests "*BuildAndDecodeTest" -Dtest.debug
|
||||
|
@ -19,6 +19,7 @@ package brut.androlib;
|
||||
import brut.androlib.meta.MetaInfo;
|
||||
import brut.androlib.meta.UsesFramework;
|
||||
import brut.androlib.res.AndrolibResources;
|
||||
import brut.androlib.res.data.ResConfigFlags;
|
||||
import brut.androlib.res.data.ResPackage;
|
||||
import brut.androlib.res.data.ResTable;
|
||||
import brut.androlib.res.data.ResUnknownFiles;
|
||||
@ -279,7 +280,22 @@ public class Androlib {
|
||||
mAndRes.setSharedLibrary(meta.sharedLibrary);
|
||||
|
||||
if (meta.sdkInfo != null && meta.sdkInfo.get("minSdkVersion") != null) {
|
||||
mMinSdkVersion = Integer.parseInt(meta.sdkInfo.get("minSdkVersion"));
|
||||
String minSdkVersion = meta.sdkInfo.get("minSdkVersion");
|
||||
|
||||
// Preview builds use short letter for API versions
|
||||
switch (minSdkVersion) {
|
||||
case "M":
|
||||
mMinSdkVersion = ResConfigFlags.SDK_MNC;
|
||||
break;
|
||||
case "N":
|
||||
mMinSdkVersion = ResConfigFlags.SDK_NOUGAT;
|
||||
break;
|
||||
case "O":
|
||||
mMinSdkVersion = ResConfigFlags.SDK_O;
|
||||
break;
|
||||
default:
|
||||
mMinSdkVersion = Integer.parseInt(meta.sdkInfo.get("minSdkVersion"));
|
||||
}
|
||||
}
|
||||
|
||||
if (outFile == null) {
|
||||
|
@ -507,6 +507,9 @@ public class ResConfigFlags {
|
||||
public final static byte SDK_LOLLIPOP = 21;
|
||||
public final static byte SDK_LOLLIPOP_MR1 = 22;
|
||||
public final static byte SDK_MNC = 23;
|
||||
public final static byte SDK_NOUGAT = 24;
|
||||
public final static byte SDK_NOUGAT_MR1 = 25;
|
||||
public final static byte SDK_O = 26;
|
||||
|
||||
public final static byte ORIENTATION_ANY = 0;
|
||||
public final static byte ORIENTATION_PORT = 1;
|
||||
|
@ -90,7 +90,8 @@ public class ResValueFactory {
|
||||
if (key == ResAttr.BAG_KEY_ATTR_TYPE) {
|
||||
return ResAttr.factory(parentVal, items, this, mPackage);
|
||||
}
|
||||
if (key == ResArrayValue.BAG_KEY_ARRAY_START) {
|
||||
// Android O Preview added an unknown enum for ResTable_map. This is hardcoded as 0 for now.
|
||||
if (key == ResArrayValue.BAG_KEY_ARRAY_START || key == 0) {
|
||||
return new ResArrayValue(parentVal, items);
|
||||
}
|
||||
if (key >= ResPluralsValue.BAG_KEY_PLURALS_START && key <= ResPluralsValue.BAG_KEY_PLURALS_END) {
|
||||
|
@ -131,8 +131,14 @@ public class StringBlock {
|
||||
if (style == null) {
|
||||
return ResXmlEncoders.escapeXmlChars(raw);
|
||||
}
|
||||
|
||||
// If the returned style is further in string, than string length. Lets skip it.
|
||||
if (style[1] > raw.length()) {
|
||||
return ResXmlEncoders.escapeXmlChars(raw);
|
||||
}
|
||||
StringBuilder html = new StringBuilder(raw.length() + 32);
|
||||
int[] opened = new int[style.length / 3];
|
||||
boolean[] unclosed = new boolean[style.length / 3];
|
||||
int offset = 0, depth = 0;
|
||||
while (true) {
|
||||
int i = -1, j;
|
||||
@ -149,6 +155,9 @@ public class StringBlock {
|
||||
int last = opened[j];
|
||||
int end = style[last + 2];
|
||||
if (end >= start) {
|
||||
if (style[last + 1] == -1 && end != -1) {
|
||||
unclosed[j] = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (offset <= end) {
|
||||
@ -160,6 +169,11 @@ public class StringBlock {
|
||||
depth = j + 1;
|
||||
if (offset < start) {
|
||||
html.append(ResXmlEncoders.escapeXmlChars(raw.substring(offset, start)));
|
||||
if (j >= 0 && unclosed.length >= j && unclosed[j]) {
|
||||
if (unclosed.length > (j + 1) && unclosed[j + 1] || unclosed.length == 1) {
|
||||
outputStyleTag(getString(style[opened[j]]), html, true);
|
||||
}
|
||||
}
|
||||
offset = start;
|
||||
}
|
||||
if (i == -1) {
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -253,6 +253,11 @@ public class BuildAndDecodeTest {
|
||||
compareValuesFiles("values-ast/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void androidOStringTest() throws BrutException, IOException {
|
||||
compareValuesFiles("values-ast/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void twoLetterNotHandledAsBcpTest() throws BrutException, IOException {
|
||||
checkFolderExists("res/values-fr");
|
||||
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="test1">"Forgot your username or password?\nVisit google.com/accounts/recovery."</string>
|
||||
<string name="test2">Forgot your username or password?\n.Visit google.com/accounts/recovery</string>
|
||||
<string name="test3"> (string8) "Forgot your username or password?\nVisit google.com/accounts/recovery."</string>
|
||||
<string name="test4">Forgot your username or password?\nVisit google.com/accounts/recovery.</string>
|
||||
<string name="test5">Forgot your username or password?
|
||||
Visit google.com/accounts/recovery.</string>
|
||||
</resources>
|
@ -31,4 +31,14 @@ bar"</string>
|
||||
<string name="test_string29" formatted="false">category=temp%temp%foo</string>
|
||||
<string name="test_string30">res/foo/</string>
|
||||
<string name="test_string31">res/foo</string>
|
||||
<string name="test_string32">[<font size="17">TEST STRING</font>]</string>
|
||||
<string name="test_string33"><font size="17">[TEST STRING]</font></string>
|
||||
<string name="test_string34">[<font size="17">TEST STRING]</font></string>
|
||||
<string name="test_string35"><font size="17">[TEST STRING</font>]</string>
|
||||
<string name="test_string36"><font size="17">TEST STRING</font></string>
|
||||
<string name="test_string37">[<font size="17">Ţåþ ţö ţýþé þåššŵöŕð one two three]</font></string>
|
||||
<string name="test_string38">[<font size="17">Ţåþ ţö ţýþé þåššŵöŕð one two three</font>]</string>
|
||||
<string name="test_string39"><font size="17">[Ţåþ ţö ţýþé þåššŵöŕð one two three</font>]</string>
|
||||
<string name="test_string40">[<font size="17">]Ţåþ ţö ţýþé þåššŵöŕð one two three</font></string>
|
||||
<string name="test_string41"><font size="17">[Ţåþ ţö ţýþé þåššŵöŕð one two three]</font></string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user