Skip to content

Commit 3182471

Browse files
authored
feat(Photomath): Add Hide update popup patch (#2637)
Co-authored-by: oSumAtrIX <[email protected]> BREAKING CHANGE: Some packages have changed locations.
1 parent be6a35f commit 3182471

File tree

7 files changed

+63
-9
lines changed

7 files changed

+63
-9
lines changed

api/revanced-patches.api

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,14 @@ public final class app/revanced/patches/photomath/detection/signature/SignatureD
418418
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
419419
}
420420

421-
public final class app/revanced/patches/photomath/misc/unlockplus/UnlockPlusPatch : app/revanced/patcher/patch/BytecodePatch {
422-
public static final field INSTANCE Lapp/revanced/patches/photomath/misc/unlockplus/UnlockPlusPatch;
421+
public final class app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch : app/revanced/patcher/patch/BytecodePatch {
422+
public static final field INSTANCE Lapp/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch;
423+
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
424+
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
425+
}
426+
427+
public final class app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch : app/revanced/patcher/patch/BytecodePatch {
428+
public static final field INSTANCE Lapp/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch;
423429
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
424430
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
425431
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package app.revanced.patches.photomath.misc.annoyances
2+
3+
import app.revanced.patcher.data.BytecodeContext
4+
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
5+
import app.revanced.patcher.patch.BytecodePatch
6+
import app.revanced.patcher.patch.annotation.CompatiblePackage
7+
import app.revanced.patcher.patch.annotation.Patch
8+
import app.revanced.patches.photomath.detection.signature.SignatureDetectionPatch
9+
import app.revanced.patches.photomath.misc.annoyances.fingerprints.HideUpdatePopupFingerprint
10+
import app.revanced.util.exception
11+
12+
@Patch(
13+
name = "Hide update popup",
14+
description = "Prevents the update popup from showing up.",
15+
dependencies = [SignatureDetectionPatch::class],
16+
compatiblePackages = [CompatiblePackage("com.microblink.photomath", ["8.32.0"])]
17+
)
18+
@Suppress("unused")
19+
object HideUpdatePopupPatch : BytecodePatch(
20+
setOf(HideUpdatePopupFingerprint)
21+
) {
22+
override fun execute(context: BytecodeContext) = HideUpdatePopupFingerprint.result?.mutableMethod?.addInstructions(
23+
2, // Insert after the null check.
24+
"return-void"
25+
) ?: throw HideUpdatePopupFingerprint.exception
26+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package app.revanced.patches.photomath.misc.annoyances.fingerprints
2+
3+
import app.revanced.patcher.extensions.or
4+
import app.revanced.patcher.fingerprint.MethodFingerprint
5+
import com.android.tools.smali.dexlib2.AccessFlags
6+
import com.android.tools.smali.dexlib2.Opcode
7+
8+
internal object HideUpdatePopupFingerprint : MethodFingerprint(
9+
customFingerprint = { _, classDef ->
10+
// The popup is shown only in the main activity
11+
classDef.type == "Lcom/microblink/photomath/main/activity/MainActivity;"
12+
},
13+
opcodes = listOf(
14+
Opcode.CONST_HIGH16,
15+
Opcode.INVOKE_VIRTUAL, // ViewPropertyAnimator.alpha(1.0f)
16+
Opcode.MOVE_RESULT_OBJECT,
17+
Opcode.CONST_WIDE_16,
18+
Opcode.INVOKE_VIRTUAL, // ViewPropertyAnimator.setDuration(1000L)
19+
),
20+
accessFlags = AccessFlags.FINAL or AccessFlags.PUBLIC,
21+
returnType = "V",
22+
)

src/main/kotlin/app/revanced/patches/photomath/misc/bookpoint/EnableBookpointPatch.kt renamed to src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package app.revanced.patches.photomath.misc.bookpoint
1+
package app.revanced.patches.photomath.misc.unlock.bookpoint
22

33
import app.revanced.util.exception
44
import app.revanced.patcher.data.BytecodeContext
55
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions
66
import app.revanced.patcher.patch.BytecodePatch
77
import app.revanced.patcher.patch.annotation.Patch
8-
import app.revanced.patches.photomath.misc.bookpoint.fingerprints.IsBookpointEnabledFingerprint
8+
import app.revanced.patches.photomath.misc.unlock.bookpoint.fingerprints.IsBookpointEnabledFingerprint
99

1010
@Patch(description = "Enables textbook access")
1111
internal object EnableBookpointPatch : BytecodePatch(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app.revanced.patches.photomath.misc.bookpoint.fingerprints
1+
package app.revanced.patches.photomath.misc.unlock.bookpoint.fingerprints
22

33
import app.revanced.patcher.extensions.or
44
import app.revanced.patcher.fingerprint.MethodFingerprint

src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/UnlockPlusPatch.kt renamed to src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app.revanced.patches.photomath.misc.unlockplus
1+
package app.revanced.patches.photomath.misc.unlock.plus
22

33
import app.revanced.util.exception
44
import app.revanced.patcher.data.BytecodeContext
@@ -7,8 +7,8 @@ import app.revanced.patcher.patch.BytecodePatch
77
import app.revanced.patcher.patch.annotation.CompatiblePackage
88
import app.revanced.patcher.patch.annotation.Patch
99
import app.revanced.patches.photomath.detection.signature.SignatureDetectionPatch
10-
import app.revanced.patches.photomath.misc.bookpoint.EnableBookpointPatch
11-
import app.revanced.patches.photomath.misc.unlockplus.fingerprints.IsPlusUnlockedFingerprint
10+
import app.revanced.patches.photomath.misc.unlock.bookpoint.EnableBookpointPatch
11+
import app.revanced.patches.photomath.misc.unlock.plus.fingerprints.IsPlusUnlockedFingerprint
1212

1313
@Patch(
1414
name = "Unlock plus",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app.revanced.patches.photomath.misc.unlockplus.fingerprints
1+
package app.revanced.patches.photomath.misc.unlock.plus.fingerprints
22

33
import app.revanced.patcher.extensions.or
44
import app.revanced.patcher.fingerprint.MethodFingerprint

0 commit comments

Comments
 (0)