From 507413dba5d5047085f1f73ad3a0dd227aa7cfd0 Mon Sep 17 00:00:00 2001 From: REAndroid Date: Fri, 2 Aug 2024 00:02:19 +0200 Subject: [PATCH] Fix: Clean requiredSplitTypes & splitTypes from manifest with id #114 --- .../apkeditor/common/AndroidManifestHelper.java | 15 +++++++++++++++ .../com/reandroid/apkeditor/merge/Merger.java | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/main/java/com/reandroid/apkeditor/common/AndroidManifestHelper.java b/src/main/java/com/reandroid/apkeditor/common/AndroidManifestHelper.java index 833ae522..919917e1 100644 --- a/src/main/java/com/reandroid/apkeditor/common/AndroidManifestHelper.java +++ b/src/main/java/com/reandroid/apkeditor/common/AndroidManifestHelper.java @@ -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 "); + } + 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){ diff --git a/src/main/java/com/reandroid/apkeditor/merge/Merger.java b/src/main/java/com/reandroid/apkeditor/merge/Merger.java index 2a78b0ab..a7aa9d27 100644 --- a/src/main/java/com/reandroid/apkeditor/merge/Merger.java +++ b/src/main/java/com/reandroid/apkeditor/merge/Merger.java @@ -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,