mirror of
https://github.com/revanced/Apktool.git
synced 2025-05-01 22:54:24 +02:00
Merge pull request #67 from droidmunkey/droidmunkey/master
Support for --framework <dir> command line argument to specify the location of the framework files
This commit is contained in:
commit
9bb2078d0f
@ -111,7 +111,11 @@ public class Main {
|
|||||||
decoder.setDecodeResources(ApkDecoder.DECODE_RESOURCES_NONE);
|
decoder.setDecodeResources(ApkDecoder.DECODE_RESOURCES_NONE);
|
||||||
} else if ("--keep-broken-res".equals(opt)) {
|
} else if ("--keep-broken-res".equals(opt)) {
|
||||||
decoder.setKeepBrokenResources(true);
|
decoder.setKeepBrokenResources(true);
|
||||||
} else {
|
} else if ("--framework".equals(opt)) {
|
||||||
|
i++;
|
||||||
|
System.out.println("Using Framework Directory: " + args[i]);
|
||||||
|
decoder.setFrameworkDir(args[i]);
|
||||||
|
} else {
|
||||||
throw new InvalidArgsError();
|
throw new InvalidArgsError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,6 +266,8 @@ public class Main {
|
|||||||
" Force delete destination directory.\n" +
|
" Force delete destination directory.\n" +
|
||||||
" -t <tag>, --frame-tag <tag>\n" +
|
" -t <tag>, --frame-tag <tag>\n" +
|
||||||
" Try to use framework files tagged by <tag>.\n" +
|
" Try to use framework files tagged by <tag>.\n" +
|
||||||
|
" --framework <dir>\n" +
|
||||||
|
" Use the specified directory for framework files" +
|
||||||
" --keep-broken-res\n" +
|
" --keep-broken-res\n" +
|
||||||
" Use if there was an error and some resources were dropped, e.g.:\n" +
|
" Use if there was an error and some resources were dropped, e.g.:\n" +
|
||||||
" \"Invalid config flags detected. Dropping resources\", but you\n" +
|
" \"Invalid config flags detected. Dropping resources\", but you\n" +
|
||||||
|
@ -157,6 +157,10 @@ public class ApkDecoder {
|
|||||||
public void setKeepBrokenResources(boolean keepBrokenResources) {
|
public void setKeepBrokenResources(boolean keepBrokenResources) {
|
||||||
mKeepBrokenResources = keepBrokenResources;
|
mKeepBrokenResources = keepBrokenResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFrameworkDir(String dir) {
|
||||||
|
mFrameworkDir = dir;
|
||||||
|
}
|
||||||
|
|
||||||
public ResTable getResTable() throws AndrolibException {
|
public ResTable getResTable() throws AndrolibException {
|
||||||
if (mResTable == null) {
|
if (mResTable == null) {
|
||||||
@ -167,6 +171,7 @@ public class ApkDecoder {
|
|||||||
"Apk doesn't contain either AndroidManifest.xml file or resources.arsc file");
|
"Apk doesn't contain either AndroidManifest.xml file or resources.arsc file");
|
||||||
}
|
}
|
||||||
AndrolibResources.sKeepBroken = mKeepBrokenResources;
|
AndrolibResources.sKeepBroken = mKeepBrokenResources;
|
||||||
|
AndrolibResources.sFrameworkFolder = mFrameworkDir;
|
||||||
mResTable = mAndrolib.getResTable(mApkFile, hasResources);
|
mResTable = mAndrolib.getResTable(mApkFile, hasResources);
|
||||||
mResTable.setFrameTag(mFrameTag);
|
mResTable.setFrameTag(mFrameTag);
|
||||||
}
|
}
|
||||||
@ -271,5 +276,6 @@ public class ApkDecoder {
|
|||||||
private boolean mForceDelete = false;
|
private boolean mForceDelete = false;
|
||||||
private String mFrameTag;
|
private String mFrameTag;
|
||||||
private boolean mKeepBrokenResources = false;
|
private boolean mKeepBrokenResources = false;
|
||||||
|
private String mFrameworkDir = null;
|
||||||
private boolean mBakDeb = true;
|
private boolean mBakDeb = true;
|
||||||
}
|
}
|
||||||
|
@ -545,8 +545,11 @@ final public class AndrolibResources {
|
|||||||
private File getFrameworkDir() throws AndrolibException {
|
private File getFrameworkDir() throws AndrolibException {
|
||||||
String path;
|
String path;
|
||||||
|
|
||||||
/* store in user-home, for Mac OS X */
|
/* if a framework path was specified on the command line, use it */
|
||||||
if (System.getProperty("os.name").equals("Mac OS X")) {
|
if (sFrameworkFolder != null) {
|
||||||
|
path = sFrameworkFolder;
|
||||||
|
} else if (System.getProperty("os.name").equals("Mac OS X")) {
|
||||||
|
/* store in user-home, for Mac OS X */
|
||||||
path = System.getProperty("user.home") + File.separatorChar +
|
path = System.getProperty("user.home") + File.separatorChar +
|
||||||
"Library/apktool/framework"; }
|
"Library/apktool/framework"; }
|
||||||
else {
|
else {
|
||||||
@ -556,6 +559,9 @@ final public class AndrolibResources {
|
|||||||
File dir = new File(path);
|
File dir = new File(path);
|
||||||
if (! dir.exists()) {
|
if (! dir.exists()) {
|
||||||
if (! dir.mkdirs()) {
|
if (! dir.mkdirs()) {
|
||||||
|
if (sFrameworkFolder != null) {
|
||||||
|
System.out.println("Can't create Framework directory: " + dir);
|
||||||
|
}
|
||||||
throw new AndrolibException("Can't create directory: " + dir);
|
throw new AndrolibException("Can't create directory: " + dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -573,7 +579,7 @@ final public class AndrolibResources {
|
|||||||
|
|
||||||
// TODO: dirty static hack. I have to refactor decoding mechanisms.
|
// TODO: dirty static hack. I have to refactor decoding mechanisms.
|
||||||
public static boolean sKeepBroken = false;
|
public static boolean sKeepBroken = false;
|
||||||
|
public static String sFrameworkFolder = null;
|
||||||
|
|
||||||
private final static Logger LOGGER =
|
private final static Logger LOGGER =
|
||||||
Logger.getLogger(AndrolibResources.class.getName());
|
Logger.getLogger(AndrolibResources.class.getName());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user