use of brut.directory.ExtFile in project Apktool by iBotPeaches.
the class Androlib method buildManifestRaw.
public boolean buildManifestRaw(ExtFile appDir) throws AndrolibException {
try {
File apkDir = new File(appDir, APK_DIRNAME);
LOGGER.info("Copying raw AndroidManifest.xml...");
appDir.getDirectory().copyToDir(apkDir, APK_MANIFEST_FILENAMES);
return true;
} catch (DirectoryException ex) {
throw new AndrolibException(ex);
}
}
use of brut.directory.ExtFile in project Apktool by iBotPeaches.
the class ApkDecoder method setApkFile.
public void setApkFile(File apkFile) {
mApkFile = new ExtFile(apkFile);
mResTable = null;
}
use of brut.directory.ExtFile in project Apktool by iBotPeaches.
the class AndrolibResources method loadFrameworkPkg.
public ResPackage loadFrameworkPkg(ResTable resTable, int id, String frameTag) throws AndrolibException {
File apk = getFrameworkApk(id, frameTag);
LOGGER.info("Loading resource table from file: " + apk);
ResPackage[] pkgs = getResPackagesFromApk(new ExtFile(apk), resTable, true);
ResPackage pkg;
if (pkgs.length > 1) {
pkg = selectPkgWithMostResSpecs(pkgs);
} else if (pkgs.length == 0) {
throw new AndrolibException("Arsc files with zero or multiple packages");
} else {
pkg = pkgs[0];
}
if (pkg.getId() != id) {
throw new AndrolibException("Expected pkg of id: " + String.valueOf(id) + ", got: " + pkg.getId());
}
resTable.addPackage(pkg, false);
return pkg;
}
use of brut.directory.ExtFile in project Apktool by iBotPeaches.
the class AndrolibResources method decodeManifestWithResources.
public void decodeManifestWithResources(ResTable resTable, ExtFile apkFile, File outDir) throws AndrolibException {
Duo<ResFileDecoder, AXmlResourceParser> duo = getResFileDecoder();
ResFileDecoder fileDecoder = duo.m1;
ResAttrDecoder attrDecoder = duo.m2.getAttrDecoder();
attrDecoder.setCurrentPackage(resTable.listMainPackages().iterator().next());
Directory inApk, in = null, out;
try {
inApk = apkFile.getDirectory();
out = new FileDirectory(outDir);
LOGGER.info("Decoding AndroidManifest.xml with resources...");
fileDecoder.decodeManifest(inApk, "AndroidManifest.xml", out, "AndroidManifest.xml");
// Remove versionName / versionCode (aapt API 16)
if (!resTable.getAnalysisMode()) {
// check for a mismatch between resources.arsc package and the package listed in AndroidManifest
// also remove the android::versionCode / versionName from manifest for rebuild
// this is a required change to prevent aapt warning about conflicting versions
// it will be passed as a parameter to aapt like "--min-sdk-version" via apktool.yml
adjustPackageManifest(resTable, outDir.getAbsolutePath() + File.separator + "AndroidManifest.xml");
ResXmlPatcher.removeManifestVersions(new File(outDir.getAbsolutePath() + File.separator + "AndroidManifest.xml"));
mPackageId = String.valueOf(resTable.getPackageId());
}
} catch (DirectoryException ex) {
throw new AndrolibException(ex);
}
}
use of brut.directory.ExtFile in project Apktool by iBotPeaches.
the class Androlib method decodeUnknownFiles.
public void decodeUnknownFiles(ExtFile apkFile, File outDir, ResTable resTable) throws AndrolibException {
LOGGER.info("Copying unknown files...");
File unknownOut = new File(outDir, UNK_DIRNAME);
try {
Directory unk = apkFile.getDirectory();
// loop all items in container recursively, ignoring any that are pre-defined by aapt
Set<String> files = unk.getFiles(true);
for (String file : files) {
if (!isAPKFileNames(file) && !file.endsWith(".dex")) {
// copy file out of archive into special "unknown" folder
unk.copyToDir(unknownOut, file);
// lets record the name of the file, and its compression type
// so that we may re-include it the same way
mResUnknownFiles.addUnknownFileInfo(file, String.valueOf(unk.getCompressionLevel(file)));
}
}
} catch (DirectoryException ex) {
throw new AndrolibException(ex);
}
}
Aggregations