mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-06 10:05:54 +01:00
Use framework files from hard disk when building apk.
This commit is contained in:
parent
51a429ebd9
commit
2eb8b20d40
@ -158,7 +158,8 @@ public class Androlib {
|
||||
|
||||
new File(appDir, APK_DIRNAME).mkdirs();
|
||||
buildSources(appDir, forceBuildAll, debug);
|
||||
buildResources(appDir, forceBuildAll, framework);
|
||||
buildResources(appDir, forceBuildAll, framework,
|
||||
(Map<String, Object>) meta.get("usesFramework"));
|
||||
buildLib(appDir, forceBuildAll);
|
||||
buildApk(appDir, framework);
|
||||
}
|
||||
@ -232,9 +233,11 @@ public class Androlib {
|
||||
}
|
||||
|
||||
public void buildResources(ExtFile appDir, boolean forceBuildAll,
|
||||
boolean framework) throws AndrolibException {
|
||||
boolean framework, Map<String, Object> usesFramework)
|
||||
throws AndrolibException {
|
||||
if (! buildResourcesRaw(appDir, forceBuildAll)
|
||||
&& ! buildResourcesFull(appDir, forceBuildAll, framework)) {
|
||||
&& ! buildResourcesFull(appDir, forceBuildAll, framework,
|
||||
usesFramework)) {
|
||||
LOGGER.warning("Could not find resources");
|
||||
}
|
||||
}
|
||||
@ -263,7 +266,8 @@ public class Androlib {
|
||||
}
|
||||
|
||||
public boolean buildResourcesFull(File appDir, boolean forceBuildAll,
|
||||
boolean framework) throws AndrolibException {
|
||||
boolean framework, Map<String, Object> usesFramework)
|
||||
throws AndrolibException {
|
||||
try {
|
||||
if (! new File(appDir, "res").exists()) {
|
||||
return false;
|
||||
@ -288,10 +292,7 @@ public class Androlib {
|
||||
apkFile,
|
||||
new File(appDir, "AndroidManifest.xml"),
|
||||
new File(appDir, "res"),
|
||||
ninePatch, null,
|
||||
new File[]{
|
||||
mAndRes.getAndroidResourcesFile(),
|
||||
mAndRes.getHtcResourcesFile()},
|
||||
ninePatch, null, parseUsesFramework(usesFramework),
|
||||
false, framework
|
||||
);
|
||||
|
||||
@ -379,6 +380,27 @@ public class Androlib {
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
private File[] parseUsesFramework(Map<String, Object> usesFramework)
|
||||
throws AndrolibException {
|
||||
if (usesFramework == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Integer> ids = (List<Integer>) usesFramework.get("ids");
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String tag = (String) usesFramework.get("tag");
|
||||
File[] files = new File[ids.size()];
|
||||
int i = 0;
|
||||
for (int id : ids) {
|
||||
files[i++] = mAndRes.getFrameworkApk(id, tag);
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
private boolean isModified(File working, File stored) {
|
||||
if (! stored.exists()) {
|
||||
return true;
|
||||
|
@ -17,6 +17,7 @@
|
||||
package brut.androlib;
|
||||
|
||||
import brut.androlib.err.OutDirExistsException;
|
||||
import brut.androlib.res.data.ResPackage;
|
||||
import brut.androlib.res.data.ResTable;
|
||||
import brut.androlib.res.util.ExtFile;
|
||||
import brut.common.BrutException;
|
||||
@ -24,8 +25,7 @@ import brut.directory.Directory;
|
||||
import brut.directory.DirectoryException;
|
||||
import brut.util.OS;
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
@ -165,9 +165,32 @@ public class ApkDecoder {
|
||||
meta.put("version", Androlib.getVersion());
|
||||
meta.put("isFrameworkApk",
|
||||
Boolean.valueOf(mAndrolib.isFrameworkApk(getResTable())));
|
||||
putUsesFramework(meta);
|
||||
mAndrolib.writeMetaFile(mOutDir, meta);
|
||||
}
|
||||
|
||||
private void putUsesFramework(Map<String, Object> meta) {
|
||||
Set<ResPackage> pkgs = mResTable.listFramePackages();
|
||||
if (pkgs.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Integer[] ids = new Integer[pkgs.size()];
|
||||
int i = 0;
|
||||
for (ResPackage pkg : pkgs) {
|
||||
ids[i++] = pkg.getId();
|
||||
}
|
||||
|
||||
Map<String, Object> uses = new LinkedHashMap<String, Object>();
|
||||
uses.put("ids", ids);
|
||||
|
||||
if (mFrameTag != null) {
|
||||
uses.put("tag", mFrameTag);
|
||||
}
|
||||
|
||||
meta.put("usesFramework", uses);
|
||||
}
|
||||
|
||||
private final Androlib mAndrolib;
|
||||
|
||||
private ExtFile mApkFile;
|
||||
|
@ -301,7 +301,7 @@ final public class AndrolibResources {
|
||||
}
|
||||
}
|
||||
|
||||
private File getFrameworkApk(int id, String frameTag)
|
||||
public File getFrameworkApk(int id, String frameTag)
|
||||
throws AndrolibException {
|
||||
File dir = getFrameworkDir();
|
||||
File apk;
|
||||
|
Loading…
Reference in New Issue
Block a user