From 4d11c13e44ba89a1da3f8214149cab93baf22cbf Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Fri, 12 Mar 2021 07:37:47 -0500 Subject: [PATCH] refactor: remove duplicated code --- .../java/brut/androlib/res/AndrolibResources.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java index 79023d1a..65f1b27a 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java @@ -813,7 +813,7 @@ final public class AndrolibResources { } if (id == 1) { - try (InputStream in = AndrolibResources.class.getResourceAsStream("/brut/androlib/android-framework.jar"); + try (InputStream in = getAndroidFrameworkResourcesAsStream(); OutputStream out = new FileOutputStream(apk)) { IOUtils.copy(in, out); return apk; @@ -946,8 +946,7 @@ final public class AndrolibResources { publicizeResources(arsc, ARSCDecoder.decode(new ByteArrayInputStream(arsc), true, true).getFlagsOffsets()); } - public void publicizeResources(byte[] arsc, FlagsOffset[] flagsOffsets) - throws AndrolibException { + public void publicizeResources(byte[] arsc, FlagsOffset[] flagsOffsets) { for (FlagsOffset flags : flagsOffsets) { int offset = flags.offset + 3; int end = offset + 4 * flags.count; @@ -1031,12 +1030,8 @@ final public class AndrolibResources { return apkOptions.isAapt2() ? 2 : 1; } - public File getAndroidResourcesFile() throws AndrolibException { - try { - return Jar.getResourceAsFile("/brut/androlib/android-framework.jar"); - } catch (BrutException ex) { - throw new AndrolibException(ex); - } + public InputStream getAndroidFrameworkResourcesAsStream() { + return Jar.class.getResourceAsStream("/brut/androlib/android-framework.jar"); } public void close() throws IOException {