Storing resources.arsc uncompressed in framework apk files.

This commit is contained in:
Ryszard Wiśniewski 2010-04-02 13:38:50 +02:00
parent 602fd95f8a
commit 4bd9ea4b60
2 changed files with 27 additions and 21 deletions

View File

@ -108,11 +108,13 @@ public class Androlib {
public void build(ExtFile appDir, boolean forceBuildAll) public void build(ExtFile appDir, boolean forceBuildAll)
throws AndrolibException { throws AndrolibException {
boolean framework = mAndRes.detectWhetherAppIsFramework(appDir);
new File(appDir, APK_DIRNAME).mkdirs(); new File(appDir, APK_DIRNAME).mkdirs();
buildSources(appDir, forceBuildAll); buildSources(appDir, forceBuildAll);
buildResources(appDir, forceBuildAll); buildResources(appDir, forceBuildAll, framework);
buildLib(appDir, forceBuildAll); buildLib(appDir, forceBuildAll);
buildApk(appDir); buildApk(appDir, framework);
} }
public void buildSources(File appDir, boolean forceBuildAll) public void buildSources(File appDir, boolean forceBuildAll)
@ -160,10 +162,10 @@ public class Androlib {
return true; return true;
} }
public void buildResources(ExtFile appDir, boolean forceBuildAll) public void buildResources(ExtFile appDir, boolean forceBuildAll,
throws AndrolibException { boolean framework) throws AndrolibException {
if (! buildResourcesRaw(appDir, forceBuildAll) if (! buildResourcesRaw(appDir, forceBuildAll)
&& ! buildResourcesFull(appDir, forceBuildAll)) { && ! buildResourcesFull(appDir, forceBuildAll, framework)) {
LOGGER.warning("Could not find resources"); LOGGER.warning("Could not find resources");
} }
} }
@ -191,8 +193,8 @@ public class Androlib {
} }
} }
public boolean buildResourcesFull(File appDir, boolean forceBuildAll) public boolean buildResourcesFull(File appDir, boolean forceBuildAll,
throws AndrolibException { boolean framework) throws AndrolibException {
try { try {
if (! forceBuildAll) { if (! forceBuildAll) {
LOGGER.info("Checking whether resources has changed..."); LOGGER.info("Checking whether resources has changed...");
@ -213,8 +215,8 @@ public class Androlib {
mAndRes.aaptPackage( mAndRes.aaptPackage(
apkFile, apkFile,
new File(appDir, "AndroidManifest.xml"), new File(appDir, "AndroidManifest.xml"),
new File(appDir, "res"), ninePatch, null, false, new File(appDir, "res"),
mAndRes.detectWhetherAppIsFramework(appDir) ninePatch, null, false, framework
); );
new ExtFile(apkFile).getDirectory() new ExtFile(apkFile).getDirectory()
@ -246,7 +248,8 @@ public class Androlib {
} }
} }
public void buildApk(File appDir) throws AndrolibException { public void buildApk(File appDir, boolean framework)
throws AndrolibException {
LOGGER.info("Building apk file"); LOGGER.info("Building apk file");
File outApk = new File(appDir, OUT_APK_FILENAME); File outApk = new File(appDir, OUT_APK_FILENAME);
if (outApk.exists()) { if (outApk.exists()) {
@ -262,7 +265,7 @@ public class Androlib {
assetDir = null; assetDir = null;
} }
mAndRes.aaptPackage(outApk, null, null, mAndRes.aaptPackage(outApk, null, null,
new File(appDir, APK_DIRNAME), assetDir, false, false); new File(appDir, APK_DIRNAME), assetDir, false, true);
} }
private boolean isModified(File working, File stored) { private boolean isModified(File working, File stored) {

View File

@ -87,7 +87,7 @@ final public class AndrolibResources {
public void aaptPackage(File apkFile, File manifest, File resDir, public void aaptPackage(File apkFile, File manifest, File resDir,
File rawDir, File assetDir, boolean update, boolean framework) File rawDir, File assetDir, boolean update, boolean framework)
throws AndrolibException { throws AndrolibException {
String[] cmd = new String[13]; String[] cmd = new String[14];
int i = 0; int i = 0;
cmd[i++] = "aapt"; cmd[i++] = "aapt";
cmd[i++] = "p"; cmd[i++] = "p";
@ -97,21 +97,24 @@ final public class AndrolibResources {
cmd[i++] = "-F"; cmd[i++] = "-F";
cmd[i++] = apkFile.getAbsolutePath(); cmd[i++] = apkFile.getAbsolutePath();
if (resDir != null) {
if (framework) { if (framework) {
cmd[i++] = "-x"; cmd[i++] = "-x";
} else { } else {
cmd[i++] = "-I"; cmd[i++] = "-I";
cmd[i++] = getAndroidResourcesFile().getAbsolutePath(); cmd[i++] = getAndroidResourcesFile().getAbsolutePath();
} }
cmd[i++] = "-S";
cmd[i++] = resDir.getAbsolutePath();
} else if (framework) {
cmd[i++] = "-0";
cmd[i++] = "arsc";
}
if (manifest != null) { if (manifest != null) {
cmd[i++] = "-M"; cmd[i++] = "-M";
cmd[i++] = manifest.getAbsolutePath(); cmd[i++] = manifest.getAbsolutePath();
} }
if (resDir != null) {
cmd[i++] = "-S";
cmd[i++] = resDir.getAbsolutePath();
}
if (assetDir != null) { if (assetDir != null) {
cmd[i++] = "-A"; cmd[i++] = "-A";
cmd[i++] = assetDir.getAbsolutePath(); cmd[i++] = assetDir.getAbsolutePath();