mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-07 18:45:58 +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();
|
new File(appDir, APK_DIRNAME).mkdirs();
|
||||||
buildSources(appDir, forceBuildAll, debug);
|
buildSources(appDir, forceBuildAll, debug);
|
||||||
buildResources(appDir, forceBuildAll, framework);
|
buildResources(appDir, forceBuildAll, framework,
|
||||||
|
(Map<String, Object>) meta.get("usesFramework"));
|
||||||
buildLib(appDir, forceBuildAll);
|
buildLib(appDir, forceBuildAll);
|
||||||
buildApk(appDir, framework);
|
buildApk(appDir, framework);
|
||||||
}
|
}
|
||||||
@ -232,9 +233,11 @@ public class Androlib {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void buildResources(ExtFile appDir, boolean forceBuildAll,
|
public void buildResources(ExtFile appDir, boolean forceBuildAll,
|
||||||
boolean framework) throws AndrolibException {
|
boolean framework, Map<String, Object> usesFramework)
|
||||||
|
throws AndrolibException {
|
||||||
if (! buildResourcesRaw(appDir, forceBuildAll)
|
if (! buildResourcesRaw(appDir, forceBuildAll)
|
||||||
&& ! buildResourcesFull(appDir, forceBuildAll, framework)) {
|
&& ! buildResourcesFull(appDir, forceBuildAll, framework,
|
||||||
|
usesFramework)) {
|
||||||
LOGGER.warning("Could not find resources");
|
LOGGER.warning("Could not find resources");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,7 +266,8 @@ public class Androlib {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean buildResourcesFull(File appDir, boolean forceBuildAll,
|
public boolean buildResourcesFull(File appDir, boolean forceBuildAll,
|
||||||
boolean framework) throws AndrolibException {
|
boolean framework, Map<String, Object> usesFramework)
|
||||||
|
throws AndrolibException {
|
||||||
try {
|
try {
|
||||||
if (! new File(appDir, "res").exists()) {
|
if (! new File(appDir, "res").exists()) {
|
||||||
return false;
|
return false;
|
||||||
@ -288,10 +292,7 @@ public class Androlib {
|
|||||||
apkFile,
|
apkFile,
|
||||||
new File(appDir, "AndroidManifest.xml"),
|
new File(appDir, "AndroidManifest.xml"),
|
||||||
new File(appDir, "res"),
|
new File(appDir, "res"),
|
||||||
ninePatch, null,
|
ninePatch, null, parseUsesFramework(usesFramework),
|
||||||
new File[]{
|
|
||||||
mAndRes.getAndroidResourcesFile(),
|
|
||||||
mAndRes.getHtcResourcesFile()},
|
|
||||||
false, framework
|
false, framework
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -379,6 +380,27 @@ public class Androlib {
|
|||||||
return VERSION;
|
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) {
|
private boolean isModified(File working, File stored) {
|
||||||
if (! stored.exists()) {
|
if (! stored.exists()) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package brut.androlib;
|
package brut.androlib;
|
||||||
|
|
||||||
import brut.androlib.err.OutDirExistsException;
|
import brut.androlib.err.OutDirExistsException;
|
||||||
|
import brut.androlib.res.data.ResPackage;
|
||||||
import brut.androlib.res.data.ResTable;
|
import brut.androlib.res.data.ResTable;
|
||||||
import brut.androlib.res.util.ExtFile;
|
import brut.androlib.res.util.ExtFile;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
@ -24,8 +25,7 @@ import brut.directory.Directory;
|
|||||||
import brut.directory.DirectoryException;
|
import brut.directory.DirectoryException;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||||
@ -165,9 +165,32 @@ public class ApkDecoder {
|
|||||||
meta.put("version", Androlib.getVersion());
|
meta.put("version", Androlib.getVersion());
|
||||||
meta.put("isFrameworkApk",
|
meta.put("isFrameworkApk",
|
||||||
Boolean.valueOf(mAndrolib.isFrameworkApk(getResTable())));
|
Boolean.valueOf(mAndrolib.isFrameworkApk(getResTable())));
|
||||||
|
putUsesFramework(meta);
|
||||||
mAndrolib.writeMetaFile(mOutDir, 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 final Androlib mAndrolib;
|
||||||
|
|
||||||
private ExtFile mApkFile;
|
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 {
|
throws AndrolibException {
|
||||||
File dir = getFrameworkDir();
|
File dir = getFrameworkDir();
|
||||||
File apk;
|
File apk;
|
||||||
|
Loading…
Reference in New Issue
Block a user