support zero package table XML decoding/encoding

This commit is contained in:
REAndroid 2023-03-08 16:30:33 -05:00
parent 490deb59a3
commit 53d8e192fa
2 changed files with 28 additions and 2 deletions

View File

@ -152,6 +152,22 @@ import java.util.*;
for(PackageBlock packageBlock:tableBlock.listPackages()){
decodePublicXml(packageBlock, outDir);
}
if(tableBlock.getPackageArray().childesCount()==0){
decodeEmptyTable(outDir);
}
}
private void decodeEmptyTable(File outDir) throws IOException {
logMessage("Decoding empty table ...");
String pkgName = apkModule.getPackageName();
if(pkgName==null){
return;
}
File pkgDir = new File(outDir, "0-"+pkgName);
File resDir = new File(pkgDir, ApkUtil.RES_DIR_NAME);
File values = new File(resDir, "values");
File pubXml = new File(values, ApkUtil.FILE_NAME_PUBLIC_XML);
XMLDocument xmlDocument = new XMLDocument("resources");
xmlDocument.save(pubXml, false);
}
private void decodePublicXml(PackageBlock packageBlock, File outDir)
throws IOException {

View File

@ -77,6 +77,9 @@
for(File pubXmlFile:pubXmlFileList){
ResourceIds.Table.Package pkgResourceIds=map.get(pubXmlFile);
if(pkgResourceIds==null){
continue;
}
addParsedFiles(pubXmlFile);
PackageBlock packageBlock = createPackage(pkgResourceIds, pubXmlFile);
@ -101,6 +104,9 @@
}
for(File pubXmlFile:pubXmlFileList){
ResourceIds.Table.Package pkgResourceIds=map.get(pubXmlFile);
if(pkgResourceIds==null){
continue;
}
addParsedFiles(pubXmlFile);
PackageBlock packageBlock=packageBlockMap.get(pubXmlFile);
@ -165,8 +171,12 @@
}
ResourceIds resourceIds=new ResourceIds();
resourceIds.fromXml(pubXmlFile);
ResourceIds.Table.Package pkg = resourceIds.getTable()
.listPackages().get(0);
List<ResourceIds.Table.Package> pkgList = resourceIds.getTable()
.listPackages();
if(pkgList.size()==0){
continue;
}
ResourceIds.Table.Package pkg = pkgList.get(0);
if(pkg.name==null){
pkg.name=packageName;
}