Skip to content

Commit

Permalink
Fix: Clean requiredSplitTypes & splitTypes from manifest with id #114
Browse files Browse the repository at this point in the history
  • Loading branch information
REAndroid committed Aug 1, 2024
1 parent 0d54699 commit 507413d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ public static void removeAttributeFromManifestByName(AndroidManifestBlock androi
logger.logMessage("Removed-attribute : " + resourceName);
}
}
public static void removeAttributeFromManifestById(AndroidManifestBlock androidManifestBlock,
int resourceId, APKLogger logger){
ResXmlElement manifestElement = androidManifestBlock.getManifestElement();
if(manifestElement == null){
if(logger != null){
logger.logMessage("WARN: AndroidManifest don't have <manifest>");
}
return;
}
int removed = manifestElement.removeAttributesWithId(resourceId);
if (removed > 0 && logger != null) {
logger.logMessage("Removed-attribute : " + HexUtil.toHex8("@0x", resourceId));
}
}


public static void removeAttributeFromManifestAndApplication(AndroidManifestBlock androidManifestBlock,
int resourceId, APKLogger logger, String nameForLogging){
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/reandroid/apkeditor/merge/Merger.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ private void sanitizeManifest(ApkModule apkModule) {
}
AndroidManifestBlock manifest = apkModule.getAndroidManifest();
logMessage("Sanitizing manifest ...");

// FIXME: declare ID_requiredSplitTypes & ID_splitTypes at AndroidManifest
int ID_requiredSplitTypes = 0x0101064e;
int ID_splitTypes = 0x0101064f;

AndroidManifestHelper.removeAttributeFromManifestById(manifest,
ID_requiredSplitTypes, this);
AndroidManifestHelper.removeAttributeFromManifestById(manifest,
ID_splitTypes, this);
AndroidManifestHelper.removeAttributeFromManifestByName(manifest,
AndroidManifest.NAME_splitTypes, this);

AndroidManifestHelper.removeAttributeFromManifestByName(manifest,
AndroidManifest.NAME_requiredSplitTypes, this);
AndroidManifestHelper.removeAttributeFromManifestByName(manifest,
Expand Down

0 comments on commit 507413d

Please sign in to comment.