Merge pull request #2182 from JingYeoh/bugfix/arsc/multipackage

bugfix, fix get wrong package ResPackage for multi-pkg resources.arsc.
This commit is contained in:
Connor Tumbleson 2019-10-06 05:22:00 -04:00 committed by GitHub
commit 03c1de4800
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -99,16 +99,19 @@ final public class AndrolibResources {
throws AndrolibException { throws AndrolibException {
int id = 0; int id = 0;
int value = 0; int value = 0;
int index = 0;
for (ResPackage resPackage : pkgs) { for (int i = 0; i < pkgs.length; i++) {
ResPackage resPackage = pkgs[i];
if (resPackage.getResSpecCount() > value && ! resPackage.getName().equalsIgnoreCase("android")) { if (resPackage.getResSpecCount() > value && ! resPackage.getName().equalsIgnoreCase("android")) {
value = resPackage.getResSpecCount(); value = resPackage.getResSpecCount();
id = resPackage.getId(); id = resPackage.getId();
index = i;
} }
} }
// if id is still 0, we only have one pkgId which is "android" -> 1 // if id is still 0, we only have one pkgId which is "android" -> 1
return (id == 0) ? pkgs[0] : pkgs[1]; return (id == 0) ? pkgs[0] : pkgs[index];
} }
public ResPackage loadFrameworkPkg(ResTable resTable, int id, String frameTag) public ResPackage loadFrameworkPkg(ResTable resTable, int id, String frameTag)