mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-21 17:27:41 +01:00
Cleanup
- switch to java7 try-with-resources - add check in unit-tests for checking control
This commit is contained in:
parent
3e6fc8c5ef
commit
869d287aaa
@ -24,6 +24,7 @@ import brut.androlib.res.data.value.ResFileValue;
|
|||||||
import brut.directory.DirUtil;
|
import brut.directory.DirUtil;
|
||||||
import brut.directory.Directory;
|
import brut.directory.Directory;
|
||||||
import brut.directory.DirectoryException;
|
import brut.directory.DirectoryException;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -106,25 +107,13 @@ public class ResFileDecoder {
|
|||||||
|
|
||||||
public void decode(Directory inDir, String inFileName, Directory outDir,
|
public void decode(Directory inDir, String inFileName, Directory outDir,
|
||||||
String outFileName, String decoder) throws AndrolibException {
|
String outFileName, String decoder) throws AndrolibException {
|
||||||
InputStream in = null;
|
try (
|
||||||
OutputStream out = null;
|
InputStream in = inDir.getFileInput(inFileName);
|
||||||
try {
|
OutputStream out = outDir.getFileOutput(outFileName)
|
||||||
in = inDir.getFileInput(inFileName);
|
) {
|
||||||
out = outDir.getFileOutput(outFileName);
|
|
||||||
mDecoders.decode(in, out, decoder);
|
mDecoders.decode(in, out, decoder);
|
||||||
} catch (DirectoryException ex) {
|
} catch (DirectoryException | IOException ex) {
|
||||||
throw new AndrolibException(ex);
|
throw new AndrolibException(ex);
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (in != null) {
|
|
||||||
in.close();
|
|
||||||
}
|
|
||||||
if (out != null) {
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
} catch (IOException ex) {
|
|
||||||
throw new AndrolibException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,29 +127,15 @@ public class ResFileDecoder {
|
|||||||
|
|
||||||
public void decodeManifest(Directory inDir, String inFileName,
|
public void decodeManifest(Directory inDir, String inFileName,
|
||||||
Directory outDir, String outFileName) throws AndrolibException {
|
Directory outDir, String outFileName) throws AndrolibException {
|
||||||
InputStream in = null;
|
try (
|
||||||
OutputStream out = null;
|
InputStream in = inDir.getFileInput(inFileName);
|
||||||
try {
|
OutputStream out = outDir.getFileOutput(outFileName)
|
||||||
in = inDir.getFileInput(inFileName);
|
) {
|
||||||
out = outDir.getFileOutput(outFileName);
|
((XmlPullStreamDecoder) mDecoders.getDecoder("xml")).decodeManifest(in, out);
|
||||||
((XmlPullStreamDecoder) mDecoders.getDecoder("xml"))
|
} catch (DirectoryException | IOException ex) {
|
||||||
.decodeManifest(in, out);
|
|
||||||
} catch (DirectoryException ex) {
|
|
||||||
throw new AndrolibException(ex);
|
throw new AndrolibException(ex);
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (in != null) {
|
|
||||||
in.close();
|
|
||||||
}
|
|
||||||
if (out != null) {
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
} catch (IOException ex) {
|
|
||||||
throw new AndrolibException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Logger LOGGER = Logger.getLogger(ResFileDecoder.class
|
private final static Logger LOGGER = Logger.getLogger(ResFileDecoder.class.getName());
|
||||||
.getName());
|
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ public class BuildAndDecodeTest {
|
|||||||
// hacky fix - load test by changing name of control
|
// hacky fix - load test by changing name of control
|
||||||
File test = new File(control.toString().replace("testapp-orig", "testapp-new"));
|
File test = new File(control.toString().replace("testapp-orig", "testapp-new"));
|
||||||
|
|
||||||
if (test.isFile()) {
|
if (test.isFile() && control.isFile()) {
|
||||||
if (control.hashCode() != test.hashCode()) {
|
if (control.hashCode() != test.hashCode()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user