diff --git a/brut.apktool/apktool-lib/src/main/java/android/content/res/XmlResourceParser.java b/brut.apktool/apktool-lib/src/main/java/android/content/res/XmlResourceParser.java index 37b31dc7..3e8d70f8 100644 --- a/brut.apktool/apktool-lib/src/main/java/android/content/res/XmlResourceParser.java +++ b/brut.apktool/apktool-lib/src/main/java/android/content/res/XmlResourceParser.java @@ -15,9 +15,8 @@ */ package android.content.res; -import org.xmlpull.v1.XmlPullParser; - import android.util.AttributeSet; +import org.xmlpull.v1.XmlPullParser; /** * The XML parsing interface returned for an XML resource. This is a standard @@ -26,9 +25,9 @@ import android.util.AttributeSet; * it is done reading the resource. */ public interface XmlResourceParser extends XmlPullParser, AttributeSet { - /** - * Close this interface to the resource. Calls on the interface are no - * longer value after this call. - */ + /** + * Close this interface to the resource. Calls on the interface are no + * longer value after this call. + */ void close(); } diff --git a/brut.apktool/apktool-lib/src/main/java/android/util/AttributeSet.java b/brut.apktool/apktool-lib/src/main/java/android/util/AttributeSet.java index f4ddd678..fa1756cf 100644 --- a/brut.apktool/apktool-lib/src/main/java/android/util/AttributeSet.java +++ b/brut.apktool/apktool-lib/src/main/java/android/util/AttributeSet.java @@ -16,58 +16,52 @@ package android.util; public interface AttributeSet { - int getAttributeCount(); + int getAttributeCount(); - String getAttributeName(int index); + String getAttributeName(int index); - String getAttributeValue(int index); + String getAttributeValue(int index); - String getPositionDescription(); + String getPositionDescription(); - int getAttributeNameResource(int index); + int getAttributeNameResource(int index); - int getAttributeListValue(int index, String[] options, int defaultValue); + int getAttributeListValue(int index, String[] options, int defaultValue); - boolean getAttributeBooleanValue(int index, boolean defaultValue); + boolean getAttributeBooleanValue(int index, boolean defaultValue); - int getAttributeResourceValue(int index, int defaultValue); + int getAttributeResourceValue(int index, int defaultValue); - int getAttributeIntValue(int index, int defaultValue); + int getAttributeIntValue(int index, int defaultValue); - int getAttributeUnsignedIntValue(int index, int defaultValue); + int getAttributeUnsignedIntValue(int index, int defaultValue); - float getAttributeFloatValue(int index, float defaultValue); + float getAttributeFloatValue(int index, float defaultValue); - String getIdAttribute(); + String getIdAttribute(); - String getClassAttribute(); + String getClassAttribute(); - int getIdAttributeResourceValue(int index); + int getIdAttributeResourceValue(int index); - int getStyleAttribute(); + int getStyleAttribute(); - String getAttributeValue(String namespace, String attribute); + String getAttributeValue(String namespace, String attribute); - int getAttributeListValue(String namespace, String attribute, - String[] options, int defaultValue); + int getAttributeListValue(String namespace, String attribute, String[] options, int defaultValue); - boolean getAttributeBooleanValue(String namespace, String attribute, - boolean defaultValue); + boolean getAttributeBooleanValue(String namespace, String attribute, boolean defaultValue); - int getAttributeResourceValue(String namespace, String attribute, - int defaultValue); + int getAttributeResourceValue(String namespace, String attribute, int defaultValue); - int getAttributeIntValue(String namespace, String attribute, - int defaultValue); + int getAttributeIntValue(String namespace, String attribute, int defaultValue); - int getAttributeUnsignedIntValue(String namespace, String attribute, - int defaultValue); + int getAttributeUnsignedIntValue(String namespace, String attribute, int defaultValue); - float getAttributeFloatValue(String namespace, String attribute, - float defaultValue); + float getAttributeFloatValue(String namespace, String attribute, float defaultValue); - // TODO: remove - int getAttributeValueType(int index); + // TODO: remove + int getAttributeValueType(int index); - int getAttributeValueData(int index); + int getAttributeValueData(int index); } diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResAttr.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResAttr.java index 0b0925dc..9ce16577 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResAttr.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResAttr.java @@ -35,14 +35,13 @@ public class ResAttr extends ResBagValue implements ResValuesXmlSerializable { mL10n = l10n; } - public String convertToResXmlFormat(ResScalarValue value) - throws AndrolibException { + public String convertToResXmlFormat(ResScalarValue value) throws AndrolibException { return null; } @Override - public void serializeToResValuesXml(XmlSerializer serializer, - ResResource res) throws IOException, AndrolibException { + public void serializeToResValuesXml(XmlSerializer serializer, ResResource res) + throws IOException, AndrolibException { String type = getTypeAsString(); serializer.startTag(null, "attr"); @@ -90,30 +89,24 @@ public class ResAttr extends ResBagValue implements ResValuesXmlSerializable { if (i == items.length) { return new ResAttr(parent, scalarType, min, max, l10n); } - Duo[] attrItems = new Duo[items.length - - i]; + Duo[] attrItems = new Duo[items.length - i]; int j = 0; for (; i < items.length; i++) { int resId = items[i].m1; pkg.addSynthesizedRes(resId); - attrItems[j++] = new Duo<>( - factory.newReference(resId, null), - (ResIntValue) items[i].m2); + attrItems[j++] = new Duo<>(factory.newReference(resId, null), (ResIntValue) items[i].m2); } switch (type & 0xff0000) { case TYPE_ENUM: - return new ResEnumAttr(parent, scalarType, min, max, l10n, - attrItems); + return new ResEnumAttr(parent, scalarType, min, max, l10n, attrItems); case TYPE_FLAGS: - return new ResFlagsAttr(parent, scalarType, min, max, l10n, - attrItems); + return new ResFlagsAttr(parent, scalarType, min, max, l10n, attrItems); } throw new AndrolibException("Could not decode attr value"); } - protected void serializeBody(XmlSerializer serializer, ResResource res) - throws AndrolibException, IOException { + protected void serializeBody(XmlSerializer serializer, ResResource res) throws AndrolibException, IOException { } protected String getTypeAsString() { diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/Res9patchStreamDecoder.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/Res9patchStreamDecoder.java index 3950ec1b..33619e58 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/Res9patchStreamDecoder.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/Res9patchStreamDecoder.java @@ -25,12 +25,15 @@ import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.awt.image.Raster; import java.awt.image.WritableRaster; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.DataInput; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; public class Res9patchStreamDecoder implements ResStreamDecoder { @Override - public void decode(InputStream in, OutputStream out) - throws AndrolibException { + public void decode(InputStream in, OutputStream out) throws AndrolibException { try { byte[] data = IOUtils.toByteArray(in); @@ -112,29 +115,29 @@ public class Res9patchStreamDecoder implements ResStreamDecoder { ImageIO.write(im2, "png", out); } catch (IOException | NullPointerException ex) { + // In my case this was triggered because a .png file was + // containing a html document instead of an image. + // This could be more verbose and try to MIME ? throw new AndrolibException(ex); - } // In my case this was triggered because a .png file was - // containing a html document instead of an image. - // This could be more verbose and try to MIME ? - + } } private NinePatch getNinePatch(byte[] data) throws AndrolibException, - IOException { + IOException { ExtDataInput di = new ExtDataInput(new ByteArrayInputStream(data)); find9patchChunk(di, NP_CHUNK_TYPE); return NinePatch.decode(di); } private OpticalInset getOpticalInset(byte[] data) throws AndrolibException, - IOException { + IOException { ExtDataInput di = new ExtDataInput(new ByteArrayInputStream(data)); find9patchChunk(di, OI_CHUNK_TYPE); return OpticalInset.decode(di); } private void find9patchChunk(DataInput di, int magic) throws AndrolibException, - IOException { + IOException { di.skipBytes(8); while (true) { int size; @@ -195,19 +198,18 @@ public class Res9patchStreamDecoder implements ResStreamDecoder { int[] xDivs = di.readIntArray(numXDivs); int[] yDivs = di.readIntArray(numYDivs); - return new NinePatch(padLeft, padRight, padTop, padBottom, xDivs, - yDivs); + return new NinePatch(padLeft, padRight, padTop, padBottom, xDivs, yDivs); } } private static class OpticalInset { - public final int layoutBoundsLeft, layoutBoundsTop, layoutBoundsRight, layoutBoundsBottom; + public final int layoutBoundsLeft, layoutBoundsTop, layoutBoundsRight, layoutBoundsBottom; public OpticalInset(int layoutBoundsLeft, int layoutBoundsTop, - int layoutBoundsRight, int layoutBoundsBottom) { - this.layoutBoundsLeft = layoutBoundsLeft; - this.layoutBoundsTop = layoutBoundsTop; - this.layoutBoundsRight = layoutBoundsRight; + int layoutBoundsRight, int layoutBoundsBottom) { + this.layoutBoundsLeft = layoutBoundsLeft; + this.layoutBoundsTop = layoutBoundsTop; + this.layoutBoundsRight = layoutBoundsRight; this.layoutBoundsBottom = layoutBoundsBottom; } @@ -217,7 +219,7 @@ public class Res9patchStreamDecoder implements ResStreamDecoder { int layoutBoundsRight = Integer.reverseBytes(di.readInt()); int layoutBoundsBottom = Integer.reverseBytes(di.readInt()); return new OpticalInset(layoutBoundsLeft, layoutBoundsTop, - layoutBoundsRight, layoutBoundsBottom); + layoutBoundsRight, layoutBoundsBottom); } } } diff --git a/brut.apktool/apktool-lib/src/main/java/org/xmlpull/renamed/MXSerializer.java b/brut.apktool/apktool-lib/src/main/java/org/xmlpull/renamed/MXSerializer.java index 2d54eda1..4cc046ae 100644 --- a/brut.apktool/apktool-lib/src/main/java/org/xmlpull/renamed/MXSerializer.java +++ b/brut.apktool/apktool-lib/src/main/java/org/xmlpull/renamed/MXSerializer.java @@ -468,7 +468,8 @@ public class MXSerializer implements XmlSerializer { // now check that prefix is still in scope for (int p = namespaceEnd - 1; p > i; --p) { if (prefix == namespacePrefix[p]) { - } // too bad - prefix is redeclared with different namespace + // too bad - prefix is redeclared with different namespace + } } return prefix; } diff --git a/brut.j.dir/src/main/java/brut/directory/Directory.java b/brut.j.dir/src/main/java/brut/directory/Directory.java index c0828b37..86c848a6 100644 --- a/brut.j.dir/src/main/java/brut/directory/Directory.java +++ b/brut.j.dir/src/main/java/brut/directory/Directory.java @@ -16,44 +16,60 @@ */ package brut.directory; -import java.io.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.Map; import java.util.Set; public interface Directory { Set getFiles(); + Set getFiles(boolean recursive); + Map getDirs(); + Map getDirs(boolean recursive); boolean containsFile(String path); + boolean containsDir(String path); InputStream getFileInput(String path) throws DirectoryException; + OutputStream getFileOutput(String path) throws DirectoryException; + Directory getDir(String path) throws PathNotExist; + Directory createDir(String path) throws DirectoryException; boolean removeFile(String path); void copyToDir(Directory out) throws DirectoryException; + void copyToDir(Directory out, String[] fileNames) throws DirectoryException; + void copyToDir(Directory out, String fileName) throws DirectoryException; + void copyToDir(File out) throws DirectoryException; + void copyToDir(File out, String[] fileNames) throws DirectoryException; + void copyToDir(File out, String fileName) throws DirectoryException; long getSize(String fileName) - throws DirectoryException; - long getCompressedSize(String fileName) - throws DirectoryException; - int getCompressionLevel(String fileName) - throws DirectoryException; + throws DirectoryException; + long getCompressedSize(String fileName) + throws DirectoryException; + + int getCompressionLevel(String fileName) + throws DirectoryException; void close() throws IOException;