From 8c4fa72ae6fd1e47ab5261355cce9cbcd8f3312f Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 22 Mar 2026 17:52:11 +0100 Subject: [PATCH] chore: Update example patch --- .../template/patches/example/ExamplePatch.kt | 6 +++-- .../template/patches/example/Fingerprints.kt | 10 ++++---- .../app/template/patches/shared/Constants.kt | 24 +++++++++++++++++++ 3 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 patches/src/main/kotlin/app/template/patches/shared/Constants.kt diff --git a/patches/src/main/kotlin/app/template/patches/example/ExamplePatch.kt b/patches/src/main/kotlin/app/template/patches/example/ExamplePatch.kt index db22206a2..cdb551bcc 100644 --- a/patches/src/main/kotlin/app/template/patches/example/ExamplePatch.kt +++ b/patches/src/main/kotlin/app/template/patches/example/ExamplePatch.kt @@ -2,15 +2,17 @@ package app.template.patches.example import app.morphe.patcher.extensions.InstructionExtensions.addInstructions import app.morphe.patcher.patch.bytecodePatch +import app.template.patches.shared.Constants.COMPATIBILITY_EXAMPLE private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/template/extension/ExamplePatch;" @Suppress("unused") val examplePatch = bytecodePatch( name = "Example Patch", - description = "Example patch to start with." + description = "Example patch to start with.", + default = true ) { - compatibleWith("com.example.app"("1.0.0")) + compatibleWith(COMPATIBILITY_EXAMPLE) extendWith("extensions/extension.mpp") diff --git a/patches/src/main/kotlin/app/template/patches/example/Fingerprints.kt b/patches/src/main/kotlin/app/template/patches/example/Fingerprints.kt index e3a919f4f..fd4285b8a 100644 --- a/patches/src/main/kotlin/app/template/patches/example/Fingerprints.kt +++ b/patches/src/main/kotlin/app/template/patches/example/Fingerprints.kt @@ -2,11 +2,13 @@ package app.template.patches.example import app.morphe.patcher.Fingerprint import app.morphe.patcher.InstructionLocation.* +import app.morphe.patcher.StringComparisonType import app.morphe.patcher.fieldAccess import app.morphe.patcher.literal import app.morphe.patcher.methodCall import app.morphe.patcher.opcode import app.morphe.patcher.string +import app.template.patches.example.AdLoaderFingerprint.classDef import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode @@ -15,11 +17,11 @@ import com.android.tools.smali.dexlib2.Opcode object AdLoaderFingerprint : Fingerprint( // Exact access flags accessFlags = listOf(AccessFlags.PUBLIC, AccessFlags.FINAL), - // Return type is matched using String.startsWith() + // Return type is matched using implicit coparison depending on how the type is declared. + // See StringComparisonType for more. returnType = "Z", - // Declared parameters are matched using String.startsWith() - // Non obfuscated classes should be declared using the full class name. - // While obfuscated class names must be declared only using the object type + // Declared parameters are matched using StringComparisonType implicit comparison. + // Obfuscated class names must be declared only using the object type // Since obfuscated names change between releases. // Last parameter is simply `L` since it's an obfuscated class object. parameters = listOf("Ljava/lang/String;", "I", "L"), diff --git a/patches/src/main/kotlin/app/template/patches/shared/Constants.kt b/patches/src/main/kotlin/app/template/patches/shared/Constants.kt new file mode 100644 index 000000000..5d3881563 --- /dev/null +++ b/patches/src/main/kotlin/app/template/patches/shared/Constants.kt @@ -0,0 +1,24 @@ +package app.template.patches.shared + +import app.morphe.patcher.patch.ApkFileType +import app.morphe.patcher.patch.AppTarget +import app.morphe.patcher.patch.Compatibility + +object Constants { + val COMPATIBILITY_EXAMPLE = Compatibility( + name = "XYZ app", + packageName = "com.example.app", + apkFileType = ApkFileType.APK, + appIconColor = 0xFF0045, // Icon color in Morphe Manager + targets = listOf( + // "version = null" means the patch works with the latest app target + // and is expected to work with all future app targets + AppTarget( + version = "2.0.0" + ), + AppTarget( + version = "1.0.2", + ) + ) + ) +}