mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-19 08:17:35 +01:00
Removes general access bit hack
- fixed in aosp: android_libcore/commit/25681be69e19a834b00cfbf54cd99ac13f12b9ff - reverts 42f69fd74597fd42a5bb1e0c3d3564d207d0eb4b - reverts 47a5eac0b0a4188f610a734d0aad27a35450994c - fixes googlecode issue 744
This commit is contained in:
parent
e281f81546
commit
81e6af093b
1
CHANGES
1
CHANGES
@ -56,6 +56,7 @@ v2.0.0 (TBA)
|
|||||||
-Fixed (issue #590) - Fixed issue with segfaulting aapt with certain apks.
|
-Fixed (issue #590) - Fixed issue with segfaulting aapt with certain apks.
|
||||||
-Fixed (issue #545) - Fixed issue with undefined attrs w/ updated internal frameworks
|
-Fixed (issue #545) - Fixed issue with undefined attrs w/ updated internal frameworks
|
||||||
-Fixed (issue #702) - Fixed improper handling of MNC_ZERO which caused dupe`d resources
|
-Fixed (issue #702) - Fixed improper handling of MNC_ZERO which caused dupe`d resources
|
||||||
|
-Fixed (issue #744) - Fixed warnings of "Cleaning up unclosed ZipFile..."
|
||||||
-Fixed issue with APKs with multiple dex files.
|
-Fixed issue with APKs with multiple dex files.
|
||||||
-Fixed issue with using Apktool without smali/baksmali for ApktoolProperties (Thanks teprrr)
|
-Fixed issue with using Apktool without smali/baksmali for ApktoolProperties (Thanks teprrr)
|
||||||
-Fixed issue with non-URI standard characters in apk name (Thanks rover12421)
|
-Fixed issue with non-URI standard characters in apk name (Thanks rover12421)
|
||||||
|
@ -35,6 +35,8 @@ import java.util.*;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
import org.yaml.snakeyaml.DumperOptions;
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
@ -174,7 +176,7 @@ public class Androlib {
|
|||||||
// with regular looping of apkFile for easy copy
|
// with regular looping of apkFile for easy copy
|
||||||
try {
|
try {
|
||||||
Directory unk = apkFile.getDirectory();
|
Directory unk = apkFile.getDirectory();
|
||||||
ZipExtFile apkZipFile = new ZipExtFile(apkFile.getAbsolutePath());
|
ZipFile apkZipFile = new ZipFile(apkFile.getAbsolutePath());
|
||||||
|
|
||||||
// loop all items in container recursively, ignoring any that are pre-defined by aapt
|
// loop all items in container recursively, ignoring any that are pre-defined by aapt
|
||||||
Set<String> files = unk.getFiles(true);
|
Set<String> files = unk.getFiles(true);
|
||||||
@ -184,8 +186,6 @@ public class Androlib {
|
|||||||
// copy file out of archive into special "unknown" folder
|
// copy file out of archive into special "unknown" folder
|
||||||
unk.copyToDir(unknownOut, file);
|
unk.copyToDir(unknownOut, file);
|
||||||
try {
|
try {
|
||||||
// ignore encryption
|
|
||||||
apkZipFile.getEntry(file).getGeneralPurposeBit().useEncryption(false);
|
|
||||||
invZipFile = apkZipFile.getEntry(file);
|
invZipFile = apkZipFile.getEntry(file);
|
||||||
|
|
||||||
// lets record the name of the file, and its compression type
|
// lets record the name of the file, and its compression type
|
||||||
|
@ -24,16 +24,15 @@ import brut.androlib.res.data.ResTable;
|
|||||||
import brut.androlib.res.util.ExtFile;
|
import brut.androlib.res.util.ExtFile;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.directory.DirectoryException;
|
import brut.directory.DirectoryException;
|
||||||
import brut.directory.ZipExtFile;
|
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||||
@ -196,13 +195,13 @@ public class ApkDecoder {
|
|||||||
public void setCompressionMode() throws AndrolibException, IOException {
|
public void setCompressionMode() throws AndrolibException, IOException {
|
||||||
// read the resources.arsc checking for STORED vs DEFLATE
|
// read the resources.arsc checking for STORED vs DEFLATE
|
||||||
// this will determine whether we compress on rebuild or not.
|
// this will determine whether we compress on rebuild or not.
|
||||||
ZipExtFile zef = new ZipExtFile(mApkFile.getAbsolutePath());
|
ZipFile zf = new ZipFile(mApkFile.getAbsolutePath());
|
||||||
ZipArchiveEntry ze = zef.getEntry("resources.arsc");
|
ZipEntry ze = zf.getEntry("resources.arsc");
|
||||||
if (ze != null) {
|
if (ze != null) {
|
||||||
int compression = ze.getMethod();
|
int compression = ze.getMethod();
|
||||||
mCompressResources = (compression == ZipEntry.DEFLATED);
|
mCompressResources = (compression == ZipEntry.DEFLATED);
|
||||||
}
|
}
|
||||||
zef.close();
|
zf.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTargetSdkVersion() throws AndrolibException, IOException {
|
public void setTargetSdkVersion() throws AndrolibException, IOException {
|
||||||
|
@ -42,8 +42,6 @@ import javax.xml.transform.*;
|
|||||||
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
|
||||||
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.NamedNodeMap;
|
import org.w3c.dom.NamedNodeMap;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
@ -665,10 +663,10 @@ final public class AndrolibResources {
|
|||||||
public void installFramework(File frameFile, String tag)
|
public void installFramework(File frameFile, String tag)
|
||||||
throws AndrolibException {
|
throws AndrolibException {
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
ZipArchiveOutputStream out = null;
|
ZipOutputStream out = null;
|
||||||
try {
|
try {
|
||||||
ZipExtFile zip = new ZipExtFile(frameFile);
|
ZipFile zip = new ZipFile(frameFile);
|
||||||
ZipArchiveEntry entry = zip.getEntry("resources.arsc");
|
ZipEntry entry = zip.getEntry("resources.arsc");
|
||||||
|
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
throw new AndrolibException("Can't find resources.arsc file");
|
throw new AndrolibException("Can't find resources.arsc file");
|
||||||
@ -685,21 +683,17 @@ final public class AndrolibResources {
|
|||||||
+ (tag == null ? "" : '-' + tag)
|
+ (tag == null ? "" : '-' + tag)
|
||||||
+ ".apk");
|
+ ".apk");
|
||||||
|
|
||||||
out = new ZipArchiveOutputStream(new FileOutputStream(outFile));
|
out = new ZipOutputStream(new FileOutputStream(outFile));
|
||||||
out.setMethod(ZipOutputStream.STORED);
|
out.setMethod(ZipOutputStream.STORED);
|
||||||
CRC32 crc = new CRC32();
|
CRC32 crc = new CRC32();
|
||||||
crc.update(data);
|
crc.update(data);
|
||||||
entry = new ZipArchiveEntry("resources.arsc");
|
entry = new ZipEntry("resources.arsc");
|
||||||
entry.setSize(data.length);
|
entry.setSize(data.length);
|
||||||
entry.setCrc(crc.getValue());
|
entry.setCrc(crc.getValue());
|
||||||
out.putArchiveEntry(entry);
|
out.putNextEntry(entry);
|
||||||
out.write(data);
|
out.write(data);
|
||||||
|
|
||||||
out.closeArchiveEntry();
|
|
||||||
zip.close();
|
zip.close();
|
||||||
LOGGER.info("Framework installed to: " + outFile);
|
LOGGER.info("Framework installed to: " + outFile);
|
||||||
} catch (ZipException ex) {
|
|
||||||
throw new AndrolibException(ex);
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new AndrolibException(ex);
|
throw new AndrolibException(ex);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package brut.directory;
|
|
||||||
|
|
||||||
import org.apache.commons.compress.archivers.zip.*;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.zip.ZipException;
|
|
||||||
|
|
||||||
public class ZipExtFile extends ZipFile {
|
|
||||||
|
|
||||||
public ZipExtFile(File f) throws IOException {
|
|
||||||
super(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ZipExtFile(String name) throws IOException {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ZipExtFile(String name, String encoding) throws IOException {
|
|
||||||
super(name, encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ZipExtFile(File f, String encoding) throws IOException {
|
|
||||||
super(f, encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ZipExtFile(File f, String encoding, boolean useUnicodeExtraFields) throws IOException {
|
|
||||||
super(f, encoding, useUnicodeExtraFields);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputStream getInputStream(ZipArchiveEntry ze)
|
|
||||||
throws IOException {
|
|
||||||
ze.getGeneralPurposeBit().useEncryption(false); // credit: Panxiaobo
|
|
||||||
return super.getInputStream(ze);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ZipArchiveEntry getEntry(String name) {
|
|
||||||
return super.getEntry(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package brut.directory;
|
package brut.directory;
|
||||||
|
|
||||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -24,9 +23,11 @@ import java.io.OutputStream;
|
|||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
public class ZipRODirectory extends AbstractDirectory {
|
public class ZipRODirectory extends AbstractDirectory {
|
||||||
private ZipExtFile mZipFile;
|
private ZipFile mZipFile;
|
||||||
private String mPath;
|
private String mPath;
|
||||||
|
|
||||||
public ZipRODirectory(String zipFileName) throws DirectoryException {
|
public ZipRODirectory(String zipFileName) throws DirectoryException {
|
||||||
@ -37,7 +38,7 @@ public class ZipRODirectory extends AbstractDirectory {
|
|||||||
this(zipFile, "");
|
this(zipFile, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZipRODirectory(ZipExtFile zipFile) {
|
public ZipRODirectory(ZipFile zipFile) {
|
||||||
this(zipFile, "");
|
this(zipFile, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,14 +50,14 @@ public class ZipRODirectory extends AbstractDirectory {
|
|||||||
public ZipRODirectory(File zipFile, String path) throws DirectoryException {
|
public ZipRODirectory(File zipFile, String path) throws DirectoryException {
|
||||||
super();
|
super();
|
||||||
try {
|
try {
|
||||||
mZipFile = new ZipExtFile(zipFile);
|
mZipFile = new ZipFile(zipFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new DirectoryException(e);
|
throw new DirectoryException(e);
|
||||||
}
|
}
|
||||||
mPath = path;
|
mPath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZipRODirectory(ZipExtFile zipFile, String path) {
|
public ZipRODirectory(ZipFile zipFile, String path) {
|
||||||
super();
|
super();
|
||||||
mZipFile = zipFile;
|
mZipFile = zipFile;
|
||||||
mPath = path;
|
mPath = path;
|
||||||
@ -72,8 +73,7 @@ public class ZipRODirectory extends AbstractDirectory {
|
|||||||
protected InputStream getFileInputLocal(String name)
|
protected InputStream getFileInputLocal(String name)
|
||||||
throws DirectoryException {
|
throws DirectoryException {
|
||||||
try {
|
try {
|
||||||
mZipFile.getEntry(getPath() + name).getGeneralPurposeBit().useEncryption(false);
|
return getZipFile().getInputStream(new ZipEntry(getPath() + name));
|
||||||
return getZipFile().getInputStream(mZipFile.getEntry(getPath() + name));
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new PathNotExist(name, e);
|
throw new PathNotExist(name, e);
|
||||||
}
|
}
|
||||||
@ -105,12 +105,9 @@ public class ZipRODirectory extends AbstractDirectory {
|
|||||||
mDirs = new LinkedHashMap<String, AbstractDirectory>();
|
mDirs = new LinkedHashMap<String, AbstractDirectory>();
|
||||||
|
|
||||||
int prefixLen = getPath().length();
|
int prefixLen = getPath().length();
|
||||||
Enumeration<? extends ZipArchiveEntry> entries = getZipFile().getEntries();
|
Enumeration<? extends ZipEntry> entries = getZipFile().entries();
|
||||||
while (entries.hasMoreElements()) {
|
while (entries.hasMoreElements()) {
|
||||||
ZipArchiveEntry entry = entries.nextElement();
|
ZipEntry entry = entries.nextElement();
|
||||||
|
|
||||||
// ignore general purpose bit, since AOSP does
|
|
||||||
entry.getGeneralPurposeBit().useEncryption(false);
|
|
||||||
String name = entry.getName();
|
String name = entry.getName();
|
||||||
|
|
||||||
if (name.equals(getPath()) || ! name.startsWith(getPath())) {
|
if (name.equals(getPath()) || ! name.startsWith(getPath())) {
|
||||||
@ -140,7 +137,7 @@ public class ZipRODirectory extends AbstractDirectory {
|
|||||||
return mPath;
|
return mPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ZipExtFile getZipFile() {
|
private ZipFile getZipFile() {
|
||||||
return mZipFile;
|
return mZipFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':brut.j.common'),
|
compile project(':brut.j.common'),
|
||||||
depends.commons_io,
|
depends.commons_io
|
||||||
depends.commons_compress
|
|
||||||
testCompile depends.junit
|
testCompile depends.junit
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,6 @@ subprojects {
|
|||||||
antlr: 'org.antlr:antlr:3.5',
|
antlr: 'org.antlr:antlr:3.5',
|
||||||
antlr_runtime: 'org.antlr:antlr-runtime:3.5',
|
antlr_runtime: 'org.antlr:antlr-runtime:3.5',
|
||||||
commons_cli: 'commons-cli:commons-cli:1.2',
|
commons_cli: 'commons-cli:commons-cli:1.2',
|
||||||
commons_compress: 'org.apache.commons:commons-compress:1.4.1',
|
|
||||||
commons_io: 'commons-io:commons-io:2.4',
|
commons_io: 'commons-io:commons-io:2.4',
|
||||||
commons_lang: 'org.apache.commons:commons-lang3:3.1',
|
commons_lang: 'org.apache.commons:commons-lang3:3.1',
|
||||||
findbugs: 'com.google.code.findbugs:jsr305:1.3.9',
|
findbugs: 'com.google.code.findbugs:jsr305:1.3.9',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user