Evolve Update-Framework to Empty Framework Directory

- allows emptying of framework via (empty-framework-dir)
 - checks in place to only delete files that are APKs, non recursive
This commit is contained in:
Connor Tumbleson
2016-10-06 09:18:16 -04:00
parent daa1e1d753
commit 6361fa9725
3 changed files with 31 additions and 12 deletions

View File

@ -684,8 +684,8 @@ public class Androlib {
mAndRes.installFramework(frameFile);
}
public void updateFramework() throws AndrolibException {
mAndRes.updateFramework();
public void emptyFrameworkDirectory() throws AndrolibException {
mAndRes.emptyFrameworkDirectory();
}
public boolean isFrameworkApk(ResTable resTable) {

View File

@ -591,16 +591,29 @@ final public class AndrolibResources {
throw new CantFindFrameworkResException(id);
}
public void updateFramework() throws AndrolibException {
public void emptyFrameworkDirectory() throws AndrolibException {
File dir = getFrameworkDir();
File apk;
apk = new File(dir, "1.apk");
if (! apk.exists()) {
LOGGER.warning("Can't update framework, no file found at: " + apk.getAbsolutePath());
LOGGER.warning("Can't empty framework directory, no file found at: " + apk.getAbsolutePath());
} else {
try {
if (apk.exists() && dir.listFiles().length > 1 && ! apkOptions.forceDeleteFramework) {
LOGGER.warning("More than default framework detected. Please run command with `--force` parameter to wipe framework directory.");
} else {
for (File file : dir.listFiles()) {
if (file.isFile() && file.getName().endsWith(".apk")) {
LOGGER.info("Removing " + file.getName() + " framework file...");
file.delete();
}
}
}
} catch (NullPointerException e) {
throw new AndrolibException(e);
}
}
}