mirror of
https://github.com/revanced/Apktool.git
synced 2025-06-12 05:07:41 +02:00
fixes #439
Extends ZipFile using apache commons compress ZipFile, to have finer control over the header allowing some parts to be ignored, ex: the general access bit
This commit is contained in:
@ -151,7 +151,7 @@ public class Androlib {
|
||||
// with regular looping of apkFile for easy copy
|
||||
try {
|
||||
Directory unk = apkFile.getDirectory();
|
||||
ZipFile apkZipFile = new ZipFile(apkFile.getAbsolutePath());
|
||||
ZipExtFile apkZipFile = new ZipExtFile(apkFile.getAbsolutePath());
|
||||
|
||||
// loop all items in container recursively, ignoring any that are pre-defined by aapt
|
||||
Set<String> files = unk.getFiles(true);
|
||||
@ -162,6 +162,8 @@ public class Androlib {
|
||||
// to be re-included on build
|
||||
unk.copyToDir(unknownOut,file);
|
||||
try {
|
||||
// ignore encryption
|
||||
apkZipFile.getEntry(file.toString()).getGeneralPurposeBit().useEncryption(false);
|
||||
invZipFile = apkZipFile.getEntry(file.toString());
|
||||
|
||||
// lets record the name of the file, and its compression type
|
||||
|
@ -24,12 +24,13 @@ import brut.androlib.res.data.ResTable;
|
||||
import brut.androlib.res.util.ExtFile;
|
||||
import brut.common.BrutException;
|
||||
import brut.directory.DirectoryException;
|
||||
import brut.directory.ZipExtFile;
|
||||
import brut.util.OS;
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
/**
|
||||
@ -95,18 +96,17 @@ public class ApkDecoder {
|
||||
}
|
||||
|
||||
if (hasResources()) {
|
||||
|
||||
// read the resources.arsc checking for STORED vs DEFLATE
|
||||
// compression
|
||||
// this will determine whether we compress on rebuild or not.
|
||||
JarFile jf = new JarFile(mApkFile.getAbsoluteFile());
|
||||
JarEntry je = jf.getJarEntry("resources.arsc");
|
||||
if (je != null) {
|
||||
int compression = je.getMethod();
|
||||
ZipExtFile zef = new ZipExtFile(mApkFile.getAbsolutePath());
|
||||
ZipArchiveEntry ze = zef.getEntry("resources.arsc");
|
||||
if (ze != null) {
|
||||
int compression = ze.getMethod();
|
||||
mCompressResources = (compression != ZipEntry.STORED)
|
||||
&& (compression == ZipEntry.DEFLATED);
|
||||
}
|
||||
jf.close();
|
||||
zef.close();
|
||||
|
||||
switch (mDecodeResources) {
|
||||
case DECODE_RESOURCES_NONE:
|
||||
|
Reference in New Issue
Block a user