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:
Connor Tumbleson
2013-04-06 12:50:42 -05:00
parent 51013d9e0a
commit 42f69fd745
7 changed files with 94 additions and 25 deletions

View File

@ -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

View File

@ -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: