Added support for framework apks.

This commit is contained in:
Ryszard Wiśniewski 2010-04-01 17:38:30 +02:00
parent 5a6e684f80
commit 9234017707
2 changed files with 21 additions and 2 deletions

View File

@ -214,7 +214,7 @@ public class Androlib {
apkFile,
new File(appDir, "AndroidManifest.xml"),
new File(appDir, "res"), ninePatch, null, false,
false
mAndRes.detectWhetherAppIsFramework(appDir)
);
new ExtFile(apkFile).getDirectory()

View File

@ -29,7 +29,9 @@ import brut.directory.*;
import brut.util.*;
import java.io.*;
import java.util.Arrays;
import java.util.Iterator;
import java.util.logging.Logger;
import org.apache.commons.io.IOUtils;
import org.xmlpull.v1.XmlSerializer;
/**
@ -38,8 +40,10 @@ import org.xmlpull.v1.XmlSerializer;
final public class AndrolibResources {
public ResTable getResTable(ExtFile apkFile) throws AndrolibException {
ResTable resTable = new ResTable();
decodeArsc(resTable, new ExtFile(getAndroidResourcesFile()), false);
decodeArsc(resTable, apkFile, true);
if (! resTable.hasPackage(1)) {
decodeArsc(resTable, new ExtFile(getAndroidResourcesFile()), false);
}
return resTable;
}
@ -123,6 +127,21 @@ final public class AndrolibResources {
}
}
public boolean detectWhetherAppIsFramework(File appDir)
throws AndrolibException {
Iterator<String> it;
try {
it = IOUtils.lineIterator(
new FileReader(new File(appDir, "res/values/public.xml")));
} catch (FileNotFoundException ex) {
throw new AndrolibException(
"Could not detect whether app is framework one", ex);
}
it.next();
it.next();
return it.next().contains("0x01");
}
public void tagSmaliResIDs(ResTable resTable, File smaliDir)
throws AndrolibException {
new ResSmaliUpdater().tagResIDs(resTable, smaliDir);