build(Needs bump): Bump dependencies

This commit is contained in:
oSumAtrIX
2023-08-23 05:01:09 +02:00
parent 3072412c79
commit 1817dbd10c
214 changed files with 473 additions and 1271 deletions
@@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.misc.fix.verticalscroll.patch.VerticalScrollPatch
@@ -33,7 +31,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
@Description("Removes general ads.")
@HideAdsCompatibility
class HideAdsPatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
context.classes.forEach { classDef ->
classDef.methods.forEach { method ->
with(method.implementation) {
@@ -67,7 +65,5 @@ class HideAdsPatch : BytecodePatch() {
}
}
}
return PatchResultSuccess()
}
}
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.ad.general.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -22,7 +20,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch.P
)
@HideAdsCompatibility
class HideAdsResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
PreferenceScreen.ADS.addPreferences(
SwitchPreference(
"revanced_hide_general_ads",
@@ -71,8 +69,6 @@ class HideAdsResourcePatch : ResourcePatch {
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
adAttributionId = ResourceMappingPatch.resourceMappings.single { it.name == "ad_attribution" }.id
return PatchResultSuccess()
}
internal companion object {
@@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@@ -21,7 +19,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@Name("Hide get premium")
@HideGetPremiumCompatibility
class HideGetPremiumPatch : BytecodePatch(listOf(GetPremiumViewFingerprint)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.ADS.addPreferences(
SwitchPreference(
"revanced_hide_get_premium",
@@ -64,9 +62,7 @@ class HideGetPremiumPatch : BytecodePatch(listOf(GetPremiumViewFingerprint)) {
"""
)
}
} ?: return GetPremiumViewFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw GetPremiumViewFingerprint.toErrorResult()
}
private companion object {
@@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
@@ -28,7 +26,7 @@ class VideoAdsPatch : BytecodePatch(
LoadVideoAdsFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.ADS.addPreferences(
SwitchPreference(
"revanced_hide_video_ads",
@@ -49,7 +47,5 @@ class VideoAdsPatch : BytecodePatch(
""",
ExternalLabel("show_video_ads", loadVideoAdsFingerprintMethod.getInstruction(0))
)
return PatchResultSuccess()
}
}
@@ -4,8 +4,6 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.interaction.copyvideourl.annotation.CopyVideoUrlCompatibility
@@ -31,14 +29,12 @@ class CopyVideoUrlBytecodePatch : BytecodePatch() {
)
}
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// Initialize buttons and inject visibility control
BUTTONS_DESCRIPTORS.forEach { descriptor ->
PlayerControlsBytecodePatch.initializeControl("$descriptor->initializeButton(Landroid/view/View;)V")
PlayerControlsBytecodePatch.injectVisibilityCheckCall("$descriptor->changeVisibility(Z)V")
}
return PatchResultSuccess()
}
}
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.interaction.copyvideourl.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
@@ -16,7 +14,7 @@ import app.revanced.util.resources.ResourceUtils.mergeStrings
@DependsOn([BottomControlsResourcePatch::class, SettingsPatch::class])
class CopyVideoUrlResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
PreferenceScreen(
"revanced_copy_video_url_preference_screen",
@@ -49,7 +47,5 @@ class CopyVideoUrlResourcePatch : ResourcePatch {
context.mergeStrings("copyvideourl/host/values/strings.xml")
BottomControlsResourcePatch.addControls("copyvideourl/host/layout/${BottomControlsResourcePatch.TARGET_RESOURCE_NAME}")
return PatchResultSuccess()
}
}
@@ -4,8 +4,6 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.interaction.downloads.annotation.ExternalDownloadsCompatibility
@@ -23,7 +21,7 @@ class ExternalDownloadsBytecodePatch : BytecodePatch() {
const val BUTTON_DESCRIPTOR = "Lapp/revanced/integrations/videoplayer/ExternalDownloadButton;"
}
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
/*
initialize the control
*/
@@ -37,7 +35,5 @@ class ExternalDownloadsBytecodePatch : BytecodePatch() {
PlayerControlsBytecodePatch.injectVisibilityCheckCall(
"$BUTTON_DESCRIPTOR->changeVisibility(Z)V")
return PatchResultSuccess()
}
}
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.interaction.downloads.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.settings.preference.impl.*
@@ -15,7 +13,7 @@ import app.revanced.util.resources.ResourceUtils.mergeStrings
@DependsOn([BottomControlsResourcePatch::class, SettingsPatch::class])
class ExternalDownloadsResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
PreferenceScreen(
"revanced_external_downloader_preference_screen",
@@ -47,7 +45,5 @@ class ExternalDownloadsResourcePatch : ResourcePatch {
// Add download button node
BottomControlsResourcePatch.addControls("downloads/host/layout/${BottomControlsResourcePatch.TARGET_RESOURCE_NAME}")
return PatchResultSuccess()
}
}
@@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
@@ -31,7 +29,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
class EnableSeekbarTappingPatch : BytecodePatch(
listOf(OnTouchEventHandlerFingerprint, SeekbarTappingFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// Find the required methods to tap the seekbar.
val seekbarTappingMethods = OnTouchEventHandlerFingerprint.result?.let {
val patternScanResult = it.scanResult.patternScanResult!!
@@ -45,7 +43,7 @@ class EnableSeekbarTappingPatch : BytecodePatch(
}
}
seekbarTappingMethods ?: return OnTouchEventHandlerFingerprint.toErrorResult()
seekbarTappingMethods ?: throw OnTouchEventHandlerFingerprint.toErrorResult()
SeekbarTappingFingerprint.result?.let {
val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1
@@ -74,8 +72,6 @@ class EnableSeekbarTappingPatch : BytecodePatch(
ExternalLabel("disabled", getInstruction(insertIndex))
)
}
} ?: return SeekbarTappingFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw SeekbarTappingFingerprint.toErrorResult()
}
}
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.interaction.seekbar.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.settings.preference.impl.StringResource
@@ -11,7 +9,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@DependsOn([SettingsPatch::class])
class EnableSeekbarTappingResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
SwitchPreference(
"revanced_seekbar_tapping",
@@ -20,6 +18,5 @@ class EnableSeekbarTappingResourcePatch : ResourcePatch {
StringResource("revanced_seekbar_tapping_summary_off", "Seekbar tapping is disabled")
)
)
return PatchResultSuccess()
}
}
@@ -1,15 +1,13 @@
package app.revanced.patches.youtube.interaction.swipecontrols.patch.bytecode
import app.revanced.extensions.transformMethods
import app.revanced.extensions.traverseClassHierarchy
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.TypeUtil.traverseClassHierarchy
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
import app.revanced.patches.shared.fingerprints.WatchWhileActivityFingerprint
import app.revanced.patches.youtube.interaction.swipecontrols.annotation.SwipeControlsCompatibility
@@ -37,7 +35,7 @@ class SwipeControlsBytecodePatch : BytecodePatch(
SwipeControlsHostActivityFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val wrapperClass = SwipeControlsHostActivityFingerprint.result!!.mutableClass
val targetClass = WatchWhileActivityFingerprint.result!!.mutableClass
@@ -61,6 +59,5 @@ class SwipeControlsBytecodePatch : BytecodePatch(
).toMutable()
}
}
return PatchResultSuccess()
}
}
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.interaction.swipecontrols.patch.resource
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.settings.preference.impl.*
@@ -12,7 +10,7 @@ import app.revanced.util.resources.ResourceUtils.copyResources
@DependsOn([SettingsPatch::class])
class SwipeControlsResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
PreferenceScreen(
"revanced_swipe_controls_preference_screen",
@@ -102,6 +100,5 @@ class SwipeControlsResourcePatch : ResourcePatch {
"ic_sc_volume_normal.xml"
)
)
return PatchResultSuccess()
}
}
@@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.StringResource
@@ -29,7 +27,7 @@ class AutoCaptionsPatch : BytecodePatch(
StartVideoInformerFingerprint, SubtitleButtonControllerFingerprint, SubtitleTrackFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_auto_captions",
@@ -72,7 +70,5 @@ class AutoCaptionsPatch : BytecodePatch(
nop
"""
)
return PatchResultSuccess()
}
}
@@ -3,9 +3,7 @@ package app.revanced.patches.youtube.layout.branding.header.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.layout.branding.header.annotations.PremiumHeadingCompatibility
@@ -18,9 +16,9 @@ import kotlin.io.path.exists
@Description("Shows premium branding on the home screen.")
@PremiumHeadingCompatibility
class PremiumHeadingPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
val resDirectory = context["res"]
if (!resDirectory.isDirectory) return PatchResultError("The res folder can not be found.")
if (!resDirectory.isDirectory) throw PatchException("The res folder can not be found.")
val (original, replacement) = "yt_premium_wordmark_header" to "yt_wordmark_header"
val modes = arrayOf("light", "dark")
@@ -32,7 +30,7 @@ class PremiumHeadingPatch : ResourcePatch {
val toPath = headingDirectory.resolve("${replacement}_$mode.png").toPath()
if (!fromPath.exists())
return PatchResultError("The file $fromPath does not exist in the resources. Therefore, this patch can not succeed.")
throw PatchException("The file $fromPath does not exist in the resources. Therefore, this patch can not succeed.")
Files.copy(
fromPath,
toPath,
@@ -40,7 +38,5 @@ class PremiumHeadingPatch : ResourcePatch {
)
}
}
return PatchResultSuccess()
}
}
@@ -16,7 +16,7 @@ import java.nio.file.Files
@Description("Changes the YouTube launcher icon and name to your choice (defaults to ReVanced).")
@CustomBrandingCompatibility
class CustomBrandingPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
fun copyResources(resourceGroups: List<ResourceUtils.ResourceGroup>) {
iconPath?.let { iconPathString ->
val iconPath = File(iconPathString)
@@ -62,8 +62,6 @@ class CustomBrandingPatch : ResourcePatch {
"android:label=\"$appName"
)
)
return PatchResultSuccess()
}
companion object : OptionsContainer() {
@@ -3,8 +3,6 @@ package app.revanced.patches.youtube.layout.buttons.action.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
@@ -22,7 +20,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@Description("Adds the options to hide action buttons under a video.")
@HideButtonsCompatibility
class HideButtonsPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
PreferenceScreen(
"revanced_hide_buttons_preference_screen",
@@ -94,8 +92,6 @@ class HideButtonsPatch : ResourcePatch {
)
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
return PatchResultSuccess()
}
private companion object {
@@ -8,8 +8,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
@@ -33,7 +31,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
class HideAutoplayButtonPatch : BytecodePatch(
listOf(LayoutConstructorFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_autoplay_button",
@@ -70,8 +68,6 @@ class HideAutoplayButtonPatch : BytecodePatch(
""",
ExternalLabel("hidden", jumpInstruction)
)
} ?: return LayoutConstructorFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw LayoutConstructorFingerprint.toErrorResult()
}
}
@@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.StringResource
@@ -25,7 +23,7 @@ import com.android.tools.smali.dexlib2.Opcode
class HideCaptionsButtonPatch : BytecodePatch(listOf(
SubtitleButtonControllerFingerprint,
)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_captions_button",
@@ -48,7 +46,5 @@ class HideCaptionsButtonPatch : BytecodePatch(listOf(
invoke-static {v0}, Lapp/revanced/integrations/patches/HideCaptionsButtonPatch;->hideCaptionsButton(Landroid/widget/ImageView;)V
"""
)
return PatchResultSuccess()
}
}
@@ -5,9 +5,7 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.StringResource
@@ -22,7 +20,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@Description("Hides the cast button in the video player.")
@CastButtonCompatibility
class HideCastButtonPatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_cast_button",
@@ -33,7 +31,7 @@ class HideCastButtonPatch : BytecodePatch() {
)
val buttonClass = context.findClass("MediaRouteButton")
?: return PatchResultError("MediaRouteButton class not found.")
?: throw PatchException("MediaRouteButton class not found.")
buttonClass.mutableClass.methods.find { it.name == "setVisibility" }?.apply {
addInstructions(
@@ -43,8 +41,6 @@ class HideCastButtonPatch : BytecodePatch() {
move-result p1
"""
)
} ?: return PatchResultError("setVisibility method not found.")
return PatchResultSuccess()
} ?: throw PatchException("setVisibility method not found.")
}
}
@@ -8,8 +8,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
@@ -36,7 +34,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Description("Adds options to hide or change navigation buttons.")
@NavigationButtonsCompatibility
class NavigationButtonsPatch : BytecodePatch(listOf(AddCreateButtonViewFingerprint)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
PreferenceScreen(
"revanced_navigation_buttons_preference_screen",
@@ -103,7 +101,7 @@ class NavigationButtonsPatch : BytecodePatch(listOf(AddCreateButtonViewFingerpri
initializeButtonsResult.mutableClass
)
)
return it.toErrorResult()
throw it.toErrorResult()
}
.map { it.result!!.scanResult.patternScanResult!! }
@@ -152,7 +150,7 @@ class NavigationButtonsPatch : BytecodePatch(listOf(AddCreateButtonViewFingerpri
"""
)
}
} ?: return AddCreateButtonViewFingerprint.toErrorResult()
} ?: throw AddCreateButtonViewFingerprint.toErrorResult()
/*
* Resolve fingerprints
@@ -160,7 +158,7 @@ class NavigationButtonsPatch : BytecodePatch(listOf(AddCreateButtonViewFingerpri
InitializeButtonsFingerprint.result!!.let {
if (!PivotBarCreateButtonViewFingerprint.resolve(context, it.mutableMethod, it.mutableClass))
return PivotBarCreateButtonViewFingerprint.toErrorResult()
throw PivotBarCreateButtonViewFingerprint.toErrorResult()
}
PivotBarCreateButtonViewFingerprint.result!!.apply {
@@ -180,7 +178,6 @@ class NavigationButtonsPatch : BytecodePatch(listOf(AddCreateButtonViewFingerpri
mutableMethod.injectHook(hook, insertIndex)
}
return PatchResultSuccess()
}
private companion object {
@@ -5,9 +5,7 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.youtube.layout.buttons.navigation.fingerprints.InitializeButtonsFingerprint
@@ -18,10 +16,10 @@ import app.revanced.patches.youtube.layout.buttons.navigation.fingerprints.Pivot
class ResolvePivotBarFingerprintsPatch : BytecodePatch(
listOf(PivotBarConstructorFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// imageOnlyTabResourceId is used in InitializeButtonsFingerprint fingerprint
ResourceMappingPatch.resourceMappings.find { it.type == "layout" && it.name == "image_only_tab" }
?.let { imageOnlyTabResourceId = it.id } ?: return PatchResultError("Failed to find resource")
?.let { imageOnlyTabResourceId = it.id } ?: throw PatchException("Failed to find resource")
PivotBarConstructorFingerprint.result?.let {
// Resolve InitializeButtonsFingerprint on the class of the method
@@ -30,9 +28,8 @@ class ResolvePivotBarFingerprintsPatch : BytecodePatch(
context,
it.classDef
)
) return InitializeButtonsFingerprint.toErrorResult()
} ?: return PivotBarConstructorFingerprint.toErrorResult()
return PatchResultSuccess()
) throw InitializeButtonsFingerprint.toErrorResult()
} ?: throw PivotBarConstructorFingerprint.toErrorResult()
}
internal companion object {
@@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.StringResource
@@ -32,7 +30,7 @@ class HidePlayerButtonsPatch : BytecodePatch(
const val HAS_PREVIOUS = 6
}
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_player_buttons",
@@ -69,7 +67,6 @@ class HidePlayerButtonsPatch : BytecodePatch(
move-result v$hasPreviousParameterRegister
"""
)
} ?: return PlayerControlsVisibilityModelFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw PlayerControlsVisibilityModelFingerprint.toErrorResult()
}
}
@@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.layout.hide.albumcards.annotations.AlbumCardsCompatibility
@@ -27,7 +25,7 @@ class AlbumCardsPatch : BytecodePatch(
AlbumCardsFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
AlbumCardsFingerprint.result?.let {
it.mutableMethod.apply {
val checkCastAnchorIndex = it.scanResult.patternScanResult!!.endIndex
@@ -43,8 +41,6 @@ class AlbumCardsPatch : BytecodePatch(
"hideAlbumCard(Landroid/view/View;)V"
)
}
} ?: return AlbumCardsFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw AlbumCardsFingerprint.toErrorResult()
}
}
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.layout.hide.albumcards.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -16,7 +14,7 @@ class AlbumCardsResourcePatch : ResourcePatch {
internal var albumCardId: Long = -1
}
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_album_cards",
@@ -29,7 +27,5 @@ class AlbumCardsResourcePatch : ResourcePatch {
albumCardId = ResourceMappingPatch.resourceMappings.single {
it.type == "layout" && it.name == "album_card"
}.id
return PatchResultSuccess()
}
}
@@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.layout.hide.breakingnews.annotations.BreakingNewsCompatibility
@@ -25,7 +23,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
class BreakingNewsPatch : BytecodePatch(
listOf(BreakingNewsFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
BreakingNewsFingerprint.result?.let {
val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1
val moveResultIndex = insertIndex - 1
@@ -44,9 +42,7 @@ class BreakingNewsPatch : BytecodePatch(
)
}
} ?: return BreakingNewsFingerprint.toErrorResult()
} ?: throw BreakingNewsFingerprint.toErrorResult()
return PatchResultSuccess()
}
}
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.layout.hide.breakingnews.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -16,7 +14,7 @@ class BreakingNewsResourcePatch : ResourcePatch {
internal var horizontalCardListId: Long = -1
}
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_breaking_news",
@@ -29,7 +27,5 @@ class BreakingNewsResourcePatch : ResourcePatch {
horizontalCardListId = ResourceMappingPatch.resourceMappings.single {
it.type == "layout" && it.name == "horizontal_card_list"
}.id
return PatchResultSuccess()
}
}
@@ -3,8 +3,6 @@ package app.revanced.patches.youtube.layout.hide.comments.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
@@ -21,7 +19,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@HideCommentsCompatibility
@DependsOn([SettingsPatch::class, LithoFilterPatch::class])
class CommentsPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
@@ -45,8 +43,6 @@ class CommentsPatch : ResourcePatch {
StringResource("revanced_comments_preference_screen_summary", "Manage the visibility of comments section components")
)
)
return PatchResultSuccess()
}
private companion object {
@@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.layout.hide.crowdfundingbox.annotations.CrowdfundingBoxCompatibility
@@ -27,7 +25,7 @@ class CrowdfundingBoxPatch : BytecodePatch(
CrowdfundingBoxFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
CrowdfundingBoxFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
@@ -35,9 +33,7 @@ class CrowdfundingBoxPatch : BytecodePatch(
addInstruction(insertIndex, "invoke-static {v$objectRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR")
}
} ?: return CrowdfundingBoxFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw CrowdfundingBoxFingerprint.toErrorResult()
}
private companion object {
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.layout.hide.crowdfundingbox.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -16,7 +14,7 @@ class CrowdfundingBoxResourcePatch : ResourcePatch {
internal var crowdfundingBoxId: Long = -1
}
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_crowdfunding_box",
@@ -29,7 +27,5 @@ class CrowdfundingBoxResourcePatch : ResourcePatch {
crowdfundingBoxId = ResourceMappingPatch.resourceMappings.single {
it.type == "layout" && it.name == "donation_companion"
}.id
return PatchResultSuccess()
}
}
@@ -8,8 +8,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.layout.hide.endscreencards.annotations.HideEndscreenCardsCompatibility
@@ -32,7 +30,7 @@ class HideEndscreenCardsPatch : BytecodePatch(
LayoutVideoFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
fun MethodFingerprint.injectHideCall() {
val layoutResult = result ?: throw toErrorResult()
layoutResult.mutableMethod.apply {
@@ -51,7 +49,5 @@ class HideEndscreenCardsPatch : BytecodePatch(
LayoutIconFingerprint,
LayoutVideoFingerprint
).forEach(MethodFingerprint::injectHideCall)
return PatchResultSuccess()
}
}
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.layout.hide.endscreencards.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -18,7 +16,7 @@ class HideEndscreenCardsResourcePatch : ResourcePatch {
var layoutVideo: Long = -1
}
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_endscreen_cards",
@@ -35,7 +33,5 @@ class HideEndscreenCardsResourcePatch : ResourcePatch {
layoutCircle = findEndscreenResourceId("circle")
layoutIcon = findEndscreenResourceId("icon")
layoutVideo = findEndscreenResourceId("video")
return PatchResultSuccess()
}
}
@@ -8,8 +8,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.layout.hide.filterbar.annotations.HideFilterBar
@@ -31,7 +29,7 @@ class HideFilterBarPatch : BytecodePatch(
FilterBarHeightFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
FilterBarHeightFingerprint.patch<TwoRegisterInstruction> { register ->
"""
invoke-static { v$register }, $INTEGRATIONS_CLASS_DESCRIPTOR->hideInFeed(I)I
@@ -50,8 +48,6 @@ class HideFilterBarPatch : BytecodePatch(
move-result v$register
"""
}
return PatchResultSuccess()
}
private companion object {
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.layout.hide.filterbar.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -13,7 +11,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
class HideFilterBarResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
PreferenceScreen(
"revanced_hide_filter_bar_preference",
@@ -78,8 +76,6 @@ class HideFilterBarResourcePatch : ResourcePatch {
relatedChipCloudMarginId = "related_chip_cloud_reduced_margins".layoutResourceId("layout")
filterBarHeightId = "filter_bar_height".layoutResourceId()
barContainerHeightId = "bar_container_height".layoutResourceId()
return PatchResultSuccess()
}
internal companion object {
@@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.layout.hide.floatingmicrophone.annotations.HideFloatingMicrophoneButtonCompatibility
@@ -23,7 +21,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
class HideFloatingMicrophoneButtonPatch : BytecodePatch(
listOf(ShowFloatingMicrophoneButtonFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
ShowFloatingMicrophoneButtonFingerprint.result?.let { result ->
with(result.mutableMethod) {
val insertIndex = result.scanResult.patternScanResult!!.startIndex + 1
@@ -37,9 +35,7 @@ class HideFloatingMicrophoneButtonPatch : BytecodePatch(
"""
)
}
} ?: return ShowFloatingMicrophoneButtonFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw ShowFloatingMicrophoneButtonFingerprint.toErrorResult()
}
private companion object {
@@ -1,9 +1,7 @@
package app.revanced.patches.youtube.layout.hide.floatingmicrophone.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -15,7 +13,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
@HideFloatingMicrophoneButtonCompatibility
class HideFloatingMicrophoneButtonResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_floating_microphone_button",
@@ -29,8 +27,7 @@ class HideFloatingMicrophoneButtonResourcePatch : ResourcePatch {
)
fabButtonId = ResourceMappingPatch.resourceMappings.find { it.type == "id" && it.name == "fab" }?.id
?: return PatchResultError("Can not find required fab button resource id")
return PatchResultSuccess()
?: throw PatchException("Can not find required fab button resource id")
}
internal companion object {
@@ -8,8 +8,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
@@ -30,7 +28,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch.P
class HideLayoutComponentsPatch : BytecodePatch(
listOf(ConvertElementToFlatBufferFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_gray_separator",
@@ -274,11 +272,9 @@ class HideLayoutComponentsPatch : BytecodePatch(
addInstruction(0, "move-object/from16 v$freeRegister, p3")
}
} ?: return ConvertElementToFlatBufferFingerprint.toErrorResult()
} ?: throw ConvertElementToFlatBufferFingerprint.toErrorResult()
// endregion
return PatchResultSuccess()
}
internal companion object {
@@ -8,8 +8,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
@@ -34,7 +32,7 @@ class HideInfoCardsPatch : BytecodePatch(
InfocardsMethodCallFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
InfocardsIncognitoFingerprint.also {
it.resolve(context, InfocardsIncognitoParentFingerprint.result!!.classDef)
}.result!!.mutableMethod.apply {
@@ -68,7 +66,5 @@ class HideInfoCardsPatch : BytecodePatch(
)
)
}
return PatchResultSuccess()
}
}
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.layout.hide.infocards.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -18,7 +16,7 @@ class HideInfocardsResourcePatch : ResourcePatch {
var drawerResourceId: Long = -1
}
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_info_cards",
@@ -31,7 +29,5 @@ class HideInfocardsResourcePatch : ResourcePatch {
drawerResourceId = ResourceMappingPatch.resourceMappings.single {
it.type == "id" && it.name == "info_cards_drawer_header"
}.id
return PatchResultSuccess()
}
}
@@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.layout.hide.loadmorebutton.bytecode.fingerprints.HideLoadMoreButtonFingerprint
@@ -22,7 +20,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@DependsOn([HideLoadMoreButtonResourcePatch::class])
@HideLoadMoreButtonCompatibility
class HideLoadMoreButtonPatch : BytecodePatch(listOf(HideLoadMoreButtonFingerprint)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
HideLoadMoreButtonFingerprint.result?.let {
it.mutableMethod.apply {
val moveRegisterIndex = it.scanResult.patternScanResult!!.endIndex
@@ -35,9 +33,7 @@ class HideLoadMoreButtonPatch : BytecodePatch(listOf(HideLoadMoreButtonFingerpri
"$INTEGRATIONS_CLASS_DESCRIPTOR->hideLoadMoreButton(Landroid/view/View;)V"
)
}
} ?: return HideLoadMoreButtonFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw HideLoadMoreButtonFingerprint.toErrorResult()
}
private companion object {
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.layout.hide.loadmorebutton.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -12,7 +10,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
class HideLoadMoreButtonResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_load_more_button",
@@ -25,8 +23,6 @@ class HideLoadMoreButtonResourcePatch : ResourcePatch {
expandButtonDownId = ResourceMappingPatch.resourceMappings.single {
it.type == "layout" && it.name == "expand_button_down"
}.id
return PatchResultSuccess()
}
internal companion object {
@@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.layout.hide.personalinformation.annotations.HideEmailAddressCompatibility
@@ -27,7 +25,7 @@ class HideEmailAddressPatch : BytecodePatch(
AccountSwitcherAccessibilityLabelFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
AccountSwitcherAccessibilityLabelFingerprint.result?.let {
it.mutableMethod.apply {
val setVisibilityConstIndex = it.scanResult.patternScanResult!!.endIndex
@@ -43,8 +41,6 @@ class HideEmailAddressPatch : BytecodePatch(
"""
)
}
} ?: return AccountSwitcherAccessibilityLabelFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw AccountSwitcherAccessibilityLabelFingerprint.toErrorResult()
}
}
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.layout.hide.personalinformation.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -16,7 +14,7 @@ class HideEmailAddressResourcePatch : ResourcePatch {
internal var accountSwitcherAccessibilityLabelId: Long = -1
}
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_email_address",
@@ -29,7 +27,5 @@ class HideEmailAddressResourcePatch : ResourcePatch {
accountSwitcherAccessibilityLabelId = ResourceMappingPatch.resourceMappings.single {
it.type == "string" && it.name == "account_switcher_accessibility_label"
}.id
return PatchResultSuccess()
}
}
@@ -3,8 +3,6 @@ package app.revanced.patches.youtube.layout.hide.player.flyoutmenupanel.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
@@ -21,7 +19,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@DependsOn([LithoFilterPatch::class, SettingsPatch::class])
@HidePlayerFlyoutMenuItemsCompatibility
class HidePlayerFlyoutMenuPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
PreferenceScreen(
KEY,
@@ -93,8 +91,6 @@ class HidePlayerFlyoutMenuPatch : ResourcePatch {
)
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
return PatchResultSuccess()
}
private companion object {
@@ -8,8 +8,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.layout.hide.player.overlay.annotations.HidePlayerOverlayPatchCompatibility
@@ -23,7 +21,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@DependsOn([HidePlayerOverlayResourcePatch::class])
@HidePlayerOverlayPatchCompatibility
class HidePlayerOverlayPatch : BytecodePatch(listOf(CreatePlayerOverviewFingerprint)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
CreatePlayerOverviewFingerprint.result?.let { result ->
result.mutableMethod.apply {
val viewRegisterIndex =
@@ -37,9 +35,7 @@ class HidePlayerOverlayPatch : BytecodePatch(listOf(CreatePlayerOverviewFingerpr
"$INTEGRATIONS_CLASS_DESCRIPTOR->hidePlayerOverlay(Landroid/widget/ImageView;)V"
)
}
} ?: return CreatePlayerOverviewFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw CreatePlayerOverviewFingerprint.toErrorResult()
}
private companion object {
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.layout.hide.player.overlay.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -12,7 +10,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
class HidePlayerOverlayResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_player_overlay",
@@ -25,8 +23,6 @@ class HidePlayerOverlayResourcePatch : ResourcePatch {
scrimOverlayId = ResourceMappingPatch.resourceMappings.single {
it.type == "id" && it.name == "scrim_overlay"
}.id
return PatchResultSuccess()
}
internal companion object {
@@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.fingerprints.SeekbarFingerprint
@@ -35,7 +33,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
class HideSeekbarPatch : BytecodePatch(
listOf(SeekbarFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SeekbarPreferencesPatch.addPreferences(
SwitchPreference(
"revanced_hide_seekbar",
@@ -65,7 +63,5 @@ class HideSeekbarPatch : BytecodePatch(
nop
"""
)
return PatchResultSuccess()
}
}
@@ -10,8 +10,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@@ -46,7 +44,7 @@ class HideShortsComponentsPatch : BytecodePatch(
SetPivotBarVisibilityParentFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
// region Hide the Shorts shelf.
@@ -63,7 +61,7 @@ class HideShortsComponentsPatch : BytecodePatch(
"hideShortsShelf"
)
}
} ?: return ReelConstructorFingerprint.toErrorResult()
} ?: throw ReelConstructorFingerprint.toErrorResult()
// endregion
@@ -72,7 +70,7 @@ class HideShortsComponentsPatch : BytecodePatch(
// Some Shorts buttons are views, hide them by setting their visibility to GONE.
CreateShortsButtonsFingerprint.result?.let {
ShortsButtons.values().forEach { button -> button.injectHideCall(it.mutableMethod) }
} ?: return CreateShortsButtonsFingerprint.toErrorResult()
} ?: throw CreateShortsButtonsFingerprint.toErrorResult()
// endregion
@@ -94,7 +92,7 @@ class HideShortsComponentsPatch : BytecodePatch(
)
}
}
} ?: return SetPivotBarVisibilityParentFingerprint.toErrorResult()
} ?: throw SetPivotBarVisibilityParentFingerprint.toErrorResult()
// Hook to hide the navigation bar when Shorts are being played.
RenderBottomNavigationBarParentFingerprint.result?.let {
@@ -104,7 +102,7 @@ class HideShortsComponentsPatch : BytecodePatch(
RenderBottomNavigationBarFingerprint.result!!.mutableMethod.apply {
addInstruction(0, "invoke-static { }, $FILTER_CLASS_DESCRIPTOR->hideNavigationBar()V")
}
} ?: return RenderBottomNavigationBarParentFingerprint.toErrorResult()
} ?: throw RenderBottomNavigationBarParentFingerprint.toErrorResult()
// Required to prevent a black bar from appearing at the bottom of the screen.
BottomNavigationBarFingerprint.result?.let {
@@ -119,11 +117,9 @@ class HideShortsComponentsPatch : BytecodePatch(
"hideNavigationBar(Landroid/view/View;)Landroid/view/View;"
)
}
} ?: return BottomNavigationBarFingerprint.toErrorResult()
} ?: throw BottomNavigationBarFingerprint.toErrorResult()
// endregion
return PatchResultSuccess()
}
private companion object {
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.layout.hide.shorts.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -13,7 +11,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
class HideShortsComponentsResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
PreferenceScreen(
"revanced_shorts_preference_screen",
@@ -94,8 +92,6 @@ class HideShortsComponentsResourcePatch : ResourcePatch {
reelMultipleItemShelfId = "reel_multiple_items_shelf".getId()
reelPlayerRightLargeIconSize = "reel_player_right_large_icon_size".getId()
return PatchResultSuccess()
}
companion object {
@@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.StringResource
@@ -27,7 +25,7 @@ class HideTimestampPatch : BytecodePatch(
TimeCounterFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_timestamp",
@@ -49,8 +47,6 @@ class HideTimestampPatch : BytecodePatch(
nop
"""
)
} ?: return TimeCounterFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw TimeCounterFingerprint.toErrorResult()
}
}
@@ -7,9 +7,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.StringResource
@@ -30,7 +28,7 @@ class HideWatermarkPatch : BytecodePatch(
HideWatermarkParentFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_video_watermark",
@@ -42,7 +40,7 @@ class HideWatermarkPatch : BytecodePatch(
HideWatermarkFingerprint.resolve(context, HideWatermarkParentFingerprint.result!!.classDef)
val result = HideWatermarkFingerprint.result
?: return PatchResultError("Required parent method could not be found.")
?: throw PatchException("Required parent method could not be found.")
val method = result.mutableMethod
val line = method.implementation!!.instructions.size - 5
@@ -55,7 +53,5 @@ class HideWatermarkPatch : BytecodePatch(
move-result p2
"""
)
return PatchResultSuccess()
}
}
@@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.StringResource
@@ -27,7 +25,7 @@ class PlayerPopupPanelsPatch : BytecodePatch(
EngagementPanelControllerFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_player_popup_panels",
@@ -38,7 +36,7 @@ class PlayerPopupPanelsPatch : BytecodePatch(
)
val engagementPanelControllerMethod = EngagementPanelControllerFingerprint
.result?.mutableMethod ?: return EngagementPanelControllerFingerprint.toErrorResult()
.result?.mutableMethod ?: throw EngagementPanelControllerFingerprint.toErrorResult()
engagementPanelControllerMethod.addInstructionsWithLabels(
0,
@@ -53,7 +51,5 @@ class PlayerPopupPanelsPatch : BytecodePatch(
nop
"""
)
return PatchResultSuccess()
}
}
@@ -4,8 +4,6 @@ import app.revanced.extensions.doRecursively
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.layout.player.background.annotations.PlayerControlsBackgroundCompatibility
@@ -16,7 +14,7 @@ import org.w3c.dom.Element
@Description("Removes the background from the video player controls.")
@PlayerControlsBackgroundCompatibility
class PlayerControlsBackgroundPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
context.xmlEditor[RESOURCE_FILE_PATH].use { editor ->
editor.file.doRecursively node@{ node ->
if (node !is Element) return@node
@@ -26,8 +24,6 @@ class PlayerControlsBackgroundPatch : ResourcePatch {
}
}
}
return PatchResultSuccess()
}
private companion object {
@@ -13,9 +13,7 @@ import app.revanced.patcher.extensions.MethodFingerprintExtensions.name
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.layout.returnyoutubedislike.annotations.ReturnYouTubeDislikeCompatibility
@@ -51,7 +49,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch(
RemoveLikeFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// region Inject newVideoLoaded event handler to update dislikes when a new video is loaded.
VideoIdPatch.injectCall("$INTEGRATIONS_CLASS_DESCRIPTOR->newVideoLoaded(Ljava/lang/String;)V")
@@ -73,7 +71,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch(
invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->sendVote(I)V
"""
)
} ?: return PatchResultError("Failed to find ${fingerprint.name} method.")
} ?: throw PatchException("Failed to find ${fingerprint.name} method.")
}
// endregion
@@ -128,7 +126,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch(
"""
)
}
} ?: return TextComponentContextFingerprint.toErrorResult()
} ?: throw TextComponentContextFingerprint.toErrorResult()
// endregion
@@ -168,7 +166,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch(
"""
)
}
} ?: return ShortsTextViewFingerprint.toErrorResult()
} ?: throw ShortsTextViewFingerprint.toErrorResult()
// endregion
@@ -186,11 +184,9 @@ class ReturnYouTubeDislikePatch : BytecodePatch(
"invoke-static {v$resourceIdentifierRegister, v$textViewRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->setOldUILayoutDislikes(ILandroid/widget/TextView;)V"
)
}
} ?: return DislikesOldLayoutTextViewFingerprint.toErrorResult()
} ?: throw DislikesOldLayoutTextViewFingerprint.toErrorResult()
// endregion
return PatchResultSuccess()
}
private companion object {
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.layout.returnyoutubedislike.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -17,7 +15,7 @@ class ReturnYouTubeDislikeResourcePatch : ResourcePatch {
internal var oldUIDislikeId: Long = -1
}
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.addPreference(
Preference(
StringResource("revanced_ryd_settings_title", "Return YouTube Dislike"),
@@ -31,7 +29,5 @@ class ReturnYouTubeDislikeResourcePatch : ResourcePatch {
oldUIDislikeId = ResourceMappingPatch.resourceMappings.single {
it.type == "id" && it.name == "dislike_button"
}.id
return PatchResultSuccess()
}
}
@@ -4,12 +4,9 @@ import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@@ -31,7 +28,7 @@ class WideSearchbarPatch : BytecodePatch(
SetWordmarkHeaderFingerprint, CreateSearchSuggestionsFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_wide_searchbar",
@@ -41,7 +38,7 @@ class WideSearchbarPatch : BytecodePatch(
)
)
val result = CreateSearchSuggestionsFingerprint.result ?: return CreateSearchSuggestionsFingerprint.toErrorResult()
val result = CreateSearchSuggestionsFingerprint.result ?: throw CreateSearchSuggestionsFingerprint.toErrorResult()
// patch methods
mapOf(
@@ -50,8 +47,6 @@ class WideSearchbarPatch : BytecodePatch(
).forEach { (fingerprint, callIndex) ->
context.walkMutable(callIndex, fingerprint).injectSearchBarHook()
}
return PatchResultSuccess()
}
private companion object {
@@ -4,12 +4,9 @@ import app.revanced.extensions.indexOfFirstConstantInstructionValue
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.layout.seekbar.annotations.SeekbarColorCompatibility
@@ -29,7 +26,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
class SeekbarColorBytecodePatch : BytecodePatch(
listOf(PlayerSeekbarColorFingerprint, ShortsSeekbarColorFingerprint, SetSeekbarClickedColorFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
fun MutableMethod.addColorChangeInstructions(resourceId: Long) {
var registerIndex = indexOfFirstConstantInstructionValue(resourceId) + 2
var colorRegister = getInstruction<OneRegisterInstruction>(registerIndex).registerA
@@ -45,11 +42,11 @@ class SeekbarColorBytecodePatch : BytecodePatch(
PlayerSeekbarColorFingerprint.result?.mutableMethod?.apply {
addColorChangeInstructions(SeekbarColorResourcePatch.inlineTimeBarColorizedBarPlayedColorDarkId)
addColorChangeInstructions(SeekbarColorResourcePatch.inlineTimeBarPlayedNotHighlightedColorId)
} ?: return PlayerSeekbarColorFingerprint.toErrorResult()
} ?: throw PlayerSeekbarColorFingerprint.toErrorResult()
ShortsSeekbarColorFingerprint.result?.mutableMethod?.apply {
addColorChangeInstructions(SeekbarColorResourcePatch.reelTimeBarPlayedColorId)
} ?: return ShortsSeekbarColorFingerprint.toErrorResult()
} ?: throw ShortsSeekbarColorFingerprint.toErrorResult()
SetSeekbarClickedColorFingerprint.result?.let { result ->
result.mutableMethod.let {
@@ -70,11 +67,9 @@ class SeekbarColorBytecodePatch : BytecodePatch(
)
}
}
} ?: return SetSeekbarClickedColorFingerprint.toErrorResult()
} ?: throw SetSeekbarClickedColorFingerprint.toErrorResult()
lithoColorOverrideHook(INTEGRATIONS_CLASS_DESCRIPTOR, "getLithoColor")
return PatchResultSuccess()
}
private companion object {
@@ -1,7 +1,8 @@
package app.revanced.patches.youtube.layout.seekbar.resource
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.*
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@@ -10,11 +11,11 @@ import org.w3c.dom.Element
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
class SeekbarColorResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
fun findColorResource(resourceName: String): Long {
return ResourceMappingPatch.resourceMappings
.find { it.type == "color" && it.name == resourceName }?.id
?: throw PatchResultError("Could not find color resource: $resourceName")
?: throw PatchException("Could not find color resource: $resourceName")
}
reelTimeBarPlayedColorId =
@@ -29,7 +30,7 @@ class SeekbarColorResourcePatch : ResourcePatch {
val layerList = editor.file.getElementsByTagName("layer-list").item(0) as Element
val progressNode = layerList.getElementsByTagName("item").item(1) as Element
if (!progressNode.getAttributeNode("android:id").value.endsWith("progress")) {
return PatchResultError("Could not find progress bar")
throw PatchException("Could not find progress bar")
}
val scaleNode = progressNode.getElementsByTagName("scale").item(0) as Element
val shapeNode = scaleNode.getElementsByTagName("shape").item(0) as Element
@@ -37,8 +38,6 @@ class SeekbarColorResourcePatch : ResourcePatch {
"app.revanced.integrations.patches.theme.ProgressBarDrawable")
scaleNode.replaceChild(replacementNode, shapeNode)
}
return PatchResultSuccess()
}
companion object {
@@ -12,11 +12,9 @@ import java.io.Closeable
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
class SeekbarPreferencesPatch : ResourcePatch, Closeable {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
// Nothing to do here. All work is done in close method.
return PatchResultSuccess()
}
override fun close() {
@@ -4,16 +4,13 @@ import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@@ -64,11 +61,11 @@ class SponsorBlockBytecodePatch : BytecodePatch(
AutoRepeatParentFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
LayoutConstructorFingerprint.result?.let {
if (!ControlsOverlayFingerprint.resolve(context, it.classDef))
throw ControlsOverlayFingerprint.toErrorResult()
} ?: return LayoutConstructorFingerprint.toErrorResult()
} ?: throw LayoutConstructorFingerprint.toErrorResult()
/*
* Hook the video time methods
@@ -222,7 +219,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
"invoke-static {v$frameLayoutRegister}, $INTEGRATIONS_SPONSORBLOCK_VIEW_CONTROLLER_CLASS_DESCRIPTOR->initialize(Landroid/view/ViewGroup;)V"
)
}
} ?: return ControlsOverlayFingerprint.toErrorResult()
} ?: throw ControlsOverlayFingerprint.toErrorResult()
// get rectangle field name
RectangleFieldInvalidatorFingerprint.resolve(context, seekbarSignatureResult.classDef)
@@ -255,23 +252,21 @@ class SponsorBlockBytecodePatch : BytecodePatch(
)
}
}
} ?: return PatchResultError("Could not find the method which contains the replaceMeWith* strings")
} ?: throw PatchException("Could not find the method which contains the replaceMeWith* strings")
// The vote and create segment buttons automatically change their visibility when appropriate,
// but if buttons are showing when the end of the video is reached then they will not automatically hide.
// Add a hook to forcefully hide when the end of the video is reached.
AutoRepeatParentFingerprint.result ?: return AutoRepeatParentFingerprint.toErrorResult()
AutoRepeatParentFingerprint.result ?: throw AutoRepeatParentFingerprint.toErrorResult()
AutoRepeatFingerprint.also {
it.resolve(context, AutoRepeatParentFingerprint.result!!.classDef)
}.result?.mutableMethod?.addInstruction(
0,
"invoke-static {}, $INTEGRATIONS_SPONSORBLOCK_VIEW_CONTROLLER_CLASS_DESCRIPTOR->endOfVideoReached()V"
) ?: return AutoRepeatFingerprint.toErrorResult()
) ?: throw AutoRepeatFingerprint.toErrorResult()
// TODO: isSBChannelWhitelisting implementation
return PatchResultSuccess()
}
private companion object {
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.layout.sponsorblock.resource.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -17,7 +15,7 @@ import app.revanced.util.resources.ResourceUtils.mergeStrings
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
class SponsorBlockResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.addPreference(
Preference(
StringResource("revanced_sponsorblock_settings_title", "SponsorBlock"),
@@ -91,7 +89,5 @@ class SponsorBlockResourcePatch : ResourcePatch {
break
}
}.close() // close afterwards
return PatchResultSuccess()
}
}
@@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.ArrayResource
@@ -30,7 +28,7 @@ class SpoofAppVersionPatch : BytecodePatch(
SpoofAppVersionFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_spoof_app_version",
@@ -79,9 +77,7 @@ class SpoofAppVersionPatch : BytecodePatch(
move-result-object v$buildOverrideNameRegister
"""
)
} ?: return SpoofAppVersionFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw SpoofAppVersionFingerprint.toErrorResult()
}
private companion object {
@@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.StringResource
@@ -26,7 +24,7 @@ class DisableShortsOnStartupPatch : BytecodePatch(
UserWasInShortsFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_disable_resuming_shorts_player",
@@ -51,7 +49,5 @@ class DisableShortsOnStartupPatch : BytecodePatch(
nop
"""
)
return PatchResultSuccess()
}
}
@@ -4,14 +4,11 @@ import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@@ -39,7 +36,7 @@ class TabletMiniPlayerPatch : BytecodePatch(
MiniPlayerOverrideFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_tablet_miniplayer",
@@ -50,7 +47,7 @@ class TabletMiniPlayerPatch : BytecodePatch(
)
// First resolve the fingerprints via the parent fingerprint.
MiniPlayerDimensionsCalculatorParentFingerprint.result ?: return MiniPlayerDimensionsCalculatorParentFingerprint.toErrorResult()
MiniPlayerDimensionsCalculatorParentFingerprint.result ?: throw MiniPlayerDimensionsCalculatorParentFingerprint.toErrorResult()
val miniPlayerClass = MiniPlayerDimensionsCalculatorParentFingerprint.result!!.classDef
/*
@@ -81,7 +78,7 @@ class TabletMiniPlayerPatch : BytecodePatch(
.filter { (_, instruction) -> instruction.opcode == Opcode.RETURN }
.map { (index, _) -> index }
if (returnIndices.isEmpty()) throw PatchResultError("No return instructions found.")
if (returnIndices.isEmpty()) throw PatchException("No return instructions found.")
// This method clobbers register p0 to return the value, calculate to override.
val returnedRegister = implementation.registerCount - parameters.size
@@ -92,14 +89,12 @@ class TabletMiniPlayerPatch : BytecodePatch(
}
return@let
} ?: return MiniPlayerOverrideFingerprint.toErrorResult()
} ?: throw MiniPlayerOverrideFingerprint.toErrorResult()
/*
* Size check return value override.
*/
MiniPlayerResponseModelSizeCheckFingerprint.addProxyCall()
return PatchResultSuccess()
}
// Helper methods.
@@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.layout.theme.annotations.ThemeCompatibility
import app.revanced.patches.youtube.layout.theme.bytecode.fingerprints.LithoThemeFingerprint
@@ -16,14 +14,12 @@ import app.revanced.patches.youtube.layout.theme.bytecode.fingerprints.LithoThem
@Description("Adds a hook to set color of Litho components.")
@ThemeCompatibility
class LithoColorHookPatch : BytecodePatch(listOf(LithoThemeFingerprint)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
LithoThemeFingerprint.result?.let {
insertionIndex = it.scanResult.patternScanResult!!.endIndex - 1
colorRegister = "p1"
insertionMethod = it.mutableMethod
} ?: return LithoThemeFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw LithoThemeFingerprint.toErrorResult()
}
companion object {
private var insertionIndex : Int = -1
@@ -17,10 +17,8 @@ import app.revanced.patches.youtube.layout.theme.resource.ThemeResourcePatch
@ThemeCompatibility
class ThemeBytecodePatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
LithoColorHookPatch.lithoColorOverrideHook(INTEGRATIONS_CLASS_DESCRIPTOR, "getValue")
return PatchResultSuccess()
}
companion object : OptionsContainer() {
@@ -1,9 +1,7 @@
package app.revanced.patches.youtube.layout.theme.resource
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -19,7 +17,7 @@ import org.w3c.dom.Element
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class, SeekbarPreferencesPatch::class])
class ThemeResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SeekbarPreferencesPatch.addPreferences(
SwitchPreference(
"revanced_seekbar_custom_color",
@@ -85,13 +83,11 @@ class ThemeResourcePatch : ResourcePatch {
return@editSplashScreen
}
}
return PatchResultError("Failed to modify launch screen")
throw PatchException("Failed to modify launch screen")
}
}
}
return PatchResultSuccess()
}
private fun addColorResource(
@@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.alternativethumbnails.annotations
package app.revanced.patches.youtube.layout.thumbnails.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.alternativethumbnails.bytecode.fingerprints
package app.revanced.patches.youtube.layout.thumbnails.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
@@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.alternativethumbnails.bytecode.fingerprints
package app.revanced.patches.youtube.layout.thumbnails.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
@@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.alternativethumbnails.bytecode.fingerprints
package app.revanced.patches.youtube.layout.thumbnails.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
@@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.alternativethumbnails.bytecode.fingerprints
package app.revanced.patches.youtube.layout.thumbnails.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
@@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.alternativethumbnails.bytecode.fingerprints
package app.revanced.patches.youtube.layout.thumbnails.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
@@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.alternativethumbnails.bytecode.patch
package app.revanced.patches.youtube.layout.thumbnails.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
@@ -8,23 +8,12 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.settings.preference.impl.ArrayResource
import app.revanced.patches.shared.settings.preference.impl.ListPreference
import app.revanced.patches.shared.settings.preference.impl.NonInteractivePreference
import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.youtube.layout.alternativethumbnails.annotations.AlternativeThumbnailsCompatibility
import app.revanced.patches.youtube.layout.alternativethumbnails.bytecode.fingerprints.CronetURLRequestCallbackOnFailureFingerprint
import app.revanced.patches.youtube.layout.alternativethumbnails.bytecode.fingerprints.CronetURLRequestCallbackOnResponseStartedFingerprint
import app.revanced.patches.youtube.layout.alternativethumbnails.bytecode.fingerprints.CronetURLRequestCallbackOnSucceededFingerprint
import app.revanced.patches.youtube.layout.alternativethumbnails.bytecode.fingerprints.MessageDigestImageUrlFingerprint
import app.revanced.patches.youtube.layout.alternativethumbnails.bytecode.fingerprints.MessageDigestImageUrlParentFingerprint
import app.revanced.patches.shared.settings.preference.impl.*
import app.revanced.patches.youtube.layout.thumbnails.annotations.AlternativeThumbnailsCompatibility
import app.revanced.patches.youtube.layout.thumbnails.fingerprints.*
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@@ -32,11 +21,11 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
@Name("Alternative thumbnails")
@AlternativeThumbnailsCompatibility
@Description("Adds an option to replace video thumbnails with still image captures of the video.")
@Description("Adds options to replace video thumbnails with still image captures of the video.")
class AlternativeThumbnailsPatch : BytecodePatch(
listOf(MessageDigestImageUrlParentFingerprint, CronetURLRequestCallbackOnResponseStartedFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
PreferenceScreen(
"revanced_alt_thumbnails_preference_screen",
@@ -84,23 +73,23 @@ class AlternativeThumbnailsPatch : BytecodePatch(
)
MessageDigestImageUrlParentFingerprint.result
?: return MessageDigestImageUrlParentFingerprint.toErrorResult()
?: throw MessageDigestImageUrlParentFingerprint.toErrorResult()
MessageDigestImageUrlFingerprint.resolve(context, MessageDigestImageUrlParentFingerprint.result!!.classDef)
MessageDigestImageUrlFingerprint.result?.apply {
loadImageUrlMethod = mutableMethod
} ?: return MessageDigestImageUrlFingerprint.toErrorResult()
} ?: throw MessageDigestImageUrlFingerprint.toErrorResult()
addImageUrlHook(INTEGRATIONS_CLASS_DESCRIPTOR, true)
CronetURLRequestCallbackOnResponseStartedFingerprint.result
?: return CronetURLRequestCallbackOnResponseStartedFingerprint.toErrorResult()
?: throw CronetURLRequestCallbackOnResponseStartedFingerprint.toErrorResult()
CronetURLRequestCallbackOnSucceededFingerprint.resolve(
context,
CronetURLRequestCallbackOnResponseStartedFingerprint.result!!.classDef
)
CronetURLRequestCallbackOnSucceededFingerprint.result?.apply {
loadImageSuccessCallbackMethod = mutableMethod
} ?: return CronetURLRequestCallbackOnSucceededFingerprint.toErrorResult()
} ?: throw CronetURLRequestCallbackOnSucceededFingerprint.toErrorResult()
addImageUrlSuccessCallbackHook(INTEGRATIONS_CLASS_DESCRIPTOR)
@@ -110,10 +99,7 @@ class AlternativeThumbnailsPatch : BytecodePatch(
)
CronetURLRequestCallbackOnFailureFingerprint.result?.apply {
loadImageErrorCallbackMethod = mutableMethod
} ?: return CronetURLRequestCallbackOnFailureFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw CronetURLRequestCallbackOnFailureFingerprint.toErrorResult()
}
internal companion object {
@@ -7,9 +7,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.StringResource
@@ -30,7 +28,7 @@ class AutoRepeatPatch : BytecodePatch(
AutoRepeatParentFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.MISC.addPreferences(
SwitchPreference(
"revanced_auto_repeat",
@@ -42,7 +40,7 @@ class AutoRepeatPatch : BytecodePatch(
//Get Result from the ParentFingerprint which is the playMethod we need to get.
val parentResult = AutoRepeatParentFingerprint.result
?: return PatchResultError("ParentFingerprint did not resolve.")
?: throw PatchException("ParentFingerprint did not resolve.")
//this one needs to be called when app/revanced/integrations/patches/AutoRepeatPatch;->shouldAutoRepeat() returns true
val playMethod = parentResult.mutableMethod
@@ -52,7 +50,7 @@ class AutoRepeatPatch : BytecodePatch(
//This is the method we search for
val result = AutoRepeatFingerprint.result
?: return PatchResultError("FingerPrint did not resolve.")
?: throw PatchException("FingerPrint did not resolve.")
val method = result.mutableMethod
//Instructions to add to the smali code
@@ -67,7 +65,7 @@ class AutoRepeatPatch : BytecodePatch(
//Get the implementation so we can do a check for null and get instructions size.
val implementation = method.implementation
?: return PatchResultError("No Method Implementation found!")
?: throw PatchException("No Method Implementation found!")
//Since addInstructions needs an index which starts counting at 0 and size starts counting at 1,
//we have to remove 1 to get the latest instruction
@@ -80,6 +78,5 @@ class AutoRepeatPatch : BytecodePatch(
method.addInstructionsWithLabels(index, instructions)
//Everything worked as expected, return Success
return PatchResultSuccess()
}
}
@@ -5,8 +5,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.misc.bottomsheet.hook.fingerprints.CreateBottomSheetFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
@@ -16,7 +14,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
class BottomSheetHookPatch : BytecodePatch(
listOf(CreateBottomSheetFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
CreateBottomSheetFingerprint.result?.let {
it.mutableMethod.apply {
val returnLinearLayoutIndex = implementation!!.instructions.lastIndex
@@ -31,9 +29,7 @@ class BottomSheetHookPatch : BytecodePatch(
)
}
}
} ?: return CreateBottomSheetFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw CreateBottomSheetFingerprint.toErrorResult()
}
internal companion object {
@@ -1,20 +1,16 @@
package app.revanced.patches.youtube.misc.bottomsheet.hook.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@DependsOn([ResourceMappingPatch::class])
class BottomSheetHookResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
bottomSheetMargins = ResourceMappingPatch.resourceMappings.find { it.name == "bottom_sheet_margins" }?.id
?: return PatchResultError("Could not find resource")
return PatchResultSuccess()
?: throw PatchException("Could not find resource")
}
internal companion object {
@@ -3,8 +3,6 @@ package app.revanced.patches.youtube.misc.debugging.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
@@ -20,7 +18,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@Description("Adds debugging options.")
@DebuggingCompatibility
class DebuggingPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.MISC.addPreferences(
app.revanced.patches.shared.settings.preference.impl.PreferenceScreen(
"revanced_debug_preference_screen",
@@ -67,7 +65,5 @@ class DebuggingPatch : ResourcePatch {
StringResource("revanced_debug_preference_screen_summary", "Enable or disable debugging options")
)
)
return PatchResultSuccess()
}
}
@@ -7,9 +7,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.youtube.misc.fix.backtoexitgesture.annotation.FixBackToExitGestureCompatibility
import app.revanced.patches.youtube.misc.fix.backtoexitgesture.fingerprints.OnBackPressedFingerprint
import app.revanced.patches.youtube.misc.fix.backtoexitgesture.fingerprints.RecyclerViewScrollingFingerprint
@@ -25,12 +22,12 @@ class FixBackToExitGesturePatch : BytecodePatch(
OnBackPressedFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
RecyclerViewTopScrollingFingerprint.apply {
resolve(
context,
RecyclerViewTopScrollingParentFingerprint.result?.classDef
?: return RecyclerViewTopScrollingParentFingerprint.toErrorResult()
?: throw RecyclerViewTopScrollingParentFingerprint.toErrorResult()
)
}
@@ -44,15 +41,7 @@ class FixBackToExitGesturePatch : BytecodePatch(
OnBackPressedFingerprint to IntegrationsMethod(
"p0", "onBackPressed", "Lcom/google/android/apps/youtube/app/watchwhile/WatchWhileActivity;"
)
).forEach { (fingerprint, target) ->
try {
fingerprint.injectCall(target)
} catch (error: PatchResultError) {
return error
}
}
return PatchResultSuccess()
).forEach { (fingerprint, target) -> fingerprint.injectCall(target) }
}
private companion object {
@@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.misc.fix.playback.annotations.ClientSpoofCompatibility
@@ -23,7 +21,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
class ClientSpoofPatch : BytecodePatch(
listOf(UserAgentHeaderBuilderFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
UserAgentHeaderBuilderFingerprint.result?.let { result ->
val insertIndex = result.scanResult.patternScanResult!!.endIndex
result.mutableMethod.apply {
@@ -32,9 +30,7 @@ class ClientSpoofPatch : BytecodePatch(
addInstruction(insertIndex, "const-string v$packageNameRegister, \"$ORIGINAL_PACKAGE_NAME\"")
}
} ?: return UserAgentHeaderBuilderFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw UserAgentHeaderBuilderFingerprint.toErrorResult()
}
private companion object {
@@ -4,14 +4,11 @@ import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.ProtobufParameterBuilderFingerprint
@@ -36,7 +33,7 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
ScrubbedPreviewLayoutFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// hook parameter
ProtobufParameterBuilderFingerprint.result?.let {
@@ -55,14 +52,14 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
"""
)
}
} ?: return ProtobufParameterBuilderFingerprint.toErrorResult()
} ?: throw ProtobufParameterBuilderFingerprint.toErrorResult()
// 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 ?: return StoryboardThumbnailParentFingerprint.toErrorResult()
StoryboardThumbnailParentFingerprint.result ?: throw StoryboardThumbnailParentFingerprint.toErrorResult()
StoryboardThumbnailFingerprint.resolve(context, StoryboardThumbnailParentFingerprint.result!!.classDef)
StoryboardThumbnailFingerprint.result?.apply {
val endIndex = scanResult.patternScanResult!!.endIndex
@@ -84,7 +81,7 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
return v0
"""
)
} ?: return StoryboardThumbnailFingerprint.toErrorResult()
} ?: throw StoryboardThumbnailFingerprint.toErrorResult()
// Seekbar thumbnail now show up but are always a blank image.
@@ -102,9 +99,7 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
"""
)
}
} ?: return ScrubbedPreviewLayoutFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw ScrubbedPreviewLayoutFingerprint.toErrorResult()
}
private companion object {
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.misc.fix.playback.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -13,7 +11,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
class SpoofSignatureVerificationResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.MISC.addPreferences(
SwitchPreference(
"revanced_spoof_signature_verification",
@@ -33,8 +31,6 @@ class SpoofSignatureVerificationResourcePatch : ResourcePatch {
scrubbedPreviewThumbnailResourceId = ResourceMappingPatch.resourceMappings.single {
it.type == "id" && it.name == "thumbnail"
}.id
return PatchResultSuccess()
}
companion object {
@@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@@ -29,7 +27,7 @@ class OpenLinksExternallyPatch : BytecodePatch(
InitializeCustomTabSupportFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.MISC.addPreferences(
SwitchPreference(
"revanced_external_browser",
@@ -44,7 +42,7 @@ class OpenLinksExternallyPatch : BytecodePatch(
BindSessionServiceFingerprint,
InitializeCustomTabSupportFingerprint
).forEach {
val result = it.result ?: return it.toErrorResult()
val result = it.result ?: throw it.toErrorResult()
val insertIndex = result.scanResult.patternScanResult!!.endIndex + 1
with(result.mutableMethod) {
val register = (implementation!!.instructions[insertIndex - 1] as Instruction21c).registerA
@@ -57,7 +55,5 @@ class OpenLinksExternallyPatch : BytecodePatch(
)
}
}
return PatchResultSuccess()
}
}
@@ -12,8 +12,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
@@ -61,14 +59,14 @@ class LithoFilterPatch : BytecodePatch(
* }
* }
*/
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
ComponentContextParserFingerprint.result?.also {
arrayOf(
EmptyComponentBuilderFingerprint,
ReadComponentIdentifierFingerprint
).forEach { fingerprint ->
if (fingerprint.resolve(context, it.mutableMethod, it.mutableClass)) return@forEach
return fingerprint.toErrorResult()
throw fingerprint.toErrorResult()
}
}?.let { bytesToComponentContextMethod ->
@@ -77,7 +75,7 @@ class LithoFilterPatch : BytecodePatch(
ProtobufBufferReferenceFingerprint.result
?.mutableMethod?.addInstruction(0,
" invoke-static { p2 }, $INTEGRATIONS_CLASS_DESCRIPTOR->setProtoBuffer(Ljava/nio/ByteBuffer;)V")
?: return ProtobufBufferReferenceFingerprint.toErrorResult()
?: throw ProtobufBufferReferenceFingerprint.toErrorResult()
// endregion
@@ -143,7 +141,7 @@ class LithoFilterPatch : BytecodePatch(
}
// endregion
} ?: return ComponentContextParserFingerprint.toErrorResult()
} ?: throw ComponentContextParserFingerprint.toErrorResult()
LithoFilterFingerprint.result?.mutableMethod?.apply {
removeInstructions(2, 4) // Remove dummy filter.
@@ -159,9 +157,7 @@ class LithoFilterPatch : BytecodePatch(
"""
)
}
} ?: return LithoFilterFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw LithoFilterFingerprint.toErrorResult()
}
override fun close() = LithoFilterFingerprint.result!!
@@ -4,8 +4,6 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.fingerprints.WatchWhileActivityFingerprint
@@ -40,7 +38,7 @@ class MicroGBytecodePatch : BytecodePatch(
WatchWhileActivityFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// apply common microG patch
MicroGBytecodeHelper.patchBytecode(
context, arrayOf(
@@ -65,7 +63,5 @@ class MicroGBytecodePatch : BytecodePatch(
// inject the notice for MicroG
MicroGBytecodeHelper.injectNotice(WatchWhileActivityFingerprint)
return PatchResultSuccess()
}
}
@@ -1,8 +1,6 @@
package app.revanced.patches.youtube.misc.microg.patch.resource
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.settings.preference.impl.Preference
@@ -20,7 +18,7 @@ import app.revanced.util.microg.MicroGResourceHelper
@DependsOn([SettingsResourcePatch::class])
class MicroGResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
SettingsPatch.addPreference(
Preference(
StringResource("microg_settings", "MicroG Settings"),
@@ -47,7 +45,5 @@ class MicroGResourcePatch : ResourcePatch {
// add strings
MicroGResourceHelper.addStrings(context)
return PatchResultSuccess()
}
}
@@ -4,13 +4,10 @@ import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@@ -39,7 +36,7 @@ class MinimizedPlaybackPatch : BytecodePatch(
KidsMinimizedPlaybackPolicyControllerFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// TODO: remove this empty preference sometime after mid 2023
SettingsPatch.PreferenceScreen.MISC.addPreferences(
NonInteractivePreference(
@@ -57,10 +54,10 @@ class MinimizedPlaybackPatch : BytecodePatch(
return v0
"""
)
} ?: return MinimizedPlaybackManagerFingerprint.toErrorResult()
} ?: throw MinimizedPlaybackManagerFingerprint.toErrorResult()
// Enable minimized playback option in YouTube settings
MinimizedPlaybackSettingsParentFingerprint.result ?: return MinimizedPlaybackSettingsParentFingerprint.toErrorResult()
MinimizedPlaybackSettingsParentFingerprint.result ?: throw MinimizedPlaybackSettingsParentFingerprint.toErrorResult()
MinimizedPlaybackSettingsFingerprint.resolve(context, MinimizedPlaybackSettingsParentFingerprint.result!!.classDef)
MinimizedPlaybackSettingsFingerprint.result?.apply {
val booleanCalls = method.implementation!!.instructions.withIndex()
@@ -78,7 +75,7 @@ class MinimizedPlaybackPatch : BytecodePatch(
return v0
"""
)
} ?: return MinimizedPlaybackSettingsFingerprint.toErrorResult()
} ?: throw MinimizedPlaybackSettingsFingerprint.toErrorResult()
// Force allowing background play for videos labeled for kids.
// Some regions and YouTube accounts do not require this patch.
@@ -87,9 +84,7 @@ class MinimizedPlaybackPatch : BytecodePatch(
0,
"return-void"
)
} ?: return KidsMinimizedPlaybackPolicyControllerFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw KidsMinimizedPlaybackPolicyControllerFingerprint.toErrorResult()
}
private companion object {
@@ -8,8 +8,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint
import app.revanced.patches.youtube.misc.playercontrols.annotation.PlayerControlsCompatibility
@@ -28,16 +26,14 @@ class PlayerControlsBytecodePatch : BytecodePatch(
BottomControlsInflateFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
LayoutConstructorFingerprint.result?.let {
if (!PlayerControlsVisibilityFingerprint.resolve(context, it.classDef))
throw LayoutConstructorFingerprint.toErrorResult()
} ?: return LayoutConstructorFingerprint.toErrorResult()
} ?: throw LayoutConstructorFingerprint.toErrorResult()
showPlayerControlsFingerprintResult = PlayerControlsVisibilityFingerprint.result!!
inflateFingerprintResult = BottomControlsInflateFingerprint.result!!
return PatchResultSuccess()
}
internal companion object {
@@ -1,9 +1,7 @@
package app.revanced.patches.youtube.misc.playercontrols.resource.patch
import app.revanced.patcher.data.DomFileEditor
import app.revanced.patcher.util.DomFileEditor
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@@ -11,14 +9,12 @@ import java.io.Closeable
@DependsOn([ResourceMappingPatch::class])
class BottomControlsResourcePatch : ResourcePatch, Closeable {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
resourceContext = context
targetXmlEditor = context.xmlEditor[TARGET_RESOURCE]
bottomUiContainerResourceId = ResourceMappingPatch.resourceMappings
.single { it.type == "id" && it.name == "bottom_ui_container_stub" }.id
return PatchResultSuccess()
}
companion object {
@@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.playeroverlay.annotation.PlayerOverlaysHookCompatibility
@@ -21,13 +19,12 @@ class PlayerOverlaysHookPatch : BytecodePatch(
PlayerOverlaysOnFinishInflateFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// hook YouTubePlayerOverlaysLayout.onFinishInflate()
val method = PlayerOverlaysOnFinishInflateFingerprint.result!!.mutableMethod
method.addInstruction(
method.implementation!!.instructions.size - 2,
"invoke-static { p0 }, Lapp/revanced/integrations/patches/PlayerOverlaysHookPatch;->YouTubePlayerOverlaysLayout_onFinishInflateHook(Ljava/lang/Object;)V"
)
return PatchResultSuccess()
}
}
@@ -8,8 +8,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.playertype.fingerprint.PlayerTypeFingerprint
@@ -22,11 +20,11 @@ import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
class PlayerTypeHookPatch : BytecodePatch(
listOf(PlayerTypeFingerprint, VideoStateFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
PlayerTypeFingerprint.result?.mutableMethod?.addInstruction(
0,
"invoke-static {p1}, $INTEGRATIONS_CLASS_DESCRIPTOR->setPlayerType(Ljava/lang/Enum;)V"
) ?: return PlayerTypeFingerprint.toErrorResult()
) ?: throw PlayerTypeFingerprint.toErrorResult()
VideoStateFingerprint.result?.let {
it.mutableMethod.apply {
@@ -41,9 +39,7 @@ class PlayerTypeHookPatch : BytecodePatch(
"""
)
}
} ?: return VideoStateFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw VideoStateFingerprint.toErrorResult()
}
companion object {
@@ -9,8 +9,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.settings.preference.impl.Preference
import app.revanced.patches.shared.settings.util.AbstractPreferenceScreen
@@ -29,7 +27,7 @@ import java.io.Closeable
class SettingsPatch : BytecodePatch(
listOf(LicenseActivityFingerprint, SetThemeFingerprint)
), Closeable {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// TODO: Remove this when it is only required at one place.
fun getSetThemeInstructionString(
registers: String = "v0",
@@ -57,7 +55,7 @@ class SettingsPatch : BytecodePatch(
addInstruction(returnIndex + 1, "return-object v0")
}
}
} ?: return SetThemeFingerprint.toErrorResult()
} ?: throw SetThemeFingerprint.toErrorResult()
// Modify the license activity and remove all existing layout code.
@@ -88,8 +86,6 @@ class SettingsPatch : BytecodePatch(
}
}
return PatchResultSuccess()
}
internal companion object {
@@ -1,10 +1,8 @@
package app.revanced.patches.youtube.misc.settings.resource.patch
import app.revanced.patcher.data.DomFileEditor
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.DomFileEditor
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.shared.settings.preference.addPreference
import app.revanced.patches.shared.settings.preference.impl.*
@@ -21,7 +19,7 @@ class SettingsResourcePatch : AbstractSettingsResourcePatch(
"revanced_prefs",
"settings"
) {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
super.execute(context)
// Used for a fingerprint from SettingsPatch.
@@ -88,8 +86,6 @@ class SettingsResourcePatch : AbstractSettingsResourcePatch(
)
context.mergeStrings("settings/host/values/strings.xml")
return PatchResultSuccess()
}
@@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
@@ -25,7 +23,7 @@ import app.revanced.patches.youtube.misc.zoomhaptics.fingerprints.ZoomHapticsFin
class ZoomHapticsPatch : BytecodePatch(
listOf(ZoomHapticsFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.MISC.addPreferences(
SwitchPreference(
"revanced_disable_zoom_haptics",
@@ -47,7 +45,5 @@ class ZoomHapticsPatch : BytecodePatch(
""",
ExternalLabel("vibrate", zoomHapticsFingerprintMethod.getInstruction(0))
)
return PatchResultSuccess()
}
}
@@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.StringResource
@@ -27,7 +25,7 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference
class HDRBrightnessPatch : BytecodePatch(
listOf(HDRBrightnessFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.VIDEO.addPreferences(
SwitchPreference(
"revanced_hdr_auto_brightness",
@@ -55,7 +53,5 @@ class HDRBrightnessPatch : BytecodePatch(
"""
)
}
return PatchResultSuccess()
}
}
@@ -4,15 +4,12 @@ import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
@@ -44,7 +41,7 @@ class VideoInformationPatch : BytecodePatch(
OnPlaybackSpeedItemClickFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
with(PlayerInitFingerprint.result!!) {
playerInitMethod = mutableClass.methods.first { MethodUtil.isConstructor(it) }
@@ -136,11 +133,9 @@ class VideoInformationPatch : BytecodePatch(
getReference(speedSelectionMethodInstructions, 1, Opcode.IGET)
setPlaybackSpeedMethodReference =
getReference(speedSelectionMethodInstructions, 2, Opcode.IGET)
} ?: return OnPlaybackSpeedItemClickFingerprint.toErrorResult()
} ?: throw OnPlaybackSpeedItemClickFingerprint.toErrorResult()
userSelectedPlaybackSpeedHook(INTEGRATIONS_CLASS_DESCRIPTOR, "userSelectedPlaybackSpeed")
return PatchResultSuccess()
}
companion object {
@@ -9,9 +9,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.ArrayResource
@@ -42,7 +40,7 @@ class RememberVideoQualityPatch : BytecodePatch(
NewVideoQualityChangedFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// This is bloated as each value has it's own String key/value
// ideally the entries would be raw values (and not a key to a String resource)
val entries = listOf(
@@ -119,7 +117,7 @@ class RememberVideoQualityPatch : BytecodePatch(
// Inject a call to set the remembered quality once a video loads.
VideoQualitySetterFingerprint.result?.also {
if (!SetQualityByIndexMethodClassFieldReferenceFingerprint.resolve(context, it.classDef))
return PatchResultError("Could not resolve fingerprint to find setQualityByIndex method")
throw PatchException("Could not resolve fingerprint to find setQualityByIndex method")
}?.let {
// This instruction refers to the field with the type that contains the setQualityByIndex method.
val instructions = SetQualityByIndexMethodClassFieldReferenceFingerprint.result!!
@@ -139,7 +137,7 @@ class RememberVideoQualityPatch : BytecodePatch(
// Get the name of the setQualityByIndex method.
val setQualityByIndexMethod = setQualityByIndexMethodClass.methods
.find { method -> method.parameterTypes.first() == "I" }
?: return PatchResultError("Could not find setQualityByIndex method")
?: throw PatchException("Could not find setQualityByIndex method")
it.mutableMethod.addInstructions(
0,
@@ -160,7 +158,7 @@ class RememberVideoQualityPatch : BytecodePatch(
move-result p2
""",
)
} ?: return VideoQualitySetterFingerprint.toErrorResult()
} ?: throw VideoQualitySetterFingerprint.toErrorResult()
// Inject a call to remember the selected quality.
@@ -174,8 +172,8 @@ class RememberVideoQualityPatch : BytecodePatch(
0,
"invoke-static {p$listItemIndexParameter}, $INTEGRATIONS_CLASS_DESCRIPTOR->userChangedQuality(I)V"
)
} ?: return PatchResultError("Failed to find onItemClick method")
} ?: return VideoQualityItemOnClickParentFingerprint.toErrorResult()
} ?: throw PatchException("Failed to find onItemClick method")
} ?: throw VideoQualityItemOnClickParentFingerprint.toErrorResult()
// Remember video quality if not using old layout menu.
@@ -189,10 +187,8 @@ class RememberVideoQualityPatch : BytecodePatch(
"invoke-static {v$qualityRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->userChangedQualityInNewFlyout(I)V"
)
}
} ?: return NewVideoQualityChangedFingerprint.toErrorResult()
} ?: throw NewVideoQualityChangedFingerprint.toErrorResult()
return PatchResultSuccess()
}
private companion object {
@@ -4,8 +4,6 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.video.speed.custom.patch.CustomPlaybackSpeedPatch
@@ -17,7 +15,6 @@ import app.revanced.patches.youtube.video.speed.remember.patch.RememberPlaybackS
@DependsOn([CustomPlaybackSpeedPatch::class, RememberPlaybackSpeedPatch::class])
@PlaybackSpeedCompatibility
class PlaybackSpeed : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult {
return PatchResultSuccess() // All patches this patch depends on succeed.
override fun execute(context: BytecodeContext) { // All patches this patch depends on succeed.
}
}
@@ -11,9 +11,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
import app.revanced.patches.shared.settings.preference.impl.InputType
@@ -44,7 +42,7 @@ class CustomPlaybackSpeedPatch : BytecodePatch(
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.VIDEO.addPreferences(
TextPreference(
key = "revanced_custom_playback_speeds",
@@ -66,7 +64,7 @@ class CustomPlaybackSpeedPatch : BytecodePatch(
val sizeCallIndex = arrayGenMethodImpl.instructions
.indexOfFirst { ((it as? ReferenceInstruction)?.reference as? MethodReference)?.name == "size" }
if (sizeCallIndex == -1) return PatchResultError("Couldn't find call to size()")
if (sizeCallIndex == -1) throw PatchException("Couldn't find call to size()")
val sizeCallResultRegister =
(arrayGenMethodImpl.instructions.elementAt(sizeCallIndex + 1) as OneRegisterInstruction).registerA
@@ -173,12 +171,10 @@ class CustomPlaybackSpeedPatch : BytecodePatch(
invoke-virtual { v0 }, $showOldPlaybackSpeedMenuMethod
"""
)
} ?: return ShowOldPlaybackSpeedMenuIntegrationsFingerprint.toErrorResult()
} ?: return GetOldPlaybackSpeedsFingerprint.toErrorResult()
} ?: throw ShowOldPlaybackSpeedMenuIntegrationsFingerprint.toErrorResult()
} ?: throw GetOldPlaybackSpeedsFingerprint.toErrorResult()
// endregion
return PatchResultSuccess()
}
private companion object {
@@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.settings.preference.impl.ArrayResource
@@ -30,7 +28,7 @@ class RememberPlaybackSpeedPatch : BytecodePatch(
InitializePlaybackSpeedValuesFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.VIDEO.addPreferences(
SwitchPreference(
"revanced_remember_playback_speed_last_selected",
@@ -105,9 +103,7 @@ class RememberPlaybackSpeedPatch : BytecodePatch(
""".trimIndent(),
ExternalLabel("do_not_override", mutableMethod.getInstruction(0))
)
} ?: return InitializePlaybackSpeedValuesFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw InitializePlaybackSpeedValuesFingerprint.toErrorResult()
}
private companion object {
@@ -8,8 +8,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
@@ -25,7 +23,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
class VideoIdPatch : BytecodePatch(
listOf(VideoIdFingerprint, VideoIdFingerprintBackgroundPlay)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
/**
* Supplies the method and register index of the video id register.
*
@@ -53,8 +51,6 @@ class VideoIdPatch : BytecodePatch(
backgroundPlaybackInsertIndex = insertIndex
backgroundPlaybackVideoIdRegister = videoIdRegister
}
return PatchResultSuccess()
}
companion object {

Some files were not shown because too many files have changed in this diff Show More