mirror of
https://github.com/revanced/Apktool.git
synced 2024-11-18 18:39:23 +01:00
Merge branch 'alexeikh-issue-1843'
This commit is contained in:
commit
6460fde436
@ -168,7 +168,9 @@ public class Androlib {
|
||||
String ext;
|
||||
|
||||
for (String file : files) {
|
||||
if (isAPKFileNames(file) && unk.getCompressionLevel(file) == 0) {
|
||||
if (isAPKFileNames(file) &&
|
||||
unk.getCompressionLevel(file) == 0 &&
|
||||
unk.getSize(file) != 0) {
|
||||
|
||||
if (StringUtils.countMatches(file, ".") > 1) {
|
||||
ext = file;
|
||||
|
@ -20,6 +20,7 @@ import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
import brut.androlib.meta.MetaInfo;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.common.BrutException;
|
||||
import brut.util.OS;
|
||||
@ -481,6 +482,15 @@ public class BuildAndDecodeTest extends BaseTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void confirmZeroByteFileIsNotStored() throws BrutException {
|
||||
MetaInfo metaInfo = new Androlib().readMetaFile(sTestNewDir);
|
||||
|
||||
for (String item : metaInfo.doNotCompress) {
|
||||
assertNotSame(item, "empty");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawableXxhdpiTest() throws BrutException, IOException {
|
||||
compareResFolder("drawable-xxhdpi");
|
||||
|
@ -88,7 +88,7 @@ public class UnknownCompressionTest extends BaseTest {
|
||||
@Test
|
||||
public void confirmJsonFileIsDeflatedTest() throws BrutException, IOException {
|
||||
Integer control = sTestOrigDir.getDirectory().getCompressionLevel("test.json");
|
||||
Integer rebuilt = sTestOrigDir.getDirectory().getCompressionLevel("test.json");
|
||||
Integer rebuilt = sTestNewDir.getDirectory().getCompressionLevel("test.json");
|
||||
|
||||
assertEquals(control, rebuilt);
|
||||
assertEquals(new Integer(8), rebuilt);
|
||||
@ -97,7 +97,7 @@ public class UnknownCompressionTest extends BaseTest {
|
||||
@Test
|
||||
public void confirmPngFileIsCorrectlyDeflatedTest() throws BrutException, IOException {
|
||||
Integer control = sTestOrigDir.getDirectory().getCompressionLevel("950x150.png");
|
||||
Integer rebuilt = sTestOrigDir.getDirectory().getCompressionLevel("950x150.png");
|
||||
Integer rebuilt = sTestNewDir.getDirectory().getCompressionLevel("950x150.png");
|
||||
|
||||
assertEquals(control, rebuilt);
|
||||
assertEquals(new Integer(8), rebuilt);
|
||||
|
@ -17,6 +17,7 @@
|
||||
package brut.androlib.aapt2;
|
||||
|
||||
import brut.androlib.*;
|
||||
import brut.androlib.meta.MetaInfo;
|
||||
import brut.common.BrutException;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.util.OS;
|
||||
@ -72,6 +73,12 @@ public class BuildAndDecodeTest extends BaseTest {
|
||||
compareValuesFiles("values/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void confirmZeroByteFileIsNotStored() throws BrutException {
|
||||
MetaInfo metaInfo = new Androlib().readMetaFile(sTestNewDir);
|
||||
assertNull(metaInfo.doNotCompress);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void navigationResourceTest() throws BrutException {
|
||||
compareXmlFiles("res/navigation/nav_graph.xml");
|
||||
|
@ -47,6 +47,10 @@ public interface Directory {
|
||||
public void copyToDir(File out, String fileName)
|
||||
throws DirectoryException;
|
||||
|
||||
public long getSize(String fileName)
|
||||
throws DirectoryException;
|
||||
public long getCompressedSize(String fileName)
|
||||
throws DirectoryException;
|
||||
public int getCompressionLevel(String fileName)
|
||||
throws DirectoryException;
|
||||
|
||||
|
@ -40,6 +40,22 @@ public class FileDirectory extends AbstractDirectory {
|
||||
mDir = dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize(String fileName)
|
||||
throws DirectoryException {
|
||||
File file = new File(generatePath(fileName));
|
||||
if (! file.isFile()) {
|
||||
throw new DirectoryException("file must be a file: " + file);
|
||||
}
|
||||
return file.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCompressedSize(String fileName)
|
||||
throws DirectoryException {
|
||||
return getSize(fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractDirectory createDirLocal(String name) throws DirectoryException {
|
||||
File dir = new File(generatePath(name));
|
||||
|
@ -100,14 +100,34 @@ public class ZipRODirectory extends AbstractDirectory {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize(String fileName)
|
||||
throws DirectoryException {
|
||||
ZipEntry entry = getZipFileEntry(fileName);
|
||||
return entry.getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCompressedSize(String fileName)
|
||||
throws DirectoryException {
|
||||
ZipEntry entry = getZipFileEntry(fileName);
|
||||
return entry.getCompressedSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCompressionLevel(String fileName)
|
||||
throws DirectoryException {
|
||||
ZipEntry entry = mZipFile.getEntry(fileName);
|
||||
ZipEntry entry = getZipFileEntry(fileName);
|
||||
return entry.getMethod();
|
||||
}
|
||||
|
||||
private ZipEntry getZipFileEntry(String fileName)
|
||||
throws DirectoryException {
|
||||
ZipEntry entry = mZipFile.getEntry(fileName);
|
||||
if (entry == null) {
|
||||
throw new PathNotExist("Entry not found: " + fileName);
|
||||
}
|
||||
return entry.getMethod();
|
||||
return entry;
|
||||
}
|
||||
|
||||
private void loadAll() {
|
||||
|
Loading…
Reference in New Issue
Block a user