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,6 +1,6 @@
|
||||
package app.revanced.patches.youtube.misc.bottomsheet.hook.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.extensions.InstructionExtensions.getInstruction
|
||||
@@ -29,7 +29,7 @@ class BottomSheetHookPatch : BytecodePatch(
|
||||
)
|
||||
}
|
||||
}
|
||||
} ?: throw CreateBottomSheetFingerprint.toErrorResult()
|
||||
} ?: throw CreateBottomSheetFingerprint.exception
|
||||
}
|
||||
|
||||
internal companion object {
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.youtube.misc.fix.backtoexitgesture.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
@@ -27,7 +27,7 @@ class FixBackToExitGesturePatch : BytecodePatch(
|
||||
resolve(
|
||||
context,
|
||||
RecyclerViewTopScrollingParentFingerprint.result?.classDef
|
||||
?: throw RecyclerViewTopScrollingParentFingerprint.toErrorResult()
|
||||
?: throw RecyclerViewTopScrollingParentFingerprint.exception
|
||||
)
|
||||
}
|
||||
|
||||
@@ -68,6 +68,6 @@ class FixBackToExitGesturePatch : BytecodePatch(
|
||||
mutableMethod.addInstruction(
|
||||
scanResult.patternScanResult!!.endIndex, targetMethod.toString()
|
||||
)
|
||||
} ?: throw this.toErrorResult()
|
||||
} ?: throw this.exception
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.youtube.misc.fix.playback.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
|
||||
@@ -30,7 +30,7 @@ class ClientSpoofPatch : BytecodePatch(
|
||||
addInstruction(insertIndex, "const-string v$packageNameRegister, \"$ORIGINAL_PACKAGE_NAME\"")
|
||||
}
|
||||
|
||||
} ?: throw UserAgentHeaderBuilderFingerprint.toErrorResult()
|
||||
} ?: throw UserAgentHeaderBuilderFingerprint.exception
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.youtube.misc.fix.playback.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
|
||||
@@ -52,14 +52,14 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw ProtobufParameterBuilderFingerprint.toErrorResult()
|
||||
} ?: throw ProtobufParameterBuilderFingerprint.exception
|
||||
|
||||
|
||||
// When signature spoofing is enabled, the seekbar when tapped does not show
|
||||
// the video time, chapter names, or the video thumbnail.
|
||||
// Changing the value returned of this method forces all of these to show up,
|
||||
// except the thumbnails are blank, which is handled with the patch below.
|
||||
StoryboardThumbnailParentFingerprint.result ?: throw StoryboardThumbnailParentFingerprint.toErrorResult()
|
||||
StoryboardThumbnailParentFingerprint.result ?: throw StoryboardThumbnailParentFingerprint.exception
|
||||
StoryboardThumbnailFingerprint.resolve(context, StoryboardThumbnailParentFingerprint.result!!.classDef)
|
||||
StoryboardThumbnailFingerprint.result?.apply {
|
||||
val endIndex = scanResult.patternScanResult!!.endIndex
|
||||
@@ -81,7 +81,7 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
|
||||
return v0
|
||||
"""
|
||||
)
|
||||
} ?: throw StoryboardThumbnailFingerprint.toErrorResult()
|
||||
} ?: throw StoryboardThumbnailFingerprint.exception
|
||||
|
||||
|
||||
// Seekbar thumbnail now show up but are always a blank image.
|
||||
@@ -99,7 +99,7 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw ScrubbedPreviewLayoutFingerprint.toErrorResult()
|
||||
} ?: throw ScrubbedPreviewLayoutFingerprint.exception
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.youtube.misc.links.open.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
|
||||
@@ -42,7 +42,7 @@ class OpenLinksExternallyPatch : BytecodePatch(
|
||||
BindSessionServiceFingerprint,
|
||||
InitializeCustomTabSupportFingerprint
|
||||
).forEach {
|
||||
val result = it.result ?: throw it.toErrorResult()
|
||||
val result = it.result ?: throw it.exception
|
||||
val insertIndex = result.scanResult.patternScanResult!!.endIndex + 1
|
||||
with(result.mutableMethod) {
|
||||
val register = (implementation!!.instructions[insertIndex - 1] as Instruction21c).registerA
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.youtube.misc.litho.filter.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
@@ -66,7 +66,7 @@ class LithoFilterPatch : BytecodePatch(
|
||||
ReadComponentIdentifierFingerprint
|
||||
).forEach { fingerprint ->
|
||||
if (fingerprint.resolve(context, it.mutableMethod, it.mutableClass)) return@forEach
|
||||
throw fingerprint.toErrorResult()
|
||||
throw fingerprint.exception
|
||||
}
|
||||
}?.let { bytesToComponentContextMethod ->
|
||||
|
||||
@@ -75,7 +75,7 @@ class LithoFilterPatch : BytecodePatch(
|
||||
ProtobufBufferReferenceFingerprint.result
|
||||
?.mutableMethod?.addInstruction(0,
|
||||
" invoke-static { p2 }, $INTEGRATIONS_CLASS_DESCRIPTOR->setProtoBuffer(Ljava/nio/ByteBuffer;)V")
|
||||
?: throw ProtobufBufferReferenceFingerprint.toErrorResult()
|
||||
?: throw ProtobufBufferReferenceFingerprint.exception
|
||||
|
||||
// endregion
|
||||
|
||||
@@ -141,7 +141,7 @@ class LithoFilterPatch : BytecodePatch(
|
||||
}
|
||||
|
||||
// endregion
|
||||
} ?: throw ComponentContextParserFingerprint.toErrorResult()
|
||||
} ?: throw ComponentContextParserFingerprint.exception
|
||||
|
||||
LithoFilterFingerprint.result?.mutableMethod?.apply {
|
||||
removeInstructions(2, 4) // Remove dummy filter.
|
||||
@@ -157,7 +157,7 @@ class LithoFilterPatch : BytecodePatch(
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw LithoFilterFingerprint.toErrorResult()
|
||||
} ?: throw LithoFilterFingerprint.exception
|
||||
}
|
||||
|
||||
override fun close() = LithoFilterFingerprint.result!!
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.youtube.misc.minimizedplayback.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
|
||||
@@ -54,10 +54,10 @@ class MinimizedPlaybackPatch : BytecodePatch(
|
||||
return v0
|
||||
"""
|
||||
)
|
||||
} ?: throw MinimizedPlaybackManagerFingerprint.toErrorResult()
|
||||
} ?: throw MinimizedPlaybackManagerFingerprint.exception
|
||||
|
||||
// Enable minimized playback option in YouTube settings
|
||||
MinimizedPlaybackSettingsParentFingerprint.result ?: throw MinimizedPlaybackSettingsParentFingerprint.toErrorResult()
|
||||
MinimizedPlaybackSettingsParentFingerprint.result ?: throw MinimizedPlaybackSettingsParentFingerprint.exception
|
||||
MinimizedPlaybackSettingsFingerprint.resolve(context, MinimizedPlaybackSettingsParentFingerprint.result!!.classDef)
|
||||
MinimizedPlaybackSettingsFingerprint.result?.apply {
|
||||
val booleanCalls = method.implementation!!.instructions.withIndex()
|
||||
@@ -75,7 +75,7 @@ class MinimizedPlaybackPatch : BytecodePatch(
|
||||
return v0
|
||||
"""
|
||||
)
|
||||
} ?: throw MinimizedPlaybackSettingsFingerprint.toErrorResult()
|
||||
} ?: throw MinimizedPlaybackSettingsFingerprint.exception
|
||||
|
||||
// Force allowing background play for videos labeled for kids.
|
||||
// Some regions and YouTube accounts do not require this patch.
|
||||
@@ -84,7 +84,7 @@ class MinimizedPlaybackPatch : BytecodePatch(
|
||||
0,
|
||||
"return-void"
|
||||
)
|
||||
} ?: throw KidsMinimizedPlaybackPolicyControllerFingerprint.toErrorResult()
|
||||
} ?: throw KidsMinimizedPlaybackPolicyControllerFingerprint.exception
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.youtube.misc.playercontrols.bytecode.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
|
||||
@@ -29,8 +29,8 @@ class PlayerControlsBytecodePatch : BytecodePatch(
|
||||
override fun execute(context: BytecodeContext) {
|
||||
LayoutConstructorFingerprint.result?.let {
|
||||
if (!PlayerControlsVisibilityFingerprint.resolve(context, it.classDef))
|
||||
throw LayoutConstructorFingerprint.toErrorResult()
|
||||
} ?: throw LayoutConstructorFingerprint.toErrorResult()
|
||||
throw LayoutConstructorFingerprint.exception
|
||||
} ?: throw LayoutConstructorFingerprint.exception
|
||||
|
||||
showPlayerControlsFingerprintResult = PlayerControlsVisibilityFingerprint.result!!
|
||||
inflateFingerprintResult = BottomControlsInflateFingerprint.result!!
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.youtube.misc.playertype.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
|
||||
@@ -24,7 +24,7 @@ class PlayerTypeHookPatch : BytecodePatch(
|
||||
PlayerTypeFingerprint.result?.mutableMethod?.addInstruction(
|
||||
0,
|
||||
"invoke-static {p1}, $INTEGRATIONS_CLASS_DESCRIPTOR->setPlayerType(Ljava/lang/Enum;)V"
|
||||
) ?: throw PlayerTypeFingerprint.toErrorResult()
|
||||
) ?: throw PlayerTypeFingerprint.exception
|
||||
|
||||
VideoStateFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
@@ -39,7 +39,7 @@ class PlayerTypeHookPatch : BytecodePatch(
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw VideoStateFingerprint.toErrorResult()
|
||||
} ?: throw VideoStateFingerprint.exception
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.youtube.misc.settings.bytecode.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
|
||||
@@ -55,7 +55,7 @@ class SettingsPatch : BytecodePatch(
|
||||
addInstruction(returnIndex + 1, "return-object v0")
|
||||
}
|
||||
}
|
||||
} ?: throw SetThemeFingerprint.toErrorResult()
|
||||
} ?: throw SetThemeFingerprint.exception
|
||||
|
||||
|
||||
// Modify the license activity and remove all existing layout code.
|
||||
|
||||
Reference in New Issue
Block a user