need option to specify framework folder #286

Closed
iBotPeaches opened this Issue Mar 18, 2015 · 2 comments

Comments

Projects
None yet
1 participant
@iBotPeaches
Owner

iBotPeaches commented Mar 18, 2015

Original issue 175 created by KinkyMunkey on 2011-06-06T17:01:29.000Z:

This code will not work on a web server because $HOME is set to /var/www/ and that is not writable (nor do we wish to make it writable)

I added a way to specify the framework folder - please merge this patch into the trunk :-)

Thanks!

---- START PATCH ----

diff --git a/apktool-cli/src/main/java/brut/apktool/Main.java b/apktool-cli/src/main/java/brut/apktool/Main.java
index 0963c01..ae7064d 100644
--- a/apktool-cli/src/main/java/brut/apktool/Main.java
+++ b/apktool-cli/src/main/java/brut/apktool/Main.java
@@ -96,6 +96,10 @@ public class Main {
decoder.setDecodeResources(ApkDecoder.DECODE_RESOURCES_NONE);
} else if ("--keep-broken-res".equals(opt)) {
decoder.setKeepBrokenResources(true);

  •        } else if ("--framework".equals(opt)) {
    
  •           i++;
    
  •           System.out.println("Using Framework Directory: " + args[i]);
    
  •            decoder.setFrameworkDir(args[i]);
         } else {
             throw new InvalidArgsError();
         }
    
    @@ -223,6 +227,8 @@ public class Main {
    " Force delete destination directory.\n" +
    " -t <tag>, --frame-tag <tag>\n" +
    " Try to use framework files tagged by <tag>.\n" +
  •        &quot;           --framework &lt;dir&gt;\n&quot; +
    
  •        &quot;            Use the specified directory for framework files&quot; +
         &quot;        --keep-broken-res\n&quot; +
         &quot;            Use if there was an error and some resources were dropped, e.g.:\n&quot; +
         &quot;            &quot;Invalid config flags detected. Dropping resources&quot;, but you\n&quot; +
    
    diff --git a/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java b/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java
    index 8d74e5c..f479b19 100644
    --- a/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java
    +++ b/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java
    @@ -137,6 +137,10 @@ public class ApkDecoder {
    public void setKeepBrokenResources(boolean keepBrokenResources) {
    mKeepBrokenResources = keepBrokenResources;
    }
  • public void setFrameworkDir(String dir) {
  •   mFrameworkDir = dir;  
    
  • }

public ResTable getResTable() throws AndrolibException {
if (mResTable == null) {
@@ -145,6 +149,7 @@ public class ApkDecoder {
"Apk doesn't containt resources.arsc file");
}
AndrolibResources.sKeepBroken = mKeepBrokenResources;

  •        AndrolibResources.sFrameworkFolder = mFrameworkDir;
         mResTable = mAndrolib.getResTable(mApkFile);
         mResTable.setFrameTag(mFrameTag);
     }
    
    @@ -231,4 +236,5 @@ public class ApkDecoder {
    private boolean mForceDelete = false;
    private String mFrameTag;
    private boolean mKeepBrokenResources = false;
  • private String mFrameworkDir = null;
    }
    diff --git a/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java b/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java
    index 86bda2c..0aabb59 100644
    --- a/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java
    +++ b/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java
    @@ -466,10 +466,13 @@ final public class AndrolibResources {
    }

private File getFrameworkDir() throws AndrolibException {

  •    File dir = new File(System.getProperty(&quot;user.home&quot;) +
    
  •    File dir = new File(sFrameworkFolder != null ? sFrameworkFolder : System.getProperty(&quot;user.home&quot;) +
         File.separatorChar + &quot;apktool&quot; + File.separatorChar + &quot;framework&quot;);
     if (! dir.exists()) {
         if (! dir.mkdirs()) {
    
  •           if (sFrameworkFolder != null) {
    
  •                   System.out.println(&quot;Can't create Framework directory: &quot; + dir);
    
  •           }
             throw new AndrolibException(&quot;Can't create directory: &quot; + dir);
         }
     }
    

    @@ -487,6 +490,7 @@ final public class AndrolibResources {

    // TODO: dirty static hack. I have to refactor decoding mechanisms.
    public static boolean sKeepBroken = false;

  • public static String sFrameworkFolder = null;

private final static Logger LOGGER =

@iBotPeaches iBotPeaches self-assigned this Mar 18, 2015

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 18, 2015

Owner

Comment #1 originally posted by connor.tumbleson on 2012-11-19T15:31:34.000Z:

I'll merge this in for v1.5.1

Owner

iBotPeaches commented Mar 18, 2015

Comment #1 originally posted by connor.tumbleson on 2012-11-19T15:31:34.000Z:

I'll merge this in for v1.5.1

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 18, 2015

Owner

Comment #2 originally posted by connor.tumbleson on 2012-12-17T18:54:52.000Z:

Fixed.

Thanks to Robert.

Owner

iBotPeaches commented Mar 18, 2015

Comment #2 originally posted by connor.tumbleson on 2012-12-17T18:54:52.000Z:

Fixed.

Thanks to Robert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment