refactor: remove duplicated code

This commit is contained in:
Connor Tumbleson 2021-03-12 07:37:47 -05:00
parent bb2acaf3e1
commit 4d11c13e44
No known key found for this signature in database
GPG Key ID: C3CC0A201EC7DA75

View File

@ -813,7 +813,7 @@ final public class AndrolibResources {
} }
if (id == 1) { if (id == 1) {
try (InputStream in = AndrolibResources.class.getResourceAsStream("/brut/androlib/android-framework.jar"); try (InputStream in = getAndroidFrameworkResourcesAsStream();
OutputStream out = new FileOutputStream(apk)) { OutputStream out = new FileOutputStream(apk)) {
IOUtils.copy(in, out); IOUtils.copy(in, out);
return apk; return apk;
@ -946,8 +946,7 @@ final public class AndrolibResources {
publicizeResources(arsc, ARSCDecoder.decode(new ByteArrayInputStream(arsc), true, true).getFlagsOffsets()); publicizeResources(arsc, ARSCDecoder.decode(new ByteArrayInputStream(arsc), true, true).getFlagsOffsets());
} }
public void publicizeResources(byte[] arsc, FlagsOffset[] flagsOffsets) public void publicizeResources(byte[] arsc, FlagsOffset[] flagsOffsets) {
throws AndrolibException {
for (FlagsOffset flags : flagsOffsets) { for (FlagsOffset flags : flagsOffsets) {
int offset = flags.offset + 3; int offset = flags.offset + 3;
int end = offset + 4 * flags.count; int end = offset + 4 * flags.count;
@ -1031,12 +1030,8 @@ final public class AndrolibResources {
return apkOptions.isAapt2() ? 2 : 1; return apkOptions.isAapt2() ? 2 : 1;
} }
public File getAndroidResourcesFile() throws AndrolibException { public InputStream getAndroidFrameworkResourcesAsStream() {
try { return Jar.class.getResourceAsStream("/brut/androlib/android-framework.jar");
return Jar.getResourceAsFile("/brut/androlib/android-framework.jar");
} catch (BrutException ex) {
throw new AndrolibException(ex);
}
} }
public void close() throws IOException { public void close() throws IOException {