From c6861e12417e496ea3c64502ac8fe22ec40020bb Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Sun, 12 May 2013 10:15:36 -0500 Subject: [PATCH] move multi catches to multi-catch (java 7), fixed pkg id not being correctly read from apktool.yml --- CHANGES | 1 + .../src/main/java/brut/androlib/Androlib.java | 2 +- .../brut/androlib/res/AndrolibResources.java | 52 +++++++------------ 3 files changed, 20 insertions(+), 35 deletions(-) diff --git a/CHANGES b/CHANGES index bcff94b9..8356fde2 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,7 @@ v2.0.0 (TBA) -Fixed (issue #427) - Correctly handles `--frame-path` on [b]uild -Fixed (issue #396) - Correctly handle android:debuggable while in debug mode. -Fixed (issue #340) - Fixed superclass errors on debug mode. +-Fixed (issue #458) - Fixed pkg id not being correctly set in framework files. -Updated known bytes for configurations to 38 (from addition of layout direction) -Fixed NPE when handling odex apks even with --no-src specified. (Thanks Rodrigo Chiossi) diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java index c3f94a76..7a637035 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java @@ -268,7 +268,7 @@ public class Androlib { flags.put("compression", meta.get("compressionType") == null ? false : (Boolean) meta.get("compressionType")); mAndRes.setSdkInfo((Map) meta.get("sdkInfo")); - mAndRes.setPackageId((String)meta.get("packageId")); + mAndRes.setPackageId((Map) meta.get("packageInfo")); mAndRes.setVersionInfo((Map) meta.get("versionInfo")); if (outFile == null) { 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 45e7c4ae..33e111f5 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 @@ -182,19 +182,11 @@ final public class AndrolibResources { DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(new File(filePath)); transformer.transform(source, result); - - } catch (ParserConfigurationException ex) { - throw new AndrolibException(ex); - } catch (SAXException ex) { - throw new AndrolibException(ex); - } catch (IOException ex) { - throw new AndrolibException(ex); - } catch (TransformerConfigurationException ex) { - throw new AndrolibException(ex); - } catch (TransformerException ex) { - throw new AndrolibException(ex); - } - } + + } catch (SAXException | ParserConfigurationException | IOException | TransformerException ex) { + throw new AndrolibException(ex); + } + } public void adjust_package_manifest(ResTable resTable, String filePath) throws AndrolibException { @@ -233,16 +225,10 @@ final public class AndrolibResources { StreamResult result = new StreamResult(new File(filePath)); transformer.transform(source, result); - } catch (ParserConfigurationException ex) { - throw new AndrolibException(ex); - } catch (TransformerException ex) { - throw new AndrolibException(ex); - } catch (IOException ex) { - throw new AndrolibException(ex); - } catch (SAXException ex) { - throw new AndrolibException(ex); - } - } + } catch (SAXException | ParserConfigurationException | IOException | TransformerException ex) { + throw new AndrolibException(ex); + } + } } public void remove_manifest_versions(String filePath) @@ -279,15 +265,7 @@ final public class AndrolibResources { StreamResult result = new StreamResult(new File(filePath)); transformer.transform(source, result); - } catch (ParserConfigurationException ex) { - throw new AndrolibException(ex); - } catch (SAXException ex) { - throw new AndrolibException(ex); - } catch (IOException ex) { - throw new AndrolibException(ex); - } catch (TransformerConfigurationException ex) { - throw new AndrolibException(ex); - } catch (TransformerException ex) { + } catch (SAXException | ParserConfigurationException | IOException | TransformerException ex) { throw new AndrolibException(ex); } } @@ -372,8 +350,10 @@ final public class AndrolibResources { } } - public void setPackageId(String id) { - mPackageId = id; + public void setPackageId(Map map) { + if (map != null) { + mPackageId = map.get("cur_package_id"); + } } public void aaptPackage(File apkFile, File manifest, File resDir, @@ -495,6 +475,10 @@ final public class AndrolibResources { } try { OS.exec(cmd.toArray(new String[0])); + if (flags.get("verbose")) { + LOGGER.info("command ran: "); + LOGGER.info(cmd.toString()); + } } catch (BrutException ex) { throw new AndrolibException(ex); }