Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/com/reandroid/apk/ApkModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ private void ensureLoadedManifestLinked() {
}
packageBlock = tableBlock.pickOne(manifestBlock.guessCurrentPackageId());
if(packageBlock == null) {
packageBlock = tableBlock.pickOne();
packageBlock = tableBlock.pickOrEmptyPackage();
}
if(packageBlock != null) {
manifestBlock.setPackageBlock(packageBlock);
Copy link
Owner

@REAndroid REAndroid Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you,

there are some cases where packages will be constructed latter, can you experiment with this one ?
put setApkFile out of if block

        if(packageBlock != null) {
            manifestBlock.setPackageBlock(packageBlock);
        }
        manifestBlock.setApkFile(this);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm ...
The purpose of ensureLoadedManifestLinked() is to check multiple times that manifest has correct package. In both cases ( pickOneOrEmpty & setApkFile) the manifest will claim having correct package even if new package is produced latter.

My other idea is :

        if(packageBlock != null && !packageBlock.isEmpty()) {
            TableBlock linkedTable = packageBlock.getTableBlock();
            if(linkedTable == tableBlock) {
                return;
            }
        }
        packageBlock = tableBlock.pickOne(manifestBlock.guessCurrentPackageId());
        if(packageBlock == null) {
            packageBlock = tableBlock.pickOrEmptyPackage();
        }

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/reandroid/apk/ApkModuleXmlEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void encodeManifestXml(File mainDirectory) {
if(packageId != null){
packageBlock = tableBlock.pickOne(packageId);
}else {
packageBlock = tableBlock.pickOne();
packageBlock = tableBlock.pickOrEmptyPackage();
}
if(packageBlock != null){
tableBlock.setCurrentPackage(packageBlock);
Expand Down