decoder: Extend "keep-broken-res" to also ignore duplicate resources

This commit is contained in:
Christopher R. Palmer 2016-02-15 11:13:49 -05:00
parent b29df52b87
commit 4a02f5321c
2 changed files with 14 additions and 3 deletions

View File

@ -73,6 +73,8 @@ public class ApkDecoder {
public void decode() throws AndrolibException, IOException, DirectoryException {
File outDir = getOutDir();
AndrolibResources.sKeepBroken = mKeepBrokenResources;
if (!mForceDelete && outDir.exists()) {
throw new OutDirExistsException();
}
@ -239,7 +241,6 @@ public class ApkDecoder {
throw new AndrolibException(
"Apk doesn't contain either AndroidManifest.xml file or resources.arsc file");
}
AndrolibResources.sKeepBroken = mKeepBrokenResources;
mResTable = mAndrolib.getResTable(mApkFile, hasResources);
}
return mResTable;

View File

@ -249,8 +249,18 @@ public class ARSCDecoder {
}
ResResource res = new ResResource(mType, spec, value);
mType.addResource(res);
spec.addResource(res);
try {
mType.addResource(res);
spec.addResource(res);
} catch (AndrolibException e) {
if (mKeepBroken) {
mType.addResource(res, true);
spec.addResource(res, true);
System.err.println("ignoring exception: " + e);
} else {
throw e;
}
}
mPkg.addResource(res);
}