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