mirror of
https://github.com/revanced/Apktool.git
synced 2025-04-30 06:04:25 +02:00
Merge branch 'upstream'
This commit is contained in:
commit
61bcd855dd
@ -196,18 +196,12 @@ public class YamlReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void readStringList(List<String> list) throws AndrolibException {
|
public void readStringList(List<String> list) throws AndrolibException {
|
||||||
readList(list,
|
readList(list, (items, reader) -> items.add(reader.getLine().getValue()));
|
||||||
(items, reader) -> {
|
}
|
||||||
items.add(reader.getLine().getValue());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
public void readIntList(List<Integer> list) throws AndrolibException {
|
public void readIntList(List<Integer> list) throws AndrolibException {
|
||||||
readList(list,
|
readList(list, (items, reader) -> items.add(reader.getLine().getValueInt()));
|
||||||
(items, reader) -> {
|
}
|
||||||
items.add(reader.getLine().getValueInt());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
public void readMap(Map<String, String> map) throws AndrolibException {
|
public void readMap(Map<String, String> map) throws AndrolibException {
|
||||||
readObject(map,
|
readObject(map,
|
||||||
@ -216,5 +210,5 @@ public class YamlReader {
|
|||||||
YamlLine line = reader.getLine();
|
YamlLine line = reader.getLine();
|
||||||
items.put(line.getKey(), line.getValue());
|
items.put(line.getKey(), line.getValue());
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
@ -407,28 +407,13 @@ public class AXmlResourceParser implements XmlResourceParser {
|
|||||||
String stringBlockValue = valueRaw == -1 ? null : ResXmlEncoders.escapeXmlChars(mStringBlock.getString(valueRaw));
|
String stringBlockValue = valueRaw == -1 ? null : ResXmlEncoders.escapeXmlChars(mStringBlock.getString(valueRaw));
|
||||||
String resourceMapValue = null;
|
String resourceMapValue = null;
|
||||||
|
|
||||||
// Ensure we only track down obfuscated values for reference/attribute type values. Otherwise we might
|
// Ensure we only track down obfuscated values for reference/attribute type values. Otherwise, we might
|
||||||
// spam lookups against resource table for invalid ids.
|
// spam lookups against resource table for invalid ids.
|
||||||
if (valueType == TypedValue.TYPE_REFERENCE || valueType == TypedValue.TYPE_DYNAMIC_REFERENCE ||
|
if (valueType == TypedValue.TYPE_REFERENCE || valueType == TypedValue.TYPE_DYNAMIC_REFERENCE ||
|
||||||
valueType == TypedValue.TYPE_ATTRIBUTE || valueType == TypedValue.TYPE_DYNAMIC_ATTRIBUTE) {
|
valueType == TypedValue.TYPE_ATTRIBUTE || valueType == TypedValue.TYPE_DYNAMIC_ATTRIBUTE) {
|
||||||
resourceMapValue = decodeFromResourceId(valueData);
|
resourceMapValue = decodeFromResourceId(valueData);
|
||||||
}
|
}
|
||||||
String value = stringBlockValue;
|
String value = getPreferredString(stringBlockValue, resourceMapValue);
|
||||||
|
|
||||||
if (stringBlockValue != null && resourceMapValue != null) {
|
|
||||||
int slashPos = stringBlockValue.lastIndexOf("/");
|
|
||||||
int colonPos = stringBlockValue.lastIndexOf(":");
|
|
||||||
|
|
||||||
// Handle a value with a format of "@yyy/xxx", but avoid "@yyy/zzz:xxx"
|
|
||||||
if (slashPos != -1) {
|
|
||||||
if (colonPos == -1) {
|
|
||||||
String type = stringBlockValue.substring(0, slashPos);
|
|
||||||
value = type + "/" + resourceMapValue;
|
|
||||||
}
|
|
||||||
} else if (! stringBlockValue.equals(resourceMapValue)) {
|
|
||||||
value = resourceMapValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// try to decode from resource table
|
// try to decode from resource table
|
||||||
int attrResId = getAttributeNameResource(index);
|
int attrResId = getAttributeNameResource(index);
|
||||||
@ -662,6 +647,26 @@ public class AXmlResourceParser implements XmlResourceParser {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getPreferredString(String stringBlockValue, String resourceMapValue) {
|
||||||
|
String value = stringBlockValue;
|
||||||
|
|
||||||
|
if (stringBlockValue != null && resourceMapValue != null) {
|
||||||
|
int slashPos = stringBlockValue.lastIndexOf("/");
|
||||||
|
int colonPos = stringBlockValue.lastIndexOf(":");
|
||||||
|
|
||||||
|
// Handle a value with a format of "@yyy/xxx", but avoid "@yyy/zzz:xxx"
|
||||||
|
if (slashPos != -1) {
|
||||||
|
if (colonPos == -1) {
|
||||||
|
String type = stringBlockValue.substring(0, slashPos);
|
||||||
|
value = type + "/" + resourceMapValue;
|
||||||
|
}
|
||||||
|
} else if (! stringBlockValue.equals(resourceMapValue)) {
|
||||||
|
value = resourceMapValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
private void resetEventInfo() {
|
private void resetEventInfo() {
|
||||||
mEvent = -1;
|
mEvent = -1;
|
||||||
mLineNumber = -1;
|
mLineNumber = -1;
|
||||||
|
@ -157,18 +157,6 @@ public class ResFileDecoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decodeManifest(Directory inDir, String inFileName,
|
|
||||||
Directory outDir, String outFileName) throws AndrolibException {
|
|
||||||
try (
|
|
||||||
InputStream in = inDir.getFileInput(inFileName);
|
|
||||||
OutputStream out = outDir.getFileOutput(outFileName)
|
|
||||||
) {
|
|
||||||
((XmlPullStreamDecoder) mDecoders.getDecoder("xml")).decodeManifest(in, out);
|
|
||||||
} catch (DirectoryException | IOException ex) {
|
|
||||||
throw new AndrolibException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Logger LOGGER = Logger.getLogger(ResFileDecoder.class.getName());
|
private final static Logger LOGGER = Logger.getLogger(ResFileDecoder.class.getName());
|
||||||
|
|
||||||
private final static String[] RAW_IMAGE_EXTENSIONS = new String[] {
|
private final static String[] RAW_IMAGE_EXTENSIONS = new String[] {
|
||||||
|
@ -77,13 +77,13 @@ public class SkipAssetTest extends BaseTest {
|
|||||||
checkFileDoesExist("assets" + File.separator + "ranges" + File.separator + "ranges.kotlin_builtins");
|
checkFileDoesExist("assets" + File.separator + "ranges" + File.separator + "ranges.kotlin_builtins");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkFileDoesNotExist(String path) throws BrutException {
|
private void checkFileDoesNotExist(String path) {
|
||||||
File f = new File(sTestOrigDir, path);
|
File f = new File(sTestOrigDir, path);
|
||||||
|
|
||||||
assertFalse(f.isFile());
|
assertFalse(f.isFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkFileDoesExist(String path) throws BrutException {
|
private void checkFileDoesExist(String path) {
|
||||||
File f = new File(sTestOrigDir, path);
|
File f = new File(sTestOrigDir, path);
|
||||||
|
|
||||||
assertTrue(f.isFile());
|
assertTrue(f.isFile());
|
||||||
|
@ -22,7 +22,6 @@ import brut.androlib.Config;
|
|||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
import org.custommonkey.xmlunit.XMLUnit;
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -34,10 +33,7 @@ import org.xml.sax.SAXException;
|
|||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
|
|
||||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class BuildAndDecodeTest extends BaseTest {
|
public class BuildAndDecodeTest extends BaseTest {
|
||||||
|
@ -59,7 +59,7 @@ public class AndResGuardTest extends BaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkifAndResDecodeRemapsRFolderInRawMode() throws BrutException, IOException {
|
public void checkIfAndResDecodeRemapsRFolderInRawMode() throws BrutException, IOException {
|
||||||
|
|
||||||
Config config = Config.getDefaultConfig();
|
Config config = Config.getDefaultConfig();
|
||||||
config.forceDelete = true;
|
config.forceDelete = true;
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package brut.androlib.decode;
|
package brut.androlib.decode;
|
||||||
|
|
||||||
import brut.androlib.ApkDecoder;
|
|
||||||
import brut.androlib.BaseTest;
|
import brut.androlib.BaseTest;
|
||||||
import brut.androlib.Config;
|
import brut.androlib.Config;
|
||||||
import brut.androlib.TestUtils;
|
import brut.androlib.TestUtils;
|
||||||
@ -32,9 +31,7 @@ import org.junit.AfterClass;
|
|||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class DecodeArrayTest extends BaseTest {
|
public class DecodeArrayTest extends BaseTest {
|
||||||
|
|
||||||
@ -54,7 +51,6 @@ public class DecodeArrayTest extends BaseTest {
|
|||||||
public void decodeStringArray() throws BrutException {
|
public void decodeStringArray() throws BrutException {
|
||||||
ExtFile apkFile = new ExtFile(sTmpDir, "issue1994.apk");
|
ExtFile apkFile = new ExtFile(sTmpDir, "issue1994.apk");
|
||||||
ApkInfo apkInfo = new ApkInfo(apkFile);
|
ApkInfo apkInfo = new ApkInfo(apkFile);
|
||||||
//ApkDecoder apkDecoder = new ApkDecoder(apkFile);
|
|
||||||
ResourcesDecoder resourcesDecoder = new ResourcesDecoder(Config.getDefaultConfig(), apkInfo);
|
ResourcesDecoder resourcesDecoder = new ResourcesDecoder(Config.getDefaultConfig(), apkInfo);
|
||||||
|
|
||||||
resourcesDecoder.loadMainPkg();
|
resourcesDecoder.loadMainPkg();
|
||||||
|
@ -67,6 +67,6 @@ public class DecodeKotlinTest extends BaseTest {
|
|||||||
public void kotlinDecodeTest() throws IOException {
|
public void kotlinDecodeTest() throws IOException {
|
||||||
File kotlinActivity = new File(sTestNewDir, "smali/org/example/kotlin/mixed/KotlinActivity.smali");
|
File kotlinActivity = new File(sTestNewDir, "smali/org/example/kotlin/mixed/KotlinActivity.smali");
|
||||||
|
|
||||||
assertTrue(FileUtils.readFileToString(kotlinActivity).contains("KotlinActivity.kt"));
|
assertTrue(FileUtils.readFileToString(kotlinActivity, "UTF-8").contains("KotlinActivity.kt"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import org.junit.*;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
public class DuplicateDexTest extends BaseTest {
|
public class DuplicateDexTest extends BaseTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@ -58,7 +58,6 @@ public class ExternalEntityTest extends BaseTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void doctypeTest() throws IOException {
|
public void doctypeTest() throws IOException {
|
||||||
|
|
||||||
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||||
"<manifest android:versionCode=\"1\" android:versionName=\"1.0\" android:compileSdkVersion=\"23\" android:compileSdkVersionCodename=\"6.0-2438415\" " +
|
"<manifest android:versionCode=\"1\" android:versionName=\"1.0\" android:compileSdkVersion=\"23\" android:compileSdkVersionCodename=\"6.0-2438415\" " +
|
||||||
"hardwareAccelerated=\"true\" package=\"com.ibotpeaches.doctype\" platformBuildVersionCode=\"24\" platformBuildVersionName=\"6.0-2456767\" " +
|
"hardwareAccelerated=\"true\" package=\"com.ibotpeaches.doctype\" platformBuildVersionCode=\"24\" platformBuildVersionName=\"6.0-2456767\" " +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user