From fbbecd33bbc92999d79d74f0abf54d129e3ee407 Mon Sep 17 00:00:00 2001 From: Marko <34315725+rospino74@users.noreply.github.com> Date: Sat, 27 Jan 2024 02:57:22 +0100 Subject: [PATCH] feat(Photomath): Add `Hide update popup` patch (#2637) Co-authored-by: oSumAtrIX BREAKING CHANGE: Some packages have changed locations. --- api/revanced-patches.api | 10 +++++-- .../misc/annoyances/HideUpdatePopupPatch.kt | 26 +++++++++++++++++++ .../HideUpdatePopupFingerprint.kt | 22 ++++++++++++++++ .../bookpoint/EnableBookpointPatch.kt | 4 +-- .../IsBookpointEnabledFingerprint.kt | 2 +- .../plus}/UnlockPlusPatch.kt | 6 ++--- .../fingerprints/IsPlusUnlockedFingerprint.kt | 2 +- 7 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/fingerprints/HideUpdatePopupFingerprint.kt rename src/main/kotlin/app/revanced/patches/photomath/misc/{ => unlock}/bookpoint/EnableBookpointPatch.kt (81%) rename src/main/kotlin/app/revanced/patches/photomath/misc/{ => unlock}/bookpoint/fingerprints/IsBookpointEnabledFingerprint.kt (85%) rename src/main/kotlin/app/revanced/patches/photomath/misc/{unlockplus => unlock/plus}/UnlockPlusPatch.kt (80%) rename src/main/kotlin/app/revanced/patches/photomath/misc/{unlockplus => unlock/plus}/fingerprints/IsPlusUnlockedFingerprint.kt (86%) diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 1555a1497..8df98dba0 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -418,8 +418,14 @@ public final class app/revanced/patches/photomath/detection/signature/SignatureD public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public final class app/revanced/patches/photomath/misc/unlockplus/UnlockPlusPatch : app/revanced/patcher/patch/BytecodePatch { - public static final field INSTANCE Lapp/revanced/patches/photomath/misc/unlockplus/UnlockPlusPatch; +public final class app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch; + public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V +} + +public final class app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } diff --git a/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt b/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt new file mode 100644 index 000000000..147555907 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt @@ -0,0 +1,26 @@ +package app.revanced.patches.photomath.misc.annoyances + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.photomath.detection.signature.SignatureDetectionPatch +import app.revanced.patches.photomath.misc.annoyances.fingerprints.HideUpdatePopupFingerprint +import app.revanced.util.exception + +@Patch( + name = "Hide update popup", + description = "Prevents the update popup from showing up.", + dependencies = [SignatureDetectionPatch::class], + compatiblePackages = [CompatiblePackage("com.microblink.photomath", ["8.32.0"])] +) +@Suppress("unused") +object HideUpdatePopupPatch : BytecodePatch( + setOf(HideUpdatePopupFingerprint) +) { + override fun execute(context: BytecodeContext) = HideUpdatePopupFingerprint.result?.mutableMethod?.addInstructions( + 2, // Insert after the null check. + "return-void" + ) ?: throw HideUpdatePopupFingerprint.exception +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/fingerprints/HideUpdatePopupFingerprint.kt b/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/fingerprints/HideUpdatePopupFingerprint.kt new file mode 100644 index 000000000..f57666b63 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/fingerprints/HideUpdatePopupFingerprint.kt @@ -0,0 +1,22 @@ +package app.revanced.patches.photomath.misc.annoyances.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +internal object HideUpdatePopupFingerprint : MethodFingerprint( + customFingerprint = { _, classDef -> + // The popup is shown only in the main activity + classDef.type == "Lcom/microblink/photomath/main/activity/MainActivity;" + }, + opcodes = listOf( + Opcode.CONST_HIGH16, + Opcode.INVOKE_VIRTUAL, // ViewPropertyAnimator.alpha(1.0f) + Opcode.MOVE_RESULT_OBJECT, + Opcode.CONST_WIDE_16, + Opcode.INVOKE_VIRTUAL, // ViewPropertyAnimator.setDuration(1000L) + ), + accessFlags = AccessFlags.FINAL or AccessFlags.PUBLIC, + returnType = "V", +) diff --git a/src/main/kotlin/app/revanced/patches/photomath/misc/bookpoint/EnableBookpointPatch.kt b/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt similarity index 81% rename from src/main/kotlin/app/revanced/patches/photomath/misc/bookpoint/EnableBookpointPatch.kt rename to src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt index f3dc575e0..6d12d0e29 100644 --- a/src/main/kotlin/app/revanced/patches/photomath/misc/bookpoint/EnableBookpointPatch.kt +++ b/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt @@ -1,11 +1,11 @@ -package app.revanced.patches.photomath.misc.bookpoint +package app.revanced.patches.photomath.misc.unlock.bookpoint import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.photomath.misc.bookpoint.fingerprints.IsBookpointEnabledFingerprint +import app.revanced.patches.photomath.misc.unlock.bookpoint.fingerprints.IsBookpointEnabledFingerprint @Patch(description = "Enables textbook access") internal object EnableBookpointPatch : BytecodePatch( diff --git a/src/main/kotlin/app/revanced/patches/photomath/misc/bookpoint/fingerprints/IsBookpointEnabledFingerprint.kt b/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/fingerprints/IsBookpointEnabledFingerprint.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/photomath/misc/bookpoint/fingerprints/IsBookpointEnabledFingerprint.kt rename to src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/fingerprints/IsBookpointEnabledFingerprint.kt index 0a60647a4..e5ae3c2da 100644 --- a/src/main/kotlin/app/revanced/patches/photomath/misc/bookpoint/fingerprints/IsBookpointEnabledFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/fingerprints/IsBookpointEnabledFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.photomath.misc.bookpoint.fingerprints +package app.revanced.patches.photomath.misc.unlock.bookpoint.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/UnlockPlusPatch.kt b/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/UnlockPlusPatch.kt rename to src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt index 15ec53aba..8895696cd 100644 --- a/src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/UnlockPlusPatch.kt +++ b/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.photomath.misc.unlockplus +package app.revanced.patches.photomath.misc.unlock.plus import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext @@ -7,8 +7,8 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.photomath.detection.signature.SignatureDetectionPatch -import app.revanced.patches.photomath.misc.bookpoint.EnableBookpointPatch -import app.revanced.patches.photomath.misc.unlockplus.fingerprints.IsPlusUnlockedFingerprint +import app.revanced.patches.photomath.misc.unlock.bookpoint.EnableBookpointPatch +import app.revanced.patches.photomath.misc.unlock.plus.fingerprints.IsPlusUnlockedFingerprint @Patch( name = "Unlock plus", diff --git a/src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/fingerprints/IsPlusUnlockedFingerprint.kt b/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/fingerprints/IsPlusUnlockedFingerprint.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/fingerprints/IsPlusUnlockedFingerprint.kt rename to src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/fingerprints/IsPlusUnlockedFingerprint.kt index 72db0e6bf..2ab140b1d 100644 --- a/src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/fingerprints/IsPlusUnlockedFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/fingerprints/IsPlusUnlockedFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.photomath.misc.unlockplus.fingerprints +package app.revanced.patches.photomath.misc.unlock.plus.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint