From d07f52bd6aa4ff5167836f294951a79a2f9d830e Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Mon, 12 Aug 2013 12:28:28 -0500 Subject: [PATCH] fix prop location of smali/baksmali, add more checks --- .../java/brut/androlib/ApktoolProperties.java | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApktoolProperties.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApktoolProperties.java index 01be7808..0634817f 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApktoolProperties.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApktoolProperties.java @@ -16,6 +16,9 @@ package brut.androlib; +import org.jf.baksmali.baksmali; +import org.jf.smali.main; + import java.io.IOException; import java.io.InputStream; import java.util.Properties; @@ -37,8 +40,7 @@ public class ApktoolProperties { } private static void loadProps() { - InputStream in = ApktoolProperties.class - .getResourceAsStream("/properties/apktool.properties"); + InputStream in = ApktoolProperties.class.getResourceAsStream("/properties/apktool.properties"); sProps = new Properties(); try { sProps.load(in); @@ -47,25 +49,31 @@ public class ApktoolProperties { LOGGER.warning("Can't load properties."); } - InputStream templateStream = ApktoolProperties.class - .getResourceAsStream("/properties/baksmali.properties"); + InputStream templateStream = baksmali.class.getClassLoader().getResourceAsStream("baksmali.properties"); Properties properties = new Properties(); String version = "(unknown)"; - try { - properties.load(templateStream); - version = properties.getProperty("application.version"); - } catch (IOException ex) { - } + + if (templateStream != null) { + try { + properties.load(templateStream); + version = properties.getProperty("application.version"); + } catch (IOException ignored) { + } + } sProps.put("baksmaliVersion", version); - templateStream = ApktoolProperties.class - .getResourceAsStream("/properties/smali.properties"); + + + templateStream = main.class.getClassLoader().getResourceAsStream("smali.properties"); properties = new Properties(); version = "(unknown)"; - try { - properties.load(templateStream); - version = properties.getProperty("application.version"); - } catch (IOException ex) { - } + + if (templateStream != null) { + try { + properties.load(templateStream); + version = properties.getProperty("application.version"); + } catch (IOException ignored) { + } + } sProps.put("smaliVersion", version); }