Handles multiple package framework files correctly.

This commit is contained in:
Connor Tumbleson 2013-10-12 15:40:06 -05:00
parent 64bcb32d81
commit 68c1809a48
2 changed files with 26 additions and 3 deletions

View File

@ -24,6 +24,7 @@ v2.0.0 (TBA)
-Fixed (issue #510) - Any error output is sent stderr instead of stdout
-Fixed (issue #426) - Filename too long (JesusFreke)
-Fixed (issue #524) - INSTALL_FAILED_DEXOPT fix (JesusFreke)
-Fixed (issue #473) - multiple package frameworks are treated correctly.
-Added output to list Apktool version to help debugging.
-Updated known bytes for configurations to 38 (from addition of layout direction)
-Fixed NPE when handling odex apks even with --no-src specified. (Thanks Rodrigo Chiossi)

View File

@ -425,13 +425,35 @@ public class ARSCDecoder {
}
public ResPackage getOnePackage() throws AndrolibException {
if (mPackages.length != 1) {
throw new AndrolibException(
"Arsc file contains zero or multiple packages");
if (mPackages.length <= 0) {
throw new AndrolibException(
"Arsc file contains zero packages");
} else if (mPackages.length != 1) {
int id = findPackageWithMostResSpecs();
LOGGER.warning("Arsc file contains multiple packages. Using package " + mPackages[id].getName() + " as default.");
return mPackages[id];
}
return mPackages[0];
}
public int findPackageWithMostResSpecs() {
int count = -1;
int id = 0;
// set starting point to package id 0.
count = mPackages[0].getResSpecCount();
// loop through packages looking for largest
for (int i = 0; i < mPackages.length; i++) {
if (mPackages[i].getResSpecCount() >= count) {
count = mPackages[i].getResSpecCount();
id = i;
}
}
return id;
}
public ResTable getResTable() {
return mResTable;
}