diff --git a/patches/src/main/kotlin/app/revanced/patches/pandora/ads/DisableAudioAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/pandora/ads/DisableAudioAdsPatch.kt index 8c92c7421..cb038a579 100644 --- a/patches/src/main/kotlin/app/revanced/patches/pandora/ads/DisableAudioAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/pandora/ads/DisableAudioAdsPatch.kt @@ -4,9 +4,7 @@ import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.util.returnEarly @Suppress("unused", "ObjectPropertyName") -val `Disable Audio Ads` by creatingBytecodePatch( - description = "Disable audio ads" -) { +val `Disable Audio Ads` by creatingBytecodePatch { compatibleWith("com.pandora.android") apply { diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt index 8bfa18fec..49e7e6c70 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt @@ -2,8 +2,8 @@ package app.revanced.patches.reddit.customclients.infinityforreddit.subscription import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethod import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.InstructionMatchingFunctions.invoke import app.revanced.patcher.instructions -import app.revanced.patcher.invoke import app.revanced.patcher.patch.BytecodePatchContext internal val BytecodePatchContext.billingClientOnServiceConnectedMethod by gettingFirstMutableMethod("Billing service connected") diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt index 85a9ed8d1..d037f1895 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt @@ -1,11 +1,11 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy -import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.patch.bytecodePatch +import app.revanced.util.returnEarly @Suppress("unused") val disablePiracyDetectionPatch = bytecodePatch { apply { - piracyDetectionMethod.addInstruction(0, "return-void") + detectPiracyMethod.returnEarly() } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt index d64d1e195..b2688168e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt @@ -1,12 +1,16 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy -import app.revanced.patcher.* import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.InstructionMatchingFunctions.invoke +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass +import app.revanced.patcher.instructions import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -internal val BytecodePatchContext.piracyDetectionMethod by gettingFirstMutableMethodDeclaratively { +internal val BytecodePatchContext.detectPiracyMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PRIVATE, AccessFlags.STATIC) returnType("V") instructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt index 17c7cb492..bd90bd127 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt @@ -1,7 +1,7 @@ package app.revanced.patches.reddit.customclients.sync.detection.piracy -import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.patch.bytecodePatch +import app.revanced.util.returnEarly val disablePiracyDetectionPatch = bytecodePatch( description = "Disables detection of modified versions.", @@ -10,6 +10,6 @@ val disablePiracyDetectionPatch = bytecodePatch( apply { // Do not throw an error if the fingerprint is not resolved. // This is fine because new versions of the target app do not need this patch. - piracyDetectionMethod.addInstruction(0, "return-void") + detectPiracyMethodOrNull?.returnEarly() } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt index b3cf7e98d..34a2aba72 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt @@ -1,14 +1,18 @@ package app.revanced.patches.reddit.customclients.sync.detection.piracy -import app.revanced.patcher.* -import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclarativelyOrNull +import app.revanced.patcher.InstructionMatchingFunctions.invoke +import app.revanced.patcher.accessFlags +import app.revanced.patcher.custom import app.revanced.patcher.extensions.instructions import app.revanced.patcher.extensions.reference +import app.revanced.patcher.instructions import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -internal val BytecodePatchContext.piracyDetectionMethod by gettingFirstMutableMethodDeclaratively( +internal val BytecodePatchContext.detectPiracyMethodOrNull by gettingFirstMutableMethodDeclarativelyOrNull( "Lcom/github/javiersantos/piracychecker/PiracyChecker;" ) { accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt index a3ebe101a..cd43c2374 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt @@ -1,5 +1,6 @@ package app.revanced.patches.reddit.customclients.sync.syncforreddit.annoyances.startup +import app.revanced.patcher.extensions.instructions import app.revanced.patcher.extensions.removeInstruction import app.revanced.patcher.patch.creatingBytecodePatch @@ -14,10 +15,8 @@ val `Disable Sync for Lemmy bottom sheet` = creatingBytecodePatch( ) apply { - mainActivityOnCreateMethod.apply { - val showBottomSheetIndex = implementation!!.instructions.lastIndex - 1 + val showBottomSheetIndex = mainActivityOnCreateMethod.instructions.lastIndex - 1 - removeInstruction(showBottomSheetIndex) - } + mainActivityOnCreateMethod.removeInstruction(showBottomSheetIndex) } }