feat: Use an extension property to create new exception when failing to resolve a fingerprint
This commit adds the extension property to the public API
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
||||
package app.revanced.patches.reddit.customclients
|
||||
|
||||
import android.os.Environment
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
||||
@@ -47,7 +47,7 @@ abstract class AbstractSpoofClientPatch(
|
||||
|
||||
fun List<MethodFingerprint>?.executePatch(
|
||||
patch: List<MethodFingerprintResult>.(BytecodeContext) -> Unit
|
||||
) = this?.map { it.result ?: throw it.toErrorResult() }?.patch(context)
|
||||
) = this?.map { it.result ?: throw it.exception }?.patch(context)
|
||||
|
||||
clientIdFingerprints.executePatch { patchClientId(context) }
|
||||
userAgentFingerprints.executePatch { patchUserAgent(context) }
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.reddit.customclients.joeyforreddit.ads.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Package
|
||||
@@ -24,6 +24,6 @@ class DisableAdsPatch : BytecodePatch(listOf(IsAdFreeUserFingerprint)) {
|
||||
const/4 v0, 0x1
|
||||
return v0
|
||||
"""
|
||||
) ?: throw IsAdFreeUserFingerprint.toErrorResult()
|
||||
) ?: throw IsAdFreeUserFingerprint.exception
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
@@ -13,6 +13,6 @@ class DisablePiracyDetectionPatch : BytecodePatch(listOf(PiracyDetectionFingerpr
|
||||
"""
|
||||
return-void
|
||||
"""
|
||||
) ?: throw PiracyDetectionFingerprint.toErrorResult()
|
||||
) ?: throw PiracyDetectionFingerprint.exception
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.reddit.customclients.syncforreddit.ads.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.annotation.*
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
@@ -24,7 +24,7 @@ class DisableAdsPatch : BytecodePatch(listOf(IsAdsEnabledFingerprint)) {
|
||||
return v0
|
||||
"""
|
||||
)
|
||||
} ?: throw IsAdsEnabledFingerprint.toErrorResult()
|
||||
} ?: throw IsAdsEnabledFingerprint.exception
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.reddit.customclients.syncforreddit.api.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Package
|
||||
@@ -48,7 +48,7 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
return-object v0
|
||||
"""
|
||||
)
|
||||
} ?: throw GetBearerTokenFingerprint.toErrorResult()
|
||||
} ?: throw GetBearerTokenFingerprint.exception
|
||||
}.let {
|
||||
val occurrenceIndex = it.scanResult.stringsScanResult!!.matches.first().index
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.reddit.layout.disablescreenshotpopup.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
@@ -19,6 +19,6 @@ class DisableScreenshotPopupPatch : BytecodePatch(
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
DisableScreenshotPopupFingerprint.result?.mutableMethod?.addInstruction(0, "return-void")
|
||||
?: throw DisableScreenshotPopupFingerprint.toErrorResult()
|
||||
?: throw DisableScreenshotPopupFingerprint.exception
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.reddit.misc.tracking.url.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
@@ -22,7 +22,7 @@ class SanitizeUrlQueryPatch : BytecodePatch(
|
||||
ShareLinkFormatterFingerprint.result?.mutableMethod?.addInstructions(
|
||||
0,
|
||||
"return-object p0"
|
||||
) ?: throw ShareLinkFormatterFingerprint.toErrorResult()
|
||||
) ?: throw ShareLinkFormatterFingerprint.exception
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user